Provide methods to manage front end controllers.
Inheritance: extends Controller
 /**
  * Forwards the request to the Frontend class if there is a page object.
  *
  * @param PostResponseEvent $event The event object
  */
 public function onKernelTerminate(PostResponseEvent $event)
 {
     if (!$this->framework->isInitialized()) {
         return;
     }
     Frontend::indexPageIfApplicable($event->getResponse());
 }
Exemplo n.º 2
0
 /**
  * Initialize the object (do not remove)
  */
 public function __construct()
 {
     parent::__construct();
     // See #4099
     define('BE_USER_LOGGED_IN', false);
     define('FE_USER_LOGGED_IN', false);
 }
Exemplo n.º 3
0
 /**
  * Initialize the object
  */
 public function __construct()
 {
     // Load the user object before calling the parent constructor
     $this->import('FrontendUser', 'User');
     parent::__construct();
     // Check whether a user is logged in
     define('BE_USER_LOGGED_IN', $this->getLoginStatus('BE_USER_AUTH'));
     define('FE_USER_LOGGED_IN', $this->getLoginStatus('FE_USER_AUTH'));
 }
 /**
  * Forwards the request to the Frontend class and sets the response if any.
  *
  * @param GetResponseEvent $event The event object
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$this->isFrontendMasterRequest($event)) {
         return;
     }
     $this->framework->initialize();
     if (null !== ($response = Frontend::getResponseFromCache())) {
         $event->setResponse($response);
     }
 }
Exemplo n.º 5
0
 /**
  * Initialize the object (do not remove)
  */
 public function __construct()
 {
     parent::__construct();
     // See #4099
     if (!defined('BE_USER_LOGGED_IN')) {
         define('BE_USER_LOGGED_IN', false);
     }
     if (!defined('FE_USER_LOGGED_IN')) {
         define('FE_USER_LOGGED_IN', false);
     }
 }
Exemplo n.º 6
0
 /**
  * Initialize the object
  */
 public function __construct()
 {
     // Load the user object before calling the parent constructor
     $this->import('FrontendUser', 'User');
     parent::__construct();
     // Check whether a user is logged in
     define('BE_USER_LOGGED_IN', $this->getLoginStatus('BE_USER_AUTH'));
     define('FE_USER_LOGGED_IN', $this->getLoginStatus('FE_USER_AUTH'));
     // No back end user logged in
     if (!$_SESSION['DISABLE_CACHE']) {
         // Maintenance mode (see #4561 and #6353)
         if (\Config::get('maintenanceMode') && !\System::getContainer()->get('kernel')->isDebug()) {
             throw new ServiceUnavailableException('This site is currently down for maintenance. Please come back later.');
         }
     }
 }
Exemplo n.º 7
0
 /**
  * Point to `Frontend::addToUrl()` in front end templates (see #6736)
  *
  * @param string  $strRequest      The request string to be added
  * @param boolean $blnIgnoreParams If true, the $_GET parameters will be ignored
  * @param array   $arrUnset        An optional array of keys to unset
  *
  * @return string The new URI string
  */
 public static function addToUrl($strRequest, $blnIgnoreParams = false, $arrUnset = array())
 {
     return \Frontend::addToUrl($strRequest, $blnIgnoreParams, $arrUnset);
 }
Exemplo n.º 8
0
 /**
  * Add enclosures to a template
  *
  * @param object $objTemplate The template object to add the enclosures to
  * @param array  $arrItem     The element or module as array
  * @param string $strKey      The name of the enclosures field in $arrItem
  */
 public static function addEnclosuresToTemplate($objTemplate, $arrItem, $strKey = 'enclosure')
 {
     $arrEnclosures = deserialize($arrItem[$strKey]);
     if (!is_array($arrEnclosures) || empty($arrEnclosures)) {
         return;
     }
     $objFiles = \FilesModel::findMultipleByUuids($arrEnclosures);
     if ($objFiles === null) {
         return;
     }
     $file = \Input::get('file', true);
     // Send the file to the browser and do not send a 404 header (see #5178)
     if ($file != '') {
         while ($objFiles->next()) {
             if ($file == $objFiles->path) {
                 static::sendFileToBrowser($file);
             }
         }
         $objFiles->reset();
     }
     /** @var \PageModel $objPage */
     global $objPage;
     $arrEnclosures = array();
     $allowedDownload = trimsplit(',', strtolower(\Config::get('allowedDownload')));
     // Add download links
     while ($objFiles->next()) {
         if ($objFiles->type == 'file') {
             if (!in_array($objFiles->extension, $allowedDownload) || !is_file(TL_ROOT . '/' . $objFiles->path)) {
                 continue;
             }
             $objFile = new \File($objFiles->path);
             $strHref = \Environment::get('request');
             // Remove an existing file parameter (see #5683)
             if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
                 $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
             }
             $strHref .= (strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objFiles->path);
             $arrMeta = \Frontend::getMetaData($objFiles->meta, $objPage->language);
             if (empty($arrMeta) && $objPage->rootFallbackLanguage !== null) {
                 $arrMeta = \Frontend::getMetaData($objFiles->meta, $objPage->rootFallbackLanguage);
             }
             // Use the file name as title if none is given
             if ($arrMeta['title'] == '') {
                 $arrMeta['title'] = specialchars($objFile->basename);
             }
             $arrEnclosures[] = array('link' => $arrMeta['title'], 'filesize' => static::getReadableSize($objFile->filesize), 'title' => specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename)), 'href' => $strHref, 'enclosure' => $objFiles->path, 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'extension' => $objFile->extension, 'meta' => $arrMeta);
         }
     }
     $objTemplate->enclosure = $arrEnclosures;
 }
Exemplo n.º 9
0
 /**
  * @param MessageContent $messageContent
  * @param array          $contents
  *
  * @return array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function handleFoundedContent(MessageContent $messageContent, array $contents)
 {
     if (count($contents) < 1) {
         return array();
     }
     $messageCategory = $messageContent->getMessage()->getCategory();
     $viewOnlinePageModel = \PageModel::findByPk($messageCategory->getViewOnlinePage());
     if (!$viewOnlinePageModel) {
         $viewOnlinePageModel = \PageModel::findByPk(Frontend::getRootIdFromUrl());
     }
     $viewOnlinePageModel->loadDetails();
     $replaced = array();
     $replacedIn = array();
     foreach ($contents as $content) {
         foreach (array('type', 'galleryTpl', 'customTpl', 'eventTemplate', 'newsTemplate') as $propertyTemplate) {
             if ($content instanceof \Model) {
                 if (empty($content->{$propertyTemplate})) {
                     continue;
                 }
                 $template = $this->findTemplate($content->{$propertyTemplate}, $messageCategory);
                 if ($content->{$propertyTemplate} === $template) {
                     continue;
                 }
                 $content->{$propertyTemplate} = $template;
                 $replaced[] = $template;
                 $replacedIn[] = $content;
             }
             if ($content instanceof EntityInterface) {
                 $getPropertyTemplate = 'get' . ucfirst($propertyTemplate);
                 $setPropertyTemplate = 'set' . ucfirst($propertyTemplate);
                 if (!method_exists($content, $getPropertyTemplate) || !$content->{$getPropertyTemplate}()) {
                     continue;
                 }
                 $template = $this->findTemplate($content->{$getPropertyTemplate}(), $messageCategory);
                 if ($content->{$getPropertyTemplate}() === $template) {
                     continue;
                 }
                 $content->{$setPropertyTemplate}($template);
                 $replaced[] = $template;
                 $replacedIn[] = $content;
             }
         }
     }
     return array($replaced, $replacedIn);
 }