/** * vraci current language colname podle konvenci * @param string $name puvodni nazev parametru * @return mixed */ protected function getColNameLNGCurrent($name) { try { return $name . "_" . LBoxFront::getDisplayLanguage(); } catch (Exception $e) { throw $e; } }
/** * pretizeno o kontrolu vzhledem k multilang */ public function getDOM() { try { if ($this->dom instanceof DOMDocument) { return $this->dom; } $configNameBase = $this->configName; try { $this->configName .= "." . LBoxFront::getDisplayLanguage(); return parent::getDOM(); } catch (Exception $e) { $this->configName = $configNameBase; return parent::getDOM(); } } catch (Exception $e) { throw $e; } }
/** * * @param string $type node type * @param int $seq node order on page * @param LBoxComponent $caller * @param string $lng * @return LBoxMetanode */ public static function getNode($type = "", $seq = 1, LBoxComponent $caller, $lng = "") { try { if (!is_int($seq) || $seq < 1) { throw new LBoxExceptionMetanodes("\$seq: " . LBoxExceptionMetanodes::MSG_PARAM_INT_NOTNULL, LBoxExceptionMetanodes::CODE_BAD_PARAM); } if (strlen($type) < 1) { throw new LBoxExceptionMetanodes(LBoxExceptionMetanodes::MSG_PARAM_STRING_NOTNULL, LBoxExceptionMetanodes::CODE_BAD_PARAM); } if (strlen($lng) < 1) { $lng = LBoxFront::getDisplayLanguage(); } // get node className switch (strtolower($type)) { case self::NODES_TYPE_INT: $nodeClassName = "LBoxMetanodeInt"; break; case self::NODES_TYPE_STRING: $nodeClassName = "LBoxMetanodeString"; break; case self::NODES_TYPE_RICHTEXT: $nodeClassName = "LBoxMetanodeRichText"; break; default: throw new LBoxExceptionMetanodes("{$type}: " . LBoxExceptionMetanodes::MSG_NODETYPE_UNRECOGNIZED, LBoxExceptionMetanodes::CODE_NODETYPE_UNRECOGNIZED); } // try cache var $callerType = $caller instanceof LBoxPage ? "pages" : "components"; if (array_key_exists($callerType, self::$cache) && array_key_exists($caller->config->id, self::$cache[$callerType]) && array_key_exists($seq, self::$cache[$callerType][$caller->config->id])) { if (self::$cache[$callerType][$caller->config->id][$seq] instanceof LBoxMetanode) { // check propability of second call for same metanode of another node type if (self::$cache[$callerType][$caller->config->id][$seq] instanceof $nodeClassName) { return self::$cache[$callerType][$caller->config->id][$seq]; } } } return self::$cache[$callerType][$caller->config->id][$seq] = new $nodeClassName($seq, $caller, $lng); } catch (Exception $e) { throw $e; } }
/** * pretizeno o kontrolu vzhledem k multilang */ public function getDOM() { try { if ($this->dom instanceof DOMDocument) { return $this->dom; } $configNameBase = $this->configName; try { $this->configName .= "." . LBoxFront::getDisplayLanguage(); return parent::getDOM(); } catch (Exception $e) { try { $this->configName = $configNameBase; return parent::getDOM(); } catch (Exception $e) { if ($e->getCode() == LBoxExceptionConfig::CODE_TYPE_NOT_FOUND) { die($this->configName . ".xml not found due to langdomain did not recognized!"); } } } } 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; } }
/** * vraci cesty k lang souborum podle jazyka a sablony, ktera instanci obsluhuje * @return array */ protected function getLanguageFilePaths() { try { $lang = LBoxFront::getDisplayLanguage(); $out = array(); $out[] = LBoxUtil::fixPathSlashes($this->templatePath . ".{$lang}.xml"); $out[] = LBoxUtil::fixPathSlashes(LBOX_PATH_FILES_I18N . "/project.{$lang}.xml"); return $out; } catch (Exception $e) { throw $e; } }
/** * getter na editacni form pro AJAX GUI * @return LBoxForm */ public function getForm() { try { if (!$this->isActive()) { return NULL; } if ($this->form instanceof LBoxForm) { return $this->form; } $type = get_class($this); $nodeType = eval("return {$type}::TYPE;"); $nodeControlClassName = eval("return {$type}::XT_FORM_CTRL_CLASSNAME;"); $nodeControlTemplate = eval("return {$type}::XT_FORM_CTRL_TEMPLATE_FILENAME;"); $seq = $this->seq; $callerID = $this->caller->id; $formID = "metanode-{$callerID}-{$seq}-{$nodeType}"; $ctrlType = new LBoxFormControlFillHidden("type", "", $nodeType); $ctrlType->setTemplateFileName("metanode_hidden.html"); $ctrlSeq = new LBoxFormControlFillHidden("seq", "", $seq); $ctrlSeq->setTemplateFileName("metanode_hidden.html"); $ctrlCallerID = new LBoxFormControlFillHidden("caller_id", "", $callerID); $ctrlCallerID->setTemplateFileName("metanode_hidden.html"); $ctrlCallerType = new LBoxFormControlFillHidden("caller_type", "", $this->caller instanceof LBoxPage || $this->caller instanceof PageList ? "page" : "component"); $ctrlCallerType->setTemplateFileName("metanode_hidden.html"); $ctrlLng = new LBoxFormControlFillHidden("lng", "", LBoxFront::getDisplayLanguage()); $ctrlLng->setTemplateFileName("metanode_hidden.html"); $ctrlContent = new $nodeControlClassName("content", "", $this->getContent()); $ctrlContent->setTemplateFileName($nodeControlTemplate); // vlozime ho do dialog boxu pro JS GUI $ctrlDialog = new LBoxFormControlMultiple("dialog", ""); $ctrlDialog->setTemplateFileName("metanode_dialog.html"); $ctrlDialog->addControl($ctrlContent); $this->form = new LBoxForm($formID, "post", "", "editovat"); $this->form->setTemplateFileName("metanode_xt_toedit.html"); $this->form->action = LBoxConfigSystem::getInstance()->getParamByPath("metanodes/api/url"); $this->form->addControl($ctrlDialog); $this->form->addProcessor(new ProcessorMetanodeXTToEdit()); $this->form->className = "metanode"; $this->form->addControl($ctrlType); $this->form->addControl($ctrlSeq); $this->form->addControl($ctrlCallerID); $this->form->addControl($ctrlCallerType); $this->form->addControl($ctrlLng); return $this->form; } 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; } }