private function _render() { if (!empty($this->_tree)) { return true; } $filter = $this->master->getProperty('data')->order($this->date_field); if (is_null($view =& $this->master->startDataView($filter))) { return false; } $rows =& $view->getProperty('rows'); if (empty($rows)) { $this->_tree = array(); $this->master->endView(); return true; } $tree =& $this->_tree; foreach ($rows as $id => &$row) { $action = str_replace('-id-', $id, $this->action); $row['url'] = TIP::buildActionUriFromTag($action, (string) $this->master); $row['title'] = $this->_renderField($this->title_field, $row); // Suppose the date is in SQL format $date = $row[$this->date_field]; list($y, $m, $day) = sscanf($date, "%d-%d-%d"); // Compute the year $year = sprintf('%04d', $y); if (!array_key_exists($year, $tree)) { $tree[$year] = array('title' => $year, 'url' => TIP::modifyActionUri(null, null, null, array($this->id => $year)), 'sub' => array(), 'ITEMS' => 0); isset($this->count_field) && ($tree[$year]['COUNT'] = 0); } ++$tree[$year]['ITEMS']; isset($this->count_field) && ($tree[$year]['COUNT'] += $row[$this->count_field]); // Compute the month $months =& $tree[$year]['sub']; $month = strftime('%B', mktime(0, 0, 0, $m, $day, $year)); $month_id = $year . sprintf('%02d', $m); if (!array_key_exists($month_id, $months)) { $months[$month_id] = array('title' => $month, 'url' => TIP::modifyActionUri(null, null, null, array($this->id => $month_id)), 'sub' => array(), 'ITEMS' => 0); isset($this->count_field) && ($months[$month_id]['COUNT'] = 0); } ++$months[$month_id]['ITEMS']; isset($this->count_field) && ($months[$month_id]['COUNT'] += $row[$this->count_field]); $months[$month_id]['sub'][$id] =& $row; isset($this->count_field) && ($row['COUNT'] = $row[$this->count_field]); } return true; }