当前位置: 首页>>代码示例>>PHP>>正文


PHP Blorg::ngettext方法代码示例

本文整理汇总了PHP中Blorg::ngettext方法的典型用法代码示例。如果您正苦于以下问题:PHP Blorg::ngettext方法的具体用法?PHP Blorg::ngettext怎么用?PHP Blorg::ngettext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Blorg的用法示例。


在下文中一共展示了Blorg::ngettext方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: displayContent

 protected function displayContent()
 {
     $path = $this->app->config->blorg->path . 'tag';
     $tags = $this->getTags();
     if (count($tags) > 0) {
         $ul_tag = new SwatHtmlTag('ul');
         if ($this->getValue('cloud_view')) {
             $ul_tag->class = 'blorg-tag-cloud';
         }
         $ul_tag->open();
         $max = 0;
         foreach ($tags as $tag) {
             if ($tag->post_count > $max) {
                 $max = $tag->post_count;
             }
         }
         $locale = SwatI18NLocale::get();
         foreach ($tags as $tag) {
             if ($tag->post_count > 0 || $this->getValue('show_empty')) {
                 $popularity = $tag->post_count / $max;
                 $li_tag = new SwatHtmlTag('li');
                 $li_tag->open();
                 $tag_span_tag = new SwatHtmlTag('span');
                 $tag_span_tag->class = $this->getTagClass($popularity);
                 $tag_span_tag->open();
                 $anchor_tag = new SwatHtmlTag('a');
                 $anchor_tag->href = $path . '/' . $tag->shortname;
                 $anchor_tag->setContent($tag->title);
                 $anchor_tag->display();
                 if ($this->getValue('show_post_counts')) {
                     echo ' ';
                     $span_tag = new SwatHtmlTag('span');
                     $span_tag->setContent(sprintf(Blorg::ngettext('(%s post)', '(%s posts)', $tag->post_count), $locale->formatNumber($tag->post_count)));
                     $span_tag->display();
                 }
                 if ($this->getValue('show_feed_links')) {
                     echo ' ';
                     $span_tag = new SwatHtmlTag('span');
                     $span_tag->class = 'feed';
                     $span_tag->open();
                     echo '(';
                     $anchor_tag = new SwatHtmlTag('a');
                     $anchor_tag->class = 'feed';
                     $anchor_tag->href = $path . '/' . $tag->shortname . '/feed';
                     $anchor_tag->setContent('Feed');
                     $anchor_tag->display();
                     echo ')';
                     $span_tag->close();
                 }
                 $tag_span_tag->close();
                 // breaking space for inline list items in cloud view
                 if ($this->getValue('cloud_view')) {
                     echo ' ';
                 }
                 $li_tag->close();
             }
         }
         $ul_tag->close();
     }
 }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:60,代码来源:BlorgTagGadget.php

示例2: processDBData

    protected function processDBData()
    {
        parent::processDBData();
        $item_list = $this->getItemList('integer');
        $instance_id = $this->app->getInstanceId();
        // delete attached files using their dataobjects to remove the actual
        // files
        $sql = sprintf('select * from BlorgFile
			inner join BlorgPost on BlorgPost.id = BlorgFile.post
			where BlorgPost.instance %s %s and BlorgFile.post in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $files = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgFileWrapper'));
        foreach ($files as $file) {
            $file->setFileBase('../');
            $file->delete();
        }
        // delete the posts
        $sql = sprintf('delete from BlorgPost
			where instance %s %s and id in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
        $num = SwatDB::exec($this->app->db, $sql);
        if (isset($this->app->memcache)) {
            $this->app->memcache->flushNS('posts');
        }
        $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been deleted.', '%s posts have been deleted.', $num), SwatString::numberFormat($num)));
        $this->app->messages->add($message);
    }
开发者ID:nburka,项目名称:blorg,代码行数:25,代码来源:Delete.php

示例3: processActions

    public function processActions(SwatTableView $view, SwatActions $actions)
    {
        $num = count($view->getSelection());
        $message = null;
        $items = SwatDB::implodeSelection($this->app->db, $view->getSelection(), 'integer');
        switch ($actions->selected->id) {
            case 'delete':
                $this->app->replacePage($this->getComponentName() . '/Delete');
                $this->app->getPage()->setItems($view->getSelection());
                break;
            case 'enable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(true, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been shown on site.', '%s authors have been shown on site.', $num), SwatString::numberFormat($num)));
                break;
            case 'disable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(false, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been hidden on site.', '%s authors have been hidden on site.', $num), SwatString::numberFormat($num)));
                break;
        }
        if ($message !== null) {
            $this->app->messages->add($message);
        }
    }
开发者ID:nburka,项目名称:blorg,代码行数:33,代码来源:Index.php

示例4: processDBData

 protected function processDBData()
 {
     parent::processDBData();
     $item_list = $this->getItemList('integer');
     $sql = sprintf('delete from BlorgTag where id in (%s)', $item_list);
     $num = SwatDB::exec($this->app->db, $sql);
     if (isset($this->app->memcache)) {
         $this->app->memcache->flushNs('tags');
         $this->app->memcache->flushNs('posts');
     }
     $message = new SwatMessage(sprintf(Blorg::ngettext('One tag has been deleted.', '%s tags have been deleted.', $num), SwatString::numberFormat($num)));
     $this->app->messages->add($message);
 }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:13,代码来源:Delete.php

示例5: displayContent

 protected function displayContent()
 {
     $conversations = $this->getActiveConversations();
     if (count($conversations) > 0) {
         // get last visited date based on cookie value
         if ($this->app->hasModule('SiteCookieModule')) {
             $cookie = $this->app->getModule('SiteCookieModule');
             try {
                 if (isset($cookie->last_visit_date)) {
                     $last_visit_date = new SwatDate($cookie->last_visit_date);
                 } else {
                     $last_visit_date = new SwatDate();
                 }
             } catch (SiteCookieException $e) {
                 $last_visit_date = new SwatDate();
             }
         } else {
             $last_visit_date = new SwatDate();
         }
         echo '<ul>';
         $locale = SwatI18NLocale::get();
         $class_name = SwatDBClassMap::get('BlorgPost');
         foreach ($conversations as $conversation) {
             $post = new $class_name($conversation);
             $last_comment_date = new SwatDate($conversation->last_comment_date);
             $last_comment_date->setTZById('UTC');
             $li_tag = new SwatHtmlTag('li');
             // is last comment is later than last visit date, mark as new
             if (SwatDate::compare($last_comment_date, $last_visit_date) > 0) {
                 $li_tag->class = 'new';
             }
             $li_tag->open();
             $anchor_tag = new SwatHtmlTag('a');
             $anchor_tag->href = $this->getPostRelativeUri($post);
             $anchor_tag->setContent($post->getTitle());
             $span_tag = new SwatHtmlTag('span');
             $span_tag->setContent(sprintf(Blorg::ngettext('(%s comment)', '(%s comments)', $post->getVisibleCommentCount()), $locale->formatNumber($post->getVisibleCommentCount())));
             $anchor_tag->display();
             echo ' ';
             $span_tag->display();
             $li_tag->close();
         }
         echo '</ul>';
     }
 }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:45,代码来源:BlorgActiveConversationsGadget.php

示例6: displayCommentCount

 /**
  * Displays the number of comments for a weblog post
  */
 protected function displayCommentCount(BlorgPost $post)
 {
     if ($this->getMode('comment_count') > SiteView::MODE_NONE) {
         $link = $this->getLink('comment_count');
         $count = $post->getVisibleCommentCount();
         if ($link === false) {
             $comment_count_tag = new SwatHtmlTag('span');
         } else {
             $comment_count_tag = new SwatHtmlTag('a');
             if (is_string($link)) {
                 $comment_count_tag->href = $link;
             } else {
                 $comment_count_tag->href = $this->getRelativeUri($post) . '#comments';
             }
             switch ($post->comment_status) {
                 case SiteCommentStatus::LOCKED:
                     $comment_count_tag->title = sprintf(Blorg::_('View comments for %s'), $post->getTitle());
                     break;
                 case SiteCommentStatus::OPEN:
                 case SiteCommentStatus::MODERATED:
                     $comment_count_tag->title = sprintf(Blorg::_('Comment on %s'), $post->getTitle());
                     break;
             }
         }
         $comment_count_tag->class = 'comment-count';
         if ($count == 0) {
             $comment_count_tag->setContent(Blorg::_('leave a comment'));
         } else {
             $locale = SwatI18NLocale::get();
             $comment_count_tag->setContent(sprintf(Blorg::ngettext('%s comment', '%s comments', $count), $locale->formatNumber($count)));
         }
         $comment_count_tag->display();
     }
 }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:37,代码来源:BlorgPostView.php

示例7: displayPostCount

 /**
  * 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;
     }
 }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:50,代码来源:BlorgAuthorView.php

示例8: publishPosts

    protected function publishPosts(SwatViewSelection $post_ids)
    {
        $num = 0;
        $transaction = new SwatDBTransaction($this->app->db);
        try {
            $instance_id = $this->app->getInstanceId();
            $post_ids = SwatDB::implodeSelection($this->app->db, $post_ids);
            $sql = sprintf('select id, shortname, title, bodytext from BlorgPost
				where instance %s %s and id in (%s) and enabled = %s', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $post_ids, $this->app->db->quote(false, 'boolean'));
            $posts = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgPostWrapper'));
            foreach ($posts as $post) {
                if ($post->shortname === null) {
                    $post->shortname = $this->getPostShortname($post);
                }
                $post->enabled = true;
                $post->save();
                $num++;
            }
            $transaction->commit();
        } catch (Exception $e) {
            $transaction->rollback();
            throw $e;
        }
        if ($num > 0 && isset($this->app->memcache)) {
            $this->app->memcache->flushNs('posts');
        }
        $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been shown on site.', '%s posts have been shown on site.', $num), SwatString::numberFormat($num)));
    }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:28,代码来源:Index.php

示例9: displayArchive

 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();
 }
开发者ID:nburka,项目名称:blorg,代码行数:44,代码来源:BlorgArchivePage.php

示例10: displayArchive

 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();
 }
开发者ID:nburka,项目名称:blorg,代码行数:25,代码来源:BlorgTagIndexPage.php

示例11: displayArchive

 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();
 }
开发者ID:GervaisdeM,项目名称:blorg,代码行数:46,代码来源:BlorgArchiveGadget.php


注:本文中的Blorg::ngettext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。