/**
  * @param string $strBuffer
  * @return string
  */
 public static function addMarksaleScriptToDynamicScriptTags($strBuffer)
 {
     if (TL_MODE == 'FE') {
         /* @var $objPage \Contao\PageModel */
         global $objPage;
         $objParentPage = \PageModel::findOneBy(array('id=?', 'type=?'), array($objPage->rootId, 'root'));
         $objTemplate = new \FrontendTemplate('marksale_default');
         $objTemplate->mstcId = $objParentPage->mstcId;
         $GLOBALS['TL_BODY'][] = $objTemplate->parse();
     }
     return $strBuffer;
 }
 /**
  * Generate module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->imagepath = '';
     $objCoverPicture = \ModuleCoverpictureModel::findOneBy('jumpTo', $objPage->id);
     if ($objCoverPicture->singleSRC == '') {
         //get parent page
         $objParentPage = \PageModel::findOneBy('id', $objPage->id);
         while (($objCoverPicture->singleSRC == '' || $objCoverPicture->no_inheritance == 1) && $objParentPage->type != 'root') {
             $objCoverPicture = \ModuleCoverpictureModel::findOneBy('jumpTo', $objParentPage->id);
             // next parent ...
             if ($objParentPage->pid) {
                 $objParentPage = \PageModel::findOneBy('id', $objParentPage->pid);
                 $objCoverPicture = \ModuleCoverpictureModel::findOneBy('jumpTo', $objParentPage->id);
             }
         }
     }
     // no Picture found -> default
     if (!$objCoverPicture) {
         $objCoverPicture = \ModuleCoverpictureModel::findByStandard(1);
     }
     $objFile = $this->getCoverpictureImageObjFile($objCoverPicture->singleSRC);
     if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) {
         $this->Template->imagepath = '';
     }
     // Use as background image
     if ($objCoverPicture->use_as_background == false) {
         $this->Template->imagepath = $objFile->path;
         // Resize image
         if ($objCoverPicture->resize_image) {
             $size = deserialize($objCoverPicture->size);
             $this->Template->imagepath = $this->getImage($this->urlEncode($objFile->path), $size[0], $size[1], $size[2]);
         }
         // Image map (thanks to Felix Pfeiffer)
         if ($objCoverPicture->imageMap != "") {
             $imgMapID = uniqid('imap_');
             $this->Template->imgMapID = $imgMapID;
             $text = '<map name="%s" id="%s">%s</map>';
             $this->Template->imgMap = sprintf($text, $imgMapID, $imgMapID, $objCoverPicture->imageMap);
         }
         $this->Template->pagetitle = $objPage->pageTitle;
     } else {
         $this->Template->use_as_background = true;
         $this->generateBackgroundImage($objCoverPicture);
     }
 }
예제 #3
0
파일: Backend.php 프로젝트: eknoes/core
 /**
  * Add the file meta information to the request
  *
  * @param string  $strUuid
  * @param string  $strPtable
  * @param integer $intPid
  */
 public static function addFileMetaInformationToRequest($strUuid, $strPtable, $intPid)
 {
     $objFile = \FilesModel::findByUuid($strUuid);
     if ($objFile === null) {
         return;
     }
     $arrMeta = deserialize($objFile->meta);
     if (empty($arrMeta)) {
         return;
     }
     $objPage = null;
     switch ($strPtable) {
         case 'tl_article':
             $objPage = \PageModel::findOneBy(array('tl_page.id=(SELECT pid FROM tl_article WHERE id=?)'), $intPid);
             break;
         case 'tl_news':
             $objPage = \PageModel::findOneBy(array('tl_page.id=(SELECT jumpTo FROM tl_news_archive WHERE id=(SELECT pid FROM tl_news WHERE id=?))'), $intPid);
             break;
         case 'tl_news_archive':
             $objPage = \PageModel::findOneBy(array('tl_page.id=(SELECT jumpTo FROM tl_news_archive WHERE id=?)'), $intPid);
             break;
         case 'tl_calendar_events':
             $objPage = \PageModel::findOneBy(array('tl_page.id=(SELECT jumpTo FROM tl_calendar WHERE id=(SELECT pid FROM tl_calendar_events WHERE id=?))'), $intPid);
             break;
         case 'tl_calendar':
             $objPage = \PageModel::findOneBy(array('tl_page.id=(SELECT jumpTo FROM tl_calendar WHERE id=?)'), $intPid);
             break;
         case 'tl_faq_category':
             $objPage = \PageModel::findOneBy(array('tl_page.id=(SELECT jumpTo FROM tl_faq_category WHERE id=?)'), $intPid);
             break;
         default:
             // HOOK: support custom modules
             if (isset($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest']) && is_array($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'])) {
                 foreach ($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'] as $callback) {
                     if (($val = \System::importStatic($callback[0])->{$callback[1]}($strPtable, $intPid)) !== false) {
                         $objPage = $val;
                     }
                 }
                 if ($objPage instanceof \Database\Result && $objPage->numRows < 1) {
                     return;
                 }
                 if (is_object($objPage) && !$objPage instanceof \PageModel) {
                     $objPage = \PageModel::findByPk($objPage->id);
                 }
             }
             break;
     }
     if ($objPage === null) {
         return;
     }
     $objPage->loadDetails();
     // Convert the language to a locale (see #5678)
     $strLanguage = str_replace('-', '_', $objPage->rootLanguage);
     if (isset($arrMeta[$strLanguage])) {
         if (\Input::post('alt') == '' && !empty($arrMeta[$strLanguage]['title'])) {
             \Input::setPost('alt', $arrMeta[$strLanguage]['title']);
         }
         if (\Input::post('caption') == '' && !empty($arrMeta[$strLanguage]['caption'])) {
             \Input::setPost('caption', $arrMeta[$strLanguage]['caption']);
         }
     }
 }
 protected function findParentWithSettings(\PageModel $objPage, $property = null)
 {
     if ($objPage->type === 'root') {
         $objPage->pam = $objPage->pam_root;
         $objPage->paSpeed = $objPage->paRootSpeed;
         $objPage->paTimeout = $objPage->paRootTimeout;
     }
     if ($property) {
         if ($objPage->{$property} != '') {
             return $objPage;
         }
     }
     if ($objPage->paSpeed && $objPage->paTimeout && $objPage->sortBy != '') {
         return $objPage;
     }
     if (!$objPage->pid) {
         return null;
     }
     return $this->findParentWithSettings(\PageModel::findOneBy('id', $objPage->pid), $property);
 }
예제 #5
0
 public static function getHomepageUrl()
 {
     $strLanguage = $GLOBALS['TL_LANGUAGE'];
     $objRootPage = \PageModel::findOneBy(array('type', 'language'), array('root', $strLanguage));
     if ($objRootPage) {
         $objHomePage = \PageModel::findFirstPublishedRegularByPid($objRootPage->id);
         if ($objHomePage) {
             return \Controller::generateFrontendUrl($objHomePage->row());
         } else {
             $homepageUrl = array('de' => 'startseite.html', 'en' => 'home.html');
             return $homepageUrl[$strLanguage];
         }
     }
     return false;
 }