Ejemplo n.º 1
0
 /**
  * Displays the number of posts for a weblog author
  */
 protected function displayPostCount(BlorgAuthor $author)
 {
     switch ($this->getMode('post_count')) {
         case SiteView::MODE_ALL:
             $link = $this->getLink('post_count');
             $count = count($author->getVisiblePosts());
             if ($link === false) {
                 $post_count_tag = new SwatHtmlTag('span');
             } else {
                 $post_count_tag = new SwatHtmlTag('a');
                 if (is_string($link)) {
                     $post_count_tag->href = $link;
                 } else {
                     $post_count_tag->href = $this->getRelativeUri($author) . '#posts';
                 }
             }
             $post_count_tag->class = 'post-count';
             if ($count == 0) {
                 $post_count_tag->setContent(Blorg::_('no posts'));
             } else {
                 $locale = SwatI18NLocale::get();
                 $post_count_tag->setContent(sprintf(Blorg::ngettext('%s post', '%s posts', $count), $locale->formatNumber($count)));
             }
             $post_count_tag->display();
             break;
         case SiteView::MODE_SUMMARY:
             $count = count($author->getVisiblePosts());
             if ($count > 0) {
                 $link = $this->getLink('post_count');
                 if ($link === false) {
                     $post_count_tag = new SwatHtmlTag('span');
                 } else {
                     $post_count_tag = new SwatHtmlTag('a');
                     if (is_string($link)) {
                         $post_count_tag->href = $link;
                     } else {
                         $post_count_tag->href = $this->getRelativeUri($author) . '#posts';
                     }
                 }
                 $post_count_tag->class = 'author-post-count';
                 $locale = SwatI18NLocale::get();
                 $post_count_tag->setContent(sprintf(Blorg::ngettext('(%s post)', '(%s posts)', $count), $locale->formatNumber($count)));
                 $post_count_tag->display();
             }
             break;
     }
 }