protected function displayByDateAdded(PinholeTagList $tag_list) { $now = new SwatDate(); $now->convertTZById($this->app->config->date->time_zone); $store = new SwatTableStore(); foreach ($tag_list as $tag) { $ds = new SwatDetailsStore(); $ds->tag = $tag; $tag_date = $tag->getDataObject()->first_modified; $tag_date->convertTZById($this->app->config->date->time_zone); $days_past = $now->diff($tag_date)->days; if ($days_past <= 1) { $ds->date_part = Pinhole::_('Today'); } elseif ($days_past <= $now->getDayOfWeek() + 1) { $ds->date_part = Pinhole::_('This Week'); } elseif ($days_past <= $now->getDay()) { $ds->date_part = Pinhole::_('This Month'); } elseif ($days_past <= $now->getDayOfYear()) { $ds->date_part = Pinhole::_('This Year'); } else { $ds->date_part = sprintf(Pinhole::_('%s'), $tag_date->getYear()); } $store->add($ds); } $ul_tag = new SwatHtmlTag('ul'); $li_tag = new SwatHtmlTag('li'); $ul_tag->open(); $part = null; foreach ($store as $ds) { if ($part !== $ds->date_part) { if ($part !== null) { $li_tag->close(); } $li_tag->open(); $h2_tag = new SwatHtmlTag('h2'); $h2_tag->class = 'pinhole-tag-entity'; $h2_tag->setContent($ds->date_part); $h2_tag->display(); } elseif ($part !== null) { echo ', '; } $this->displayTag($ds->tag); $part = $ds->date_part; } $li_tag->close(); $ul_tag->close(); }