Load page TSconfig

@param int $pageId The current page ID
@param array $typoScriptSetup The PlugIn configuration

@return LayoutSetup
975132
public function init($pageId, array $typoScriptSetup = [])
    {
        $this->setLanguageService($GLOBALS['LANG']);
        $pageId = (strpos($pageId, 'NEW') === 0) ? 0 : (int)$pageId;
        if ((int)$pageId < 0) {
            $pageId = Helper::getInstance()->getPidFromUid($pageId);
        }
        $this->realPid = $pageId;
        $this->loadLayoutSetup($pageId);
        foreach ($this->layoutSetup as $key => $setup) {
            $columns = $this->getLayoutColumns($key);
            if ($columns['allowed'] || $columns['disallowed'] || $columns['maxitems']) {
                $this->layoutSetup[$key]['columns'] = $columns;
                unset($this->layoutSetup[$key]['columns']['allowed']);
                $this->layoutSetup[$key]['allowed'] = $columns['allowed'] ?: [];
                $this->layoutSetup[$key]['disallowed'] = $columns['disallowed'] ?: [];
                $this->layoutSetup[$key]['maxitems'] = $columns['maxitems'] ?: [];
            }
        }
        $this->setTypoScriptSetup($typoScriptSetup);
        return $this;
    }
691766
public function buildPageResourceId(
        $siteId,
        $pageType,
        $pageName
    ) {
        return $this->resourceName->get(
            ResourceName::RESOURCE_SITES,
            $siteId,
            ResourceName::RESOURCE_PAGES,
            $pageType,
            $pageName
        );
    }
669237
protected function getTemplateLayoutsFromTsConfig($pageUid)
    {
        $templateLayouts = [];
        $pagesTsConfig = BackendUtility::getPagesTSconfig($pageUid);
        if (isset($pagesTsConfig['tx_dvoconnector.']['templateLayouts.']) && is_array($pagesTsConfig['tx_dvoconnector.']['templateLayouts.'])) {
            $templateLayouts = $pagesTsConfig['tx_dvoconnector.']['templateLayouts.'];
        }
        return $templateLayouts;
    }
671773
public function getSitePage(
        SiteEntity $site,
        $pageId
    ) {
        try {
            /** @var \Rcm\Entity\Page $page */
            $page = $this->findOneBy(
                [
                    'site' => $site,
                    'pageId' => $pageId
                ]
            );
        } catch (\Exception $e) {
            $page = null;
        }

        return $page;
    }
995238
protected function getPageEditLink($pageId, $documentSetId)
    {
        return Controller::join_links(
            CMSPageEditController::singleton()->getEditForm($pageId)->FormAction(),
            'field/DocumentSets/item',
            (int) $documentSetId
        );
    }
549121
public static function getAllowedPageTypes($pageId, $configurationName = 'pages')
    {
        $rootPath = '';
        $configuration = self::getConfigurationFromPageId($pageId, $rootPath);
        return $configuration->getIndexQueueAllowedPageTypesArrayByConfigurationName($configurationName);
    }
195423
public function findPageSettings($pageId)
    {
        $this->makeSelect();
        $this->sql .= ' and page_id = ?';
        $this->bindValues[] = $pageId;

        return $this->find();
    }
1005507
function loadTemplate(templatePath, identifier) {
  return plugin.myrmex.fire('beforeTemplateLoad', templatePath, identifier)
  .spread((templatePath, name) => {
    const templateDoc = _.cloneDeep(require(path.join(templatePath)));

    // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring the document
    const Template = require('./template');
    const template = new Template(templateDoc, identifier);

    // This event allows to inject code to alter the template configuration
    return plugin.myrmex.fire('afterTemplateLoad', template);
  })
  .spread(template => {
    return Promise.resolve(template);
  });
}
622936
protected function initializeSettings()
    {
        /** @var $typoScriptService TypoScriptService */
        $typoScriptService = $this->objectManager->get(TypoScriptService::class);

        // Make sure plugin.tx_solr.settings are available in the view as {settings}
        $this->settings = $typoScriptService->convertTypoScriptArrayToPlainArray(
            $this->typoScriptConfiguration->getObjectByPathOrDefault('plugin.tx_solr.settings.', [])
        );
    }
954888
public function getModuleConfiguration(string $moduleId) : ModuleConfiguration
    {
        if (array_key_exists($moduleId, $this->moduleConfigurations)) {
            return $this->moduleConfigurations[$moduleId];
        }
        throw new DomainException('There is no module configuration with id ' . $moduleId);
    }
1298724
protected function getRequest(array $requestArguments = [], $pageId = 0, $languageId = 0)
    {
        $searchRequest = GeneralUtility::makeInstance(SearchRequest::class,
            /** @scrutinizer ignore-type */ $requestArguments,
            /** @scrutinizer ignore-type */ $pageId,
            /** @scrutinizer ignore-type */ $languageId,
            /** @scrutinizer ignore-type */ $this->typoScriptConfiguration);
        return $searchRequest;
    }
76223
private function updateMelisPlugin($pageId, $plugin, $pluginId, $content, $updateSettings = false)
    {

        $pluginContent         = $content;
        $pluginSessionSettings = isset($_SESSION['meliscms']['content-pages'][$pageId]['private:melisPluginSettings'][$pluginId]) ?
            $_SESSION['meliscms']['content-pages'][$pageId]['private:melisPluginSettings'][$pluginId] : '';
        $pluginSettings        = (array) json_decode($pluginSessionSettings);
        
        if($plugin == 'melisTag') {

            $pattern = '/type\=\"([html|media|textarea]*\")/';
            if(preg_match($pattern, $pluginContent, $matches)) {
                $type = isset($matches[0]) ? $matches[0] : null;
                if($type) {
                    // apply sizes
                    if($pluginSettings) {
                        /* $replacement   = $type .' width_desktop="'.$pluginSettings['width_desktop'].
                            '" width_tablet="'.$pluginSettings['width_tablet'].
                            '" width_mobile="'.$pluginSettings['width_mobile'].'"';
                        $pluginContent = preg_replace($pattern, $replacement, $pluginContent); */
                        
                        $pluginContent = $this->setPluginWidthXmlAttribute($pluginContent, $pluginSettings);
                    }
                }
            }
        }
        else {
            $pattern = '\<'.$plugin.'\sid\=\"(.*?)*\"';

            if(preg_match('/'.$pattern.'/', $pluginContent, $matches)) {
                $id = isset($matches[0]) ? $matches[0] : null;
                
                if($id) {
                    if($pluginSettings) {
                        /* $replacement   = $id .' width_desktop="'.$pluginDesktop.
                            '" width_tablet="'.$pluginTablet.
                            '" width_mobile="'.$pluginMobile.'"';
                        $pluginContent = preg_replace('/'.$pattern.'/', $replacement, $pluginContent); */
                        
                        $pluginContent = $this->setPluginWidthXmlAttribute($pluginContent, $pluginSettings);
                    }
                }
            }
        }
        

        if(isset($_SESSION['meliscms']['content-pages'][$pageId][$plugin][$pluginId])) {
            $_SESSION['meliscms']['content-pages'][$pageId][$plugin][$pluginId] =
                $this->getPluginContentWithInsertedContainerId($pageId, $plugin, $pluginId, $pluginContent);

            $pluginContent = $_SESSION['meliscms']['content-pages'][$pageId][$plugin][$pluginId];
            if($updateSettings) {

                $_SESSION['meliscms']['content-pages'][$pageId][$plugin][$pluginId] = $this->reapplySettings($pageId, $plugin, $pluginId, $pluginContent);
            }

            if($plugin == 'melisTag') {
                $content =  $this->updateContent($pageId, $plugin, $pluginId, $pluginContent);
                $_SESSION['meliscms']['content-pages'][$pageId][$plugin][$pluginId] = $content;
            }

        }

    }
234827
public function setType($type)
    {
        $types = array(
            'file',
            'script',
            'ready',
            'block',
            'var'
        );

        if (! in_array($type, $types)) {
            Throw new PageException('Javascript targets have to be "file", "script", "block", "var" or "ready"');
        }

        $this->type = $type;

        return $this;
    }
337947
function (item, pageConfig) {
            var templateCfg = {
                classpath : item.template
            };
            var args = item.args || [];
            var extraArg = {};
            if (item.contentId) {
                extraArg.contents = this._getPlaceholderContents(pageConfig, item.contentId);
            }
            args.push(extraArg);

            templateCfg.args = args;
            if (item.module) {
                var module = this._rootModule.getPageModule(this.currentPageId, item.module);
                templateCfg.moduleCtrl = module;
                this._modulesInPage.push(module);
            }
            if (item.data) {
                templateCfg.data = item.data;
            }
            return templateCfg;
        }
71382
protected function getSubPageIds($pageId)
    {
        /** @var $queryGenerator \TYPO3\CMS\Core\Database\QueryGenerator */
        $queryGenerator = GeneralUtility::makeInstance(QueryGenerator::class);

        // here we retrieve only the subpages of this page because the permission clause is not evaluated
        // on the root node.
        $permissionClause = ' 1 ' . BackendUtility::BEenableFields('pages');
        $treePageIdList = $queryGenerator->getTreeList($pageId, 20, 0, $permissionClause);
        $treePageIds = array_map('intval', explode(',', $treePageIdList));

            // the first one can be ignored because this is the page itself
        array_shift($treePageIds);

        return $treePageIds;
    }
1109255
public function useSiteHashFromTypoScript(int $requestedPageId): QueryBuilder
    {
        $queryConfiguration = $this->typoScriptConfiguration->getObjectByPathOrDefault('plugin.tx_solr.search.query.', []);
        $allowedSites = $this->siteHashService->getAllowedSitesForPageIdAndAllowedSitesConfiguration($requestedPageId, $queryConfiguration['allowedSites']);
        return $this->useSiteHashFromAllowedSites($allowedSites);
    }
1094587
public function setUp(ThemeInterface $theme, TemplateManager $templateManager, PageBlocksInterface $pageBlocks, Template $template = null)
    {
        $this->templateManager = $templateManager;
        $this->pageBlocks = $pageBlocks;
        $this->theme = $theme;

        $this->dispatch(PageTreeEvent\PageTreeEvents::BEFORE_PAGE_TREE_SETUP, new PageTreeEvent\BeforePageTreeSetupEvent($this));

        $language = $this->getLanguage();
        $page = $this->getPage();
        if (null !== $language && null !== $page) {
            $this->pageBlocks->refresh($language->getId(), $page->getId());
        }

        $options = array();
        if (null !== $language) {
            $options["language"] = $language->getLanguageName();
        }

        $templateName = "";
        if (null !== $page) {
            $options["page"] = $page->getPageName();
            $templateName = $page->getTemplateName();
        }

        $this->template = (null === $template) ? $this->theme->getTemplate($templateName) : $template;
        if (null === $this->template) {
            return $this;
        }

        $this->assetsManager
            ->withExtraAssets($this->cmsMode)
            ->setUp($this->template, $options)
        ;

        $this->templateManager
             ->refresh($this->theme->getThemeSlots(), $this->template, $this->pageBlocks);

        $this->setUpMetaTags($this->getSeo());

        $this->dispatch(PageTreeEvent\PageTreeEvents::AFTER_PAGE_TREE_SETUP, new PageTreeEvent\AfterPageTreeSetupEvent($this));

        return $this;
    }