Esempio n. 1
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());
     $issueModel = new IssueModel($this->getContainer()->get('db'));
     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));
         $item->categories = $issueModel->getCategories($item->id);
     }
     // Prepare the response.
     $items = array('items' => $listItems, 'pagesTotal' => $pagesTotal, 'currentPage' => $currentPage);
     $this->response->data = (object) $items;
 }