/** * Load data fixtures with the passed EntityManager * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $form = new SezioniForm(); $form->addOptions(); $form->addLingue(array('it' => 'Italian', 'en' => 'English')); $form->addIconImage(); $form->setData(array('titolo' => 'My Content Title', 'sommario' => 'My Content SubTitle', 'testo' => 'My Large Text', 'sottosezione' => 1, 'dataInserimento' => '2015-05-28 01:01:00', 'dataScadenza' => '2015-05-28 01:01:00', 'attivo' => 1, 'home' => 1, 'rss' => 1, 'utente' => 1, 'id' => 1)); $inputFilter = new ContenutiFormInputFilter(); $form->setInputFilter($inputFilter); if ($form->isValid()) { $inputFilter->exchangeArray($form->getData()); $helper = new SezioniControllerHelper(); $helper->setEntityManager($this->recoverEntityManager()); $helper->setConnection($this->recoverConnection()); $helper->insert($inputFilter); } }
public function indexAction() { $mainLayout = $this->initializeAdminArea(); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $configurations = $this->layout()->getVariable('configurations'); $languageSelection = $this->params()->fromRoute('languageSelection'); $moduleName = $this->params()->fromRoute('moduleName'); $helper = new SezioniControllerHelper(); $wrapper = $helper->recoverWrapper(new SezioniGetterWrapper(new SezioniGetter($em)), array('fields' => 'sezioni.id, sezioni.nome, sezioni.colonna, sezioni.posizione', 'attivo' => 1, 'languageAbbreviation' => $languageSelection, 'orderBy' => 'sezioni.posizione')); $isMultiLanguage = !empty($configurations['isMultiLanguage']); if ($isMultiLanguage == 1) { $helper->setLanguagesGetterWrapper(new LanguagesGetterWrapper(new LanguagesGetter($em))); $formLanguage = $helper->setupLanguageFormSearch(new LanguagesFormSearch(), array('status' => 1), $languageSelection); } $this->layout()->setVariables(array('moduleName' => $moduleName, 'records' => $wrapper->formatRecordsPerColumn($wrapper->getRecords()), 'templatePartial' => 'sezioni/sezioni-posizioni.phtml', 'formLanguage' => isset($formLanguage) ? $formLanguage : null)); $this->layout()->setTemplate($mainLayout); }
public function indexAction() { $mainLayout = $this->initializeAdminArea(); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $configurations = $this->layout()->getVariable('configurations'); $page = $this->params()->fromRoute('page'); $languageSelection = $this->params()->fromRoute('languageSelection'); $modulename = $this->params()->fromRoute('modulename'); $sessionContainer = new SessionContainer(); $sessionSearch = $sessionContainer->offsetGet(SottoSezioniSearchController::sessionIdentifier); $helper = new SezioniControllerHelper(); try { $wrapper = $helper->recoverWrapperRecordsPaginator(new SottoSezioniGetterWrapper(new SottoSezioniGetter($em)), array('isAmmTrasparente' => $modulename == 'amministrazione-trasparente' ? 1 : 0, 'languageAbbreviation' => $languageSelection, 'freeSearch' => isset($sessionSearch['testo']) ? $sessionSearch['testo'] : null), $page, null); $sezioniRecords = $helper->recoverWrapperRecords(new SezioniGetterWrapper(new SezioniGetter($em)), array('languageAbbreviation' => $languageSelection, 'fields' => 'sezioni.id, sezioni.nome', 'orderBy' => 'sezioni.posizione ASC')); $helper->checkRecordset($sezioniRecords, 'Nessuna sezione presente'); if (!empty($configurations['isMultiLanguage']) == 1) { $helper->setLanguagesGetterWrapper(new LanguagesGetterWrapper(new LanguagesGetter($em))); $formLanguage = $helper->setupLanguageFormSearch(new LanguagesFormSearch(), array('status' => 1), $languageSelection); } $formSearch = new SottoSezioniFormSearch(); $formSearch->addSezioni($helper->formatForDropwdown($sezioniRecords, 'id', 'nome')); $formSearch->addSubmitButton(); $formSearch->setData(!empty($sessionSearch) ? $sessionSearch : array()); $this->layout()->setVariables(array('tableTitle' => 'Sottosezioni ' . ucfirst(str_replace('-', ' ', $modulename)), 'tableDescription' => $wrapper->getPaginator()->getTotalItemCount() . ' sottosezioni in archivio', 'columns' => array("Nome", "Sezione", " ", " ", " "), 'sessionSearch' => $sessionSearch, 'formLanguage' => isset($formLanguage) ? $formLanguage : null, 'paginator' => $wrapper->getPaginator(), 'records' => $this->formatRecordsToShowOnTable($wrapper->setupRecords()), 'formSearch' => $formSearch, 'templatePartial' => 'datatable/datatable_sottosezioni.phtml')); } catch (\Exception $e) { $this->layout()->setVariables(array('messageText' => $e->getMessage(), 'templatePartial' => 'message-exception.phtml')); } $this->layout()->setTemplate($mainLayout); }
public function indexAction() { $mainLayout = $this->initializeAdminArea(); $id = $this->params()->fromRoute('id'); $lang = $this->params()->fromRoute('lang'); $languageSelection = $this->params()->fromRoute('languageSelection'); $modulename = $this->params()->fromRoute('modulename'); $modulenameLabel = str_replace('-', ' ', $modulename); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $helper = new SezioniControllerHelper(); $recordFromDb = $helper->recoverWrapperRecordsById(new SezioniGetterWrapper(new SezioniGetter($em)), array('id' => $id, 'limit' => 1), $id); $helper->setLanguagesGetterWrapper(new LanguagesGetterWrapper(new LanguagesGetter($em))); $languagesRecordsForDropdown = $helper->formatForDropwdown($helper->recoverWrapperRecords($helper->getLanguagesGetterWrapper(), array('status' => 1)), 'id', 'name'); $form = new SezioniForm(); $form->addIconImage(); $form->addLingue($languagesRecordsForDropdown); $form->addOptions(); // $form->addModule(); $form->addBlocco(); if (!empty($recordFromDb)) { $form->setData($recordFromDb[0]); $submitButtonValue = 'Modifica'; $formTitle = $recordFromDb[0]['nome']; $formAction = $this->url()->fromRoute('admin/sezioni-update', array('lang' => $lang, 'languageSelection' => $languageSelection, 'modulename' => $modulename)); } else { $form->setData(array('posizione' => 1, 'lingua' => 1, 'isAmmTrasparente' => $modulename != 'contenuti' ? 1 : 0)); $formTitle = 'Nuova sezione'; $submitButtonValue = 'Inserisci'; $formAction = $this->url()->fromRoute('admin/sezioni-insert', array('lang' => $lang, 'languageSelection' => $languageSelection, 'modulename' => $modulename)); } $this->layout()->setVariables(array('form' => $form, 'formAction' => $formAction, 'formTitle' => $formTitle, 'formDescription' => 'Le sezioni rappresentano i blocchi principali sui quali costruire le basi degli articoli. <strong>ATTENZIONE:</strong> se non sono presenti sottosezioni e\\o relativi articoli, le sezioni non saranno visibili sul sito pubblico.', 'submitButtonValue' => $submitButtonValue, 'formBreadCrumbCategory' => array(array('href' => '#', 'label' => ucfirst($modulenameLabel), 'title' => 'Elenco ' . $modulename), array('href' => $this->url()->fromRoute('admin/sezioni-summary', array('lang' => $lang, 'languageSelection' => $languageSelection, 'modulename' => $modulename)), 'label' => 'Sezioni', 'title' => 'Sezioni ' . $modulenameLabel)), 'templatePartial' => self::formTemplate)); $this->layout()->setTemplate($mainLayout); }
public function indexAction() { /** * @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'); } $inputFilter = new SezioniFormInputFilter(); $form = new SezioniForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new SezioniControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->setLoggedUser($userDetails); $helper->insert($inputFilter); $lastInsertId = $helper->getConnection()->lastInsertId(); $helper->getConnection()->commit(); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::albo_pretorio_id, 'message' => "Inserita nuova sezione " . $inputFilter->nome, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Sezione inserita correttamente', 'messageText' => 'Inserire almeno una sottosezione relativa o la stessa non sarà visibile sul sito web.', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/sezioni-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'modulename' => $this->params()->fromRoute('modulename'))), 'backToSummaryText' => "Elenco sezioni", 'insertAgainLabel' => "Inserisci un'altra sezione")); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $exDb) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore inserimento nuova sezione: " . $inputFilter->nome, 'type' => 'error', 'description' => $e->getMessage(), 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento nuova sezione', 'messageText' => 'Messaggio generato: ' . $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(); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $configurations = $this->layout()->getVariable('configurations'); $id = $this->params()->fromRoute('id'); $modulename = $this->params()->fromRoute('modulename'); $lang = $this->params()->fromRoute('lang'); $page = $this->params()->fromRoute('page'); $languageSelection = $this->params()->fromRoute('languageSelection'); try { $helper = new SezioniControllerHelper(); $sezioniRecords = $helper->recoverWrapperRecords(new SezioniGetterWrapper(new SezioniGetter($em)), array('fields' => 'sezioni.id, sezioni.nome', 'isAmmTrasparente' => $modulename != 'contenuti' ? 1 : 0, 'orderBy' => 'sezioni.nome')); $helper->checkRecords($sezioniRecords, 'Nessuna sezione in archivio. Impossibile inserire una sottosezione. Inserire almeno una sezione'); $sottoSezioniRecords = $helper->recoverWrapperRecordsById(new SottoSezioniGetterWrapper(new SottoSezioniGetter($em)), array('id' => $id, 'limit' => 1), $id); $form = new SottoSezioniForm(); $form->addSezioni($helper->formatForDropwdown($sezioniRecords, 'id', 'nome')); $form->addMainFormInputs(); if (!empty($sottoSezioniRecords)) { $form->setData($sottoSezioniRecords[0]); $formTitle = $sottoSezioniRecords[0]['nomeSottoSezione']; $submitButtonValue = 'Modifica'; $formBreadCrumbTitle = 'Modifica'; $formAction = $this->url()->fromRoute('admin/sottosezioni-update', array('lang' => $lang, 'languageSelection' => $languageSelection, 'modulename' => $modulename)); } else { $formTitle = 'Nuova sottosezione'; $formBreadCrumbTitle = 'Nuova'; $submitButtonValue = 'Inserisci'; $formAction = $this->url()->fromRoute('admin/sottosezioni-insert', array('lang' => $lang, 'languageSelection' => $languageSelection, 'modulename' => $modulename)); } $this->layout()->setVariables(array('form' => $form, 'formAction' => $formAction, 'formTitle' => $formTitle, 'formDescription' => 'Dati relativi alla sottosezione', 'submitButtonValue' => $submitButtonValue, 'formBreadCrumbTitle' => $formBreadCrumbTitle, 'formBreadCrumbCategory' => 'Sottosezioni', 'formBreadCrumbCategory' => array(array('href' => $this->url()->fromRoute('admin/contenuti-summary', array('lang' => $lang, 'languageSelection' => $languageSelection, 'modulename' => $modulename, 'previouspage' => $page)), 'label' => ucfirst($modulename), 'title' => 'Elenco ' . $modulename), array('href' => $this->url()->fromRoute('admin/sottosezioni-summary', array('lang' => $lang, 'modulename' => 'amministrazione-trasparente', 'languageSelection' => $languageSelection)), 'label' => 'Sottosezioni', 'title' => 'Sezioni ' . $modulename)), 'templatePartial' => self::formTemplate)); } catch (\Exception $e) { $this->layout()->setVariables(array('messageType' => 'warning', 'messageTitle' => 'Errore verificato', 'messageText' => $e->getMessage(), 'templatePartial' => 'message.phtml')); } $this->layout()->setTemplate($mainLayout); }
public function indexAction() { /** * @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'); } $inputFilter = new SezioniFormInputFilter(); $form = new SezioniForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new SezioniControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); $helper->setLoggedUser($userDetails); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->update($inputFilter); $helper->getConnection()->commit(); // TODO: upload icon, delete old icon if old icon is set and its file exists $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Aggiornata sezione " . $inputFilter->nome, 'type' => 'info', 'reference_id' => $inputFilter->id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Sezione aggiornata correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna alla sezione', 'backToSummaryLink' => $this->url()->fromRoute('admin/sezioni-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'modulename' => $this->params()->fromRoute('modulename'))), 'backToSummaryText' => "Elenco sezioni")); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $exDb) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore aggiornamento sezione ", 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $inputFilter->id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore aggiornamento sezione', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna alla sezione')); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } }