/** * pretizeno o mazani front cache */ public function clearCache() { try { LBoxCacheManagerFront::getInstance()->cleanByRecordType($this->getClassVar("itemType")); return parent::clearCache(); } catch (Exception $e) { throw $e; } }
/** * spousti zobrazeni pozadovane stranky * @throws LBoxException */ public static function run() { try { // starting timer LBoxTimer::getInstance(); // init acces AccesRecord::getInstance(); if (self::getPageCfg()->cache_off) { LBoxCacheManagerFront::getInstance()->switchListeningOff(); } self::executeInit(); // caching //var_dump(LBoxCacheManagerFront::getInstance()->wasFormSentNow());die; //if (self::getPage()->showConnivance()) { //LBoxFirePHP::table($_SERVER, "_SERVER"); if (LBoxCacheManagerFront::getInstance()->isCacheON()) { if (!LBoxXTProject::isLoggedSuperAdmin() && !LBoxXTDBFree::isLogged() && !LBoxCacheManagerFront::getInstance()->wasFormSentNow()) { if (count(self::getDataPost()) < 1) { if (LBoxCacheManagerFront::getInstance()->doesCacheExists()) { // send last modification header LBoxFirePHP::warn("cache loaded in " . LBoxTimer::getInstance()->getTimeOfLife() . "s"); header("Last-Modified: " . gmdate("D, d M Y H:i:s", LBoxCacheManagerFront::getInstance()->getLastCacheModificationTime()) . " GMT"); echo LBoxCacheManagerFront::getInstance()->getData(); LBoxCacheManagerFront::getInstance()->__destruct(); return; } } } $content = self::getRequestContent(); echo $content; if (!LBoxXTProject::isLoggedSuperAdmin() && !LBoxXTDBFree::isLogged() && !LBoxCacheManagerFront::getInstance()->wasFormSentNow()) { if (count(self::getDataPost()) < 1) { // vystup z nenalezenych URL neukladame - mohlo by umoznit snadno zahltit cache! if (self::getPageCfg()->id != LBoxConfigSystem::getInstance()->getParamByPath("pages/page404")) { //kontrola jestli vystup neni jen vypis exception if (strlen(strip_tags($content)) > 0) { LBoxCacheManagerFront::getInstance()->saveData($content); LBoxFirePHP::warn("cache stored in " . LBoxTimer::getInstance()->getTimeOfLife() . "s"); } else { LBoxFirePHP::error("cache NOT stored because output suppose to contain only exception message!"); } } } } LBoxCacheManagerFront::getInstance()->__destruct(); } else { LBoxFirePHP::warn("cache VYPNUTA"); echo self::getRequestContent(); } /*} else { echo self::getRequestContent(); }*/ } catch (Exception $e) { throw $e; } }
/** * pretizeno o mazani front cache */ public function clearCache() { try { $recordClass = $this->getClassVar("itemType"); $forceCleanForAllXTUsers = eval("return {$recordClass}::\$frontCacheForceCleanForAllXTUsers;"); LBoxCacheManagerFront::getInstance()->cleanByRecordType($recordClass, $forceCleanForAllXTUsers); return parent::clearCache(); } catch (Exception $e) { throw $e; } }
<?php DEFINE("XT_GROUP", 1); require "../../../../lBox/lib/loader.php"; session_start(); LBoxCacheManagerFront::getInstance()->switchListeningOff(); // check xt session if (!LBoxXTDBFree::isLogged(XT_GROUP) && !LBoxXTProject::isLoggedAdmin(XT_GROUP)) { header("HTTP/1.1 404 Not Found"); die; } $post = LBoxFront::getDataPost(); $postFormData = current($post); // firePHP debug //LBoxFirePHP::table($post, 'POST data debug'); try { ////////////////////////////////////////////////////////////////////// // saving data ////////////////////////////////////////////////////////////////////// foreach ($post as $formID => $data) { $typeRecord = $data["type"]; $idColname = eval("return {$typeRecord}::\$idColName;"); $flagEdit = strlen($postFormData[$idColname]) > 0; $record = strlen($postFormData[$idColname]) < 1 ? new $typeRecord() : new $typeRecord($postFormData[$idColname]); $form = LBoxMetaRecordsManager::getMetaRecord($record)->getForm(); $form->setDoNotReload(true); $form->toString($forceThrow = true); $ret = new stdclass(); // PHP base class // check controls validations errors $exceptions = array();
/** * * @param string name * @param string method * @throws LBoxExceptionForm */ public function __construct($name = "", $method = "post", $label = "", $labelSubmit = "") { try { if (strlen($name) < 1) { throw new LBoxExceptionForm("\$name: " . LBoxExceptionForm::MSG_PARAM_STRING_NOTNULL, LBoxExceptionForm::CODE_BAD_PARAM); } if (strlen($method) < 1) { throw new LBoxExceptionForm("\$method: " . LBoxExceptionForm::MSG_PARAM_STRING_NOTNULL, LBoxExceptionForm::CODE_BAD_PARAM); } $this->name = $name; $this->method = strtolower($method); $this->label = strlen($label) > 0 ? $label : $name; $this->labelSubmit = strlen($labelSubmit) > 0 ? $labelSubmit : ""; if (array_key_exists($name, self::$forms)) { throw new LBoxExceptionForm("{$name}: " . LBoxExceptionForm::MSG_FORM_DUPLICATE_FORMNAME, LBoxExceptionForm::CODE_FORM_DUPLICATE_FORMNAME); } self::$forms[$name] = $this; if (array_key_exists("LBox", (array) $_SESSION)) { if ($_SESSION["LBox"]["Forms"][$this->getName()]["succes"]) { unset($_SESSION["LBox"]["Forms"][$this->getName()]["succes"]); $this->sentSucces = true; } } // pridame form do indexace front cache manageru k aktualni URL LBoxCacheManagerFront::getInstance()->addFormUsed($this); } catch (Exception $e) { throw $e; } }
/** * zaindexuje sam sebe ve front cachi jako pouzity na aktualni strance */ protected function addUsageToCache() { try { LBoxCacheManagerFront::getInstance()->addComponentUsed($this); } catch (Exception $e) { throw $e; } }
public function process() { try { $parent = NULL; if (strlen($this->fileNamesTemplatePagesTypesPattern) < 1) { throw new LBoxExceptionFormProcessor(LBoxExceptionFormProcessor::MSG_INSTANCE_VAR_STRING_NOTNULL, LBoxExceptionFormProcessor::CODE_BAD_INSTANCE_VAR); } if (strlen($this->form->getControlByName("id")->getValue()) > 0) { $configItem = LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("id")->getValue()); // smazat cache pro existujici stranku na jeji puvodni URL jeste pred moznou zmenou! LBoxCacheManagerFront::getInstance()->cleanAllURLs(true); if ($parentID = $this->form->getControlByName("parent_id")->getValue()) { $parent = LBoxConfigManagerStructure::getInstance()->getPageById($parentID); } } else { try { if (LBoxConfigManagerStructure::getInstance()->getPageByUrl($this->form->getControlByName("url")->getValue())) { throw new LBoxExceptionConfigStructure("URL: " . LBoxExceptionConfigStructure::MSG_ATTRIBUTE_UNIQUE_NOT_UNIQUE, LBoxExceptionConfigStructure::CODE_ATTRIBUTE_UNIQUE_NOT_UNIQUE); } } catch (Exception $e) { switch ($e->getCode()) { case LBoxExceptionConfigStructure::CODE_NODE_BYURL_NOT_FOUND: NULL; break; default: throw $e; } } if ($parentID = $this->form->getControlByName("parent_id")->getValue()) { $parent = LBoxConfigManagerStructure::getInstance()->getPageById($parentID); // zaridi parental vztah jen pri vytvareni (nutno kvuli odvozeni ID) - pro editaci je dodatecne prirazeni nize $configItem = LBoxConfigStructure::getInstance()->getCreateChild($parent, $this->form->getControlByName("url")->getValue()); } else { $configItem = LBoxConfigStructure::getInstance()->getCreateItem($this->form->getControlByName("url")->getValue()); } } foreach ($this->form->getControls() as $control) { if ($control instanceof LBoxFormControlMultiple) { continue; } $name = $control->getName(); switch ($name) { case "id": case "parent_id": case "move_before": NULL; break; case "type": $configItem->template = str_replace("(.+)", $control->getValue(), $this->fileNamesTemplatePagesTypesPattern); $configItem->template = preg_replace("/[^\\w_\\-\\.]/", "", $configItem->template); break; case "url": if ($parent) { $configItem->{$name} = "/" . $parent->url . "/" . $control->getValue() . "/"; $configItem->{$name} = preg_replace("/(\\/+)/", "/", $configItem->{$name}); } else { $configItem->{$name} = "/" . $control->getValue() . "/"; $configItem->{$name} = preg_replace("/(\\/+)/", "/", $configItem->{$name}); } break; default: $configItem->{$name} = $control->getValue(); } } // move before a parent_id // - je treba dodatecne zajistit parental vztah, pri editaci horni logika to zajistuje pouze pri vytvareni, ale ne pri editaci switch (true) { // editace + parent puvodne nemel tohoto potomka case $this->form->getControlByName("id")->getValue() && $this->form->getControlByName("parent_id")->getValue() > 0 && !LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("parent_id")->getValue())->isParentOf($configItem): LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("parent_id")->getValue())->appendChild($configItem); break; // parent neni nastaven, jde o editaci a predtim nastaven byl // parent neni nastaven, jde o editaci a predtim nastaven byl case !$this->form->getControlByName("parent_id")->getValue() && $configItem->hasParent(): // uprednostnit removeFromTree() $configItem->removeFromTree(); break; // editace + move before je nastaveno na jiny node nez bylo // editace + move before je nastaveno na jiny node nez bylo case $this->form->getControlByName("move_before")->getValue() && $this->form->getControlByName("id")->getValue() && (!$configItem->hasSiblingBefore() || $configItem->getSiblingBefore()->id != $this->form->getControlByName("move_before")->getValue()): // vlozeni + moveBefore je nastaveno // vlozeni + moveBefore je nastaveno case $this->form->getControlByName("move_before")->getValue() && $this->form->getControlByName("id")->getValue(): // uprednostnit insertBefore() LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("move_before")->getValue())->insertBefore($configItem); break; // parent je nastaven // parent je nastaven case $this->form->getControlByName("parent_id")->getValue(): // uprednostnit appendChild() LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("parent_id")->getValue())->appendChild($configItem); break; default: $configItem->removeFromTree(); } LBoxConfigStructure::getInstance()->store(); // pro jistotu smazani front cache stranky na jeji potencialne zmenene URL (mohly by tam byt data z minulosti) LBoxCacheManagerFront::getInstance()->cleanAllURLs(true); //reload na nove ulozenou stranky LBoxFront::reload(LBoxConfigManagerStructure::getInstance()->getPageById($configItem->id)->url); } catch (Exception $e) { throw $e; } }
/** * pretizeno o mazani front cache */ public function resetCache() { try { // relevant cache je treba mazat bez ohledu na isCacheON() (viz parent::resetCache()), protoze se tim maze i relevantni front cache $this->resetRelevantCache(); LBoxCacheManagerFront::getInstance()->cleanByRecordType(get_class($this), $this->getClassVar("frontCacheForceCleanForAllXTUsers")); return parent::resetCache(); } catch (Exception $e) { throw $e; } }
/** * stores the data */ public function store() { try { //content // drop previous content cache if ($this->contentChanged) { /*$nodeType = $this->caller instanceOf LBoxPage ? "page" : "component"; LBoxFirePHP::log(basename(__FILE__) ."::". __LINE__.': ' . 'storing the data of metanode: '. $nodeType .'-'. $this->caller->id .'-'. $this->seq);*/ unset($this->fileH); @unlink($this->getFilePath()); if (strlen($this->content) > 0) { //LBoxFirePHP::log(basename(__FILE__) ."::". __LINE__.': ' . "saving the content data ". $this->content ." into file ". $this->getFilePath()); if (!fwrite($this->getFileH(), $this->content)) { throw new LBoxExceptionMetanodes(LBoxExceptionMetanodes::MSG_DATA_CANNOT_WRITE, LBoxExceptionMetanodes::CODE_DATA_CANNOT_WRITE); } //LBoxFirePHP::log(basename(__FILE__) ."::". __LINE__.': ' . "saving content done"); } } //styles if ($this->stylesChanged) { //LBoxFirePHP::log(basename(__FILE__) ."::". __LINE__.': ' . "deleting styles file ". $this->getFileStylesPath()); fclose($this->getFileStylesH()); unlink($this->getFileStylesPath()); if (count($this->styles) > 0) { //LBoxFirePHP::table($this->styles, basename(__FILE__) ."::". __LINE__.': ' . "saving the styles data into file ". $this->getFileStylesPath()); if (!fwrite($this->getFileStylesH(), serialize($this->styles))) { throw new LBoxExceptionMetanodes(LBoxExceptionMetanodes::MSG_DATA_CANNOT_WRITE, LBoxExceptionMetanodes::CODE_DATA_CANNOT_WRITE); } //LBoxFirePHP::log(basename(__FILE__) ."::". __LINE__.': ' . "saving styles done"); } } // smazat front cache switch (true) { case $this->caller instanceof LBoxPage: // pro stranku mazeme veskere cache URLs teto stranky LBoxCacheManagerFront::getInstance()->cleanByPageID($this->caller->config->id, true); break; default: // pro komponentu se smazou veskere URLs cache, kde byla komponenta pouzite LBoxCacheManagerFront::getInstance()->cleanByComponent($this->caller->config->id, true); } } catch (Exception $e) { throw $e; } }