Beispiel #1
0
 protected function displayArchive()
 {
     $path = $this->app->config->blorg->path . 'tag';
     $locale = SwatI18NLocale::get();
     $ul_tag = new SwatHtmLTag('ul');
     $ul_tag->class = 'blorg-archive-tags';
     $ul_tag->open();
     foreach ($this->tags as $tag) {
         $li_tag = new SwatHtmlTag('li');
         $li_tag->open();
         $anchor_tag = new SwatHtmlTag('a');
         $anchor_tag->href = sprintf('%s/%s', $path, $tag->shortname);
         $anchor_tag->setContent($tag->title);
         $post_count_span = new SwatHtmlTag('span');
         $post_count_span->setContent(sprintf(Blorg::ngettext(' (%s post)', ' (%s posts)', $tag->post_count), $locale->formatNumber($tag->post_count)));
         $heading_tag = new SwatHtmlTag('h4');
         $heading_tag->class = 'blorg-archive-tag-title';
         $heading_tag->open();
         $anchor_tag->display();
         $post_count_span->display();
         $heading_tag->close();
         $li_tag->close();
     }
     $ul_tag->close();
 }
 protected function displayArchive()
 {
     $years = $this->getYears();
     if (count($years) === 0) {
         return;
     }
     $current_year = date('Y');
     $path = $this->app->config->blorg->path . 'archive';
     $locale = SwatI18NLocale::get();
     $year_ul_tag = new SwatHtmLTag('ul');
     $year_ul_tag->class = 'blorg-archive-years';
     $year_ul_tag->open();
     foreach ($years as $year => $values) {
         $year_li_tag = new SwatHtmlTag('li');
         $year_li_tag->open();
         $year_anchor_tag = new SwatHtmlTag('a');
         $year_anchor_tag->href = sprintf('%s/%s', $path, $year);
         $year_anchor_tag->setContent($year);
         $year_anchor_tag->display();
         $post_count_span = new SwatHtmlTag('span');
         $post_count_span->setContent(sprintf(Blorg::ngettext(' (%s post)', ' (%s posts)', $values['post_count']), $locale->formatNumber($values['post_count'])));
         $post_count_span->display();
         // show month links for current year
         if ($year == $current_year) {
             $month_ul_tag = new SwatHtmlTag('ul');
             $month_ul_tag->open();
             foreach ($values['months'] as $month => $post_count) {
                 $date = new SwatDate();
                 $date->setMonth($month);
                 $month_li_tag = new SwatHtmlTag('li');
                 $month_li_tag->open();
                 $month_anchor_tag = new SwatHtmlTag('a');
                 $month_anchor_tag->href = sprintf('%s/%s/%s', $path, $year, BlorgPageFactory::$month_names[$month]);
                 $month_anchor_tag->setContent($date->formatLikeIntl('MMMM'));
                 $month_anchor_tag->display();
                 $post_count_span = new SwatHtmlTag('span');
                 $post_count_span->setContent(sprintf(Blorg::ngettext(' (%s post)', ' (%s posts)', $post_count), $locale->formatNumber($post_count)));
                 $post_count_span->display();
                 $month_li_tag->close();
             }
             $month_ul_tag->close();
         }
         $year_li_tag->close();
     }
     $year_ul_tag->close();
 }
Beispiel #3
0
 protected function displayArchive()
 {
     $path = $this->app->config->blorg->path . 'archive';
     $locale = SwatI18NLocale::get();
     $year_ul_tag = new SwatHtmLTag('ul');
     $year_ul_tag->class = 'blorg-archive-years';
     $year_ul_tag->open();
     foreach ($this->years as $year => $values) {
         $year_li_tag = new SwatHtmlTag('li');
         $year_li_tag->open();
         $year_anchor_tag = new SwatHtmlTag('a');
         $year_anchor_tag->href = sprintf('%s/%s', $path, $year);
         $year_anchor_tag->setContent($year);
         $post_count_span = new SwatHtmlTag('span');
         $post_count_span->setContent(sprintf(Blorg::ngettext(' (%s post)', ' (%s posts)', $values['post_count']), $locale->formatNumber($values['post_count'])));
         $year_heading_tag = new SwatHtmlTag('h4');
         $year_heading_tag->class = 'blorg-archive-year-title';
         $year_heading_tag->open();
         $year_anchor_tag->display();
         $post_count_span->display();
         $year_heading_tag->close();
         $month_ul_tag = new SwatHtmlTag('ul');
         $month_ul_tag->open();
         foreach ($values['months'] as $month => $post_count) {
             $date = new SwatDate();
             // Set year and day so we're sure it's a valid date, otherwise
             // the month may not be set.
             $date->setDate(2010, $month, 1);
             $month_li_tag = new SwatHtmlTag('li');
             $month_li_tag->open();
             $month_anchor_tag = new SwatHtmlTag('a');
             $month_anchor_tag->href = sprintf('%s/%s/%s', $path, $year, BlorgPageFactory::$month_names[$month]);
             $month_anchor_tag->setContent($date->getMonthName());
             $month_anchor_tag->display();
             $post_count_span = new SwatHtmlTag('span');
             $post_count_span->setContent(sprintf(Blorg::ngettext(' (%s post)', ' (%s posts)', $post_count), $locale->formatNumber($post_count)));
             $post_count_span->display();
             $month_li_tag->close();
         }
         $month_ul_tag->close();
         $year_li_tag->close();
     }
     $year_ul_tag->close();
 }