コード例 #1
0
 /**
  * Display all categories in a section
  *
  * @return	void
  */
 public function displayTask()
 {
     // Filters
     $this->view->filters = array('limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'group' => Request::getState($this->_option . '.' . $this->_controller . '.group', 'group', -1, 'int'), 'section_id' => Request::getState($this->_option . '.' . $this->_controller . '.section_id', 'section_id', -1, 'int'), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'id'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'DESC'), 'scopeinfo' => Request::getState($this->_option . '.' . $this->_controller . '.scopeinfo', 'scopeinfo', ''));
     if (strstr($this->view->filters['scopeinfo'], ':')) {
         $bits = explode(':', $this->view->filters['scopeinfo']);
         $this->view->filters['scope'] = $bits[0];
         $this->view->filters['scope_id'] = intval(end($bits));
     } else {
         $this->view->filters['scope'] = '';
         $this->view->filters['scope_id'] = -1;
     }
     $this->view->filters['admin'] = true;
     // Load the current section
     $this->view->section = new Section($this->database);
     if (!$this->view->filters['section_id'] || $this->view->filters['section_id'] <= 0) {
         // No section? Load a default blank section
         $this->view->section->loadDefault();
     } else {
         $this->view->section->load($this->view->filters['section_id']);
     }
     $this->view->sections = array();
     if ($this->view->filters['scopeinfo']) {
         $this->view->sections = $this->view->section->getRecords(array('scope' => $this->view->filters['scope'], 'scope_id' => $this->view->filters['scope_id'], 'sort' => 'title', 'sort_Dir' => 'ASC'));
     }
     $model = new Category($this->database);
     // Get a record count
     $this->view->total = $model->getCount($this->view->filters);
     // Get records
     $this->view->results = $model->getRecords($this->view->filters);
     $this->view->forum = new Manager($this->view->filters['scope'], $this->view->filters['scope_id']);
     // Output the HTML
     $this->view->display();
 }
コード例 #2
0
ファイル: section.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Get a count or list of categories
  *
  * @param   string  $rtrn    Data type to return?
  * @param   array   $filters Filters to apply to query
  * @param   boolean $clear   Clear cached data?
  * @return  mixed
  */
 public function categories($rtrn = '', $filters = array(), $clear = false)
 {
     $filters['section_id'] = isset($filters['section_id']) ? $filters['section_id'] : (int) $this->get('id');
     $filters['state'] = isset($filters['state']) ? $filters['state'] : self::APP_STATE_PUBLISHED;
     $filters['scope'] = isset($filters['scope']) ? $filters['scope'] : (string) $this->get('scope');
     $filters['scope_id'] = isset($filters['scope_id']) ? $filters['scope_id'] : (int) $this->get('scope_id');
     switch (strtolower($rtrn)) {
         case 'count':
             if (!isset($this->_cache['categories_count']) || $clear) {
                 $tbl = new Tables\Category($this->_db);
                 $this->_cache['categories_count'] = (int) $tbl->getCount($filters);
             }
             return $this->_cache['categories_count'];
             break;
         case 'first':
             return $this->categories('list', $filters)->first();
             break;
         case 'list':
         case 'results':
         default:
             if (!$this->_cache['categories'] instanceof ItemList || $clear) {
                 $tbl = new Tables\Category($this->_db);
                 if ($results = $tbl->getRecords($filters)) {
                     foreach ($results as $key => $result) {
                         $results[$key] = new Category($result, $this->get('id'), $this->get('scope'), $this->get('group_id'));
                         $results[$key]->set('section_alias', $this->get('alias'));
                     }
                 } else {
                     $results = array();
                 }
                 $this->_cache['categories'] = new ItemList($results);
             }
             return $this->_cache['categories'];
             break;
     }
 }