/**
  * Method to render the view.
  *
  * @return  string  The rendered view.
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function render()
 {
     // Set the vars to the template.
     $this->renderer->set('state', $this->model->getState());
     $this->renderer->set('project', $this->getProject());
     return parent::render();
 }
 /**
  * Initialize the controller.
  *
  * @return  $this  Method allows chaining
  *
  * @since   1.0
  */
 public function initialize()
 {
     parent::initialize();
     /* @type Application $application */
     $application = $this->getContainer()->get('app');
     $limit = $application->getUserStateFromRequest('list.limit', 'list_limit', 20, 'int');
     $page = $application->input->getInt('page');
     $value = $page ? ($page - 1) * $limit : 0;
     $limitStart = $limit != 0 ? floor($value / $limit) * $limit : 0;
     $state = $this->model->getState();
     $state->set('list.start', $limitStart);
     $state->set('list.limit', $limit);
     $this->model->setState($state);
     $this->model->setPagination(new TrackerPagination(new Uri($this->getContainer()->get('app')->get('uri.request'))));
     return $this;
 }
Exemple #3
0
 /**
  * Prepare the response.
  *
  * @return  void
  *
  * @since   1.0
  */
 protected function prepareResponse()
 {
     // Load the application
     $application = $this->getContainer()->get('app');
     // Load the model
     $model = new IssuesModel($this->getContainer()->get('db'), $application->input);
     // Get allowed user for view;
     $application->getUser()->authorize('view');
     // Set Current project;
     $model->setProject($application->getProject(true));
     // Set model state
     $this->setModelState($model);
     // Pagination
     $model->setPagination(new TrackerPagination(new Uri($application->get('uri.request'))));
     // Get list items
     $listItems = $model->getAjaxItems();
     // Get total pages
     $pagesTotal = $model->getPagination()->getPagesTotal();
     $currentPage = $model->getPagination()->getPageNo();
     // Render the label html for each item
     $renderer = new Renderer\TrackerExtension($this->getContainer());
     foreach ($listItems as $item) {
         $item->labelHtml = $renderer->renderLabels($item->labels);
         $item->opened_date = date('Y-m-d', strtotime($item->opened_date));
         $item->modified_date = date('Y-m-d', strtotime($item->modified_date));
         $item->closed_date = date('Y-m-d', strtotime($item->closed_date));
     }
     // Prepare the response.
     $items = array('items' => $listItems, 'pagesTotal' => $pagesTotal, 'currentPage' => $currentPage);
     $this->response->data = (object) $items;
 }