Exemple #1
0
 /**
  * Display a list of entries
  *
  * @return  void
  */
 public function displayTask()
 {
     // Get filters
     $this->view->filters = array('search' => Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''), 'wishlist' => Request::getState($this->_option . '.' . $this->_controller . '.wishlist', 'wishlist', 0, 'int'), 'filterby' => Request::getState($this->_option . '.' . $this->_controller . '.filterby', 'filterby', 'all'), 'tag' => Request::getState($this->_option . '.' . $this->_controller . '.tag', 'tag', ''), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'subject'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), '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'));
     if (!$this->view->filters['wishlist']) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=lists', false), Lang::txt('Missing list ID'), 'error');
         return;
     }
     $this->view->filters['sortby'] = $this->view->filters['sort'];
     $this->view->wishlist = new Wishlist($this->database);
     $this->view->wishlist->load($this->view->filters['wishlist']);
     $obj = new Wish($this->database);
     // Get record count
     $this->view->total = $obj->get_count($this->view->filters['wishlist'], $this->view->filters, true);
     // Get records
     $this->view->rows = $obj->get_wishes($this->view->filters['wishlist'], $this->view->filters, true);
     // Output the HTML
     $this->view->display();
 }
Exemple #2
0
 /**
  * Get a count or list of wishes
  *
  * @param   string   $rtrn     What data to return [count, list, first]
  * @param   array    $filters  Filters to apply to data fetch
  * @param   boolean  $clear    Clear cached data?
  * @return  mixed
  */
 public function wishes($rtrn = '', $filters = array(), $clear = false)
 {
     if (!isset($filters['wishlist'])) {
         $filters['wishlist'] = (int) $this->get('id');
     }
     $tbl = new Tables\Wish($this->_db);
     switch (strtolower($rtrn)) {
         case 'count':
             if (!is_numeric($this->_cache['wishes.count']) || $clear) {
                 $this->_cache['wishes.count'] = (int) $tbl->get_count($this->get('id'), $filters, $this->get('admin'), User::getInstance());
             }
             return $this->_cache['wishes.count'];
             break;
         case 'list':
         case 'results':
         default:
             if (!$this->_cache['wishes.list'] instanceof ItemList || $clear) {
                 if ($results = $tbl->get_wishes($this->get('id'), $filters, $this->get('admin'), User::getInstance())) {
                     foreach ($results as $key => $result) {
                         $results[$key] = new Wish($result);
                     }
                 } else {
                     $results = array();
                 }
                 $this->_cache['wishes.list'] = new ItemList($results);
             }
             return $this->_cache['wishes.list'];
             break;
     }
 }