コード例 #1
0
ファイル: TagController.php プロジェクト: jaakkop/site
 /**
  *	indexAction
  *
  *	Tag index
  *
  */
 public function indexAction()
 {
     // Get cache from registry
     $cache = Zend_Registry::get('cache');
     $cacheFile = '';
     $this->view->title = 'tag-view-title';
     // default values and GET parameters
     $limit = '0';
     $order = 'name';
     $direction = 'desc';
     $where = 'All';
     $ctype = 'all';
     $list_type = 'cloud';
     $params = $this->getRequest()->getParams();
     if (isset($params['limit'])) {
         $limit = $params['limit'];
         $cacheFile .= '?limit=' . $limit;
     }
     if (isset($params['order'])) {
         $order = $params['order'];
         $cacheFile .= '?order=' . $order;
     }
     if (isset($params['direction'])) {
         $direction = $params['direction'];
         $cacheFile .= '?direction=' . $direction;
     }
     if (isset($params['where'])) {
         $where = $params['where'];
         $cacheFile .= '?where=' . $where;
     }
     if (isset($params['ctype'])) {
         $ctype = $params['ctype'];
         $cacheFile .= '?ctype=' . $ctype;
     }
     if (isset($params['list_type'])) {
         $list_type = $params['list_type'];
         $cacheFile .= '?list_type=' . $list_type;
     }
     /*
     foreach ($params as $key => $val){
         switch ($key) {
             case 'limit':
                 $limit = $val;
                 break;
             case 'order':
                 $order = $val;
                 break;
             case 'direction':
                 $direction = $val;
                 break;
             case 'where':
                 $where = $val;
                 break;
             case 'ctype':
                 $ctype = $val;
                 break;
             case 'list_type':
                 $list_type = $val;
                 break;
             default:
                 break;
         }
     }
     */
     $cacheFile = 'Tags_' . md5($cacheFile);
     // Load tags from cache
     if (!($result = $cache->load($cacheFile))) {
         //Retrieving tags
         $tags = new Default_Model_Tags();
         $tagList = $tags->getTagCloudData($limit, $order, $direction, $where, $ctype);
         //Changing tag size
         //$this->changeTagSize($tagList);
         $tagList = $this->_helper->tagsizes->tagCalc($tagList);
         $cache->save($tagList, $cacheFile);
     } else {
         $tagList = $result;
     }
     // inject things to view
     $this->view->tag_list = $tagList;
     $this->view->order = $order;
     $this->view->direction = $direction;
     $this->view->ctype = $ctype;
     $this->view->where = $where;
     $this->view->list_type = $list_type;
 }