Ejemplo n.º 1
0
 /**
  * Display all categories in a section
  *
  * @return  void
  */
 public function displayTask()
 {
     // Filters
     $filters = array('state' => Request::getState($this->_option . '.' . $this->_controller . '.state', 'state', -1, 'int'), 'access' => Request::getState($this->_option . '.' . $this->_controller . '.access', 'access', -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'), 'search' => Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''), 'scopeinfo' => Request::getState($this->_option . '.' . $this->_controller . '.scopeinfo', 'scopeinfo', ''));
     if (strstr($filters['scopeinfo'], ':')) {
         $bits = explode(':', $filters['scopeinfo']);
         $filters['scope'] = $bits[0];
         $filters['scope_id'] = intval(end($bits));
     } else {
         $filters['scope'] = '';
         $filters['scope_id'] = -1;
     }
     $filters['admin'] = true;
     // Load the current section
     if (!$filters['section_id'] || $filters['section_id'] <= 0) {
         // No section? Load a default blank section
         $section = Section::blank();
     } else {
         $section = Section::oneOrFail($filters['section_id']);
         $filters['scope'] = $section->get('scope');
         $filters['scope_id'] = $section->get('scope_id');
         $filters['scopeinfo'] = $filters['scope'] . ':' . $filters['scope_id'];
     }
     $sections = array();
     if ($filters['scope_id'] >= 0) {
         $sections = Section::all()->whereEquals('scope', $filters['scope'])->whereEquals('scope_id', $filters['scope_id'])->ordered('title', 'ASC')->rows();
     }
     $entries = Category::all()->including(['posts', function ($post) {
         $post->select('id')->select('category_id');
     }]);
     if ($filters['search']) {
         $entries->whereLike('title', strtolower((string) $filters['search']));
     }
     if ($filters['scope']) {
         $entries->whereEquals('scope', $filters['scope']);
     }
     if ($filters['scope_id'] >= 0) {
         $entries->whereEquals('scope_id', (int) $filters['scope_id']);
     }
     if ($filters['state'] >= 0) {
         $entries->whereEquals('state', (int) $filters['state']);
     }
     if ($filters['access'] >= 0) {
         $entries->whereEquals('access', (int) $filters['access']);
     }
     if ($filters['section_id'] > 0) {
         $entries->whereEquals('section_id', (int) $filters['section_id']);
     }
     // Get records
     $rows = $entries->ordered('filter_order', 'filter_order_Dir')->paginated('limitstart', 'limit')->rows();
     $forum = new Manager($filters['scope'], $filters['scope_id']);
     // Output the HTML
     $this->view->set('rows', $rows)->set('filters', $filters)->set('section', $section)->set('sections', $sections)->set('scopes', $forum->scopes())->display();
 }
Ejemplo n.º 2
0
 /**
  * Display all sections
  *
  * @return  void
  */
 public function displayTask()
 {
     // Filters
     $filters = array('state' => Request::getState($this->_option . '.' . $this->_controller . '.state', 'state', '-1', 'int'), 'access' => Request::getState($this->_option . '.' . $this->_controller . '.access', 'access', '-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'), 'search' => Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''), 'scopeinfo' => Request::getState($this->_option . '.' . $this->_controller . '.scopeinfo', 'scopeinfo', ''));
     if (strstr($filters['scopeinfo'], ':')) {
         $bits = explode(':', $filters['scopeinfo']);
         $filters['scope'] = $bits[0];
         $filters['scope_id'] = intval(end($bits));
     } else {
         $filters['scope'] = '';
         $filters['scope_id'] = -1;
     }
     $entries = Section::all()->including(['categories', function ($category) {
         $category->select('id')->select('section_id');
     }]);
     if ($filters['search']) {
         $entries->whereLike('title', strtolower((string) $filters['search']));
     }
     if ($filters['scope']) {
         $entries->whereEquals('scope', $filters['scope']);
     }
     if ($filters['scope_id'] >= 0) {
         $entries->whereEquals('scope_id', (int) $filters['scope_id']);
     }
     if ($filters['state'] >= 0) {
         $entries->whereEquals('state', (int) $filters['state']);
     }
     if ($filters['access'] >= 0) {
         $entries->whereEquals('access', (int) $filters['access']);
     }
     // Get records
     $rows = $entries->ordered('filter_order', 'filter_order_Dir')->paginated('limitstart', 'limit')->rows();
     $forum = new Manager($filters['scope'], $filters['scope_id']);
     // Output the HTML
     $this->view->set('rows', $rows)->set('filters', $filters)->set('scopes', $forum->scopes())->display();
 }
Ejemplo n.º 3
0
 /**
  * Display all threads in a category
  *
  * @return  void
  */
 public function displayTask()
 {
     // Filters
     $filters = array('state' => Request::getState($this->_option . '.' . $this->_controller . '.state', 'state', '-1', 'int'), 'access' => Request::getState($this->_option . '.' . $this->_controller . '.access', 'access', '-1', 'int'), 'section_id' => Request::getState($this->_option . '.' . $this->_controller . '.section_id', 'section_id', -1, 'int'), 'category_id' => Request::getState($this->_option . '.' . $this->_controller . '.category_id', 'category_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'), 'search' => Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''), 'scopeinfo' => Request::getState($this->_option . '.' . $this->_controller . '.scopeinfo', 'scopeinfo', ''));
     if (strstr($filters['scopeinfo'], ':')) {
         $bits = explode(':', $filters['scopeinfo']);
         $filters['scope'] = $bits[0];
         $filters['scope_id'] = intval(end($bits));
     } else {
         $filters['scope'] = '';
         $filters['scope_id'] = -1;
     }
     // Get the category
     $category = Category::oneOrNew($filters['category_id']);
     // Get the category
     if ($category->get('id')) {
         $filters['scope'] = $category->get('scope');
         $filters['scope_id'] = $category->get('scope_id');
         $filters['scopeinfo'] = $filters['scope'] . ':' . $filters['scope_id'];
         $filters['section_id'] = $category->get('section_id');
     }
     // Get the section
     $section = Section::oneOrNew($filters['section_id']);
     if ($section->get('id') && !$filters['scopeinfo']) {
         $filters['scope'] = $section->get('scope');
         $filters['scope_id'] = $section->get('scope_id');
         $filters['scopeinfo'] = $filters['scope'] . ':' . $filters['scope_id'];
     }
     // Get sections
     $sections = array();
     if ($filters['scopeinfo']) {
         $sections = Section::all()->whereEquals('scope', $filters['scope'])->whereEquals('scope_id', $filters['scope_id'])->ordered('title', 'ASC')->rows();
     }
     // Get categories
     $categories = array();
     if ($filters['section_id']) {
         $categories = Category::all()->whereEquals('section_id', $filters['section_id'])->rows();
         if (!$filters['category_id'] || $filters['category_id'] <= 0) {
             $filters['category_id'] = array();
             foreach ($categories as $cat) {
                 $filters['category_id'][] = $cat->id;
             }
         }
     }
     // Get threads
     $entries = Post::all()->whereEquals('parent', 0);
     if ($filters['search']) {
         $entries->whereLike('comment', strtolower((string) $filters['search']));
     }
     if ($filters['scope']) {
         $entries->whereEquals('scope', $filters['scope']);
     }
     if ($filters['scope_id'] >= 0) {
         $entries->whereEquals('scope_id', (int) $filters['scope_id']);
     }
     if ($filters['state'] >= 0) {
         $entries->whereEquals('state', (int) $filters['state']);
     }
     if ($filters['access'] >= 0) {
         $entries->whereEquals('access', (int) $filters['access']);
     }
     if (is_array($filters['category_id'])) {
         if (!empty($filters['category_id'])) {
             $entries->whereIn('category_id', $filters['category_id']);
         }
         $filters['category_id'] = -1;
     } elseif ($filters['category_id'] > 0) {
         $entries->whereEquals('category_id', (int) $filters['category_id']);
     }
     $rows = $entries->ordered('filter_order', 'filter_order_Dir')->paginated('limitstart', 'limit')->rows();
     $forum = new Manager($filters['scope'], $filters['scope_id']);
     // Output the HTML
     $this->view->set('rows', $rows)->set('filters', $filters)->set('section', $section)->set('category', $category)->set('sections', $sections)->set('categories', $categories)->set('scopes', $forum->scopes())->display();
 }