コード例 #1
0
    /**
     * Include the JavaScript SDK library
     * @param string
     */
    public static function includeJavascriptSDK($strLanguage = 'en_US')
    {
        $strKey = '';
        // Use the TL_BODY if available
        if (version_compare(VERSION, '3.1', '>=')) {
            $strKey = 'TL_BODY';
        } else {
            global $objPage;
            $objLayout = \LayoutModel::findByPk($objPage->layout);
            if ($objLayout !== null) {
                // Use jQuery
                if ($objLayout->addJQuery) {
                    $strKey = 'TL_JQUERY';
                }
                // Use MooTools
                if ($objLayout->addMooTools) {
                    $strKey = 'TL_MOOTOOLS';
                }
            }
        }
        if ($strKey == '') {
            return;
        }
        $GLOBALS[$strKey]['FB_JSSDK'] = '<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/' . $strLanguage . '/all.js#xfbml=1&status=0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, \'script\', \'facebook-jssdk\'));</script>';
    }
コード例 #2
0
 public function addRules(CreateManipulatorEvent $event)
 {
     if (($rules = RuleModel::findPublishedByActiveTheme()) === null) {
         return;
     }
     // No need to check for null values again as already done by Rule::findPublishedByActiveTheme()
     global $objPage;
     $layout = \LayoutModel::findByPk($objPage->layout);
     // Do not modify anything if the template name is not the one of the current page layout
     // e.g. when a developer calls Template::output() manually
     if ($layout->template !== $event->getTemplateName()) {
         return;
     }
     $factory = $event->getFactory();
     /**
      * @var $ruleModel RuleModel
      */
     foreach ($rules as $ruleModel) {
         $query = new XPathQuery($ruleModel->getXPathExpr());
         $rule = new AttributeRule($query, 'class');
         $rule->addFilter(new CssClassFilter($ruleModel->getDirectives()));
         $rule->addFilter(new TrimWhitespacesFilter());
         $factory->addRule($rule);
     }
 }
コード例 #3
0
ファイル: Article.php プロジェクト: bit3/contao-merger2
 public function getActiveLayoutSections(\DataContainer $dc)
 {
     $callback = $GLOBALS['TL_DCA']['tl_article']['fields']['inColumn']['bit3_merger_original_options_callback'];
     if (is_array($callback)) {
         $object = \System::importStatic($callback[0]);
         $methodName = $callback[1];
         $sections = $object->{$methodName}($dc);
     } else {
         $sections = call_user_func($callback, $dc);
     }
     if ($dc->activeRecord->pid) {
         $page = \PageModel::findWithDetails($dc->activeRecord->pid);
         // Get the layout sections
         foreach (array('layout', 'mobileLayout') as $key) {
             if (!$page->{$key}) {
                 continue;
             }
             $layout = \LayoutModel::findByPk($page->{$key});
             if ($layout === null) {
                 continue;
             }
             $modules = deserialize($layout->modules);
             if (empty($modules) || !is_array($modules)) {
                 continue;
             }
             // Find all sections with an article module (see #6094)
             foreach ($modules as $module) {
                 if ($module['mod'] != 0 && $module['enable']) {
                     $this->joinModule($module['col'], $module['mod'], $sections);
                 }
             }
         }
     }
     return array_values(array_unique($sections));
 }
コード例 #4
0
 public static function isJQueryEnabled()
 {
     global $objPage;
     $blnMobile = $objPage->mobileLayout && \Environment::get('agent')->mobile;
     $intId = $blnMobile && $objPage->mobileLayout ? $objPage->mobileLayout : $objPage->layout;
     $objLayout = \LayoutModel::findByPk($intId);
     return $objLayout->addJQuery;
 }
コード例 #5
0
 /**
  * get current layout of current page
  *
  * @return \LayoutModel|\Model|null
  */
 public static function getLayout()
 {
     if (self::$pageLayout === null) {
         global $objPage;
         if ($objPage !== null) {
             self::$pageLayout = \LayoutModel::findByPk($objPage->layout);
         }
     }
     return self::$pageLayout;
 }
コード例 #6
0
ファイル: Pa2.php プロジェクト: craffft/contao-photoalbums2
 /**
  * addCssFile function.
  *
  * @access public
  * @return void
  */
 public function addCssFile()
 {
     global $objPage;
     // Get layout skipPhotoalbums2 to disable photoalbums2 css file
     $objLayout = \LayoutModel::findByPk($objPage->layout);
     // Add css
     if (TL_MODE == 'FE' && $objLayout->skipPhotoalbums2 != '1' || TL_MODE == 'BE') {
         $GLOBALS['TL_CSS'][] = TL_FILES_URL . 'system/modules/photoalbums2/assets/photoalbums2.css';
     }
 }
コード例 #7
0
ファイル: Layout.php プロジェクト: bit3/contao-xyaml
 public function load($dc)
 {
     $layout = \LayoutModel::findByPk($dc->id);
     if (!$layout->xyaml) {
         return;
     }
     \MetaPalettes::appendAfter('tl_layout', 'default', 'style', array('xyaml' => array('xyaml_iehacks', 'xyaml_addons', 'xyaml_forms', 'xyaml_navigation', 'xyaml_print', 'xyaml_screen', 'xyaml_subcolumns_linearize'), 'xyaml_files' => array('xyaml_auto_include')));
     if (version_compare(VERSION, '3', '>=') && $layout->xyaml_path_source != $GLOBALS['TL_CONFIG']['uploadPath']) {
         $GLOBALS['TL_DCA']['tl_layout']['fields']['xyaml_path']['inputType'] = 'fileSelector';
     }
     $GLOBALS['TL_DCA']['tl_layout']['fields']['xyaml_path']['eval']['path'] = $layout->xyaml_path_source;
 }
コード例 #8
0
 public function hookReplaceDynamicScriptTagsHook($strBuffer)
 {
     global $objPage;
     if (!$objPage) {
         return $strBuffer;
     }
     $objLayout = \LayoutModel::findByPk($objPage->layout);
     if (!$objLayout) {
         return $strBuffer;
     }
     \HeimrichHannot\Bootstrapper\BootstrapperAssets::registerComponents($objLayout);
     return $strBuffer;
 }
コード例 #9
0
ファイル: FontLoader.php プロジェクト: pdir/contao-fontloader
 /**
  * Add font tags
  * @param PageModel $objPage
  * @param LayoutModel $objLayout
  * @param PageRegular $objThis
  */
 public function hookGetPageLayout($objPage, &$objLayout, $objThis)
 {
     global $objPage;
     if (!$objPage) {
         return $strBuffer;
     }
     $objLayout = \LayoutModel::findByPk($objPage->layout);
     if (!$objLayout) {
         return $strBuffer;
     }
     // the dynamic script replacement array
     $arrReplace = array();
     $this->parseFontGroup($objLayout, $arrReplace);
     return $strBuffer;
 }
コード例 #10
0
 public function hookReplaceDynamicScriptTags($strBuffer)
 {
     global $objPage;
     if (!$objPage) {
         return $strBuffer;
     }
     $objLayout = \LayoutModel::findByPk($objPage->layout);
     if (!$objLayout) {
         return $strBuffer;
     }
     // the dynamic script replacement array
     $arrReplace = array();
     $this->parseExtJs($objLayout, $arrReplace);
     return $strBuffer;
 }
コード例 #11
0
 /**
  * Return all testimonials templates as array
  * @param DataContainer
  * @return array
  */
 public function getTestimonialsTemplates(DataContainer $dc)
 {
     $intPid = $dc->activeRecord->pid;
     if ($this->Input->get('act') == 'overrideAll') {
         $intPid = $this->Input->get('id');
     }
     // Get the page ID
     $objArticle = $this->Database->prepare("SELECT pid FROM tl_article WHERE id=?")->limit(1)->execute($intPid);
     // Inherit the page settings
     $objPage = $this->getPageDetails($objArticle->pid);
     // Get the theme ID
     $objLayout = LayoutModel::findByPk($objPage->layout);
     // Return all templates
     return $this->getTemplateGroup('testimonial_', $objLayout->pid);
 }
コード例 #12
0
 public function loadArticleDca($dc)
 {
     $layout = null;
     $article = \ArticleModel::findByPk($dc->id);
     $page = \PageModel::findWithDetails($article->pid);
     while (!$layout && $page) {
         if ($page->includeLayout) {
             $layout = \LayoutModel::findByPk($page->layout);
         } else {
             $page = \PageModel::findWithDetails($page->pid);
         }
     }
     if ($layout && $layout->useRevealJs) {
         \MetaPalettes::appendFields('tl_article', 'default', 'template', array('revealVerticalSlide'));
     }
 }
コード例 #13
0
ファイル: tl_content.php プロジェクト: rburch/core
 /**
  * Return all comments templates as array
  * @param \DataContainer
  * @return array
  */
 public function getCommentsTemplates(DataContainer $dc)
 {
     // Only look for a theme in the articles module (see #4808)
     if (Input::get('do') == 'article') {
         $intPid = $dc->activeRecord->pid;
         if (Input::get('act') == 'overrideAll') {
             $intPid = Input::get('id');
         }
         // Get the page ID
         $objArticle = $this->Database->prepare("SELECT pid FROM tl_article WHERE id=?")->limit(1)->execute($intPid);
         // Inherit the page settings
         $objPage = $this->getPageDetails($objArticle->pid);
         // Get the theme ID
         $objLayout = LayoutModel::findByPk($objPage->layout);
         if ($objLayout === null) {
             return array();
         }
     }
     // Return all gallery templates
     return $this->getTemplateGroup('com_', $objLayout->pid);
 }
コード例 #14
0
ファイル: Dca.php プロジェクト: richardhj/contao-childlayouts
 /**
  * Shorten the child layout's palette
  * @category onload_callback
  *
  * @param \DataContainer $dc
  */
 public function updatePalettes(\DataContainer $dc)
 {
     /** @type \Model $objLayout */
     $objLayout = \LayoutModel::findByPk($dc->id);
     // Cancel if we don't have a child layout here
     if (!$objLayout->isChild || !$objLayout->parentLayout) {
         return;
     }
     // Set original palette before changing it
     self::setOriginalPalette($GLOBALS['TL_DCA']['tl_layout']['palettes']['default']);
     // Modify palettes by means of user settings
     $strTitleLegend = strstr(static::$strOriginalPalette, ';', true);
     if (!$objLayout->specificLegends) {
         $GLOBALS['TL_DCA']['tl_layout']['palettes']['default'] = $strTitleLegend;
     } else {
         $GLOBALS['TL_DCA']['tl_layout']['palettes']['default'] = $strTitleLegend;
         foreach (trimsplit(',', $objLayout->specificLegends) as $legend) {
             $legend_details = Helper::findLegendInOriginalPalette($legend);
             $GLOBALS['TL_DCA']['tl_layout']['palettes']['default'] .= ';' . $legend_details[1] . ',' . $legend_details[3];
         }
     }
 }
コード例 #15
0
ファイル: tl_content.php プロジェクト: RockKeeper/tabcontrol
 /**
  * Return all tabcontrol templates as array
  */
 public function getTabcontrolTemplates(DataContainer $dc)
 {
     // Only look for a theme in the articles module (see #4808)
     if (Input::get('do') == 'article') {
         $intPid = $dc->activeRecord->pid;
         if (Input::get('act') == 'overrideAll') {
             $intPid = Input::get('id');
         }
         // Get the page ID
         $objArticle = $this->Database->prepare("SELECT pid FROM tl_article WHERE id=?")->limit(1)->execute($intPid);
         // Inherit the page settings
         $objPage = $this->getPageDetails($objArticle->pid);
         // Get the theme ID
         $objLayout = LayoutModel::findByPk($objPage->layout);
         if ($objLayout === null) {
             return array();
         }
     }
     $templateSnip = '';
     switch ($dc->activeRecord->tabType) {
         case 'tabcontrolstart':
             $templateSnip = 'start';
             break;
         case 'tabcontrolstop':
             $templateSnip = 'stop';
             break;
         case 'tabcontrol_end':
             $templateSnip = 'end';
             break;
         case 'tabcontroltab':
         default:
             $templateSnip = 'tab';
             break;
     }
     // Return all gallery templates
     return $this->getTemplateGroup('ce_tabcontrol_' . $templateSnip, $objLayout->pid);
 }
コード例 #16
0
 /**
  * Load all section label from used page layout.
  *
  * @param string         $value         Active used column.
  * @param \DataContainer $dataContainer Data container driver.
  *
  * @return string
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function loadSectionLabels($value, $dataContainer)
 {
     // Show only active sections
     if ($dataContainer->activeRecord->pid) {
         $page = \PageModel::findWithDetails($dataContainer->activeRecord->pid);
         // Get the layout sections
         foreach (array('layout', 'mobileLayout') as $key) {
             if (!$page->{$key}) {
                 continue;
             }
             $objLayout = \LayoutModel::findByPk($page->{$key});
             if ($objLayout === null) {
                 continue;
             }
             $sections = deserialize($objLayout->flexible_sections, true);
             foreach ($sections as $section) {
                 if (!isset($GLOBALS['TL_LANG']['tl_article'][$section['id']])) {
                     $GLOBALS['TL_LANG']['tl_article'][$section['id']] = $section['label'] ?: $section['id'];
                 }
             }
         }
     }
     return $value;
 }
コード例 #17
0
 /**
  * Update all child layouts belonging to parent layout
  * @category onsubmit_callback
  *
  * @param \DataContainer $dc
  */
 public function updateChildLayouts(\DataContainer $dc)
 {
     if ($dc->activeRecord->isChild) {
         /** @type \Model $objParentLayout */
         $objParentLayout = \LayoutModel::findByPk($dc->activeRecord->parentLayout);
         $arrData = $objParentLayout->row();
         // Delete columns that must not be overridden
         foreach (self::getColumnsToPersist() as $v) {
             unset($arrData[$v]);
         }
         // Delete columns specific for this child layout
         if ($dc->activeRecord->specificLegends) {
             $this->deleteSpecificColumns($dc->activeRecord->specificLegends, $arrData, $dc->activeRecord->row());
         }
         // Save parent data in database
         // Do not use the LayoutModel here
         \Database::getInstance()->prepare("UPDATE tl_layout %s WHERE id=?")->set($arrData)->execute($dc->id);
     } else {
         $objChildLayouts = \LayoutModel::findBy(array('tl_layout.isChild=1', 'tl_layout.id IN (SELECT tl_layout.id FROM tl_layout WHERE tl_layout.parentLayout=?)'), array($dc->id));
         if (null !== $objChildLayouts) {
             $arrData = $dc->activeRecord->row();
             // Delete columns specific for each layout
             foreach (self::getColumnsToPersist() as $v) {
                 unset($arrData[$v]);
             }
             while ($objChildLayouts->next()) {
                 if ($objChildLayouts->specificLegends) {
                     $this->deleteSpecificColumns($objChildLayouts->specificLegends, $arrData, $objChildLayouts->row());
                 }
                 // Update child layout row
                 // Do not use the LayoutModel here
                 \Database::getInstance()->prepare("UPDATE tl_layout %s WHERE id=?")->set($arrData)->execute($objChildLayouts->id);
             }
         }
     }
 }
コード例 #18
0
ファイル: tl_article.php プロジェクト: rikaix/core
 /**
  * Return all active page sections as array
  * @param \DataContainer
  * @return array
  */
 public function getActivePageSections(DataContainer $dc)
 {
     $arrCustom = array();
     $arrSections = array('header', 'left', 'right', 'main', 'footer');
     // Show only active sections
     if ($dc->activeRecord->pid) {
         // Inherit the page settings
         $objPage = $this->getPageDetails($dc->activeRecord->pid);
         // Get the layout settings
         $objLayout = LayoutModel::findByPk($objPage->layout);
         // No layout specified
         if ($objLayout === null) {
             return array('main');
         }
         $arrSections = array();
         // Header
         if ($objLayout->header) {
             $arrSections[] = 'header';
         }
         // Left column
         if ($objLayout->cols == '2cll' || $objLayout->cols == '3cl') {
             $arrSections[] = 'left';
         }
         // Right column
         if ($objLayout->cols == '2clr' || $objLayout->cols == '3cl') {
             $arrSections[] = 'right';
         }
         // Main column
         $arrSections[] = 'main';
         // Footer
         if ($objLayout->footer) {
             $arrSections[] = 'footer';
         }
         $arrCustom = deserialize($objLayout->sections);
     }
     // Always add the custom layout sections in "override all" mode
     if (Input::get('act') == 'overrideAll') {
         $arrCustom = trimsplit(',', $GLOBALS['TL_CONFIG']['customSections']);
     }
     // Add the custom layout sections
     if (is_array($arrCustom) && !empty($arrCustom)) {
         $arrSections = array_merge($arrSections, $arrCustom);
     }
     return $arrSections;
 }
コード例 #19
0
 /**
  * Get Page layout.
  *
  * @return \Model|null
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 private static function getPageLayout()
 {
     if (TL_MODE === 'FE' && isset($GLOBALS['objPage'])) {
         $layoutIdKey = $GLOBALS['objPage']->isMobile ? 'mobileLayout' : 'layout';
         return \LayoutModel::findByPk($GLOBALS['objPage']->{$layoutIdKey});
     }
     return null;
 }
コード例 #20
0
ファイル: tl_content.php プロジェクト: rikaix/core
 /**
  * Return all player templates as array
  * @param \DataContainer
  * @return array
  */
 public function getPlayerTemplates(DataContainer $dc)
 {
     $intPid = $dc->activeRecord->pid;
     // Override multiple
     if (Input::get('act') == 'overrideAll') {
         $intPid = Input::get('id');
     }
     // Get the page ID
     $objArticle = $this->Database->prepare("SELECT pid FROM tl_article WHERE id=?")->limit(1)->execute($intPid);
     // Inherit the page settings
     $objPage = $this->getPageDetails($objArticle->pid);
     // Get the theme ID
     $objLayout = LayoutModel::findByPk($objPage->layout);
     if ($objLayout === null) {
         return array();
     }
     // Return all gallery templates
     return $this->getTemplateGroup('player_', $objLayout->pid);
 }
コード例 #21
0
ファイル: PageRegular.php プロジェクト: bytehead/contao-core
 /**
  * Get a page layout and return it as database result object
  *
  * @param \PageModel $objPage
  *
  * @return \LayoutModel
  */
 protected function getPageLayout($objPage)
 {
     $blnMobile = $objPage->mobileLayout && \Environment::get('agent')->mobile;
     // Set the cookie
     if (isset($_GET['toggle_view'])) {
         if (\Input::get('toggle_view') == 'mobile') {
             $this->setCookie('TL_VIEW', 'mobile', 0);
         } else {
             $this->setCookie('TL_VIEW', 'desktop', 0);
         }
         $this->redirect($this->getReferer());
     }
     // Override the autodetected value
     if (\Input::cookie('TL_VIEW') == 'mobile') {
         $blnMobile = true;
     } elseif (\Input::cookie('TL_VIEW') == 'desktop') {
         $blnMobile = false;
     }
     $intId = $blnMobile && $objPage->mobileLayout ? $objPage->mobileLayout : $objPage->layout;
     $objLayout = \LayoutModel::findByPk($intId);
     // Die if there is no layout
     if (null === $objLayout) {
         header('HTTP/1.1 501 Not Implemented');
         $this->log('Could not find layout ID "' . $intId . '"', __METHOD__, TL_ERROR);
         die_nicely('be_no_layout', 'No layout specified');
     }
     $objPage->hasJQuery = $objLayout->addJQuery;
     $objPage->hasMooTools = $objLayout->addMooTools;
     $objPage->isMobile = $blnMobile;
     return $objLayout;
 }
コード例 #22
0
 /**
  * Replace dynamic script tags.
  *
  * @see \Contao\Controller::replaceDynamicScriptTags
  *
  * @param string $buffer
  *
  * @return string
  */
 public function hookReplaceDynamicScriptTags($buffer)
 {
     $page = $this->pageProvider->getPage();
     if ($page) {
         $headScripts = '';
         $bodyScripts = '';
         // search for the layout
         $layout = \LayoutModel::findByPk($page->layout);
         $renderMode = $this->renderModeDeterminer->determineMode();
         if (RenderMode::PRE_COMPILE == $renderMode) {
             // pre-compile javascripts
             $this->compileJavaScripts($page, $layout);
         } elseif (!$GLOBALS['TL_CONFIG']['theme_plus_disabled_advanced_asset_caching'] && RenderMode::LIVE == $renderMode) {
             // load cached javascripts
             $this->loadJavaScripts($page, $layout, $headScripts, $bodyScripts);
         } else {
             // dynamically parse javascripts
             $this->parseJavaScripts($renderMode, $page, $layout, $headScripts, $bodyScripts);
         }
         $GLOBALS['TL_JAVASCRIPT'] = [];
         // replace dynamic scripts
         return str_replace(['[[TL_HEAD]]', '[[TL_SCRIPTS]]'], [$headScripts . '[[TL_HEAD]]', $bodyScripts], $buffer);
     }
     return $buffer;
 }
コード例 #23
0
ファイル: PageRegular.php プロジェクト: rikaix/core
 /**
  * Get a page layout and return it as database result object
  * @param \Model
  * @return \Model
  */
 protected function getPageLayout($objPage)
 {
     $blnMobile = $objPage->mobileLayout && \Environment::get('agent')->mobile;
     $intId = $blnMobile ? $objPage->mobileLayout : $objPage->layout;
     $objLayout = \LayoutModel::findByPk($intId);
     // Die if there is no layout
     if ($objLayout === null) {
         header('HTTP/1.1 501 Not Implemented');
         $this->log('Could not find layout ID "' . $intId . '"', 'PageRegular getPageLayout()', TL_ERROR);
         die('No layout specified');
     }
     $objLayout->isMobile = $blnMobile;
     return $objLayout;
 }
コード例 #24
0
 /**
  * Replace dynamic script tags.
  *
  * @see \Contao\Controller::replaceDynamicScriptTags
  *
  * @param string $buffer
  *
  * @return string
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function hookReplaceDynamicScriptTags($buffer)
 {
     $page = $this->pageProvider->getPage();
     if ($page) {
         // search for the layout
         $layout = \LayoutModel::findByPk($page->layout);
         $renderMode = $this->renderModeDeterminer->determineMode();
         // the stylesheets buffer
         $stylesheets = '';
         if (RenderMode::PRE_COMPILE == $renderMode) {
             // pre-compile stylesheets
             $this->compileStylesheets($page, $layout);
         } elseif (!$GLOBALS['TL_CONFIG']['theme_plus_disabled_advanced_asset_caching'] && RenderMode::LIVE == $renderMode) {
             // load cached stylesheets
             $this->loadStylesheets($page, $layout, $stylesheets);
         } else {
             // dynamically parse stylesheets
             $this->parseStylesheets($renderMode, $page, $layout, $stylesheets);
         }
         $GLOBALS['TL_FRAMEWORK_CSS'] = [];
         $GLOBALS['TL_CSS'] = [];
         $GLOBALS['TL_USER_CSS'] = [];
         // replace dynamic scripts
         return str_replace('[[TL_CSS]]', $stylesheets, $buffer);
     }
     return $buffer;
 }
コード例 #25
0
ファイル: Googlemap.php プロジェクト: Olli/dlh_googlemaps
 /**
  * Inject CSS
  */
 public static function cssInjection()
 {
     global $objPage;
     $objLayout = \LayoutModel::findByPk($objPage->layout);
     $objLayout->framework = deserialize($objLayout->framework);
     if (is_array($objLayout->framework) && count($objLayout->framework) > 0) {
         $GLOBALS['TL_FRAMEWORK_CSS'][] = 'system/modules/dlh_googlemaps/assets/frontend.css';
     } else {
         $GLOBALS['TL_CSS'][] = 'system/modules/dlh_googlemaps/assets/frontend.css';
     }
 }
コード例 #26
0
ファイル: Helper.php プロジェクト: pressi/zdps_customize
 /**
  * Get a page layout and return it as database result object
  * @param \Model
  * @return \Model
  */
 public static function getPageLayout($objPage)
 {
     if ($objPage == NULL) {
         return false;
     }
     $object = new self();
     $blnMobile = $objPage->mobileLayout && \Environment::get('agent')->mobile;
     // Override the autodetected value
     if (\Input::cookie('TL_VIEW') == 'mobile' && $objPage->mobileLayout) {
         $blnMobile = true;
     } elseif (\Input::cookie('TL_VIEW') == 'desktop') {
         $blnMobile = false;
     }
     $intId = $blnMobile ? $objPage->mobileLayout : $objPage->layout;
     $objLayout = \LayoutModel::findByPk($intId);
     // Die if there is no layout
     if ($objLayout === null) {
         $objLayout = false;
         if ($objPage->pid > 0) {
             $objParentPage = $object->getParentPage($objPage->pid);
             $objLayout = $object->getPageLayout($objParentPage);
         }
     }
     return $objLayout;
 }
コード例 #27
0
ファイル: tl_article.php プロジェクト: Mozan/core-bundle
 /**
  * Return all active layout sections as array
  *
  * @param DataContainer $dc
  *
  * @return array
  */
 public function getActiveLayoutSections(DataContainer $dc)
 {
     // Show only active sections
     if ($dc->activeRecord->pid) {
         $arrSections = array();
         $objPage = PageModel::findWithDetails($dc->activeRecord->pid);
         // Get the layout sections
         foreach (array('layout', 'mobileLayout') as $key) {
             if (!$objPage->{$key}) {
                 continue;
             }
             $objLayout = LayoutModel::findByPk($objPage->{$key});
             if ($objLayout === null) {
                 continue;
             }
             $arrModules = deserialize($objLayout->modules);
             if (empty($arrModules) || !is_array($arrModules)) {
                 continue;
             }
             // Find all sections with an article module (see #6094)
             foreach ($arrModules as $arrModule) {
                 if ($arrModule['mod'] == 0 && $arrModule['enable']) {
                     $arrSections[] = $arrModule['col'];
                 }
             }
         }
     } else {
         $arrSections = array('header', 'left', 'right', 'main', 'footer');
         $objLayout = $this->Database->query("SELECT sections FROM tl_layout WHERE sections!=''");
         while ($objLayout->next()) {
             $arrCustom = trimsplit(',', $objLayout->sections);
             // Add the custom layout sections
             if (!empty($arrCustom) && is_array($arrCustom)) {
                 $arrSections = array_merge($arrSections, $arrCustom);
             }
         }
     }
     return array_values(array_unique($arrSections));
 }
コード例 #28
0
 /**
  * Find by active theme
  *
  * @param array
  * @return static
  */
 public static function findPublishedByActiveTheme(array $arrOptions = array())
 {
     global $objPage;
     if ($objPage === null) {
         return null;
     }
     if (($layout = \LayoutModel::findByPk($objPage->layout)) === null) {
         return null;
     }
     return static::findPublishedByThemeId($layout->pid, $arrOptions);
 }
コード例 #29
0
 /**
  * Get a page layout and return it as database result object
  * @param \Model
  * @return \Model
  */
 protected function getPageLayout($objPage)
 {
     $blnMobile = $objPage->mobileLayout && \Environment::get('agent')->mobile;
     // Override the autodetected value
     if (\Input::cookie('TL_VIEW') == 'mobile' && $objPage->mobileLayout) {
         $blnMobile = true;
     } elseif (\Input::cookie('TL_VIEW') == 'desktop') {
         $blnMobile = false;
     }
     $intId = $blnMobile ? $objPage->mobileLayout : $objPage->layout;
     $objLayout = \LayoutModel::findByPk($intId);
     return $objLayout;
 }
コード例 #30
0
    /**
     * @param $strBuffer
     */
    public function inject($strBuffer)
    {
        $page = $this->pageProvider->getPage();
        if ($page) {
            // search for the layout
            $layout = \LayoutModel::findByPk($page->layout);
            $files = [];
            $stylesheetsCount = 0;
            $stylesheetsBuffer = '';
            $javascriptsCount = 0;
            $javascriptsBuffer = '';
            foreach ($this->files as $id => $file) {
                $asset = $file->asset;
                $files[] = $id;
                while ($asset instanceof DelegatorAssetInterface) {
                    $asset = $asset->getAsset();
                }
                if ($asset instanceof FileAsset) {
                    $sourcePath = $asset->getSourcePath();
                    $fileName = basename($asset->getSourcePath());
                } else {
                    if ($asset instanceof HttpAsset) {
                        $class = new \ReflectionClass($asset);
                        $property = $class->getProperty('sourceUrl');
                        $property->setAccessible(true);
                        $sourcePath = $property->getValue($asset);
                        $fileName = parse_url($sourcePath, PHP_URL_PATH);
                    } else {
                        $sourcePath = $asset->getTargetPath();
                        $fileName = basename($sourcePath);
                    }
                }
                switch ($file->type) {
                    case 'css':
                        $icon = '<img src="assets/theme-plus/images/stylesheet.png">';
                        $type = 'css';
                        $buffer =& $stylesheetsBuffer;
                        $stylesheetsCount++;
                        break;
                    case 'js':
                        $icon = '<img src="assets/theme-plus/images/javascript.png">';
                        $type = 'js';
                        $buffer =& $javascriptsBuffer;
                        $javascriptsCount++;
                        break;
                }
                $buffer .= sprintf('<div id="monitor-%s" class="theme-plus-dev-tool-monitor theme-plus-dev-tool-type-%s theme-plus-dev-tool-loading">' . '%s ' . '<a href="%s" target="_blank" class="theme-plus-dev-tool-link">%s</a>' . '</div>
', $id, $type, $icon, $file->url, $sourcePath);
            }
            $strBuffer = preg_replace('~<base[^>]+>~', sprintf('$0
<link rel="stylesheet" href="assets/theme-plus/stylesheets/dev.css">
<script src="assets/theme-plus/javascripts/dev.js"></script>'), $strBuffer);
            $strBuffer = preg_replace('|<body[^>]*>|', sprintf('$0
<!-- indexer::stop -->
<div id="theme-plus-dev-tool" class="%s">
<div id="theme-plus-dev-tool-toggler" title="Theme+ developers tool">T+</div>
<div id="theme-plus-dev-tool-stylesheets">
  <div id="theme-plus-dev-tool-stylesheets-counter">%s <span id="theme-plus-dev-tool-stylesheets-count">0</span> / <span id="theme-plus-dev-tool-stylesheets-total">%d</span></div>
  <div id="theme-plus-dev-tool-stylesheets-files">%s</div>
</div>
<div id="theme-plus-dev-tool-javascripts">
  <div id="theme-plus-dev-tool-javascripts-counter">%s <span id="theme-plus-dev-tool-javascripts-count">0</span> / <span id="theme-plus-dev-tool-javascripts-total">%d</span></div>
  <div id="theme-plus-dev-tool-javascripts-files">%s</div>
</div>
<div id="theme-plus-dev-tool-exception"></div>
</div>
<script>initThemePlusDevTool(%s, %s);</script>
<!-- indexer::continue -->', \Input::cookie('THEME_PLUS_DEV_TOOL_COLLAPES') == 'no' ? '' : 'theme-plus-dev-tool-collapsed', \Image::getHtml('assets/theme-plus/images/stylesheet.png'), $stylesheetsCount, $stylesheetsBuffer, \Image::getHtml('assets/theme-plus/images/javascript.png'), $javascriptsCount, $javascriptsBuffer, json_encode($files), json_encode((bool) $layout->theme_plus_javascript_lazy_load)), $strBuffer);
        }
        return $strBuffer;
    }