/** * vraci form pro forward na editaci clanku * @return LBoxForm * @throws LBoxException */ protected function getFormXTToEdit() { try { if (!constant('CLI')) { if (!LBoxXTProject::isLoggedAdmin()) { return ""; } } if ($this->formToEdit instanceof LBoxForm) { return $this->formToEdit; } if (strlen($this->propertyNameRefPageEdit) < 1) { throw new LBoxExceptionOutputFilter(get_class($this) . "::\$propertyNameRefPageEdit: " . LBoxExceptionOutputFilter::MSG_INSTANCE_VAR_STRING_NOTNULL, LBoxExceptionOutputFilter::CODE_BAD_INSTANCE_VAR); } $instanceType = get_class($this->instance); $idColName = eval("return {$instanceType}::\$idColName;"); $id = $this->instance->getParamDirect(strlen($this->editURLFilterColname) > 0 ? $this->editURLFilterColname : $idColName); $controlID = new LBoxFormControlFillHidden("id", "", $id); $controlRefPageEdit = new LBoxFormControlFillHidden("rpe", "", LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::getPropertyContentByName($this->propertyNameRefPageEdit))->id); $controlPropertyNamePatternURLParam = new LBoxFormControlFillHidden("pnpup", "", $this->propertyNamePatternURLParam); $form = new LBoxForm("record_xt_to_edit_{$id}", "post", "", "editovat"); $form->setTemplateFileName("lbox_form_xt_btn_edit.html"); $form->addControl($controlID); $form->addControl($controlRefPageEdit); $form->addControl($controlPropertyNamePatternURLParam); $form->addProcessor(new ProcessorRecordToEdit()); return $this->formToEdit = $form; } catch (Exception $e) { throw $e; } }
public function prepare($name = "", $value = NULL) { try { switch ($name) { case "url": $pageItem = LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::gpcn($this->configVarNameArticleRefPage)); return LBoxUtil::getURLWithParams(array($this->instance->getParamDirect("url")), $pageItem->url); break; case "url_param": return $this->instance->getParamDirect("url"); break; case "urlAbsolute": return LBOX_REQUEST_URL_SCHEME . "://" . LBOX_REQUEST_URL_HOST . $this->prepare("url"); break; case "headingEntities": return htmlentities($this->prepare("heading")); break; case "publishedDate": return date("j.n. Y", $this->instance->time_published); break; case "published2": return date("j.n.Y | H:i:s", $this->instance->time_published); break; case "perex_raw": return strip_tags($this->instance->perex); break; default: return parent::prepare($name, $value); } } catch (Exception $e) { throw $e; } }
protected function executePrepend(PHPTAL $TAL) { //DbControl::$debug = true; try { // XT admin if (LBoxXT::isLoggedAdmin() && count($_POST[$this->getFormGroupName()]["xt"]) > 0) { switch ($_POST[$this->getFormGroupName()]["xt"]["action"]) { case "edit": $pageEditArticlesId = LBoxConfigManagerProperties::getInstance()->getPropertyByName("ref_page_xt_admin_articles")->getContent(); $pageEditArticles = LBoxConfigManagerStructure::getPageById($pageEditArticlesId); $this->reload($pageEditArticles->url . ":" . $_POST[$this->getFormGroupName()]["xt"]["id"]); break; case "delete": $this->deleteArticle($_POST[$this->getFormGroupName()]["xt"]["id"]); $this->reload(); break; } } $TAL->xtAdmin = LBoxXT::isLoggedAdmin(); $pageMoreId = LBoxConfigManagerProperties::getInstance()->getPropertyByName("ref_page_articles_news")->getContent(); $pageMore = LBoxConfigManagerStructure::getPageById($pageMoreId); $limit = $this->getListPaging(); $news = new ArticlesNewsRecords(false, array("time_published" => 0), array(1, $limit)); $news->setOutputFilterItemsClass("OutputFilterArticleNews"); $TAL->news = $news->count() > 0 ? $news : false; $TAL->urlMore = $pageMore->url; } catch (Exception $e) { throw $e; } }
public function prepare($name = "", $value = NULL) { if (!$this->record instanceof AbstractRecord) { throw new LBoxExceptionOutputFilter(LBoxExceptionOutputFilter::MSG_INSTANCE_VAR_INSTANCE_CONCRETE_NOTNULL, LBoxExceptionOutputFilter::CODE_BAD_INSTANCE_VAR); } switch ($name) { case "rssURL": if ($this->instance->rss) { $rssPageUrl = LBoxConfigManagerStructure::getInstance()->getPageById($this->instance->rss)->url; $pageId = $this->instance->page->id; return "{$rssPageUrl}:{$pageId}/" . LBoxFront::getLocationUrlParam(); } break; case "getForm": $parentId = NULL; foreach (LBoxFront::getUrlParamsArray() as $param) { if (preg_match("/" . $this->patternURLParamReplyTo . "/", $param, $matches)) { $parentId = $matches[1]; } } if ($parentId) { $record = new DiscussionsRecord($parentId); if (!$record->isInDatabase()) { LBoxFront::reload(LBoxUtil::getURLWithoutParamsByPattern(array("/" . $this->patternURLParamReplyTo . "/"))); } $record->setOutputFilter(new OutputFilterDiscussionRecord($record)); return $record->getForm(); } else { return $this->record->getForm(); } break; default: return $value; } }
public function prepare($name = "", $value = NULL) { try { switch ($name) { case "id": return $this->instance->getParamDirect("url"); break; case "heading": return $this->instance->getParamDirect("name"); break; case "createdRSS": return gmdate("D, d M Y H:i:s", strtotime($this->instance->created)) . " GMT"; break; case "url": $refPageAttName = $this->configVarNamePhotogalleryRefPage; // najdeme stranku zobrazovani fotogalerie podle reference $idPageItem = LBoxConfigManagerProperties::getInstance()->getPropertyByName($refPageAttName)->getContent(); $pageItem = LBoxConfigManagerStructure::getInstance()->getPageById($idPageItem); $urlBase = $this->instance->getParamDirect("url"); return $pageItem->url . ":{$urlBase}"; break; case "published_human_cs": return date("j.n.Y", $this->instance->__get("time_published")); break; default: return parent::prepare($name, $value); } } catch (Exception $e) { throw $e; } }
/** * destroys singleton instance from cache */ public static function resetInstance() { try { self::$instance = NULL; } catch (Exception $e) { throw $e; } }
/** * vraci URL stranky/clanku/galerie, atd.. ke ktere je diskuze pripojena * @return string */ protected function getDiscussionPageUrl() { try { $pageUrl = LBoxConfigManagerStructure::getInstance()->getPageById($this->instance->pageId)->url; $paramUrl = $this->instance->urlParam; return $pageUrl . (strlen($paramUrl) > 0 ? ":{$paramUrl}" : ""); } catch (Exception $e) { throw $e; } }
protected function executePrepend(PHPTAL $TAL) { try { $pagesIterator = LBoxConfigManagerStructure::getInstance()->getIterator(); $pagesIterator->setOutputFilterItemsClass("OutputFilterPage"); $TAL->pages = $pagesIterator; } catch (Exception $e) { throw $e; } }
/** * pridava default vlastnosti sablonam * @param PHPTAL $TAL * @throws Exception */ protected function executePrepend(PHPTAL $TAL) { try { $pagesIterator = LBoxConfigManagerStructure::getInstance()->getIterator(); $pagesIterator->setOutputFilterItemsClass("OutputFilterPage"); $TAL->structureIterator = $pagesIterator; $TAL->host = LBOX_REQUEST_URL_SCHEME . "://" . LBOX_REQUEST_URL_HOST; } catch (Exception $e) { throw $e; } }
/** * reloadne hlavni stranku adminu */ protected function reloadAdminHome() { try { if (strlen($adminHomePageID = LBoxConfigManagerProperties::getPropertyContentByName("ref_page_xt_admin")) < 1) { throw new LBoxExceptionPage("Property ref_page_xt_admin not set!"); } LBoxFront::reload(LBoxConfigManagerStructure::getPageById($adminHomePageID)->url); } catch (Exception $e) { throw $e; } }
public function prepare($name = "", $value = NULL) { switch ($name) { case "rssURL": $rssPageId = LBoxConfigManagerProperties::getInstance()->getPropertyByName($this->propertyNameRefRSSPage)->getContent(); $rssPageUrl = LBoxConfigManagerStructure::getInstance()->getPageById($rssPageId)->url; return $rssPageUrl; break; default: return parent::prepare($name, $value); } }
public function process() { try { $url = LBoxConfigManagerStructure::getInstance()->getPageById($this->form->getControlByName("rpe")->getValue())->url; if (strlen($this->form->getControlByName("pnpup")->getValue()) > 0) { $url .= ":" . str_replace("<url_param>", $this->form->getControlByName("id")->getValue(), LBoxConfigManagerProperties::gpcn($this->form->getControlByName("pnpup")->getValue())); } else { $url .= ":" . $this->form->getControlByName("id")->getValue(); } LBoxFront::reload($url); } catch (Exception $e) { throw $e; } }
public function process() { try { $data = array(); $data["from"] = LBoxConfigManagerProperties::getPropertyContentByName("registration_confirm_mail_from"); $data["to"] = $this->form->getControlByName("email")->getValue(); $data["subject"] = "Potvrzeni registrace"; $data["page_confirm"] = LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::getPropertyContentByName("ref_page_registration_confirm")); $data["processor_save"] = $this->processorSaveProfile; $mail = new MailProductsRegistrationConfirm($data); $mail->init(); } catch (Exception $e) { throw $e; } }
protected function executePrepend(PHPTAL $TAL) { try { // DbControl::$debug = true; $itemsLimit = LBoxConfigManagerProperties::getInstance()->getPropertyByName("box_last_news_limit")->getContent(); $order["time_published"] = 0; $limit = array(0, $itemsLimit); $news = new ArticlesNewsRecords(false, $order, $limit); $news4Count = new ArticlesNewsRecords(); $news->setOutputFilterItemsClass("OutputFilterArticleNews"); $TAL->iteratorNews = $news; $TAL->pageMoreCfg = LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::getInstance()->getPropertyByName("ref_page_articles_news")->getContent()); $TAL->atLeastOne = $news->count() > 0; $TAL->hasMore = $news4Count->count() > $news->count(); } catch (Exception $e) { throw $e; } }
public function prepare($name = "", $value = NULL) { try { switch ($name) { case "url": $pageDetailID = LBoxConfigManagerProperties::getInstance()->getPropertyByName("ref_page_party")->getContent(); $pageDetail = LBoxConfigManagerStructure::getInstance()->getPageById($pageDetailID); return $pageDetail->url . ":" . $this->instance->getParamDirect("url"); break; case "datetimeRSS": return gmdate("D, d M Y H:i:s", strtotime($this->instance->datetime)) . " GMT"; break; default: return $value; } } catch (Exception $e) { throw $e; } }
public function prepare($name = "", $value = NULL) { try { $classNameInstance = get_class($this->instance); $editURLFilterColname = strlen($this->editURLFilterColname) > 0 ? $this->editURLFilterColname : eval("return {$classNameInstance}::\$idColName;"); switch ($name) { case "url_detail": if (strlen($this->propertyNameRefPageDetail) < 1) { return $this->instance->getParamDirect($this->editURLFilterColname); } return LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::getPropertyContentByName($this->propertyNameRefPageDetail))->url . ":" . $this->instance->getParamDirect($this->editURLFilterColname); break; default: return $value; } } catch (Exception $e) { throw $e; } }
/** * @param string $value * @return LBoxConfigItemStructure */ protected function getExistingRelevantRecord($value = "") { try { if (strlen($value) < 1) { throw new LBoxExceptionFormValidator(LBoxExceptionFormValidator::MSG_PARAM_STRING_NOTNULL, LBoxExceptionFormValidator::CODE_BAD_PARAM); } if (!$this->controlParentID instanceof LBoxFormControl) { throw new LBoxExceptionFormValidator(LBoxExceptionFormValidator::MSG_INSTANCE_VAR_INSTANCE_CONCRETE_NOTNULL, LBoxExceptionFormValidator::CODE_BAD_INSTANCE_VAR); } try { if ($parentID = $this->controlParentID->getValue()) { $parent = LBoxConfigManagerStructure::getInstance()->getPageById($parentID); $urlParts = explode("/", $value); foreach ($urlParts as $part) { if (strlen(trim($part)) > 0) { $out = $part; } } $urlPart = LBoxUtil::getURLByNameString($out); $value = $parent->url . "/" . $urlPart . "/"; } else { $value = "/{$value}/"; } $value = preg_replace("/(\\/+)/", "/", $value); if ($page = LBoxConfigManagerStructure::getInstance()->getPageByUrl($value)) { return $page; } } catch (Exception $e) { switch ($e->getCode()) { case LBoxExceptionConfigStructure::CODE_NODE_BYURL_NOT_FOUND: NULL; break; default: throw $e; } } } catch (Exception $e) { throw $e; } }
/** * getter na record * @return DiscussionsRecord */ public function getRecord() { try { if ($this->record instanceof DiscussionsRecord) { return $this->record; } $pageID = LBoxConfigManagerStructure::getInstance()->getPageByUrl(LBOX_REQUEST_URL_VIRTUAL)->id; $locationURL = $this->getLocationUrlParam(); $discussions = new DiscussionsRecords(array("pageId" => $pageID), array("lft" => 1), array(0, 1)); if ($discussions->count() < 1) { // pokud diskuze nebyla nalezena, vytvorime ji a vratime $discussion = new DiscussionsRecord(); $discussion->pageId = $pageID; $discussion->urlParam = $locationURL; $discussion->store(); } else { $discussion = $discussions->current(); } $discussion->setOutputFilter(new OutputFilterDiscussionRecord($discussion)); return $this->record = $discussion; } catch (Exception $e) { throw $e; } }
/** * getter na motanodes podle predanych dat * @param array $data * @return LBoxMetanode */ function getMetanodeByPostData($data = array()) { try { if (count($data) < 1) { throw new LBoxException(LBoxException::MSG_PARAM_ARRAY_NOTNULL, LBoxException::CODE_BAD_PARAM); } // page metanode if ($data["caller_type"] == "page") { $callerConfig = LBoxConfigManagerStructure::getInstance()->getPageById($data["caller_id"]); $callerClassName = strlen($callerConfig->class) > 0 ? $callerConfig->class : "PageDefault"; $caller = new $callerClassName($callerConfig); } else { $callerConfig = LBoxConfigManagerComponents::getInstance()->getComponentById($data["caller_id"]); $caller = new LBoxComponentMetanodeCaller($callerConfig); } $node = LBoxMetanodeManager::getNode($data["type"], (int) $data["seq"], $caller, $data["lng"]); return $node; } catch (Exception $e) { throw $e; } }
/** * Vraci zobrazovaci URL downloadu * @return string * @throws Exception */ protected function getURLDisplay() { try { $pageDownloadsID = LBoxConfigManagerProperties::getInstance()->getPropertyByName("ref_page_downloads")->getContent(); $pageDownloads = LBoxConfigManagerStructure::getInstance()->getPageById($pageDownloadsID); $downloadType = $this->instance->getDownloadType(); $downloadsPaging = LBoxConfigManagerProperties::getInstance()->getPropertyByName("downloads_paging")->getContent(); // zjistime si na kolikate strance strankovani tento download je $myCreated = $this->instance->created; $whereAdd = "created > '{$myCreated}'"; $recordsNew = new DownloadsRecords(false, false, false, $whereAdd); $out = $pageDownloads->url; $page = ceil($recordsNew->count() / $downloadsPaging); if ($page > 1) { $out .= ":" . LBoxUtil::getPagingURLString($page); } return "{$out}#download-" . $this->instance->id; } catch (Exception $e) { throw $e; } }
/** * pretizeno o nastaveni povinnych hodnot * @param string $url * @param string $id * @return LBoxConfigItem */ public function getCreateItem($url = "", $id = "") { try { if (strlen($url) < 1) { throw new LBoxExceptionConfig(LBoxExceptionConfig::MSG_PARAM_STRING_NOTNULL, LBoxExceptionConfig::CODE_BAD_PARAM); } if (strlen($id) < 1) { $ids = array_keys($this->cacheNodes); arsort($ids); $id = current($ids) + 1; } try { if (LBoxConfigManagerStructure::getInstance()->getPageById($id)) { throw new LBoxExceptionConfigStructure("Page with this id already exists!", LBoxExceptionConfigStructure::CODE_ATTRIBUTE_UNIQUE_NOT_UNIQUE); } } catch (Exception $e) { switch ($e->getCode()) { case LBoxExceptionConfig::CODE_NODE_BYID_NOT_FOUND: case LBoxExceptionConfigStructure::CODE_NODE_BYURL_NOT_FOUND: break; default: throw $e; } } try { if (LBoxConfigManagerStructure::getInstance()->getPageByUrl($url)) { throw new LBoxExceptionConfigStructure("Page with this url already exists!", LBoxExceptionConfigStructure::CODE_ATTRIBUTE_UNIQUE_NOT_UNIQUE); } } catch (Exception $e) { switch ($e->getCode()) { case LBoxExceptionConfig::CODE_NODE_BYID_NOT_FOUND: case LBoxExceptionConfigStructure::CODE_NODE_BYURL_NOT_FOUND: break; default: throw $e; } } $instance = parent::getCreateItem(); $instance->id = $id; $instance->url = $url; return $instance; } catch (Exception $e) { throw $e; } }
/** * vrati instanci configu stranky podle URL * @param string $url * @return LBoxConfigItemStructure */ protected function getPageCFGByURL($url = "") { try { if (strlen($url) < 1) { $url = substr(LBOX_REQUEST_URL, -1) == "/" ? LBOX_REQUEST_URL : LBOX_REQUEST_URL . "/"; $url = str_replace("?/", "/", $url); $url = str_replace("//", "/", $url); } // vycistime URL od parametru a hostu $url = preg_replace("/" . LBOX_REQUEST_URL_SCHEME . ":(\\/+)/", "", $url); $url = substr($url, strpos($url, "/")); $url = preg_replace("/(\\?|\\:)(.+)/", "", $url); $displayLanguage = LBoxFront::getDisplayLanguage(); foreach (LBoxConfigManagerLangdomains::getInstance()->getLangsDomains() as $lang => $domain) { try { LBoxFront::setDisplayLanguage($lang); $configItemStructure = LBoxConfigManagerStructure::getInstance()->getPageByUrl($url); if ($configItemStructure instanceof LBoxConfigItemStructure) { break; } } catch (Exception $e) { $exception = $e; } } LBoxFront::setDisplayLanguage($displayLanguage); return $configItemStructure; } catch (Exception $e) { throw $e; } }
/** * getter na stranku s editaci * @return LBoxPage */ public function getPageEdit() { try { if ($this->pageEdit instanceof LBoxPage) { return $this->pageEdit; } if (strlen($this->propertyNameRefPageEdit) < 1) { return NULL; } $this->pageEdit = LBoxConfigManagerStructure::getInstance()->getPageById(LBoxConfigManagerProperties::getPropertyContentByName($this->propertyNameRefPageEdit)); $this->pageEdit->setOutputFilter(new OutputFilterPage($this->pageEdit)); return $this->pageEdit; } catch (Exception $e) { throw $e; } }
public function prepare($name = "", $value = NULL) { switch ($name) { case "title": $value = strlen($value) > 0 ? $value : $this->prepare("heading", $this->instance->getParamDirect("heading")); $webTitle = LBoxConfigManagerProperties::getInstance()->getPropertyByName($this->configParamNameWebTitle)->getContent(); $homePageTitlePattern = LBoxConfigManagerProperties::getInstance()->getPropertyByName($this->configParamNameHomepageTitle)->getContent(); $pageTitlePattern = LBoxConfigManagerProperties::getInstance()->getPropertyByName($this->configParamNamePageTitle)->getContent(); $pageTitle = $this->instance->isHomePage() ? $homePageTitlePattern : $pageTitlePattern; $pageTitle = str_replace("\$properties_web_title", $webTitle, $pageTitle); $pageTitle = str_replace("\$page_title", $value, $pageTitle); $pageTitle = str_replace("\$article_heading", $this->articleHeading, $pageTitle); $pageTitle = trim($pageTitle); // v pripade ze mame nakonci samotny oddelovac, odrizneme ho ze stringu if (substr($pageTitle, -1) == "|") { $pageTitle = trim(substr($pageTitle, 0, strlen($pageTitle) - 1)); } return $pageTitle; break; case "titleMenu": case "title_menu": return strlen($this->instance->getParamDirect("title")) > 0 ? $this->instance->getParamDirect("title") : (strlen($this->instance->name_menu) > 0 ? $this->instance->name_menu : $this->prepare("heading", $this->instance->getParamDirect("heading"))); break; case "nameMenu": case "name_menu": case "headingMenu": return strlen($value) > 0 ? $value : $this->instance->heading; break; case "nameBreadcrumb": case "headingBreadcrumb": return strlen($value) > 0 ? $value : $this->instance->name_menu; break; case "titleWeb": return LBoxConfigManagerProperties::getInstance()->getPropertyByName($this->configParamNameWebTitle)->getContent(); break; case "description": case "keywords": return (string) $value; break; case "isCurrent": return $this->instance->url == LBoxFront::getPage()->url; break; case "isCurrentBranch": if ($this->instance->url == LBoxFront::getPage()->url) { return true; } $parent = LBoxFront::getPage()->config; while ($parent = $parent->getParent()) { if ($parent->url == $this->instance->url) { return true; } } return false; break; case "heading": return (string) $value; break; case "name": return $this->instance->heading; break; case "name_menu": if (strlen($value) < 1) { $value = $this->instance->name; } return $value; break; case "getChildren": return $this->instance->getChildNodesIterator(); break; case "rssPage": if (strlen($this->instance->rss) < 1) { return NULL; } else { return LBoxConfigManagerStructure::getPageById($this->instance->rss); } break; case "in_menu": return $this->instance->is_accesible ? $value : false; break; case "bodyclass": return LBoxFront::getDisplayLanguage(); break; case "is_accesible": if ($this->instance->superxt == 1) { if (!LBoxXTProject::isLoggedSuperAdmin()) { return false; } } if ($this->instance->xt == 1) { if (!LBoxXTProject::isLoggedAdmin()) { return false; } } return true; break; case "getClass": return $this->getClassMenu(); break; case "getClassBreadcrumb": return $this->getClassBreadcrumb(); break; default: return $value; } }
public function testInsertBefore() { $this->assertType("LBoxConfigItemStructure", $newItem = LBoxConfigStructure::getInstance()->getCreateItem("/unittest-new-item-30/")); LBoxConfigStructure::getInstance()->store(); $this->assertType("LBoxConfigItemStructure", $newItem2 = LBoxConfigStructure::getInstance()->getCreateItem("/unittest-new-item-3001/")); LBoxConfigStructure::getInstance()->store(); $this->assertType("LBoxConfigItemStructure", $newItem3 = LBoxConfigStructure::getInstance()->getCreateItem("/unittest-new-item-3002/")); $newItem = LBoxConfigManagerStructure::getInstance()->getPageByUrl("/unittest-new-item-30/"); $newItem2 = LBoxConfigManagerStructure::getInstance()->getPageByUrl("/unittest-new-item-3001/"); $this->assertNull($newItem->appendChild($newItem2)); LBoxConfigStructure::getInstance()->store(); $newItem = LBoxConfigManagerStructure::getInstance()->getPageByUrl("/unittest-new-item-30/"); $newItem2 = LBoxConfigManagerStructure::getInstance()->getPageByUrl("/unittest-new-item-3001/"); $this->assertSame($newItem2->id, $newItem->getChildNodesIterator()->current()->id); $newItem2 = LBoxConfigManagerStructure::getInstance()->getPageByUrl("/unittest-new-item-3001/"); $newItem3 = LBoxConfigManagerStructure::getInstance()->getPageByUrl("/unittest-new-item-3002/"); $this->assertNull($newItem2->insertBefore($newItem3)); LBoxConfigStructure::getInstance()->store(); $newItem2 = LBoxConfigManagerStructure::getInstance()->getPageByUrl("/unittest-new-item-3001/"); $newItem3 = LBoxConfigManagerStructure::getInstance()->getPageByUrl("/unittest-new-item-3002/"); $this->assertSame($newItem2->id, $newItem3->getSiblingAfter()->id); $this->assertSame($newItem3->id, $newItem2->getSiblingBefore()->id); $newItem = LBoxConfigManagerStructure::getInstance()->getPageByUrl("/unittest-new-item-30/"); $newItem->delete(); LBoxConfigStructure::getInstance()->store(); }
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; } }
/** * getter na veskere moznosti vyberu in_menu * @return array */ protected function getOptionsInMenu() { try { if (count($this->optionsInMenu) > 0) { return $this->optionsInMenu; } $this->optionsInMenu[0] = 0; $this->optionsInMenu[1] = 1; $pagesIterator = LBoxConfigManagerStructure::getInstance()->getIterator(); foreach ($pagesIterator as $page) { $this->optionsInMenu[$page->in_menu] = $page->in_menu; } switch (count($this->optionsInMenu)) { case 2: krsort($this->optionsInMenu); end($this->optionsInMenu); $this->optionsInMenu[key($this->optionsInMenu)] = "ne"; reset($this->optionsInMenu); $this->optionsInMenu[key($this->optionsInMenu)] = "ano"; break; default: $this->optionsInMenu[0] = "v žádném menu"; ksort($this->optionsInMenu); } return $this->optionsInMenu; } catch (Exception $e) { throw $e; } }
/** * Vraci config home page * @return LBoxConfigItemStructure * @throws LBoxException */ public function getHomePageCfg() { try { $page = LBoxConfigManagerStructure::getInstance()->getHomePage(); if (LBoxFront::getPage()->config->getOutputFilter() instanceof LBoxOutputFilter) { $outputFilterClassName = get_class(LBoxFront::getPage()->config->getOutputFilter()); $page->setOutputFilter(new $outputFilterClassName($page)); } return $page; } catch (Exception $e) { throw $e; } }
/** * reloaduje na default logged dbfree page * @throws Exception */ public static function reloadLoggedDBFree() { try { $pageCfg = self::getPageCfg(); if (strlen($pageCfg->xt_reload_logged_dbfree) > 0) { $reloadParamParts = explode(":", $pageCfg->xt_reload_logged_dbfree); $pageReload = LBoxConfigManagerStructure::getPageById($reloadParamParts[1]); if ($pageCfg->url != $pageReload->url) { self::reload($pageReload->url); } } } catch (Exception $e) { throw $e; } }