Пример #1
0
 /**
  * Display a list of all entries
  *
  * @return  void
  */
 public function displayTask()
 {
     // Get filters
     $this->view->filters = array('state' => -1, 'access' => -1, 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'created'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'DESC'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), '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'));
     $obj = new Tables\Item($this->database);
     // Get record count
     $this->view->total = $obj->find('count', $this->view->filters);
     // Get records
     $this->view->rows = $obj->find('list', $this->view->filters);
     // Output the HTML
     $this->view->display();
 }
Пример #2
0
 /**
  * Get a count of data associated with this collection
  *
  * @param   string $what What to count
  * @return  integer
  */
 public function count($what = '')
 {
     if (!isset($this->_counts) || !is_array($this->_counts)) {
         $this->_counts = array();
     }
     $what = strtolower(trim($what));
     switch ($what) {
         case 'collection':
         case 'image':
         case 'text':
         case 'file':
         case 'link':
             if (isset($this->_counts[$what])) {
                 return (int) $this->_counts[$what];
             } else {
                 return 0;
             }
             break;
         case 'followers':
             if (!isset($this->_counts[$what])) {
                 $tbl = new Tables\Following($this->_db);
                 $this->_counts[$what] = $tbl->count(array('following_type' => 'collection', 'following_id' => $this->get('id')));
             }
             return $this->_counts[$what];
             break;
         case 'likes':
         case 'like':
         case 'votes':
         case 'vote':
             if ($this->get('likes', null) == null) {
                 $tbl = new Tables\Item($this->_db);
                 $this->set('likes', $tbl->getLikes(array('object_type' => 'collection', 'object_id' => $this->get('id'))));
             }
             return (int) $this->get('likes', 0);
             break;
         case 'reposts':
         case 'repost':
             if ($this->get('reposts', null) == null) {
                 $tbl = new Tables\Item($this->_db);
                 $this->set('reposts', $tbl->getReposts(array('object_type' => 'collection', 'object_id' => $this->get('id'))));
             }
             return (int) $this->get('reposts', 0);
             break;
         case 'posts':
         case 'post':
             if ($this->get('posts', null) == null) {
                 $this->set('posts', $this->posts(array('count' => true)));
             }
             return (int) $this->get('posts', 0);
             break;
         default:
             return 0;
             break;
     }
 }