コード例 #1
0
ファイル: BlogsController.php プロジェクト: usban/entilocali
 public function indexAction()
 {
     $mainLayout = $this->initializeFrontendWebsite();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $configurations = $this->layout()->getVariable('configurations');
     $lang = $this->params()->fromRoute('lang');
     $page = $this->params()->fromRoute('page');
     $perPage = $this->params()->fromRoute('perpage');
     $category = $this->params()->fromRoute('category');
     $helper = new PostsControllerHelper();
     $categoriesRecords = $helper->recoverWrapperRecords(new PostsCategoriesGetterWrapper(new PostsCategoriesGetter($em)), array('languageAbbr' => $lang, 'orderBy' => ''));
     $categoriesRecordsForDropDown = $helper->formatForDropwdown($categoriesRecords, 'id', 'name');
     $wrapper = $helper->recoverWrapperRecordsPaginator(new PostsGetterWrapper(new PostsGetter($em)), array('moduleCode' => 'blogs', 'categorySlug' => $category, 'languageAbbr' => $lang, 'orderBy' => 'p.id DESC'), $page, $perPage);
     $wrapper->setEntityManager($em);
     $records = $wrapper->addAttachmentsToPaginatorRecords($wrapper->setupRecords(), array('moduleId' => ModulesContainer::blogs, 'noScaduti' => 1, 'languageAbbreviation' => $lang, 'orderBy' => 'a.position'));
     $paginator = $wrapper->getPaginator();
     if (!empty($categoriesRecordsForDropDown)) {
         $formSearch = new PostsFormSearch();
         $formSearch->addCategories($categoriesRecordsForDropDown);
         $formSearch->addSubmitButton();
     }
     $this->layout()->setVariables(array('records' => $records, 'paginator' => $paginator, 'item_count' => $paginator->getTotalItemCount(), 'category' => $category, 'formSearch' => !empty($formSearch) ? $formSearch : null, 'categoryName' => Slugifier::deSlugify($category), 'mediaDir' => isset($configurations['media_dir']) ? $configurations['media_dir'] : null, 'mediaProject' => isset($configurations['media_project']) ? $configurations['media_project'] : null, 'templatePartial' => 'posts/blogs/list.phtml'));
     $this->layout()->setTemplate($mainLayout);
 }
コード例 #2
0
ファイル: PostsGetter.php プロジェクト: usban/entilocali
 /**
  * @param string|array $type post type (content, blog, photo or video)
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function setType($type)
 {
     if (is_string($type)) {
         $this->getQueryBuilder()->andWhere('p.type = :postType');
         $this->getQueryBuilder()->setParameter('postType', Slugifier::deSlugify($type));
     } elseif (is_array($type)) {
         $this->getQueryBuilder()->andWhere($this->getQueryBuilder()->expr()->in('p.type', $type));
     }
     return $this->getQueryBuilder();
 }