當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tags::count方法代碼示例

本文整理匯總了PHP中Tags::count方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tags::count方法的具體用法?PHP Tags::count怎麽用?PHP Tags::count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tags的用法示例。


在下文中一共展示了Tags::count方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fetchCidiansCloud

 public function fetchCidiansCloud($cidianCloudNum)
 {
     $totalTags = Tags::count(array('is_cidian' => 1));
     $randStart = mt_rand(0, $totalTags - $cidianCloudNum);
     $tags = Tags::find(array('is_cidian' => 1, 'limit' => array('number' => $cidianCloudNum, 'offset' => $randStart)))->toArray();
     $cidianBgs = array(1, 3);
     foreach ($tags as $key => $tag) {
         $randBg = mt_rand($cidianBgs[0], $cidianBgs[1]);
         $tags[$key]['randBg'] = $randBg;
     }
     return $tags;
 }
開發者ID:xujianjun,項目名稱:touzilicai,代碼行數:12,代碼來源:Tags.php

示例2: fetchWidgetData

 public function fetchWidgetData($view, $block = '')
 {
     $widgetData = array();
     $blockCfgKey = $block ? $view . '_' . $block : $view;
     $blockCfg = $this->_siteConfig['blockCfg'][$blockCfgKey];
     $blockNum = $this->_siteConfig['widgetCfg']['blockNum'];
     switch ($view) {
         case 'slider':
             //理財故事
         //理財故事
         case 'btslider':
             $widgetData[$block] = array('blockName' => $block, 'items' => $this->_siteConfig['slider'][$block]);
             break;
         case 'dailyword':
             $dailyword['title'] = '天天詞匯';
             $dailyword['word'] = Tags::findFirst(array("conditions" => "is_cidian = ?1", "bind" => array(1 => 1)))->toArray();
             $widgetData = $dailyword;
             break;
         case 'content':
             switch ($block) {
                 case 'node':
                     $content = TreeData::findFirst($this->_params['nid'])->toArray();
                     $content['content'] = htmlspecialchars_decode($content['content']);
                     $widgetData[$block]['content'] = $content;
                     break;
                 case 'tag':
                     $content = Tags::findFirst($this->_params['tid'])->toArray();
                     $content['content'] = htmlspecialchars_decode($content['description']);
                     $content['title'] = $content['name'];
                     $widgetData[$block]['content'] = $content;
                     break;
                 case 'static':
                     $static_content = TreeStruct::findFirst(array("conditions" => "pid = ?1", "bind" => array(1 => $this->_params['nid']), 'order' => 'lft asc'));
                     $content = array();
                     if ($static_content) {
                         $content['title'] = $static_content->TreeData->title;
                         $content['content'] = htmlspecialchars_decode($static_content->TreeData->content);
                     }
                     $widgetData[$block]['blockName'] = $block;
                     $widgetData[$block]['content'] = $content;
                     break;
                 default:
                     break;
             }
             break;
         case 'cidian':
             $cidianCloudNum = $this->_siteConfig['widgetCfg']['cidianCloudNum'];
             $tags = Tags::fetchCidiansCloud($cidianCloudNum);
             $widgetData = $tags;
             break;
         case 'hangqing':
         case 'lilv':
         case 'tool':
             break;
         case 'taglist':
             $taglist = array();
             $itemPer = $this->_siteConfig['widgetCfg']['listItemPer'];
             $start = ($this->_params['p'] - 1) * $itemPer;
             if ($this->_params['tagPrefix']) {
                 $conditions = 'pinyinPrefix="' . $this->_params['tagPrefix'] . '" and is_cidian=1';
             } else {
                 $conditions = 'is_cidian=1';
             }
             $taglist['items'] = Tags::find(array('conditions' => $conditions, 'order' => 'id desc', 'limit' => array('number' => $itemPer, 'offset' => $start)))->toArray();
             $totalTags = Tags::count($conditions);
             $params = array('total_rows' => $totalTags, 'now_page' => $this->_params['p'], 'list_rows' => $itemPer);
             $pagerLib = new Pager($params);
             $pager = $pagerLib->show(3);
             $taglist['pager'] = $pager;
             //				echo '<pre>';print_r($taglist);echo '</pre>';
             $widgetData = $taglist;
             break;
         case 'taglist_header':
             $optRanges = array(97, 122);
             $options = array();
             $options[] = '0-9';
             for ($i = $optRanges[0]; $i <= $optRanges[1]; $i++) {
                 $options[] = chr($i);
             }
             $widgetData = $options;
             break;
         case 'list':
             switch ($block) {
                 case 'node':
                     $nodeLists = array();
                     $itemPer = $this->_siteConfig['widgetCfg']['listItemPer'];
                     $start = ($this->_params['p'] - 1) * $itemPer;
                     $temNodes = TreeStruct::find(array('conditions' => 'lft>?1 and rgt<?2 and type=:type:', 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->rgt, 'type' => 'article'), 'limit' => array('number' => $itemPer, 'offset' => $start), 'order' => 'id desc'));
                     $nodes = array();
                     foreach ($temNodes as $key => $temNode) {
                         $treeData = $temNode->TreeData->toArray();
                         $nodes[$key] = $temNode->toArray();
                         $nodes[$key]['TreeData'] = $treeData;
                     }
                     $nodes = TreeStruct::addNodesAttr($nodes, array('menu' => true, 'menuLevel' => 1));
                     $totalNodes = TreeStruct::count(array('conditions' => 'lft>?1 and rgt<?2 and type=:type:', 'bind' => array(1 => $this->_params['node']->lft, 2 => $this->_params['node']->rgt, 'type' => 'article')));
                     $params = array('total_rows' => $totalNodes, 'now_page' => $this->_params['p'], 'list_rows' => $itemPer);
                     $pagerLib = new Pager($params);
                     $pager = $pagerLib->show(3);
                     $nodeLists['title'] = $this->_params['node']->TreeData->title;
//.........這裏部分代碼省略.........
開發者ID:xujianjun,項目名稱:touzilicai,代碼行數:101,代碼來源:ControllerBase.php


注:本文中的Tags::count方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。