From 388811b6842c687bf7835cc2815bd4a8a9aac451 Mon Sep 17 00:00:00 2001 From: "David F. Skoll" Date: Fri, 21 Jan 2011 16:59:03 -0500 Subject: [PATCH] Handle MOON specials. --- www/php/remind.php | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/www/php/remind.php b/www/php/remind.php index 90155dc0..f8aa46c4 100644 --- a/www/php/remind.php +++ b/www/php/remind.php @@ -59,6 +59,8 @@ class Remind function do_one_day($day, &$results, &$specials, &$options) { $class = $this->get_elem($specials, array('HTMLCLASS', $day, 0, 'body')); $shade = $this->get_elem($specials, array('SHADE', $day, 0, 'body')); + $moon = $this->get_elem($specials, array('MOON', $day, 0, 'body')); + if ($class === null) $class = 'rem-cell'; $bg = ''; if ($shade !== null) { @@ -78,8 +80,44 @@ class Remind $week = ' ' . $week; } + $moon_html = ''; + if ($moon !== null) { + $phase = -1; + if (preg_match('/(\d+)\s+(\S+)\s+(\S+)\s+(.*)$/', $moon, $matches)) { + $phase = $matches[1]; + $moonsize = $matches[2]; + $fontsize = $matches[3]; + $msg = $matches[4]; + } elseif (preg_match('/(\d+)/', $moon, $matches)) { + $phase = $matches[1]; + $msg = ''; + } + if ($phase >= 0) { + if ($phase == 0) { + $img = 'newmoon.png'; + $title = 'New Moon'; + $alt = 'new'; + } elseif ($phase == 1) { + $img = 'firstquarter.png'; + $title = 'First Quarter'; + $alt = '1st'; + } elseif ($phase == 2) { + $img = 'fullmoon.png'; + $alt = 'full'; + $title = 'Full Moon'; + } else { + $img = 'lastquarter.png'; + $alt = 'last'; + $title = 'Last Quarter'; + } + $base = rtrim($this->get_el($options, 'imgbase'), '/'); + if ($base !=== null) $img = $base . '/' . $img; + $moon_html = '
' . "\"$alt\"" . htmlspecialchars($msg) . '
'; + } + } + # Day number - $html .= '
' . $day . $week . '
'; + $html .= $moon_html . '
' . $day . $week . '
'; # And the entries $entries = $this->get_elem($results, array('entries', $day));