Beispiel #1
0
 /**
  *   listAction
  *
  *   Lists content by content type.
  *
  */
 public function listAction()
 {
     $url = $this->_urlHelper->url(array('controller' => 'index', 'language' => $this->view->language), 'lang_default', true);
     // Get cache from registry
     $cache = Zend_Registry::get('cache');
     // Set array for content data
     $data = array();
     // Get requests
     $params = $this->getRequest()->getParams();
     // Get content type
     $cty = isset($params['type']) ? $params['type'] : 'all';
     if ($cty != "idea" && $cty != "finfo" && $cty != "problem") {
         $this->_redirect($url);
     }
     // Get page nummber and items per page
     $page = isset($params['page']) ? $params['page'] : 1;
     $count = isset($params['count']) ? $params['count'] : 15;
     // Get list oreder value
     $order = isset($params['order']) ? $params['order'] : 'created';
     $ind = isset($params['ind']) ? $params['ind'] : 0;
     // Get current language id
     // $languages = new Default_Model_Languages();
     // $idLngInd = $languages->getLangIdByLangName($this->view->language);
     // Get recent content by type
     $contentModel = new Default_Model_Content();
     $data = $contentModel->listRecent($cty, $page, $count, $order, $this->view->language, $ind);
     $results = array();
     // gather other content data and insert to results array
     if (isset($data[0])) {
         $contentHasTagModel = new Default_Model_ContentHasTag();
         // $contentRatingsModel = new Default_Model_ContentRatings();
         $i = 0;
         foreach ($data as $content) {
             $results[$i] = $content;
             $results[$i]['tags'] = $contentHasTagModel->getContentTags($content['id_cnt']);
             //$results[$i]['ratingdata'] = $contentRatingsModel
             //                        ->getPercentagesById($content['id_cnt']);
             $i++;
         }
     }
     // Get total content count
     $contentCount = $contentModel->getContentCountByContentType($cty, $this->view->language);
     // Calculate total page count
     $pageCount = ceil($contentCount / $count);
     // Most viewed content
     $mostViewedData = $contentModel->getMostViewedType($cty, $page, $count, 'views', 'en', $ind);
     // Get all industries
     //$industries = new Default_Model_Industries();
     //$this->view->industries = $industries->getNamesAndIdsById($ind, $idLngInd);
     // Get industry data by id
     //$this->view->industryParent = $industries->getById($ind);
     // Load most popular tags from cache
     if (!($result = $cache->load('IndexTags'))) {
         $tagsModel = new Default_Model_Tags();
         $tags = $tagsModel->getPopular(20);
         /*
         // resize tags
         foreach ($tags as $k => $tag) {
         $size = round(50 + ($tag['count'] * 30));
         if ($size > 300) {
         $size = 300;
         }
         $tags[$k]['tag_size'] = $size;
         }
         */
         // Action helper for tags
         $tags = $this->_helper->tagsizes->popularTagCalc($tags);
         //Action helper for define is tag running number divisible by two
         $tags = $this->_helper->tagsizes->isTagDivisibleByTwo($tags);
         // Save most popular tags data to cache
         $cache->save($tags, 'IndexTags');
     } else {
         $tags = $result;
     }
     // Custom pagination to fix memory error on large amount of data
     /*
     $paginator = new Zend_View();
     $paginator->setScriptPath('../application/views/scripts');
     $paginator->pageCount = $pageCount;
     $paginator->currentPage = $page;
     $paginator->pagesInRange = 10;
     */
     // Send to view
     $this->view->tags = $tags;
     //$this->view->contentPaginator = $paginator;
     $this->view->contentData = $results;
     $this->view->type = $cty;
     $this->view->count = $count;
     $this->view->page = $page;
     $this->view->contentCount = $contentCount;
     $this->view->ind = $ind;
     $this->view->mostViewedData = $mostViewedData;
     // RSS type for the layout
     $this->view->rsstype = $cty;
 }