コード例 #1
0
 /**
  * Index action method
  *
  * @param  int $tid
  * @return void
  */
 public function index($tid = null)
 {
     if (null === $tid) {
         $this->prepareView('content/types.phtml');
         $type = new Model\ContentType();
         if ($type->hasPages($this->config->pagination)) {
             $limit = $this->config->pagination;
             $pages = new Paginator($type->getCount(), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->view->title = 'Content';
         $this->view->pages = $pages;
         $this->view->types = $type->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     } else {
         $this->prepareView('content/index.phtml');
         $content = new Model\Content();
         $type = new Model\ContentType();
         $type->getById($tid);
         if (!isset($type->id)) {
             $this->redirect(BASE_PATH . APP_URI . '/content');
         }
         if ($this->services['acl']->isAllowed($this->sess->user->role, 'content-type-' . $type->id, 'index')) {
             if ($content->hasPages($this->config->pagination, $tid)) {
                 $limit = $this->config->pagination;
                 $pages = new Paginator($content->getCount($tid), $limit);
                 $pages->useInput(true);
             } else {
                 $limit = null;
                 $pages = null;
             }
             $content->getAll($tid, $this->request->getQuery('sort'), $this->request->getQuery('title'));
             $contentFlatMap = $content->getFlatMap();
             if (count($contentFlatMap) > $this->config->pagination) {
                 $page = $this->request->getQuery('page');
                 $pages = new Paginator(count($contentFlatMap), $limit);
                 $pages->useInput(true);
                 $offset = null !== $page && (int) $page > 1 ? $page * $limit - $limit : 0;
                 $contentFlatMap = array_slice($contentFlatMap, $offset, $limit, true);
             } else {
                 $pages = null;
             }
             $this->view->title = 'Content : ' . $type->name;
             $this->view->pages = $pages;
             $this->view->tid = $tid;
             $this->view->queryString = $this->getQueryString('sort');
             $this->view->open_authoring = $type->open_authoring;
             $this->view->trash = $content->getCount($tid, -2);
             $this->view->content = $contentFlatMap;
             $this->view->searchValue = htmlentities(strip_tags($this->request->getQuery('title')), ENT_QUOTES, 'UTF-8');
         } else {
             $this->redirect(BASE_PATH . APP_URI . '/content');
         }
     }
     $this->send();
 }
コード例 #2
0
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $type = new Model\ContentType();
     if ($type->hasPages($this->config->pagination)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($type->getCount(), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->prepareView('content/types/index.phtml');
     $this->view->title = 'Content : Types';
     $this->view->pages = $pages;
     $this->view->types = $type->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     $this->send();
 }