public function process() { global $current_user; /* @var $current_user CurrentUser */ if ($pid = Request::get('pid')) { Statistics::setPartnerCookie($pid); } XMLClass::$pageNode = XMLClass::createNodeFromObject(array(), false, 'page', false); XMLClass::appendNode(XMLClass::$pageNode, ''); XMLClass::$accessNode = XMLClass::createNodeFromObject(AccessRules::getRules(), false, 'access', true); XMLClass::appendNode(XMLClass::$accessNode, ''); XMLClass::$pageNode->setAttribute('current_url', Request::$url); if ($mn = $this->getMessageNode()) { XMLClass::$pageNode->appendChild($mn); } XMLClass::$pageNode->setAttribute('prefix', Config::need('www_path') . '/'); XMLClass::$varNode = XMLClass::$xml->createElement('variables'); foreach (Request::$get_normal as $f => $v) { if (is_numeric($f)) { // cachebreaker? XMLClass::$varNode->setAttribute('n' . $f, $f); } else { XMLClass::$varNode->setAttribute($f, $v); } } XMLClass::$pageNode->appendChild(XMLClass::$varNode); XMLClass::$rootNode->appendChild(XMLClass::$xml->importNode(StructureParser::toXML(), 1)); if ($current_user->authorized) { XMLClass::$CurrentUserNode = XMLClass::createNodeFromObject($current_user->getXMLInfo(), false, 'current_user', true); } else { XMLClass::$CurrentUserNode = XMLClass::createNodeFromObject(array(), false, 'current_user', false); } XMLClass::$pageNode->appendChild(XMLClass::$CurrentUserNode); // втыкаем модули страницы $role = $current_user->getRole(); foreach ($this->modules as $module) { $this->processModule($module['name'], $module); } if ($pageTitle = StructureParser::getTitle()) { $this->buildPageTitle($pageTitle); } switch (Request::$responseType) { case 'xml': case 'xmlc': return XMLClass::dumpToBrowser(); break; case 'xsl': case 'xslc': $xslTemplateClass = new XSLClass($this->xsltFileName); return $xslTemplateClass->dumpToBrowser(); break; case 'html': $xslTemplateClass = new XSLClass($this->xsltFileName); $html = $xslTemplateClass->getHTML(XMLClass::$xml); return $html; break; default: return XMLClass::dumpToBrowser(); break; } }
public function process() { global $current_user; /* @var $current_user CurrentUser */ XMLClass::$pageNode = XMLClass::createNodeFromObject($this->pageSettings, false, 'page', false); XMLClass::appendNode(XMLClass::$pageNode, $this->pageName); XMLClass::$pageNode->setAttribute('current_url', Request::$url); XMLClass::$pageNode->setAttribute('url', Request::$urlfirst); XMLClass::$pageNode->setAttribute('page_url', Config::need('www_path') . '/' . Request::$pageName . '/'); XMLClass::$pageNode->setAttribute('prefix', Config::need('www_path') . '/'); if ($current_user->authorized) XMLClass::$CurrentUserNode = XMLClass::createNodeFromObject($current_user->getXMLInfo(), false, 'current_user', false); else XMLClass::$CurrentUserNode = XMLClass::createNodeFromObject(array(), false, 'current_user', false); XMLClass::$pageNode->appendChild(XMLClass::$CurrentUserNode); // втыкаем модули страницы $role = $current_user->getRole(); // авторизация - везде $this->pageSettings['modules'][] = array( 'users' => array( 'roles' => array( '' => '', ), 'action' => 'show', 'mode' => 'auth', 'params' => array( ), ), ); if (isset($this->pageSettings['modules']) && is_array($this->pageSettings['modules'])) { foreach ($this->pageSettings['modules'] as $fid => $module) { foreach ($module as $moduleName => $additionalSettings) { if (!isset($additionalSettings['roles'][$role])) $this->processModule($moduleName, $additionalSettings); } } } $this->appendCss(); // xml дерево создано, теперь генерируем xslt шаблон // выдаем html //Request::$responseType = 'xml'; switch (Request::$responseType) { case 'xml':case 'xmlc': return XMLClass::dumpToBrowser(); break; case 'xsl':case 'xslc': $xslTemplateClass = new XSLClass($this->pageSettings['xslt']); $xslTemplateClass->setTemplates($this->xsltFiles); return $xslTemplateClass->dumpToBrowser(); break; case 'html': $xslTemplateClass = new XSLClass($this->pageSettings['xslt']); $xslTemplateClass->setTemplates($this->xsltFiles); $html = $xslTemplateClass->getHTML(XMLClass::$xml); if ($xslTemplateClass->fetched_from_cache) { // чтобы знать, что файл из кеша Log::logHtml('xslt template GOT from cache'); } if ($xslTemplateClass->puted_into_cache) { // чтобы знать, что файл из кеша Log::logHtml('xslt template PUT to cache'); } return $html; break; default: return XMLClass::dumpToBrowser(); break; } }