/**
  * Needs to be called after (multiple) duplicate() calls with a common root
  */
 public static function afterDuplicate(Kwf_Component_Data $rootSource, Kwf_Component_Data $rootTarget)
 {
     foreach (Kwf_Component_Abstract::getComponentClasses() as $c) {
         $admin = Kwf_Component_Abstract_Admin::getInstance($c);
         $admin->afterDuplicate($rootSource, $rootTarget);
     }
 }
Beispiel #2
0
 /**
  * Returns if the given component requests https
  *
  * Return value is cached.
  */
 public static function doesComponentRequestHttps(Kwf_Component_Data $data)
 {
     $showInvisible = Kwf_Component_Data_Root::getShowInvisible();
     $foundRequestHttps = false;
     if (!$showInvisible) {
         //don't cache in preview
         $cacheId = 'reqHttps-' . $data->componentId;
         $foundRequestHttps = Kwf_Cache_Simple::fetch($cacheId);
     }
     if ($foundRequestHttps === false) {
         $foundRequestHttps = 0;
         //don't use false, false means not-cached
         if (Kwf_Component_Abstract::getFlag($data->componentClass, 'requestHttps')) {
             $foundRequestHttps = true;
         }
         if (!$foundRequestHttps && $data->getRecursiveChildComponents(array('page' => false, 'flags' => array('requestHttps' => true)))) {
             $foundRequestHttps = true;
         }
         if (!$showInvisible) {
             //don't cache in preview
             Kwf_Cache_Simple::add($cacheId, $foundRequestHttps);
         }
     }
     return $foundRequestHttps;
 }
 protected function _render($includeMaster, &$hasDynamicParts)
 {
     header('X-Robots-Tag: noindex');
     $domain = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'];
     $ret = parent::_render($includeMaster, $hasDynamicParts);
     $ret = preg_replace('#(href|src)=(["\'])(/[^/])#', '$1=$2' . $domain . '$3', $ret);
     $up = Kwf_Config::getValue('uniquePrefix');
     $up = $up ? $up . '-' : '';
     $class = str_replace('kwfUp-', $up, Kwf_Component_Abstract::formatRootElementClass($this->_data->componentClass, '') . 'Master');
     $ret = preg_replace('#<body class="([^"]+)"#', '<body class="\\1 ' . $class . '" data-' . $up . 'base-url="' . $domain . '" ', $ret);
     return $ret;
 }
 private function _getKwcClass()
 {
     $kwcClass = Kwf_Component_Abstract::formatRootElementClass($this->_componentClass, '');
     if ($this->_isMaster) {
         $kwcClass .= 'Master';
     }
     if (Kwf_Config::getValue('application.uniquePrefix')) {
         $kwcClass = str_replace('kwfUp-', Kwf_Config::getValue('application.uniquePrefix') . '-', $kwcClass);
     } else {
         $kwcClass = str_replace('kwfUp-', '', $kwcClass);
     }
     return $kwcClass;
 }
Beispiel #5
0
 public function getTemplateVars()
 {
     $ret = parent::getTemplateVars();
     $ret['paragraphs'] = array();
     foreach ($this->getData()->getChildComponents(array('generator' => 'paragraphs')) as $paragraph) {
         $cssClass = 'kwcParagraphItem';
         $row = $paragraph->chained->row;
         if (Kwc_Abstract::getSetting($this->_getSetting('masterComponentClass'), 'useMobileBreakpoints') && $row->device_visible) {
             $cssClass .= ' ' . $row->device_visible;
         }
         $cssClass .= ' outer' . ucfirst(Kwf_Component_Abstract::formatCssClass($paragraph->chained->componentClass));
         $ret['paragraphs'][] = array('data' => $paragraph, 'class' => $cssClass);
     }
     return $ret;
 }
 public function getTemplateVars()
 {
     $ret = parent::getTemplateVars();
     $ret['paragraphs'] = array();
     foreach ($this->getData()->getChildComponents(array('generator' => 'paragraphs')) as $paragraph) {
         $cssClass = $this->_getBemClass('kwcParagraphItem');
         $row = $paragraph->getRow();
         if ($this->_getSetting('useMobileBreakpoints') && $row->device_visible) {
             $cssClass .= ' ' . $this->_getBemClass($row->device_visible);
         }
         $cssClass .= ' ' . $this->_getBemClass('outer' . ucfirst($paragraph->row->component), 'outer' . ucfirst(Kwf_Component_Abstract::formatRootElementClass($paragraph->componentClass, '')));
         $ret['paragraphs'][] = array('data' => $paragraph, 'class' => $cssClass);
     }
     return $ret;
 }
Beispiel #7
0
 public function __get($var)
 {
     if ($var == 'url') {
         $c = $this;
         while ($c) {
             if (Kwf_Component_Abstract::getFlag($c->componentClass, 'hasHome') && $c->isPseudoPage) {
                 return $c->_getPseudoPageUrl();
             }
             $c = $c->parent;
         }
         $baseUrl = Kwf_Setup::getBaseUrl();
         return $baseUrl . '/';
     }
     return parent::__get($var);
 }
 public function getContents($language)
 {
     $appIds = array();
     foreach (Kwf_Component_Abstract::getComponentClasses() as $class) {
         if (!Kwc_Abstract::getFlag($class, 'hasBaseProperties')) {
             continue;
         }
         $subRoots = Kwf_Component_Data_Root::getInstance()->getComponentsByClass($class);
         foreach ($subRoots as $subRoot) {
             if ($appId = $subRoot->getBaseProperty('fbAppData.appId')) {
                 $appIds[$subRoot->componentId] = $appId;
             }
         }
     }
     if (empty($appIds)) {
         throw new Kwf_Exception('No Facebook App ID found');
     }
     return "Kwf.FacebookAppIds = " . json_encode($appIds) . ";\n";
 }
Beispiel #9
0
 public static function getChildPageByPath($component, $path)
 {
     if ($path == '') {
         $ret = $component->getChildPage(array('home' => true), array());
     } else {
         foreach (Kwc_Abstract::getComponentClasses() as $c) {
             if (Kwc_Abstract::getFlag($c, 'shortcutUrl')) {
                 $ret = call_user_func(array($c, 'getDataByShortcutUrl'), $c, $path);
                 if ($ret) {
                     return $ret;
                 }
             }
         }
         $ret = $component->getChildPageByPath($path);
     }
     if ($ret && !$ret->isPage && Kwf_Component_Abstract::getFlag($ret->componentClass, 'hasHome')) {
         $ret = $ret->getChildPage(array('home' => true), array());
     }
     return $ret;
 }
 public static function getKwcUpdates()
 {
     $ret = array();
     $processed = array();
     foreach (Kwf_Component_Abstract::getComponentClasses() as $cmpClass) {
         foreach (Kwc_Abstract::getSetting($cmpClass, 'parentClasses') as $class) {
             $class = strpos($class, '.') ? substr($class, 0, strpos($class, '.')) : $class;
             if (!isset($processed[$class])) {
                 $processed[$class] = true;
                 $curClass = $class;
                 if (substr($curClass, -10) == '_Component') {
                     $curClass = substr($curClass, 0, -10);
                 }
                 $curClass .= '_Update';
                 $ret = array_merge($ret, self::getUpdatesForDir($curClass));
             }
         }
     }
     return $ret;
 }
 public function indexAction()
 {
     $id = $this->_getParam('id');
     if (!$id) {
         throw new Kwf_ClientException("Missing Parameter: id");
     }
     $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible' => true));
     if (!$c) {
         $c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($id, array('ignoreVisible' => true));
     }
     if (!$c) {
         throw new Kwf_ClientException("Component with id '{$id}' not found");
     }
     $process = $c->getRecursiveChildComponents(array('page' => false, 'flags' => array('processInput' => true)));
     if (Kwf_Component_Abstract::getFlag($c->componentClass, 'processInput')) {
         $process[] = $c;
     }
     $postData = array();
     foreach ($process as $i) {
         Kwf_Benchmark::count('processInput', $i->componentId);
         if (method_exists($i->getComponent(), 'preProcessInput')) {
             $i->getComponent()->preProcessInput($postData);
         }
     }
     foreach ($process as $i) {
         if (method_exists($i->getComponent(), 'processInput')) {
             $i->getComponent()->processInput($postData);
         }
     }
     /*
     //deaktivert: funktioniert nicht
     $c->getComponent()->sendContent('views/component-master.tpl', true);
     */
     //zwischenlösung:
     //(unschön: keine assets, kein html-header usw)
     echo $c->render();
     Kwf_Benchmark::output();
     exit;
 }
 public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer)
 {
     $ret = parent::getTemplateVars($renderer);
     $ret['paragraphs'] = array();
     foreach ($this->getData()->getChildComponents(array('generator' => 'paragraphs')) as $paragraph) {
         $cssClass = $this->_getBemClass('kwcParagraphItem');
         $row = $paragraph->getRow();
         if ($this->_getSetting('useMobileBreakpoints') && $row->device_visible) {
             $cssClass .= ' ' . $this->_getBemClass($row->device_visible);
         }
         $cssClass .= ' ' . $this->_getBemClass('outer' . ucfirst($paragraph->row->component), 'outer' . ucfirst(substr(Kwf_Component_Abstract::formatRootElementClass($paragraph->componentClass, ''), 6)));
         $preHtml = '';
         $postHtml = '';
         foreach (Kwf_Component_Data_Root::getInstance()->getPlugins('Kwf_Component_PluginRoot_Interface_MaskComponent') as $plugin) {
             $mask = $plugin->getMaskCode($paragraph);
             $preHtml = $mask['begin'] . $preHtml;
             $postHtml = $postHtml . $mask['end'];
         }
         $ret['paragraphs'][] = array('data' => $paragraph, 'class' => $cssClass, 'preHtml' => $preHtml, 'postHtml' => $postHtml);
     }
     return $ret;
 }
 public function getItemCountCacheId($row)
 {
     // Row kann von hier (Model) oder von Admin (DB-Row) kommen
     $highestSubRoot = false;
     $c = $this->getData();
     while ($c) {
         $isSubroot = Kwf_Component_Abstract::getFlag($c->componentClass, 'subroot');
         if ($isSubroot) {
             $highestSubRoot = $c;
         }
         $c = $c->parent;
     }
     if (!$highestSubRoot) {
         $cacheClassId = '';
     } else {
         $cacheClassId = $highestSubRoot->componentId;
     }
     if (!$row instanceof Kwf_Model_Row_Interface) {
         throw new Kwf_Exception('Tables are not allowed anymore when using directories');
     }
     return preg_replace('/[^a-zA-Z0-9_]/', '_', $cacheClassId) . 'KwcDirectoriesCategoryTreeViewComponent_category' . get_class($row->getModel()) . $row->id . '_itemCount';
 }
 public function load($row)
 {
     $id = $row->component_id . '-' . $row->id;
     $data = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($id, array('ignoreVisible' => true, 'limit' => 1));
     if (!$data) {
         return "Component with '{$id}' not found";
     }
     $class = $data->componentClass;
     if (is_instance_of($class, 'Kwc_Abstract')) {
         $process = $data->getRecursiveChildComponents(array('page' => false, 'flags' => array('processInput' => true), 'ignoreVisible' => true));
         if (Kwf_Component_Abstract::getFlag($data->componentClass, 'processInput')) {
             $process[] = $data;
         }
         foreach ($process as $i) {
             if (method_exists($i->getComponent(), 'preProcessInput')) {
                 $i->getComponent()->preProcessInput(array());
             }
         }
         foreach ($process as $i) {
             if (method_exists($i->getComponent(), 'processInput')) {
                 $i->getComponent()->processInput(array());
             }
         }
         return $data->render($data->isVisible(), false);
         //$view = new Kwf_Component_Renderer();
         //return $view->renderComponent($data);
     } else {
         if (isset($row->settings)) {
             $settingsModel = new Kwf_Model_Field(array('parentModel' => $row->getModel(), 'fieldName' => 'settings'));
             $f = new $class();
             $f->setProperties($settingsModel->getRowByParentRow($row)->toArray());
             $vars = $f->getTemplateVars(array());
             $view = new Kwf_View_Ext();
             $view->item = $vars;
             return $view->render('field.tpl');
         }
     }
 }
 public static function _getSettingsIncludingPreComputed($c)
 {
     $settings = self::_loadCacheSettings($c);
     //*** load templates + componentFiles
     //vorladen fuer Kwf_Component_Abstract_Admin::getComponentFile
     $settings['componentFiles'] = Kwf_Component_Abstract::getSetting($c, 'componentFiles');
     //*** parentClasses
     $settings['parentClasses'] = Kwf_Component_Abstract::getSetting($c, 'parentClasses');
     //*** parentFilePaths
     $settings['parentFilePaths'] = Kwf_Component_Abstract::getSetting($c, 'parentFilePaths');
     //*** generators
     $settings['generators'] = Kwf_Component_Abstract::getSetting($c, 'generators');
     return $settings;
 }
Beispiel #16
0
 /**
  * Returns static settings of this component
  *
  * Override to change settings
  *
  * @return array
  */
 public static function getSettings()
 {
     $ret = parent::getSettings();
     $ret['viewCache'] = true;
     $ret['contentSender'] = 'Kwf_Component_Abstract_ContentSender_Default';
     return $ret;
 }
 protected static function _findProcessInputComponents($data)
 {
     $process = $data->getRecursiveChildComponents(array('page' => false, 'flags' => array('processInput' => true)));
     $process = array_merge($process, $data->getRecursiveChildComponents(array('page' => false, 'flags' => array('forwardProcessInput' => true))));
     if (Kwf_Component_Abstract::getFlag($data->componentClass, 'processInput')) {
         $process[] = $data;
     }
     if (Kwf_Component_Abstract::getFlag($data->componentClass, 'forwardProcessInput')) {
         $process[] = $data;
     }
     $ret = array();
     foreach ($process as $i) {
         if (Kwf_Component_Abstract::getFlag($i->componentClass, 'processInput')) {
             $ret[] = $i;
         }
         if (Kwf_Component_Abstract::getFlag($i->componentClass, 'forwardProcessInput')) {
             $ret = array_merge($ret, $i->getComponent()->getForwardProcessInputComponents());
         }
     }
     return $ret;
 }
 /**
  * Returns the processed rootElementClass used in various places for a component
  *
  * @param string|Kwf_Component_Data
  * @return string
  */
 public static function getRootElementClass($component)
 {
     if (!is_string($component)) {
         $component = $component->getData()->componentClass;
     }
     $ret = '';
     if (self::hasSetting($component, 'rootElementClass')) {
         $ret .= self::getSetting($component, 'rootElementClass') . ' ';
     }
     $ret .= Kwf_Component_Abstract::formatRootElementClass($component, '');
     return $ret;
 }
 /**
  * @internal
  */
 public static function clearModelInstances()
 {
     self::$_modelsCache = array('own' => array(), 'child' => array(), 'form' => array(), 'table' => array());
 }
Beispiel #20
0
 public function _getSettingsIncludingPreComputed($c)
 {
     $settings = self::_loadCacheSettings($c);
     //*** load templates + componentFiles
     //vorladen fuer Kwf_Component_Abstract_Admin::getComponentFile
     $settings['componentFiles'] = Kwf_Component_Abstract::getSetting($c, 'componentFiles');
     //*** parentClasses
     $settings['parentClasses'] = Kwf_Component_Abstract::getSetting($c, 'parentClasses');
     //*** parentFilePaths
     $settings['parentFilePaths'] = Kwf_Component_Abstract::getSetting($c, 'parentFilePaths');
     //*** processedCssClass
     $settings['processedCssClass'] = '';
     if (isset($settings['cssClass'])) {
         $settings['processedCssClass'] .= $settings['cssClass'] . ' ';
     }
     $cssClass = array(Kwf_Component_Abstract::formatCssClass($c));
     $dirs = explode(PATH_SEPARATOR, get_include_path());
     foreach (include VENDOR_PATH . '/composer/autoload_namespaces.php' as $ns => $i) {
         $dirs = array_merge($dirs, $i);
     }
     foreach ($settings['parentClasses'] as $i) {
         if ($i == $c) {
             continue;
         }
         $file = str_replace('_', '/', $i);
         if (substr($file, -10) != '/Component') {
             $file .= '/Component';
         }
         foreach ($dirs as $dir) {
             if (is_file($dir . '/' . $file . '.css') || is_file($dir . '/' . $file . '.scss') || is_file($dir . '/' . $file . '.printcss') || is_file($dir . '/' . $file . '.js') || is_file($dir . '/' . $file . '.defer.js')) {
                 $cssClass[] = Kwf_Component_Abstract::formatCssClass($i);
                 break;
             }
         }
     }
     $settings['processedCssClass'] .= implode(' ', array_reverse($cssClass));
     $settings['processedCssClass'] = trim($settings['processedCssClass']);
     //*** generators
     $settings['generators'] = Kwf_Component_Abstract::getSetting($c, 'generators');
     return $settings;
 }
 public function __construct(Kwf_Component_Generator_Abstract $generator)
 {
     $this->_generator = $generator;
     parent::__construct();
 }
Beispiel #22
0
 private static function _clearComponentSettingsCache($componentClasses, $setting = null)
 {
     Kwf_Component_Abstract::resetSettingsCache();
     $settings = Kwf_Component_Settings::_getSettingsCached();
     $dependenciesChanged = false;
     $generatorssChanged = false;
     $dimensionsChanged = false;
     $menuConfigChanged = false;
     foreach ($componentClasses as $c) {
         Kwf_Component_Settings::$_rebuildingSettings = true;
         if ($setting) {
             //a single setting changed
             $newSettings = $settings[$c];
             $newSettings[$setting] = Kwc_Abstract::getSetting($c, $setting);
         } else {
             //all settings might have changed
             $newSettings = Kwf_Component_Settings::_getSettingsIncludingPreComputed($c);
         }
         Kwf_Component_Settings::$_rebuildingSettings = false;
         if ($newSettings['assets'] != $settings[$c]['assets'] || $newSettings['assetsAdmin'] != $settings[$c]['assetsAdmin']) {
             $dependenciesChanged = true;
         }
         if ($newSettings['generators'] != $settings[$c]['generators']) {
             $generatorssChanged = true;
             $oldChildComponentClasses = self::_getComponentClassesFromGeneratorsSetting($settings[$c]['generators']);
             $newChildComponentClasses = self::_getComponentClassesFromGeneratorsSetting($newSettings['generators']);
         }
         if (isset($newSettings['dimensions']) && $newSettings['dimensions'] != $settings[$c]['dimensions']) {
             $dimensionsChanged = true;
         }
         if (isset($newSettings['menuConfig']) && $newSettings['menuConfig'] != $settings[$c]['menuConfig']) {
             $menuConfigChanged = true;
         }
         $settings[$c] = $newSettings;
     }
     echo "refreshed component settings cache...\n";
     if ($dependenciesChanged) {
         echo "assets changed...\n";
         self::_clearAssetsDependencies();
         self::_clearAssetsAll();
     }
     $clearCacheSimpleStatic = array('has-', 'cs-', 'flag-', 'componentClasses-', 'recCCGen-', 'genInst-', 'childComponentClasses-');
     if ($generatorssChanged) {
         echo "generators changed...\n";
         echo count(Kwc_Abstract::getComponentClasses()) . " component classes (previously)\n";
         $m = Kwf_Component_Cache::getInstance()->getModel('url');
         foreach ($m->getRows() as $r) {
             Kwf_Cache_Simple::delete('url-' . $r->url);
             $r->delete();
         }
         foreach ($newChildComponentClasses as $cmpClass) {
             if (!in_array($cmpClass, Kwc_Abstract::getComponentClasses())) {
                 self::_loadSettingsRecursive($settings, $cmpClass);
             }
         }
         $removedComponentClasses = array_diff($oldChildComponentClasses, $newChildComponentClasses);
         foreach ($removedComponentClasses as $removedCls) {
             self::_removeSettingsRecursive($settings, $removedCls);
         }
     }
     file_put_contents('build/component/settings', serialize($settings));
     echo "cleared component settings apc cache...\n";
     if (Kwf_Util_Apc::isAvailable()) {
         self::_clearApcCache(array('clearCacheSimpleStatic' => $clearCacheSimpleStatic));
     } else {
         foreach ($clearCacheSimpleStatic as $i) {
             Kwf_Cache_SimpleStatic::clear($i);
         }
     }
     echo "\n";
     if ($dimensionsChanged) {
         echo "dimensions changed...\n";
         $clearCacheSimple = array();
         foreach ($componentClasses as $c) {
             $idPrefix = str_replace(array('.', '>'), array('___', '____'), $c) . '_';
             $clearCacheSimple[] = 'media-output-' . $idPrefix;
             $clearCacheSimple[] = 'media-output-mtime-' . $idPrefix;
             foreach (glob('cache/media/' . $idPrefix . '*') as $f) {
                 echo $f . " [DELETED]\n";
                 unlink($f);
             }
         }
         Kwf_Cache_Simple::delete($clearCacheSimple);
         echo "cleared media cache...\n";
     }
     if ($menuConfigChanged) {
         echo "menu config changed...\n";
         Kwf_Acl::clearCache();
         echo "cleared acl cache...\n";
     }
     $dependentComponentClasses = array();
     foreach (Kwc_Abstract::getComponentClasses() as $c) {
         if (strpos($c, '.') !== false) {
             $params = substr($c, strpos($c, '.') + 1);
             foreach ($componentClasses as $i) {
                 if (strpos($params, $i) !== false) {
                     $dependentComponentClasses[] = $c;
                 }
             }
         }
     }
     if ($dependentComponentClasses) {
         echo "dependent componentClasses: " . count($dependentComponentClasses) . " (Cc, Trl)\n";
         echo implode(', ', $dependentComponentClasses) . "\n";
         self::_clearComponentSettingsCache($dependentComponentClasses, $setting);
     }
 }
 public function jsonSaveAction()
 {
     $postData = $this->getRequest()->getParams();
     if (!isset($postData['componentId'])) {
         throw new Kwf_Exception_Client('component not found');
     }
     $component = Kwf_Component_Data_Root::getInstance()->getComponentById((string) $postData['componentId'], array('ignoreVisible' => true));
     if (!$component) {
         throw new Kwf_Exception_Client('component not found');
     }
     $component = $component->getComponent();
     $postData['doNotRelocate'] = true;
     $component->preProcessInput($postData);
     $component->processInput($postData);
     $errors = $component->getErrors();
     $this->view->errorPlaceholder = $component->getPlaceholder('error');
     $this->view->errorFields = array();
     $this->view->errorMessages = array();
     foreach ($errors as $error) {
         if (isset($error['message'])) {
             $error['messages'] = array($error['message']);
         }
         $msgs = array();
         foreach ($error['messages'] as $msg) {
             $msgs[] = htmlspecialchars($msg);
         }
         if (isset($error['field'])) {
             //if message is associated with a specific field show it there
             $this->view->errorFields[$error['field']->getFieldName()] = implode('<br />', $msgs);
         } else {
             //else just above the form
             $this->view->errorMessages = array_merge($this->view->errorMessages, $msgs);
         }
     }
     $this->view->successContent = null;
     if (!$this->view->errorMessages && !$this->view->errorFields) {
         $success = $component->getData()->getComponent()->getSuccessComponent();
         if ($success instanceof Kwf_Component_Data) {
             if ($success->isPage) {
                 $this->view->successUrl = $success->url;
             } else {
                 $process = $success->getRecursiveChildComponents(array('page' => false, 'flags' => array('processInput' => true)));
                 if (Kwf_Component_Abstract::getFlag($success->componentClass, 'processInput')) {
                     $process[] = $success;
                 }
                 $postData = array();
                 //empty because there can't be anything as we didn't display the success yet
                 foreach ($process as $i) {
                     if (method_exists($i->getComponent(), 'preProcessInput')) {
                         $i->getComponent()->preProcessInput($postData);
                     }
                 }
                 foreach ($process as $i) {
                     if (method_exists($i->getComponent(), 'processInput')) {
                         $i->getComponent()->processInput($postData);
                     }
                 }
                 if (class_exists('Kwf_Events_ModelObserver', false)) {
                     //Nur wenn klasse jemals geladen wurde kann auch was zu processen drin sein
                     Kwf_Events_ModelObserver::getInstance()->process(false);
                 }
                 $renderer = new Kwf_Component_Renderer();
                 $this->view->successContent = $renderer->renderComponent($success);
             }
         } else {
             if (is_string($success)) {
                 $this->view->successUrl = $success;
             }
         }
     }
     $this->view->errorFields = (object) $this->view->errorFields;
 }
 /**
  * @internal
  */
 public static function reset($resetCache = true)
 {
     self::$_instance = null;
     Kwf_Component_Generator_Abstract::clearInstances();
     Kwf_Component_Abstract::clearModelInstances();
     Kwf_Events_Dispatcher::clearCache();
     if ($resetCache) {
         Kwf_Component_Abstract::resetSettingsCache();
     }
 }
 public function __construct($componentId = null)
 {
     $this->_componentId = $componentId;
     parent::__construct($componentId);
 }
Beispiel #26
0
 public function __get($var)
 {
     if ($var == 'url') {
         if (!$this->isPage) {
             $page = $this->getPage();
             if (!$page) {
                 return '';
             }
             return $page->url;
         }
         return $this->_getPseudoPageUrl();
     } else {
         if ($var == 'rel') {
             /*
                         $childs = $this->getPage()->getRecursiveChildComponents(array(
                             'flags' => array('noIndex' => true),
                             'page' => false
                         ));*/
             $page = $this->getPage();
             if (!$page) {
                 return '';
             }
             $rel = $page->_rel;
             if (Kwf_Component_Abstract::getFlag($this->getPage()->componentClass, 'noIndex')) {
                 $rel .= ' nofollow';
             }
             return trim($rel);
         } else {
             if ($var == 'filename') {
                 return rawurlencode($this->getPseudoPageOrRoot()->_filename);
             } else {
                 if ($var == 'inherits') {
                     return false;
                 } else {
                     if ($var == 'visible') {
                         if (isset($this->row->visible)) {
                             return $this->row->visible;
                         } else {
                             return true;
                         }
                     } else {
                         if ($var == 'inheritClasses') {
                             if (!isset($this->_inheritClasses)) {
                                 $this->_uniqueParentDatas = array();
                                 $this->_inheritClasses = array();
                                 if ($this->inherits) {
                                     $page = $this;
                                     while ($page = $page->parent) {
                                         foreach (Kwc_Abstract::getSetting($page->componentClass, 'generators') as $gKey => $g) {
                                             if (isset($g['inherit']) && $g['inherit']) {
                                                 if (!in_array($page->componentClass, $this->_inheritClasses)) {
                                                     $this->_inheritClasses[] = $page->componentClass;
                                                 }
                                                 if (isset($g['unique']) && $g['unique']) {
                                                     $this->_uniqueParentDatas[$page->componentClass . $gKey] = $page;
                                                 }
                                             }
                                         }
                                         if ($page->inherits) {
                                             //wenn page selbst erbt einfach von da übernehmen (rekursiver aufruf)
                                             $this->_inheritClasses = array_merge($this->_inheritClasses, $page->inheritClasses);
                                             $this->_uniqueParentDatas = array_merge($this->_uniqueParentDatas, $page->_uniqueParentDatas);
                                             break;
                                             //aufhören, rest kommt durch rekursion daher
                                         }
                                     }
                                 }
                             }
                             return $this->_inheritClasses;
                         } else {
                             if ($var == '_uniqueParentDatas') {
                                 $this->inheritClasses;
                                 //populates _uniqueParentDatas as side effect
                                 return $this->_uniqueParentDatas;
                             } else {
                                 if ($var == 'parent' && isset($this->_lazyParent)) {
                                     $ret = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_lazyParent, array('ignoreVisible' => true));
                                     $this->parent = $ret;
                                     unset($this->_lazyParent);
                                     return $ret;
                                 } else {
                                     if ($var == 'generator' && isset($this->_lazyGenerator)) {
                                         $ret = Kwf_Component_Generator_Abstract::getInstance($this->_lazyGenerator[0], $this->_lazyGenerator[1]);
                                         $this->generator = $ret;
                                         unset($this->_lazyGenerator);
                                         return $ret;
                                     } else {
                                         if ($var == 'row' && isset($this->_lazyRow)) {
                                             $ret = $this->generator->getRowByLazyRow($this->_lazyRow, $this);
                                             $this->row = $ret;
                                             unset($this->_lazyRow);
                                             return $ret;
                                         } else {
                                             if ($var == 'chained' && isset($this->_lazyChained)) {
                                                 $ret = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_lazyChained, array('ignoreVisible' => true));
                                                 $this->chained = $ret;
                                                 unset($this->_lazyChained);
                                                 return $ret;
                                             } else {
                                                 throw new Kwf_Exception("Variable '{$var}' is not set for " . get_class($this) . " with componentId '{$this->componentId}'");
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }