Ejemplo n.º 1
0
 /**
  * Gets a constant
  *
  * @param string $constant The name of the constant
  * @return string Constant-Value
  *
  * = Examples =
  *
  * <code title="Example">
  * <theme:constant constant="themes.configuration.baseurl" />
  * </code>
  * <output>
  * http://yourdomain.tld/
  * (depending on your domain)
  * </output>
  */
 public function render($constant = '')
 {
     $pageWithTheme = \KayStrobach\Themes\Utilities\FindParentPageWithThemeUtility::find($this->getFrontendController()->id);
     $pageLanguage = (int) GeneralUtility::_GP('L');
     // instantiate the cache
     /** @var \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache */
     $cache = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('themes_cache');
     $cacheLifeTime = 60 * 60 * 24 * 7 * 365 * 20;
     $cacheIdentifierString = 'theme-of-page-' . $pageWithTheme . '-of-language-' . $pageLanguage;
     $cacheIdentifier = sha1($cacheIdentifierString);
     // If flatSetup is available, cache it
     $flatSetup = $this->getFrontendController()->tmpl->flatSetup;
     if (isset($flatSetup) && is_array($flatSetup) && count($flatSetup) > 0) {
         $cache->set($cacheIdentifier, $flatSetup, array('page-' . $this->getFrontendController()->id), $cacheLifeTime);
     } else {
         $flatSetup = $cache->get($cacheIdentifier);
     }
     // If flatSetup not available and not cached, generate it!
     if (!isset($flatSetup) || !is_array($flatSetup)) {
         $this->getFrontendController()->tmpl->generateConfig();
         $flatSetup = $this->getFrontendController()->tmpl->flatSetup;
         $cache->set($cacheIdentifier, $flatSetup, array('page-' . $this->getFrontendController()->id), $cacheLifeTime);
     }
     // check if there is a value and return it
     if (is_array($flatSetup) && array_key_exists($constant, $flatSetup)) {
         return $this->getFrontendController()->tmpl->substituteConstants($flatSetup[$constant]);
     }
     return NULL;
 }
Ejemplo n.º 2
0
 /**
  * show available constants.
  *
  * @return void
  */
 public function indexAction()
 {
     $this->view->assign('selectableThemes', $this->themeRepository->findAll());
     $selectedTheme = $this->themeRepository->findByPageId($this->id);
     if ($selectedTheme !== null) {
         $nearestPageWithTheme = $this->id;
         $this->view->assign('selectedTheme', $selectedTheme);
         $this->view->assign('categories', $this->renderFields($this->tsParser, $this->id, $this->allowedCategories, $this->deniedFields));
         $categoriesFilterSettings = $this->getBackendUser()->getModuleData('mod-web_ThemesMod1/Categories/Filter/Settings', 'ses');
         if ($categoriesFilterSettings === null) {
             $categoriesFilterSettings = [];
             $categoriesFilterSettings['searchScope'] = 'all';
             $categoriesFilterSettings['showBasic'] = '1';
             $categoriesFilterSettings['showAdvanced'] = '0';
             $categoriesFilterSettings['showExpert'] = '0';
         }
         $this->view->assign('categoriesFilterSettings', $categoriesFilterSettings);
     } elseif ($this->id !== 0) {
         $nearestPageWithTheme = FindParentPageWithThemeUtility::find($this->id);
     } else {
         $nearestPageWithTheme = 0;
     }
     $this->view->assignMultiple(['pid' => $this->id, 'nearestPageWithTheme' => $nearestPageWithTheme, 'themeIsSelectable' => CheckPageUtility::hasThemeableSysTemplateRecord($this->id)]);
 }