public function indexAction()
 {
     $mainLayout = $this->initializeFrontendWebsite();
     $profondita = $this->params()->fromRoute('profondita');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $templateDir = $this->layout()->getVariable('templateDir');
     $basicLayout = $this->layout()->getVariable('amministrazione_trasparente_basiclayout');
     try {
         $helper = new ContenutiControllerHelper();
         $sottosezioniRecords = $helper->recoverWrapperRecords(new SottoSezioniGetterWrapper(new SottoSezioniGetter($em)), array('attivo' => 1, 'profonditaDa' => $profondita, 'languageAbbreviation' => 'it', 'isAmmTrasparente' => 1, 'orderBy' => 'sottosezioni.posizione ASC'));
         $wrapperContenuti = $helper->recoverWrapper(new ContenutiGetterWrapper(new ContenutiGetter($em)), array('sottosezione' => $profondita, 'attivo' => 1, 'noscaduti' => 1, 'isAmmTrasparente' => 1, 'orderBy' => 'contenuti.posizione ASC'));
         $wrapperContenuti->setEntityManager($em);
         $contenutiRecords = $wrapperContenuti->addAttachmentsFromRecords($wrapperContenuti->getRecords(), array('moduleId' => ModulesContainer::amministrazione_trasparente_id, 'noscaduti' => 1, 'languageAbbreviation' => 'it', 'orderBy' => 'a.position'));
         $helper->checkRecords($contenutiRecords, "I dati relativi all'articolo richiesto non sono stati trovati");
         $formSearch = new ContenutiFormSearch();
         $formSearch->addAnno();
         $formSearch->addCheckExpired();
         $formSearch->addSubmitButton();
         $formSearch->setData(array('anno' => date("Y")));
         $this->layout()->setVariables(array('form' => $formSearch, 'sottoSezioni' => $sottosezioniRecords, 'contenuti' => !empty($contenutiRecords) ? $contenutiRecords : null, 'templatePartial' => 'amministrazione-trasparente/amministrazione-trasparente.phtml'));
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('messageTitle' => 'Nessun articolo trovato', 'messageText' => 'Impossibile visualizzare i dati per la richiesta effettuata', 'moduleLabel' => 'Amministrazione trasparente', 'templatePartial' => 'message.phtml'));
         // TODO: log error
     }
     $this->layout()->setTemplate(isset($basicLayout) ? $templateDir . $basicLayout : $mainLayout);
 }
예제 #2
0
 public function indexAction()
 {
     $mainLayout = $this->initializeFrontendWebsite();
     $subsectionid = $this->params()->fromRoute('subsectionid');
     $lang = $this->params()->fromRoute('lang');
     /**
      * @var \Doctrine\ORM\EntityManager $em
      */
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $ammTraspSezioneId = $this->layout()->getVariable('amministrazione_trasparente_sezione_id');
     $helper = new ContenutiControllerHelper();
     $wrapper = $helper->recoverWrapper(new ContenutiGetterWrapper(new ContenutiGetter($em)), array('noscaduti' => 1, 'attivo' => 1, 'modulo' => ModulesContainer::contenuti_id, 'sottosezione' => $subsectionid, 'languageAbbreviation' => $lang));
     $wrapper->setEntityManager($em);
     $records = $wrapper->addAttachmentsFromRecords($wrapper->getRecords(), array('moduleId' => ModulesContainer::contenuti_id, 'noscaduti' => 1, 'languageAbbreviation' => $lang, 'orderBy' => 'a.position'));
     if (!empty($records)) {
         foreach ($records as &$record) {
             $wrapper = new SottoSezioniGetterWrapper(new SottoSezioniGetter($em));
             $wrapper->setInput(array('profonditaDa' => isset($record['sottosezione']) ? $record['sottosezione'] : null, 'excludeSezioneId' => isset($ammTraspSezioneId) ? $ammTraspSezioneId : null));
             $wrapper->setupQueryBuilder();
             $subSections = $wrapper->getRecords();
             if (!empty($subSections)) {
                 foreach ($subSections as $subSection) {
                     $record['sotto_sezioni'][] = $subSection;
                 }
             }
         }
     }
     $this->layout()->setVariables(array('records' => isset($records) ? $records : null, 'recordsCount' => count($records), 'templatePartial' => 'contenuti/contenuti-list.phtml'));
     $this->layout()->setTemplate($mainLayout);
 }