protected function _build($options) { echo "\nsettings...\n"; if (!file_exists('build/component')) { mkdir('build/component'); } Kwf_Component_Settings::resetSettingsCache(); foreach (glob('build/component/*') as $f) { unlink($f); } $fileName = 'build/component/settings'; try { $data = Kwf_Component_Settings::_getSettingsCached(); } catch (Kwf_Trl_BuildFileMissingException $e) { $originatingException = $e->getSettingsNonStaticTrlException(); if ($originatingException) { throw $originatingException; } throw $e; } foreach ($data as $cmp => $settings) { self::_checkSettings($cmp, $settings); } file_put_contents($fileName, serialize($data)); $componentClasses = Kwc_Abstract::getComponentClasses(); echo "masterLayouts...\n"; Kwf_Component_MasterLayout_Abstract::_buildAll($componentClasses); echo "layouts...\n"; Kwf_Component_Layout_Abstract::_buildAll($componentClasses); }
protected function _build($options) { if (!file_exists('build/component')) { mkdir('build/component'); } Kwf_Component_Settings::resetSettingsCache(); $fileName = 'build/component/settings'; if (file_exists($fileName)) { unlink($fileName); } $data = Kwf_Component_Settings::_getSettingsCached(); foreach ($data as $cmp => $settings) { self::_checkSettings($cmp, $settings); } file_put_contents($fileName, serialize($data)); }
protected function _build($options) { if (!file_exists('build/component')) { mkdir('build/component'); } Kwf_Component_Settings::resetSettingsCache(); $fileName = 'build/component/settings'; if (file_exists($fileName)) { unlink($fileName); } try { $data = Kwf_Component_Settings::_getSettingsCached(); } catch (Kwf_Trl_BuildFileMissingException $e) { $originatingException = $e->getSettingsNonStaticTrlException(); if ($originatingException) { throw $originatingException; } throw $e; } foreach ($data as $cmp => $settings) { self::_checkSettings($cmp, $settings); } file_put_contents($fileName, serialize($data)); }
/** * Returns all component classes used in this app * * Fast, result is cached * * @return string[] */ public static final function getComponentClasses() { return Kwf_Component_Settings::getComponentClasses(); }
private static function _loadSettingsRecursive(&$settings, $cmpClass) { echo "{$cmpClass} is brand new! (not yet in componentClasses)\n"; Kwf_Component_Settings::$_rebuildingSettings = true; $settings[$cmpClass] = Kwf_Component_Settings::_getSettingsIncludingPreComputed($cmpClass); Kwf_Component_Settings::$_rebuildingSettings = false; foreach (self::_getComponentClassesFromGeneratorsSetting($settings[$cmpClass]['generators']) as $c) { if (!isset($settings[$c])) { self::_loadSettingsRecursive($settings, $c); } } }
public static function dispatchKwc() { $requestPath = self::getRequestPath(); if ($requestPath === false) { return; } $fullRequestPath = $requestPath; $data = null; $baseUrl = Kwf_Setup::getBaseUrl(); if ($baseUrl) { if (substr($requestPath, 0, strlen($baseUrl)) != $baseUrl) { throw new Kwf_Exception_NotFound(); } $requestPath = substr($requestPath, strlen($baseUrl)); } $uri = substr($requestPath, 1); $i = strpos($uri, '/'); if ($i) { $uri = substr($uri, 0, $i); } if ($uri == 'robots.txt') { Kwf_Util_RobotsTxt::output(); } if ($uri == 'sitemap.xml') { $data = Kwf_Component_Data_Root::getInstance()->getPageByUrl('http://' . $_SERVER['HTTP_HOST'] . Kwf_Setup::getBaseUrl() . '/', null); Kwf_Component_Sitemap::output($data->getDomainComponent()); } if (!in_array($uri, array('media', 'kwf', 'admin', 'assets', 'vkwf', 'api'))) { if (!isset($_SERVER['HTTP_HOST'])) { $requestUrl = 'http://' . Kwf_Config::getValue('server.domain') . $fullRequestPath; } else { $requestUrl = 'http://' . $_SERVER['HTTP_HOST'] . $fullRequestPath; } Kwf_Trl::getInstance()->setUseUserLanguage(false); $root = Kwf_Component_Data_Root::getInstance(); foreach ($root->getPlugins('Kwf_Component_PluginRoot_Interface_PreDispatch') as $p) { $p->preDispatch($requestUrl); } $acceptLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null; $exactMatch = true; $data = $root->getPageByUrl($requestUrl, $acceptLanguage, $exactMatch); Kwf_Benchmark::checkpoint('getPageByUrl'); if (!$data) { throw new Kwf_Exception_NotFound(); } if (!$exactMatch) { if (rawurldecode($data->url) == $fullRequestPath) { throw new Kwf_Exception("getPageByUrl reported this isn't an exact match, but the urls are equal. wtf."); } $url = $data->url; if (!$url) { // e.g. firstChildPageData without child pages throw new Kwf_Exception_NotFound(); } foreach ($root->getPlugins('Kwf_Component_PluginRoot_Interface_PostRender') as $p) { $url = $p->processUrl($url); } if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']) { $url .= '?' . $_SERVER['QUERY_STRING']; } header('Location: ' . $url, true, 301); exit; } $root->setCurrentPage($data); Kwf_User_Autologin::processCookies(); $contentSender = Kwf_Component_Settings::getSetting($data->componentClass, 'contentSender'); $contentSender = new $contentSender($data); $contentSender->sendContent(true); Kwf_Benchmark::shutDown(); //TODO: ein flag oder sowas ähnliches stattdessen verwenden if ($data instanceof Kwc_Abstract_Feed_Component || $data instanceof Kwc_Export_Xml_Component || $data instanceof Kwc_Export_Xml_Trl_Component) { echo "<!--"; } Kwf_Benchmark::output(); if ($data instanceof Kwc_Abstract_Feed_Component || $data instanceof Kwc_Export_Xml_Component || $data instanceof Kwc_Export_Xml_Trl_Component) { echo "-->"; } exit; } else { if ($requestPath == '/kwf/util/kwc/render') { Kwf_User_Autologin::processCookies(); Kwf_Util_Component::dispatchRender(); } } }
/** * @internal */ public static function setComponentClass($componentClass) { Kwf_Component_Settings::$_rootComponentClassSet = true; self::$_rootComponentClass = $componentClass; self::reset(); }
public static function &_getSettingsCached() { self::$_cacheSettings = array(); if (!self::$_settings) { if (!self::$_rootComponentClassSet && file_exists('build/component/settings')) { self::$_settings = unserialize(file_get_contents('build/component/settings')); } else { $fullT = microtime(true); self::$_rebuildingSettings = true; self::$_settings = array(); self::$_settings['mtimeFiles'] = array(); $incPaths = explode(PATH_SEPARATOR, get_include_path()); $t = microtime(true); $classes = self::getComponentClasses(); foreach ($classes as $c) { self::$_settings[$c] = self::_getSettingsIncludingPreComputed($c); } self::$_rebuildingSettings = false; foreach (self::getComponentClasses() as $c) { $realCls = strpos($c, '.') ? substr($c, 0, strpos($c, '.')) : $c; try { call_user_func(array($realCls, 'validateSettings'), self::$_settings[$c], $c); } catch (Kwf_Exception $e) { throw new Kwf_Exception("{$c}: " . $e->getMessage()); } } } } return self::$_settings; }