/** * 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; }
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 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 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 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 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'); } } }
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; }
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}'"); } } } } } } } } } } } }
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; }