Exemple #1
0
 /**
  * List all questions
  *
  * @return  void
  */
 public function displayTask()
 {
     // Filters
     $this->view->filters = array('tag' => Request::getstate($this->_option . '.' . $this->_controller . '.tag', 'tag', ''), 'q' => Request::getstate($this->_option . '.' . $this->_controller . '.q', 'q', ''), 'filterby' => Request::getstate($this->_option . '.' . $this->_controller . '.filterby', 'filterby', 'all'), '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'), 'sortby' => '', 'sort' => Request::getstate($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'created'), 'sort_Dir' => Request::getstate($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'DESC'));
     $aq = new Tables\Question($this->database);
     // Get a record count
     $this->view->total = $aq->getCount($this->view->filters);
     // Get records
     $this->view->results = $aq->getResults($this->view->filters);
     // Did we get any results?
     if ($this->view->results) {
         foreach ($this->view->results as $key => $result) {
             $this->view->results[$key] = new Question($result);
         }
     }
     // Output the HTML
     $this->view->display();
 }
Exemple #2
0
 /**
  * Search entries
  *
  * @return     void
  */
 public function searchTask()
 {
     $this->view->config = $this->config;
     $this->view->task = $this->_task;
     // Incoming
     $this->view->filters = array('limit' => Request::getInt('limit', Config::get('list_limit')), 'start' => Request::getInt('limitstart', 0), 'tag' => Request::getVar('tags', ''), 'q' => Request::getVar('q', ''), 'filterby' => Request::getWord('filterby', ''), 'sortby' => Request::getWord('sortby', 'date'), 'sort_Dir' => Request::getWord('sortdir', 'DESC'), 'area' => Request::getVar('area', ''));
     // Validate inputs
     $this->view->filters['tag'] = $this->view->filters['tag'] ? $this->view->filters['tag'] : Request::getVar('tag', '');
     if ($this->view->filters['filterby'] && !in_array($this->view->filters['filterby'], array('open', 'closed'))) {
         $this->view->filters['filterby'] = '';
     }
     if (!in_array($this->view->filters['sortby'], array('date', 'votes', 'rewards'))) {
         $this->view->filters['sortby'] = 'date';
     }
     if ($this->view->filters['area'] && !in_array($this->view->filters['area'], array('mine', 'assigned', 'interest'))) {
         $this->view->filters['area'] = '';
     }
     // Get questions of interest
     if ($this->view->filters['area'] == 'interest') {
         require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'tags.php';
         // Get tags of interest
         $mt = new \Components\Members\Models\Tags(User::get('id'));
         $mytags = $mt->render('string');
         $this->view->filters['tag'] = $this->view->filters['tag'] ? $this->view->filters['tag'] : $mytags;
         $this->view->filters['mine'] = 0;
     }
     // Get assigned questions
     if ($this->view->filters['area'] == 'assigned') {
         require_once PATH_CORE . DS . 'components' . DS . 'com_tools' . DS . 'tables' . DS . 'author.php';
         // What tools did this user contribute?
         $TA = new \Components\Tools\Tables\Author($this->database);
         $tools = $TA->getToolContributions(User::get('id'));
         $mytooltags = array();
         if ($tools) {
             foreach ($tools as $tool) {
                 $mytooltags[] = 'tool' . $tool->toolname;
             }
         }
         $this->view->filters['tag'] = $this->view->filters['tag'] ? $this->view->filters['tag'] : implode(',', $mytooltags);
         $this->view->filters['mine'] = 0;
     }
     if ($this->view->filters['area'] == 'mine') {
         $this->view->filters['mine'] = 1;
     }
     // Instantiate a Questions object
     $aq = new Tables\Question($this->database);
     if (($this->view->filters['area'] == 'interest' || $this->view->filters['area'] == 'assigned') && !$this->view->filters['tag']) {
         // Get a record count
         $this->view->total = 0;
         // Get records
         $this->view->results = array();
     } else {
         // Get a record count
         $this->view->total = $aq->getCount($this->view->filters);
         // Get records
         $this->view->results = $aq->getResults($this->view->filters);
     }
     // Did we get any results?
     if (count($this->view->results) > 0) {
         // Do some processing on the results
         foreach ($this->view->results as $i => $result) {
             $this->view->results[$i] = new Question($result);
         }
     }
     // Set the page title
     $this->_buildTitle();
     // Set the pathway
     $this->_buildPathway();
     // Output HTML
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $this->view->setLayout('search')->display();
 }