/** * Initialize variables for the public website * * @return string */ protected function initializeFrontendWebsite($channel = 1) { $appServiceLoader = $this->recoverAppServiceLoader($channel); $configurations = $appServiceLoader->recoverService('configurations'); $sessionContainer = new SessionContainer(); if (!$this->checkPasswordPreviewArea($configurations, $sessionContainer)) { header("Location: " . $this->url()->fromRoute('password-preview')); exit; } $serviceLocator = $this->getServiceLocator(); $request = $this->getRequest(); $uri = $request->getUri(); $cookieWarningSession = $sessionContainer->offsetGet('cookie-warning'); $lang = $this->params()->fromRoute('lang') ? $this->params()->fromRoute('lang') : 'it'; $helper = new SetupAbstractControllerHelper(); $helper->setConfigurations($configurations); $helper->setRequest($request); $helper->setSezioniGetterWrapper(new SezioniGetterWrapper(new SezioniGetter($this->getServiceLocator()->get('doctrine.entitymanager.orm_default')))); $helper->setupSezioniRecords(array('attivo' => 1, 'languageAbbreviation' => isset($lang) ? $lang : 'it', 'orderBy' => 'sezioni.posizione ASC')); $sottosezioniRecords = $helper->getSezioniGetterWrapper()->addSottoSezioni($helper->getSezioniRecords(), array('attivo' => 1)); $helper->setSezioniRecords($helper->getSezioniGetterWrapper()->formatRecordsPerColumn($sottosezioniRecords)); $helper->setupServer(); $helper->setupFrontendTemplatePath(); $helper->setupPhpRenderer($this->getServiceLocator()); $helper->setupZf2appDir(); $helper->setupAppDirRelativePath(); $serverVars = $helper->getServer(); /** * @var \Zend\Mvc\I18n\Translator $translator */ $translator = $serviceLocator->get('translator'); if (file_exists('./module/Application/language/app.' . $lang . '.php')) { $translator->addTranslationFile('phparray', './module/Application/language/app.' . $lang . '.php'); } if (file_exists('./module/Application/language/form.array.' . $lang . '.php')) { $translator->addTranslationFile('phparray', './module/Application/language/form.array.' . $lang . '.php'); } $serviceLocator->get('ViewHelperManager')->get('translate')->setTranslator($translator); $this->layout()->setVariables($configurations); $this->layout()->setVariables(array('basePath' => sprintf('%s://%s%s', $uri->getScheme(), $uri->getHost(), $request->getBaseUrl() . '/'), 'publicDirRelativePath' => $helper->getAppDirRelativePath() . '/public', 'configurations' => $configurations, 'sezioni' => $helper->getSezioniRecords(), 'templateDir' => 'frontend/projects/' . $configurations['project_frontend'] . 'templates/' . $configurations['template_frontend'], 'preloadResponse' => isset($input['preloadResponse']) ? $input['preloadResponse'] : null, 'currentUrl' => "http://" . $serverVars["SERVER_NAME"] . $serverVars["REQUEST_URI"], 'currentDateTime' => date("Y-m-d H:i:s"), 'template_frontend' => $configurations['template_frontend'], 'cssName' => $sessionContainer->offSetGet('cssName'), 'passwordPreviewArea' => $this->hasPasswordPreviewArea($configurations), 'renderer' => $helper->getPhpRenderer(), 'cookieWarning' => isset($cookieWarningSession[$configurations['sitename']]) ? $cookieWarningSession[$configurations['sitename']] : null, 'lang' => isset($lang) ? $lang : 'it', 'isMultiLanguage' => isset($configurations['isMultiLanguage']) ? 1 : 0, 'defaultLanguageId' => 1, 'searchEngineForm' => new SearchEngineForm(), 'defaultLanguageAbbreviation' => 'it')); return 'frontend/projects/' . $configurations['project_frontend'] . 'templates/' . $configurations['template_frontend'] . 'layout.phtml'; }