public function txtAction()
 {
     $this->initializeFrontendWebsite();
     $id = $this->params()->fromRoute('id');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $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();
     }
     $content = '';
     $content .= $this->layout()->getVariable('sitename') . PHP_EOL;
     $content .= PHP_EOL;
     $content .= "Articolo" . PHP_EOL;
     $content .= PHP_EOL;
     foreach ($records as $record) {
         $content .= $record['titolo'] . PHP_EOL;
         if ($record['sommario'] != '') {
             $content .= strip_tags($record['sommario']) . PHP_EOL;
         }
         $content .= strip_tags($record['testo']) . PHP_EOL;
         $content .= 'Sezione: ' . $record['nomeSezione'] . PHP_EOL;
     }
     $content .= " " . PHP_EOL;
     $content .= date("Y") . ' ' . $this->layout()->getVariable('sitename');
     $response = $this->getResponse();
     $response->getHeaders()->addHeaderLine('Content-Type', 'text/plain')->addHeaderLine('Content-Disposition', 'attachment; filename="' . Slugifier::slugify($record['titolo']) . '.txt"')->addHeaderLine('Accept-Ranges', 'bytes')->addHeaderLine('Content-Length', strlen($content));
     $response->setContent($content);
     return $response;
 }
Пример #2
0
 /**
  * Add category slug to an array recordset
  *
  * @param array $recordset
  * @return array|null
  */
 public function addCategorySlugToRecordset($recordset)
 {
     foreach ($recordset as &$record) {
         $record['categorySlug'] = Slugifier::slugify($record['categoryName']);
     }
     return $recordset;
 }
 public function txtAction()
 {
     $this->initializeFrontendWebsite();
     $id = $this->params()->fromRoute('id');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $helper = new AttiConcessioneControllerHelper();
     $wrapper = $helper->recoverWrapperById(new AttiConcessioneGetterWrapper(new AttiConcessioneGetter($em)), array('id' => $id, 'limit' => 1), $id);
     $wrapper->setEntityManager($em);
     $records = $wrapper->addAttachmentsFromRecords($wrapper->getRecords(), array());
     if (empty($records)) {
         return $this->redirectForUnvalidAccess();
     }
     $content = '';
     $content .= $this->layout()->getVariable('sitename') . PHP_EOL;
     $content .= PHP_EOL;
     $content .= "Atti di concessione" . PHP_EOL;
     $content .= PHP_EOL;
     foreach ($records as $record) {
         $content .= $record['titolo'] . PHP_EOL;
         $content .= 'Numero \\ Anno: ' . $record['progressivo'] . ' \\ ' . $record['anno'] . PHP_EOL;
         $content .= 'Beneficiario CF / PIVA: ' . $record['beneficiario'] . PHP_EOL;
         $content .= 'Importo: ' . $record['importo'] . PHP_EOL;
         $content .= 'Modalità Assegnazione: ' . $record['nomemodAssegnazione'] . PHP_EOL;
         $content .= 'Ufficio e responsabile del servizio: ' . $record['nomeSezione'] . ' ' . $record['nomeResponsabileProc'] . PHP_EOL;
         $content .= "Norma o titolo a base dell'attribuzione: " . $record['titolo'] . PHP_EOL;
     }
     $content .= " " . PHP_EOL;
     $content .= date("Y") . ' ' . $this->layout()->getVariable('sitename');
     $response = $this->getResponse();
     $response->getHeaders()->addHeaderLine('Content-Type', 'text/plain')->addHeaderLine('Content-Disposition', 'attachment; filename="' . Slugifier::slugify($record['titolo']) . '.txt"')->addHeaderLine('Accept-Ranges', 'bytes')->addHeaderLine('Content-Length', strlen($content));
     $response->setContent($content);
     return $response;
 }
 /**
  * @param InputFilterAwareInterface $formData
  * @return int
  */
 public function insert(InputFilterAwareInterface $formData)
 {
     $this->assertConnection();
     $slug = Slugifier::slugify($formData->name);
     $this->getConnection()->insert(DbTableContainer::postsCategories, array('name' => $formData->name, 'description' => $formData->description, 'create_date' => date("Y-m-d H:i:s"), 'expire_date' => date("Y-m-d H:i:s"), 'parent_id' => 0, 'module_id' => $formData->moduleId, 'language_id' => $formData->languageId, 'slug' => $slug, 'seo_url' => $slug, 'seo_title' => $formData->name, 'accesskey' => '', 'template_file' => '', 'position' => isset($formData->position) ? $formData->position : 1));
     return $this->getConnection()->lastInsertId();
 }
 /**
  * @param InputFilterAwareInterface $inputFilter
  * @return int
  * @throws NullException
  */
 public function insert(InputFilterAwareInterface $formData, $moduleCode)
 {
     $this->assertConnection();
     $this->assertLoggedUser();
     $userDetails = $this->getLoggedUser();
     $this->getConnection()->insert(DbTableContainer::sottosezioni, array('nome' => $formData->nomeSottoSezione, 'sezione_id' => $formData->sezione, 'url' => $formData->url, 'url_title' => $formData->urlTitle, 'posizione' => $formData->posizione, 'attivo' => $formData->attivo, 'profondita_da' => null, 'profondita_a' => 0, 'posizione' => 1, 'is_amm_trasparente' => $moduleCode != 'contenuti' ? 1 : 0, 'slug' => Slugifier::slugify($formData->nomeSottoSezione), 'utente_id' => $userDetails->id));
     return $this->getConnection()->lastInsertId();
 }
 /**
  * @param InputFilterAwareInterface $inputFilter
  * @return int
  * @throws NullException
  */
 public function update(InputFilterAwareInterface $inputFilter)
 {
     $this->assertConnection();
     $arrayUpdate = array('sottosezione_id' => $inputFilter->sottosezione, 'titolo' => $inputFilter->titolo, 'sommario' => $inputFilter->sommario, 'testo' => $inputFilter->testo, 'data_inserimento' => $inputFilter->dataInserimento, 'data_scadenza' => $inputFilter->dataScadenza, 'attivo' => $inputFilter->attivo, 'slug' => Slugifier::slugify($inputFilter->titolo), 'home' => $inputFilter->home, 'rss' => $inputFilter->rss);
     if (isset($inputFilter->utente)) {
         $arrayUpdate['utente_id'] = $inputFilter->utente;
     }
     return $this->getConnection()->update(DbTableContainer::contenuti, $arrayUpdate, array('id' => $inputFilter->id));
 }
Пример #7
0
 /**
  * Update post on database using Doctrine connection
  *
  * @param InputFilterAwareInterface $formData
  * @return int
  */
 public function update(InputFilterAwareInterface $formData)
 {
     $this->assertConnection();
     $arrayUpdate = array('title' => $formData->title, 'subtitle' => $formData->subtitle, 'description' => $formData->description, 'slug' => Slugifier::slugify($formData->title), 'seo_title' => $formData->title, 'last_update' => date("Y-m-d H:i:s"));
     if (!empty($formData->image)) {
         $arrayUpdate['image'] = $formData->image;
     }
     return $this->getConnection()->update(DbTableContainer::posts, $arrayUpdate, array('id' => $formData->id));
 }
Пример #8
0
 public function migrate()
 {
     $this->assertRedbeanHelper();
     $this->getRedbeanHelper()->executeQuery("TRUNCATE table zfcms_comuni_sottosezioni;\r\nINSERT INTO zfcms_comuni_sottosezioni\r\n(id, sezione_id, nome, immagine, url, posizione, attivo, profondita_a, profondita_da, is_ss)\r\n(SELECT * FROM sottosezioni);");
     // Fix contents
     $records = $this->getRedbeanHelper()->getRecord("SELECT * FROM sottosezioni");
     foreach ($records as $record) {
         $this->getRedbeanHelper()->executeQuery("UPDATE zfcms_comuni_sottosezioni SET\r\n            slug = '" . Slugifier::slugify($record['nome']) . "',\r\n            nome = '" . htmlentities(addslashes($record['nome'])) . "' WHERE id = '" . $record['id'] . "'\r\n             ");
     }
 }
Пример #9
0
 public function migrate()
 {
     $this->assertRedbeanHelper();
     $contentsMigrated = $this->getRedbeanHelper()->executeQuery("TRUNCATE table zfcms_comuni_contenuti;\r\n        INSERT INTO zfcms_comuni_contenuti\r\n        (id, sottosezione_id, anno, numero, titolo, sommario, testo,\r\n        data_inserimento, data_scadenza, data_invio_regione, attivo, home, evidenza, utente_id,\r\n        rss, pub_albo_comune, data_rettifica, path, tabella, check_atti, annoammtrasp)\r\n        (SELECT * FROM contenuti);");
     // Fix contents
     $records = $this->getRedbeanHelper()->getRecord("SELECT * FROM zfcms_comuni_contenuti WHERE titolo!='' ");
     foreach ($records as $record) {
         $this->getRedbeanHelper()->executeQuery("UPDATE zfcms_comuni_contenuti SET\r\n            slug = '" . Slugifier::slugify($record['titolo']) . "',\r\n            titolo = '" . htmlentities(addslashes($record['titolo'])) . "' WHERE id = '" . $record['id'] . "'\r\n             ");
     }
 }
Пример #10
0
 public function migrate()
 {
     $this->assertRedbeanHelper();
     $this->getRedbeanHelper()->executeQuery("TRUNCATE table zfcms_comuni_sezioni;");
     $this->getRedbeanHelper()->executeQuery("INSERT INTO zfcms_comuni_sezioni\r\n                  (id, nome, colonna, posizione, link_macro, lingua, blocco, modulo_id, attivo, url, css_id )\r\n        (SELECT * FROM sezioni);");
     // Fix contents
     $records = $this->getRedbeanHelper()->getRecord("SELECT * FROM zfcms_comuni_sezioni ");
     foreach ($records as $record) {
         $this->getRedbeanHelper()->executeQuery("UPDATE zfcms_comuni_sezioni SET\r\n            slug = '" . Slugifier::slugify($record['nome']) . "',\r\n            nome = '" . htmlentities(addslashes($record['nome'])) . "' WHERE id = '" . $record['id'] . "'\r\n             ");
     }
 }
 public function csvAction()
 {
     $id = $this->params()->fromRoute('id');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $helper = new AlboPretorioControllerHelper();
     $records = $helper->recoverWrapperRecordsById(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)), array('id' => $id, 'limit' => 1), $id);
     if (!empty($records)) {
         $arrayContent = array();
         $arrayContent[] = array('Titolo', 'Numero \\ Anno', 'Sezione', 'Scadenza');
         foreach ($records as $record) {
             $arrayContent[] = array($record['titolo'], $record['numeroAtto'] . ' / ' . $record['anno'], $record['nomeSezione'], $record['dataScadenza']->format("d-m-Y"));
         }
         $csvExportHelper = new CsvExportHelper();
         $content = $csvExportHelper->makeCsvLine($arrayContent);
         $response = $this->getResponse();
         $response->getHeaders()->addHeaderLine('Content-Type', 'text/csv')->addHeaderLine('Content-Disposition', 'attachment; filename="' . Slugifier::slugify($record['titolo']) . '.csv"')->addHeaderLine('Accept-Ranges', 'bytes')->addHeaderLine('Content-Length', strlen($content));
         $response->setContent($content);
         return $response;
     }
 }
Пример #12
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);
 }
Пример #13
0
 /**
  * @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();
 }
Пример #14
0
 public function testSlugify()
 {
     $this->assertEquals(Slugifier::slugify("Today's post"), 'today-s-post');
 }
Пример #15
0
 /**
  * @param InputFilterAwareInterface $inputFilter
  * @return int
  * @throws NullException
  */
 public function update(InputFilterAwareInterface $inputFilter)
 {
     $this->assertConnection();
     return $this->getConnection()->update(DbTableContainer::sezioni, array('nome' => $inputFilter->nome, 'colonna' => $inputFilter->colonna, 'lingua' => $inputFilter->lingua, 'attivo' => $inputFilter->attivo, 'url' => $inputFilter->url, 'slug' => Slugifier::slugify($inputFilter->nome)), array('id' => $inputFilter->id));
 }