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);
 }
Example #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);
 }
 public function jsonAction()
 {
     $this->initializeFrontendWebsite();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $id = $this->params()->fromRoute('id');
     $helper = new ContenutiControllerHelper();
     $wrapper = $helper->recoverWrapperById(new ContenutiGetterWrapper(new ContenutiGetter($em)), array('id' => $id, 'limit' => 1), $id);
     $wrapper->setEntityManager($em);
     $records = $wrapper->addAttachmentsFromRecords($wrapper->getRecords(), array());
     if (empty($records)) {
         return $this->redirectForUnvalidAccess();
     }
     $record = $records[0];
     return new JsonModel(array('Titolo' => $record['titolo'], 'Testo' => $record['testo'], 'Sezione' => $record['nomeSezione']));
 }
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $id = $this->params()->fromRoute('id');
     $helper = new ContenutiControllerHelper();
     $contenutiRecords = $helper->recoverWrapperRecordsById(new ContenutiGetterWrapper(new ContenutiGetter($em)), array('id' => $id, 'limit' => 1, 'fields' => 'contenuti.id, contenuti.titolo, contenuti.tabella'), $id);
     $form = new ContenutiTabellaForm();
     $formAction = $this->url()->fromRoute('admin/amministrazione-trasparente-tabella-update', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'modulename' => 'amministrazione-trasparente'));
     $formTitle = $contenutiRecords[0]['titolo'];
     $formDescription = "Compila i dati della tabella (dati aggiuntivi all'articolo)";
     if (!empty($contenutiRecords[0])) {
         $form->setData($contenutiRecords[0]);
     }
     $this->layout()->setVariables(array('form' => $form, 'formAction' => $formAction, 'formTitle' => $formTitle, 'formDescription' => $formDescription, 'submitButtonValue' => 'Aggiorna', 'CKEditorField' => array('tabella'), 'formBreadCrumbCategory' => array(array('href' => $this->url()->fromRoute('admin/contenuti-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'modulename' => 'amministrazione-trasparente')), 'label' => 'Amministrazione Trasparente', 'title' => 'Vai alla gestione amministrazione Trasparente'), array('href' => '#', 'label' => 'Articolo', 'title' => "Vai alla gestione dell'articolo")), 'formBreadCrumbTitle' => 'Gestione tabella aggiuntiv', 'templatePartial' => self::formTemplate));
     $this->layout()->setTemplate($mainLayout);
 }
 /**
  * @return \Zend\Http\Response
  */
 public function indexAction()
 {
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     /**
      * @var \Doctrine\DBAL\Connection $connection
      */
     $connection = $em->getConnection();
     $request = $this->getRequest();
     $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
     if (!($request->isXmlHttpRequest() or $request->isPost())) {
         return $this->redirect()->toRoute('main');
     }
     $inputFilter = new ContenutiTabellaFormInputFilter();
     $form = new ContenutiTabellaForm();
     $form->setBindOnValidate(false);
     $form->setInputFilter($inputFilter->getInputFilter());
     $form->setData($post);
     $this->initializeAdminArea();
     $userDetails = $this->recoverUserDetails();
     try {
         if (!$form->isValid()) {
             throw new NullException("The form is not valid");
         }
         $inputFilter->exchangeArray($form->getData());
         $helper = new ContenutiControllerHelper();
         $helper->setConnection($connection);
         $helper->getConnection()->beginTransaction();
         $helper->updateTabella($inputFilter);
         $helper->getConnection()->commit();
         $logWriter = new LogWriter($connection);
         $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::amministrazione_trasparente_id, 'message' => "Aggiornata tabella articolo " . $inputFilter->titolo, 'type' => 'info', 'reference_id' => $inputFilter->id, 'backend' => 1));
         $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Articolo aggiornato correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'messageShowFormLink' => 1, 'messageShowForm' => "Torna alla tabella artcolo"));
         $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml');
     } catch (\Exception $e) {
         $logWriter = new LogWriter($connection);
         $logWriter->writeLog(array('user_id' => isset($userDetails->id) ? $userDetails->id : null, 'module_id' => ModulesContainer::amministrazione_trasparente_id, 'message' => "Errore aggiornamento tabella articolo amm. trasparente ", 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $inputFilter->id, 'backend' => 1));
         $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore aggiornamento tabella articolo amm. trasparente', 'messageText' => 'Messaggio generato: ' . $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => "Torna alla tabella dell'articolo amm. trasparente"));
         $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml');
     }
 }
 public function indexAction()
 {
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     /**
      * @var \Doctrine\DBAL\Connection $connection
      */
     $connection = $em->getConnection();
     $request = $this->getRequest();
     $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
     if (!($request->isXmlHttpRequest() or $request->isPost())) {
         return $this->redirect()->toRoute('main');
     }
     $modulename = $this->params()->fromRoute('modulename');
     /* $modulenameLabel = str_replace("-", " ", $modulename); */
     $inputFilter = new ContenutiFormInputFilter();
     $form = new ContenutiForm();
     $form->setBindOnValidate(false);
     $form->setInputFilter($inputFilter->getInputFilter());
     $form->setData($post);
     $this->initializeAdminArea();
     $userDetails = $this->recoverUserDetails();
     try {
         if (!$form->isValid()) {
             throw new NullException("The form is not valid");
         }
         $inputFilter->exchangeArray($form->getData());
         $helper = new ContenutiControllerHelper();
         $helper->setConnection($connection);
         $helper->setLoggedUser($userDetails);
         $helper->getConnection()->beginTransaction();
         $lastInsertId = $helper->insert($inputFilter);
         // TODO: insert in home, update home field if home is selected
         $helper->setLogWriter(new LogWriter($connection));
         $helper->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Inserito nuovo contenuto \\ articolo " . $inputFilter->titolo, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1));
         $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Articolo inserito correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/contenuti-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'modulename' => $modulename)), 'backToSummaryText' => "Elenco contenuti", 'insertAgainLabel' => "Inserisci un altro articolo \\ contenuto", 'attachmentsLink' => $this->url()->fromRoute('admin/attachments-summary', array('lang' => $this->params()->fromRoute('languageSelection'), 'module' => 'contenuti', 'referenceId' => $lastInsertId))));
         $helper->getConnection()->commit();
         $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml');
     } catch (\Exception $e) {
         $logWriter = new LogWriter($connection);
         $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore inserimento nuovo contenuto \\ articolo: " . $inputFilter->titolo, 'description' => $e->getMessage() . "; Titolo: " . $inputFilter->titolo . " Testo: " . $inputFilter->testo . ' Sottosezione: ' . $inputFilter->sottosezione, 'type' => 'error', 'backend' => 1));
         $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento contenuto \\ articolo', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati'));
         $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml');
     }
 }
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $id = $this->params()->fromRoute('id');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $userDetails = $this->layout()->getVariable('userDetails');
     $languageSelection = $this->params()->fromRoute('languageSelection');
     $modulename = $this->params()->fromRoute('modulename');
     try {
         $helper = new ContenutiControllerHelper();
         $sottoSezioniRecords = $helper->recoverWrapperRecords(new SottoSezioniGetterWrapper(new SottoSezioniGetter($em)), array('showToAll' => $userDetails->role == 'WebMaster' ? null : 1, 'languageAbbreviation' => $languageSelection, 'isAmmTrasparente' => $modulename != 'contenuti' ? 1 : 0));
         $helper->checkRecords($sottoSezioniRecords, 'Nessuna sottosezione presente');
         $sottoSezioniRecordsForDropDown = $helper->formatSottoSezioniGetterWrapperRecordsForDropdown($sottoSezioniRecords);
         $contenutiRecords = $helper->recoverWrapperRecordsById(new ContenutiGetterWrapper(new ContenutiGetter($em)), array('id' => $id, 'isAmmTrasparente' => $modulename != 'contenuti' ? 1 : 0, 'utente' => $userDetails->role == 'WebMaster' ? null : $userDetails->id, 'limit' => 1), $id);
         $form = new ContenutiForm();
         $form->addSottoSezioni($sottoSezioniRecordsForDropDown);
         $form->addMainFormElements();
         if ($userDetails->role == 'WebMaster') {
             $usersRecords = $helper->recoverWrapperRecords(new UsersGetterWrapper(new UsersGetter($em)), array('orderBy' => 'u.name'));
             $arrayToReturn = array();
             if (!empty($usersRecords)) {
                 foreach ($usersRecords as $record) {
                     $arrayToReturn[$record['id']] = $record['name'] . ' ' . $record['surname'];
                 }
             }
             $form->addUsers($arrayToReturn);
         }
         $form->addHomeBox();
         if (!empty($contenutiRecords)) {
             $form->setData($contenutiRecords[0]);
             $submitButtonValue = 'Modifica';
             $formTitle = 'Modifica articolo';
             $formDescription = "Modifica i dati relativi all'articolo. Massimo 255 caratteri per i campi testo. Utilizzare testi brevi e concisi. Evitare copia \\ incolla da file word o pagine web che potrebbero pregiudicare l’accessibilità del sito web.";
             $formAction = $this->url()->fromRoute('admin/contenuti-update', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $languageSelection, 'modulename' => $modulename));
             $formBreadCrumbTitle = '';
         } else {
             $form->setData(array('dataInserimento' => date('Y-m-d H:i:s'), 'dataScadenza' => date('Y-m-d H:i:s', strtotime('+5 years')), 'attivo' => 1, 'utente' => $userDetails->id));
             $form->addSocial();
             $formTitle = 'Nuovo articolo';
             $formDescription = "Inserisci i dati relativi all'articolo. Massimo 255 caratteri per i campi testo. Utilizzare testi brevi e concisi. Evitare copia \\ incolla da file word o pagine web che potrebbero pregiudicare l’accessibilità del sito web.";
             $submitButtonValue = 'Inserisci';
             $formAction = $this->url()->fromRoute('admin/contenuti-insert', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $languageSelection, 'modulename' => $modulename));
             $formBreadCrumbTitle = 'Nuovo artciolo';
         }
         $this->layout()->setVariables(array('form' => $form, 'formAction' => $formAction, 'formTitle' => $formTitle, 'formDescription' => $formDescription, 'submitButtonValue' => $submitButtonValue, 'CKEditorField' => array('testo'), 'formBreadCrumbCategory' => ucfirst(str_replace('-', ' ', $modulename)), 'formBreadCrumbCategoryLink' => $this->url()->fromRoute('admin/contenuti-summary', array('lang' => $this->params()->fromRoute('lang'), 'page' => $this->params()->fromRoute('previouspage'), 'languageSelection' => $languageSelection, 'modulename' => $modulename)), 'formBreadCrumbTitle' => $formBreadCrumbTitle, 'templatePartial' => self::formTemplate));
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('messageType' => 'warning', 'messageTitle' => 'Errore verificato', 'messageText' => 'Messaggio generato ' . $e->getMessage(), 'templatePartial' => 'message.phtml'));
     }
     $this->layout()->setTemplate($mainLayout);
 }
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $page = $this->params()->fromRoute('page');
     $perPage = $this->params()->fromRoute('perPage');
     $configurations = $this->layout()->getVariable('configurations');
     $userDetails = $this->layout()->getVariable('userDetails');
     $userRole = isset($userDetails->role) ? $userDetails->role : '';
     $userId = isset($userDetails->id) ? $userDetails->id : 1;
     $languageSelection = $this->params()->fromRoute('languageSelection');
     $modulename = $this->params()->fromRoute('modulename');
     $isAmmTrasparente = $modulename != 'contenuti' ? 1 : 0;
     $sessionContainer = new SessionContainer();
     $sessionSearch = $sessionContainer->offsetGet(ContenutiSearchController::sessionIdentifier);
     $helper = new ContenutiControllerHelper();
     /* Detect form switch language */
     if (!empty($configurations['isMultiLanguage']) == 1 and $modulename == 'contenuti') {
         $helper->setLanguagesGetterWrapper(new LanguagesGetterWrapper(new LanguagesGetter($em)));
         $formLanguage = $helper->setupLanguageFormSearch(new LanguagesFormSearch(), array('status' => 1), $languageSelection);
     }
     try {
         $wrapper = $helper->recoverWrapperRecordsPaginator(new ContenutiGetterWrapper(new ContenutiGetter($em)), array_merge(array('showToAll' => $userRole == 'WebMaster' ? null : 1, 'utente' => $userRole == 'WebMaster' ? null : $userId, 'languageAbbreviation' => $languageSelection, 'isAmmTrasparente' => $isAmmTrasparente, 'inhome' => isset($sessionSearch['inhome']) ? $sessionSearch['inhome'] : null, 'sottosezione' => isset($sessionSearch['sottosezioni']) ? $sessionSearch['sottosezioni'] : null, 'freeSearch' => isset($sessionSearch['testo']) ? $sessionSearch['testo'] : null, 'orderBy' => 'contenuti.id DESC'), !empty($sessionSearch) ? $sessionSearch : array()), $page, $perPage);
         $sottoSezioniRecords = $helper->recoverWrapperRecords(new SottoSezioniGetterWrapper(new SottoSezioniGetter($em)), array('isAmmTrasparente' => $isAmmTrasparente, 'showToAll' => $userRole == 'WebMaster' ? null : 1, 'languageAbbreviation' => $languageSelection));
         $helper->checkRecords($sottoSezioniRecords, 'Nessuna sottosezione presente, verificare i parametri di ricerca e se sono presenti i dati');
         $sottoSezioniRecordsForDropDown = $helper->formatSottoSezioniGetterWrapperRecordsForDropdown($sottoSezioniRecords);
         $wrapper->setEntityManager($em);
         $paginatorRecords = $wrapper->addAttachmentsToPaginatorRecords($wrapper->setupRecords(), array('moduleId' => $modulename == 'contenuti' ? ModulesContainer::contenuti_id : ModulesContainer::amministrazione_trasparente_id, 'orderBy' => 'a.position'));
         $formSearch = new ContenutiFormSearch();
         $formSearch->addSottosezioni($sottoSezioniRecordsForDropDown);
         $formSearch->addInHome();
         $formSearch->addSubmitButton();
         $formSearch->setData(array_merge(array('languageSelection' => $languageSelection), !empty($sessionSearch) ? $sessionSearch : array()));
         $paginator = $wrapper->getPaginator();
         $paginatorRecordsCount = $paginator->getTotalItemCount();
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('showMessage' => 1, 'messageType' => 'danger', 'messageTitle' => 'Si è verificato un problema', 'messageText' => $e->getMessage(), 'templatePartial' => 'message.phtml'));
     }
     $this->layout()->setVariables(array('tableTitle' => $modulename == 'contenuti' ? 'Contenuti' : 'Amministrazione trasparente', 'tableDescription' => !empty($paginatorRecordsCount) ? $paginatorRecordsCount . ' articoli in archivio' : null, 'paginator' => !empty($paginator) ? $paginator : null, 'records' => !empty($paginatorRecords) ? $this->formatRecordsToShowOnTable($paginatorRecords) : null, 'templatePartial' => 'datatable/datatable_contenuti.phtml', 'formSearch' => !empty($formSearch) ? $formSearch : null, 'formLanguage' => isset($formLanguage) ? $formLanguage : null, 'sessionSearch' => isset($sessionSearch) ? $sessionSearch : null, 'columns' => array("Sezione", "Sotto sezione", "Titolo", 'Date', 'Inserito da', " ", $userDetails->acl->hasResource("contenuti_update") ? " " : null, $userDetails->acl->hasResource("contenuti_delete") ? " " : null, $userDetails->acl->hasResource("contenuti_homepage") ? " " : null, $userDetails->acl->hasResource("contenuti_attachments") ? " " : null, ($isAmmTrasparente == 1 and $userDetails->acl->hasResource("amministrazione_trsparente_tabelle")) ? " " : null)));
     $this->layout()->setTemplate($mainLayout);
 }
 /**
  * Update contenuti and render a message view
  *
  * @return \Zend\Http\Response
  */
 public function indexAction()
 {
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     /**
      * @var \Doctrine\DBAL\Connection $connection
      */
     $connection = $em->getConnection();
     $request = $this->getRequest();
     $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
     if (!($request->isXmlHttpRequest() or $request->isPost())) {
         return $this->redirect()->toRoute('main');
     }
     $inputFilter = new ContenutiFormInputFilter();
     $form = new ContenutiForm();
     $form->setBindOnValidate(false);
     $form->setInputFilter($inputFilter->getInputFilter());
     $form->setData($post);
     $this->initializeAdminArea();
     $userDetails = $this->recoverUserDetails();
     try {
         if (!$form->isValid()) {
             throw new NullException("The form is not valid");
         }
         $inputFilter->exchangeArray($form->getData());
         $helper = new ContenutiControllerHelper();
         $helper->setConnection($connection);
         $helper->getConnection()->beginTransaction();
         $helper->update($inputFilter);
         $helper->getConnection()->commit();
         // TODO: insert or delete in home, update home field
         $helper->setLogWriter(new LogWriter($connection));
         $helper->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Aggiornato il contenuto " . $inputFilter->titolo, 'type' => 'info', 'reference_id' => $inputFilter->id, 'backend' => 1));
         $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Contenuto aggiornato correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al contenuto', 'backToSummaryLink' => $this->url()->fromRoute('admin/contenuti-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'modulename' => $this->params()->fromRoute('modulename'))), 'backToSummaryText' => "Elenco contenuti", 'attachmentsLink' => $this->url()->fromRoute('admin/attachments-summary', array('lang' => $this->params()->fromRoute('lang'), 'module' => 'contenuti', 'referenceId' => $inputFilter->id))));
         $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml');
     } catch (\Exception $e) {
         $logWriter = new LogWriter($connection);
         $logWriter->writeLog(array('user_id' => isset($userDetails->id) ? $userDetails->id : null, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore aggiornamento contenuto ID: " . $inputFilter->id, 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $inputFilter->id, 'backend' => 1));
         $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore aggiornamento contenuto', 'messageText' => 'Messaggio generato: ' . $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al contenuto'));
         $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml');
     }
 }
 public function indexAction()
 {
     $id = $this->params()->fromPost('id');
     /**
      * @var \Doctrine\ORM\EntityManager $em
      */
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     /**
      * @var \Doctrine\DBAL\Connection $connection
      */
     $connection = $em->getConnection();
     $request = $this->getRequest();
     $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
     if (!($request->isXmlHttpRequest() or $request->isPost())) {
         return $this->redirect()->toRoute('main');
     }
     $mainLayout = $this->initializeAdminArea();
     $configurations = $this->layout()->getVariable('configurations');
     $userDetails = $this->recoverUserDetails();
     $moduleId = $this->params()->fromRoute('modulename') == 'contenuti' ? ModulesContainer::contenuti_id : ModulesContainer::amministrazione_trasparente_id;
     $helper = new ContenutiControllerHelper();
     try {
         $contentRecord = $helper->recoverWrapperRecordsById(new ContenutiGetterWrapper(new ContenutiGetter($em)), array('id' => $post['deleteId'], 'limit' => 1), $post['deleteId']);
         $helper->checkRecords($contentRecord, 'Articolo da eliminare non trovato');
         $helper->setConnection($connection);
         $helper->getConnection()->beginTransaction();
         $helper->delete($post['deleteId']);
         $helper->getConnection()->commit();
         /* Delte Attachments files */
         $attachmentsHelper = new AttachmentsControllerHelper();
         $attachmentsHelper->setConnection($connection);
         $attachmentsRecords = $helper->recoverWrapperRecords(new AttachmentsGetterWrapper(new AttachmentsGetter($em)), array('referenceId' => $post['deleteId'], 'moduleId' => $moduleId));
         if (!empty($attachmentsRecords)) {
             foreach ($attachmentsRecords as $attachmentRecord) {
                 $attachmentsHelper->deleteAttachments($attachmentsRecords['id']);
                 $attachmentsHelper->deleteAttachmentsRelations($attachmentsRecords['id']);
                 $s3 = new S3($configurations['amazon_s3_accesskey'], $configurations['amazon_s3_secretkey']);
                 $s3->deleteObject($configurations['amazon_s3_bucket'], $this->params()->fromRoute('modulename') . '/' . $attachmentRecord[0]['name']);
             }
         }
         /* Delete from home page */
         $homeHelper = new HomePagePutRemoveControllerHelper();
         $homePageRecords = $homeHelper->recoverWrapperRecords(new HomePageGetterWrapper(new HomePageGetter($em)), array('referenceId' => $post['deleteId'], 'moduleId' => $moduleId, 'moduleCode' => $this->params()->fromRoute('modulename')));
         if (!empty($homePageRecords)) {
             $homePageBlocksRecords = $helper->recoverWrapperRecords(new HomePageBlocksGetterWrapper(new HomePageBlocksGetter($em)), array('fields' => 'homePageBlocks.id', 'moduleId' => $moduleId, 'limit' => 1));
             $helper->checkRecords($homePageBlocksRecords, 'Impossibile recuperare i dati relativi al modulo in home page');
             $homeHelper->setConnection($connection);
             $homeHelper->getConnection()->beginTransaction();
             $homeHelper->deleteFromHomePage($post['deleteId'], $homePageBlocksRecords[0]['id']);
             $homeHelper->getConnection()->commit();
         }
         $logWriter = new LogWriter($connection);
         $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::recoverIdFromModuleCode($this->params()->fromRoute('modulename')), 'message' => "Eliminato articolo " . $contentRecord[0]['titolo'], 'type' => 'info', 'reference_id' => $id, 'backend' => 1));
         $referer = $this->getRequest()->getHeader('Referer');
         if (is_object($referer)) {
             return $this->redirect()->toUrl($referer->getUri());
         }
     } catch (\Exception $e) {
         try {
             // $helper->getConnection()->rollBack();
         } catch (\Doctrine\DBAL\ConnectionException $dbEx) {
         }
         $logWriter = new LogWriter($connection);
         $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore eliminazione file articolo ", 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $id, 'backend' => 1));
         $referer = $this->getRequest()->getHeader('Referer');
         if (is_object($referer)) {
             $refererLink = $referer->getUri();
         }
         $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore eliminazione contenuto', 'messageText' => $e->getMessage(), 'previousPageLink' => isset($refererLink) ? $refererLink : null, 'previousPageLabel' => "Torna all'elenco", 'templatePartial' => "message.phtml"));
     }
     $this->layout()->setTemplate($mainLayout);
 }