From d5a212a132331202510071cca860532674acb3c8 Mon Sep 17 00:00:00 2001 From: Wesley Miaw Date: Fri, 14 May 2004 22:36:52 +0000 Subject: Fixed a bug where TODOs would be shown even if they did not fall into one of the following categories: 1. Completed & flag to show completed is TRUE 2. Important 3. Normal (i.e. Completed TODOs that showed up after parsing an important or normal TODO would still be shown.) Fixed a bug where if there are zero TODO items in the included calendars, the TODO list would still be shown, with incorrect contents. --- functions/template.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/functions/template.php b/functions/template.php index 481069d..f0e2352 100644 --- a/functions/template.php +++ b/functions/template.php @@ -565,6 +565,7 @@ class Page { $completed = trim($match1[1]); $important = trim($match2[1]); $normal = trim($match3[1]); + $nugget2 = ''; if (is_array($master_array['-2'])) { foreach ($master_array['-2'] as $vtodo_times) { @@ -597,6 +598,8 @@ class Page { $data = array ('{VTODO_TEXT}', '{VTODO_ARRAY}'); $rep = array ($vtodo_text, $vtodo_array); + // Reset this TODO's category. + $temp = ''; if ($status == 'COMPLETED' || (isset($val['completed_date']) && isset($val['completed_time']))) { if ($show_completed == 'yes') { $temp = $completed; @@ -606,13 +609,27 @@ class Page { } else { $temp = $normal; } - $nugget1 = str_replace($data, $rep, $temp); - $nugget2 .= $nugget1; + + // Do not include TODOs which do not have the + // category set. + if ($temp != '') { + $nugget1 = str_replace($data, $rep, $temp); + $nugget2 .= $nugget1; + } } } - $this->page = preg_replace('!<\!-- switch show_completed on -->(.*)<\!-- switch show_normal off -->!is', $nugget2, $this->page); } } + + // If there are no TODO items, completely hide the TODO list. + if ($nugget2 == '') { + $this->page = preg_replace('!<\!-- switch vtodo on -->(.*)<\!-- switch vtodo off -->!is', '', $this->page); + } + + // Otherwise display the list of TODOs. + else { + $this->page = preg_replace('!<\!-- switch show_completed on -->(.*)<\!-- switch show_normal off -->!is', $nugget2, $this->page); + } } function draw_month($template_p, $offset = '+0', $type) { @@ -869,4 +886,4 @@ class Page { print($this->page); } } -?> \ No newline at end of file +?> -- cgit v1.2.3