Пример #1
0
 /**
  * @throws \ModelModule\Model\NullException
  */
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $page = $this->params()->fromRoute('page');
     $perPage = $this->params()->fromRoute('perpage');
     try {
         $helper = new PostsControllerHelper();
         $categoriesRecords = $helper->recoverWrapperRecords(new PostsCategoriesGetterWrapper(new PostsCategoriesGetter($em)), array('fields' => 'category.id, category.name', 'orderBy' => 'category.name', 'moduleCode' => 'photo'));
         $helper->checkRecords($categoriesRecords, 'Nessuna categoria foto presente. Aggiungere almeno una categoria');
         $wrapperPosts = $helper->recoverWrapperRecordsPaginator(new PostsGetterWrapper(new PostsGetter($em)), array('moduleCode' => 'photo', 'userId' => null, 'orderBy' => 'p.id DESC', 'fields' => 'DISTINCT(p.id) AS id, p.lastUpdate,
                                 p.createDate, p.expireDate, p.hasAttachments,
                                 p.image, p.title, p.subtitle, p.description, p.slug, p.seoTitle,
                                 p.seoDescription, p.seoKeywords,
                                 users.name AS userName, users.surname AS userSurname'), $page, $perPage);
         /* Add categories to the recordset */
         $postsRecords = $wrapperPosts->setupRecords();
         $helper->checkRecords($postsRecords, 'Nessuna foto in archivio');
         foreach ($postsRecords as &$postsRecord) {
             $wrapper = new PostsGetterWrapper(new PostsGetter($em));
             $wrapper->setInput(array('fields' => 'c.id, c.name', 'id' => $postsRecord['id'], 'orderBy' => 'c.name'));
             $wrapper->setupQueryBuilder();
             $postsRecord['categories'] = $wrapper->getRecords();
         }
         $form = new PostsFormSearch();
         $form->addCategories($helper->formatForDropwdown($categoriesRecords, 'id', 'name'));
         $form->addSubmitButton();
         $paginator = $wrapperPosts->getPaginator();
         $postsRecords = $wrapperPosts->setupRecords();
         $this->layout()->setVariables(array('tableTitle' => 'Foto', 'tableDescription' => $paginator->getTotalItemCount() . ' foto in archivio.', 'paginator' => $paginator, 'records' => $this->formatColumnRecords($postsRecords), 'columns' => array('Foto', "Titolo", "Categorie", "Inserito da", "Date", " ", " "), 'formSearch' => $form, 'templatePartial' => 'datatable/datatable_photo.phtml'));
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('messageType' => 'warning', 'messageTitle' => 'Errore verificato', 'messageText' => $e->getMessage(), 'templatePartial' => 'message.phtml'));
     }
     $this->layout()->setTemplate($mainLayout);
 }
Пример #2
0
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $configurations = $this->layout()->getVariable('configurations');
     $lang = $this->params()->fromRoute('lang');
     $languageSelection = $this->params()->fromRoute('languageSelection');
     $page = $this->params()->fromRoute('page');
     $perPage = $this->params()->fromRoute('perpage');
     $sessionContainer = new SessionContainer();
     $sessionSearch = $sessionContainer->offsetGet(BlogsSearchController::sessionIdentifier);
     try {
         $helper = new PostsControllerHelper();
         $categoriesRecords = $helper->recoverWrapperRecords(new PostsCategoriesGetterWrapper(new PostsCategoriesGetter($entityManager)), array('fields' => 'category.id, category.name', 'orderBy' => 'category.name', 'languageAbbreviation' => $languageSelection ? $languageSelection : 'it', 'moduleCode' => 'blogs'));
         $helper->checkRecords($categoriesRecords, 'Nessuna categoria presente');
         $wrapperBlogPosts = $helper->recoverWrapperRecordsPaginator(new PostsGetterWrapper(new PostsGetter($entityManager)), array('moduleCode' => 'blogs', 'userId' => null, 'orderBy' => 'p.id DESC', 'languageAbbr' => $languageSelection ? $languageSelection : 'it', 'freeSearch' => isset($sessionSearch['testo']) ? $sessionSearch['testo'] : null, 'categoryId' => isset($sessionSearch['category']) ? $sessionSearch['category'] : null, 'fields' => 'DISTINCT(p.id) AS id, p.lastUpdate,
                                             p.createDate, p.expireDate, p.hasAttachments,
                                             p.image, p.title, p.subtitle, p.description, p.slug, p.seoTitle,
                                             p.seoDescription, p.seoKeywords,
                                             users.name AS userName, users.surname AS userSurname'), $page, $perPage);
         /* Add categories to the recordset */
         $postsRecords = $wrapperBlogPosts->setupRecords();
         $helper->checkRecords($postsRecords, 'Nessun blog post in archivio');
         /* Add attachments files to the recordset */
         $wrapperBlogPosts->setEntityManager($entityManager);
         $postsRecords = $wrapperBlogPosts->addAttachmentsFromRecords($postsRecords, array('moduleId' => ModulesContainer::blogs));
         foreach ($postsRecords as &$postsRecord) {
             $wrapper = new PostsGetterWrapper(new PostsGetter($entityManager));
             $wrapper->setInput(array('fields' => 'c.id, c.name', 'id' => $postsRecord['id'], 'orderBy' => 'c.name'));
             $wrapper->setupQueryBuilder();
             $postsRecord['categories'] = $wrapper->getRecords();
         }
         $paginator = $wrapperBlogPosts->getPaginator();
         $isMultiLanguage = !empty($configurations['isMultiLanguage']);
         if ($isMultiLanguage == 1) {
             $helper->setLanguagesGetterWrapper(new LanguagesGetterWrapper(new LanguagesGetter($entityManager)));
             $formLanguage = $helper->setupLanguageFormSearch(new LanguagesFormSearch(), array('status' => 1), $languageSelection);
         }
         $form = new PostsFormSearch();
         $form->addCategories($helper->formatForDropwdown($categoriesRecords, 'id', 'name'));
         $form->addSubmitButton();
         $form->setData(isset($sessionSearch) ? $sessionSearch : array());
         $this->layout()->setVariables(array('tableTitle' => 'Blogs', 'tableDescription' => $paginator->getTotalItemCount() . ' posts in archivio', 'columns' => array("Immagine", "Titolo", "Categorie", "Inserita da", "Date", " ", " ", " "), 'paginator' => $paginator, 'records' => $this->formatColumnRecords($postsRecords), 'formSearch' => $form, 'formLanguage' => !empty($formLanguage) ? $formLanguage : null, 'sessionSearch' => $sessionSearch, 'formLanguageAction' => $this->url()->fromRoute('admin/blogs-operations', array('action' => 'switchlanguage', 'lang' => $lang, 'languageSelection' => $languageSelection)), 'templatePartial' => 'datatable/datatable_blogs.phtml'));
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('messageText' => $e->getMessage(), 'templatePartial' => 'message-exception.phtml'));
     }
     $this->layout()->setTemplate($mainLayout);
 }
Пример #3
0
 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);
 }