/**
  * List of pages
  *
  */
 function index()
 {
     $per_page = 20;
     $page = (int) $this->request->get('page');
     if ($page < 1) {
         $page = 1;
     }
     // if
     $pagination = null;
     if ($this->active_category->isLoaded()) {
         $this->addBreadcrumb($this->active_category->getName());
         $pages = Pages::findByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility());
     } else {
         $this->addBreadcrumb(lang('Recently Modified'));
         list($pages, $pagination) = Pages::paginateByProject($this->active_project, $page, $per_page, STATE_VISIBLE, $this->logged_user->getVisibility());
     }
     // if
     $this->smarty->assign(array('pages' => $pages, 'pagination' => $pagination, 'categories' => Categories::findByModuleSection($this->active_project, PAGES_MODULE, 'pages'), 'pagination_url' => assemble_url('mobile_access_view_pages', array('project_id' => $this->active_project->getId())), 'page_back_url' => assemble_url('mobile_access_view_project', array('project_id' => $this->active_project->getId()))));
 }
 /**
  * Render pages associtate with a specific project, pages homepage
  *
  * @param void
  * @return null
  */
 function index()
 {
     if ($this->request->isApiCall()) {
         if ($this->active_category->isLoaded()) {
             $this->serveData(Pages::findByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility()), 'pages');
         } else {
             $this->serveData(Categories::findByModuleSection($this->active_project, PAGES_MODULE, 'pages'), 'categories');
         }
         // if
     } else {
         //BOF:mod 20121108
         $category_is_selected = false;
         $selected_category_id = $_GET['category_id'];
         if ($selected_category_id === '0' || $selected_category_id > 0) {
             $category_is_selected = true;
         }
         //EOF:mod 20121108
         $per_page = 30;
         $page = (int) $this->request->get('page');
         if ($page < 1) {
             $page = 1;
         }
         // if
         //BOF:mod 20121108
         /*
         //EOF:mod 20121108
                 if($this->active_category->isLoaded()) {
                 //BOF:mod 20121108
         */
         if ($category_is_selected) {
             //EOF:mod 20121108
             $this->setTemplate(array('module' => PAGES_MODULE, 'controller' => 'pages', 'template' => 'category'));
             //BOF:mod 20121108
             /*
             //EOF:mod 20121108
                       $this->wireframe->addPageAction(lang('Reorder Pages'), assemble_url('project_pages_reorder', array('project_id' => $this->active_project->getId(), 'category_id' => $this->active_category->getId())), null, array('id' => 'reorder_pages_button'));
                       
                       $this->smarty->assign('pages', Pages::findByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility()));
             //BOF:mod 20121108
             */
             $this->wireframe->addPageAction(lang('Reorder Pages'), assemble_url('project_pages_reorder', array('project_id' => $this->active_project->getId())), null, array('id' => 'reorder_pages_button'));
             $this->smarty->assign('pages', Pages::findByCategoryNew($this->active_project->getId(), $selected_category_id, STATE_VISIBLE, $this->logged_user->getVisibility()));
             //EOF:mod 20121108
         } else {
             list($pages, $pagination) = Pages::paginateByProject($this->active_project, $page, $per_page, STATE_VISIBLE, $this->logged_user->getVisibility());
             $grouped_pages = group_by_date($pages, $this->logged_user, 'getUpdatedOn', true);
             $this->smarty->assign(array('grouped_pages' => $grouped_pages, 'pagination' => $pagination));
         }
         // if
         //BOF:mod 20121108
         $departments = Pages::getItemsByDepartment($this->active_project->getId(), new Discussion());
         //EOF:mod 20121108
         $this->smarty->assign(array('departments' => $departments, 'selected_category_id' => $selected_category_id, 'categories_url' => assemble_url('project_manage_milestone_categories', array('project_id' => $this->active_project->getId())), 'can_manage_categories' => $this->logged_user->isProjectLeader($this->active_project) || $this->logged_user->isProjectManager()));
     }
     // if
 }