function addComponentsToEdit($menu) { $templatePath = org_glizycms_Glizycms::getSiteTemplatePath(); $originalRootComponent =& $this->_application->getRootComponent(); $originalChildren = $this->childComponents; $this->childComponents = array(); $this->addDefaultComponents($menu); $this->_pageTypeObj =& org_glizy_ObjectFactory::createPage($this->_application, $menu->menu_pageType, org_glizy_Paths::get('APPLICATION_TO_ADMIN_PAGETYPE'), array('idPrefix' => $this->getId() . '-', 'skipImport' => true, 'pathTemplate' => $templatePath, 'mode' => 'edit')); $rootComponent =& $this->_application->getRootComponent(); $rootComponent->init(); $this->_application->_rootComponent =& $originalRootComponent; $editComponents = $rootComponent->getAttribute('adm:editComponents'); $this->allowBlocks = $rootComponent->getAttribute('allowBlocks'); if (count($editComponents)) { foreach ($editComponents as $id) { $component =& $rootComponent->getComponentById($this->getId() . '-' . $id); if (!is_object($component)) { continue; } $component->remapAttributes($this->getId() . '-'); $this->addChild($component); $component->_parent =& $this; $component->setAttribute('visible', true); } } else { for ($i = 0; $i < count($rootComponent->childComponents); $i++) { $rootComponent->childComponents[$i]->remapAttributes($this->getId() . '-'); $this->addChild($rootComponent->childComponents[$i]); $rootComponent->childComponents[$i]->_parent =& $this; } } $this->childComponents = array_merge($this->childComponents, $originalChildren); }
/** * Process * * @return boolean false if the process is aborted * @access public */ function process() { $tagContent = $this->getText(); if (empty($tagContent)) { // richiede il contenuto al padre $tagContent = $this->_parent->loadContent($this->getId()); $this->setText($tagContent); } if ($this->_parent->_tagname == 'glz:Page') { if (strpos($this->getText(), '.xml') !== false) { // crea i componenti leggendoli dal pageType specificato $fileName = org_glizy_Paths::getRealPath('APPLICATION_PAGE_TYPE', $this->getText()); if (!empty($fileName)) { $originalRootComponent =& $this->_application->getRootComponent(); $this->_pageTypeObj =& org_glizy_ObjectFactory::createPage($this->_application, preg_replace('/.xml$/', '', $this->getText())); $rootComponent =& $this->_application->getRootComponent(); $rootComponent->init(); $this->_application->_rootComponent =& $originalRootComponent; for ($i = 0; $i < count($rootComponent->childComponents); $i++) { $rootComponent->childComponents[$i]->remapAttributes($this->getId() . '-'); $this->addChild($rootComponent->childComponents[$i]); $rootComponent->childComponents[$i]->_parent =& $this; } $this->processChilds(); } } else { $newComponent =& org_glizy_ObjectFactory::createComponent($this->getText(), $this->_application, $this, '', '', ''); $newComponent->init(); $this->addChild($newComponent); $this->processChilds(); } } }
protected function getEditForm($pageId, $formId = 'editForm', $formAction = 'edit') { $oldAction = __Request::get('action'); __Request::set('action', $formAction); $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $originalRootComponent = $application->getRootComponent(); $siteMap = $application->getSiteMap(); $siteMapNode = $siteMap->getNodeById($pageId); $pageType = $siteMapNode->getAttribute('pageType'); $path = org_glizy_Paths::get('APPLICATION_PAGETYPE'); $templatePath = org_glizycms_Glizycms::getSiteTemplatePath(); $options = array('skipImport' => true, 'pathTemplate' => $templatePath, 'mode' => 'edit'); $pageTypeObj =& org_glizy_ObjectFactory::createPage($application, $pageType, $path, $options); $rootComponent = $application->getRootComponent(); $rootComponent->init(); $application->_rootComponent =& $originalRootComponent; __Request::set('action', $oldAction); return $rootComponent->getComponentById($formId); }
/** * @param org_glizy_components_Component $component * @param org_glizy_application_Application $application * @param string $pageType * @param string $path * @param array $options * @param string $remapId * @param bool $atTop */ function attachPageToComponent($component, $application, $pageType, $path, $options, $remapId, $atTop = true) { $originalRootComponent = $application->getRootComponent(); $originalChildren = $component->childComponents; $component->childComponents = array(); org_glizy_ObjectFactory::createPage($application, $pageType, $path, $options); $rootComponent = $application->getRootComponent(); $rootComponent->init(); $rootComponent->execDoLater(); $application->_rootComponent =& $originalRootComponent; for ($i = 0; $i < count($rootComponent->childComponents); $i++) { $rootComponent->childComponents[$i]->remapAttributes($remapId); $component->addChild($rootComponent->childComponents[$i]); $rootComponent->childComponents[$i]->_parent =& $component; } $component->childComponents = $atTop ? array_merge($component->childComponents, $originalChildren) : array_merge($originalChildren, $component->childComponents); }
/** * @param bool $readPageId */ function _startProcess($readPageId = true) { $this->log("startProcess", GLZ_LOG_SYSTEM); if ($this->_logObj) { $this->log(array('Request' => __Request::getAllAsArray()), GLZ_LOG_SYSTEM); } if ($readPageId) { $evt = array('type' => GLZ_EVT_BEFORE_CREATE_PAGE); $this->dispatchEvent($evt); $this->_readPageId(); } org_glizy_ObjectValues::set('org.glizy.application', 'pageId', $this->_pageId); $this->_pageType = $this->siteMapMenu->pageType; if (__Request::exists('__middleware__')) { $middlewareObj = org_glizy_ObjectFactory::createObject(__Request::get('__middleware__')); // verify the cache before page rendering // this type of cache is available only for Static Page if ($middlewareObj) { $middlewareObj->beforeProcess($this->_pageId, $this->_pageType); } } org_glizy_ObjectFactory::createPage($this, $this->_pageType, null, array('pathTemplate' => org_glizy_Paths::get('APPLICATION_TEMPLATE'))); if (!is_null($this->_rootComponent)) { if (!$this->_ajaxMode) { // serve per resettare lo stato del sessionEx ad ogni caricamento delle pagine // altrimenti gli stati vecchi non vengono cancellati // quando c'è un cambio di pagina e SessionEx non è usato org_glizy_ObjectFactory::createObject('org.glizy.SessionEx', ''); $this->_rootComponent->resetDoLater(); $this->_rootComponent->init(); $this->_rootComponent->execDoLater(); $this->log("Process components", GLZ_LOG_SYSTEM); $this->_rootComponent->resetDoLater(); $evt = array('type' => GLZ_EVT_START_PROCESS); $this->dispatchEvent($evt); if (method_exists($this, 'process_onStart')) { $this->process_onStart(); } $this->_rootComponent->process(); if (method_exists($this, 'process_onEnd')) { $this->process_onEnd(); } $this->_rootComponent->execDoLater(); $evt = array('type' => GLZ_EVT_END_PROCESS); $this->dispatchEvent($evt); // check if enable the PDF output if ($this->getCurrentMenu()->printPdf) { $pdfPage = org_glizy_Paths::getRealPath('APPLICATION_TEMPLATE', 'pdf.php'); if ($pdfPage !== false) { if (__Request::get('printPdf', '0')) { org_glizy_ObjectValues::set('org.glizy.application', 'pdfMode', __Request::get('printPdf', '0') == '1'); } } else { $this->getCurrentMenu()->printPdf = false; } } $evt = array('type' => GLZ_EVT_START_RENDER); $this->dispatchEvent($evt); $this->_rootComponent->resetDoLater(); if (method_exists($this, 'render_onStart')) { $this->render_onStart(); } $this->addJScoreLibraries(); $output = $this->_rootComponent->render(); if (method_exists($this, 'render_onEnd')) { $this->render_onEnd(); } $this->_rootComponent->execDoLater(); $evt = array('type' => GLZ_EVT_END_RENDER); $this->dispatchEvent($evt); $headerErrorCode = __Request::get('glizyHeaderCode', ''); if ($headerErrorCode == '404') { header("HTTP/1.1 404 Not Found"); header("Status: 404 Not Found"); } header("Content-Type: " . $this->contentType . "; charset=" . __Config::get('CHARSET')); if ($middlewareObj) { // verify the cache after content rendering $middlewareObj->afterRender($output); } echo $output; } else { $this->startProcessAjax(); } } else { // TODO // visualizzare errore } }