$jscontent = ''; $isAutomne = $querystring = false; //current http host $httpHost = @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST']; if ($pageUrl && !$pageId) { //get page from requested url if ($cms_page = CMS_tree::analyseURL($pageUrl)) { $pageId = $cms_page->getID(); $isAutomne = true; } } elseif ($pageId) { //try to instanciate the requested page $cms_page = CMS_tree::getPageByID($pageId); $isAutomne = true; } if (!isset($cms_page) || !$cms_page || !is_object($cms_page) || $cms_page->hasError() || $cms_page->getID() != APPLICATION_ROOT_PAGE_ID && !CMS_tree::hasAncestor($cms_page->getID())) { if ($pageUrl && !$isAutomne) { if ($pageUrl == PATH_REALROOT_WR . '/' && $httpHost != @parse_url(CMS_websitesCatalog::getMainURL(), PHP_URL_HOST)) { //Website domain is not properly set if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $jscontent = "\n\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\ttitle: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_INCORRECT_DOMAIN) . "', \n\t\t\t\t\t\tmsg: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_INCORRECT_WEBSITE_CONFIG, array($httpHost, @parse_url(CMS_websitesCatalog::getMainURL(), PHP_URL_HOST))) . "',\n\t\t\t\t\t\tbuttons:\tExt.MessageBox.OK,\n\t\t\t\t\t\ticon: \t\tExt.MessageBox.WARNING,\n\t\t\t\t\t\tfn: \t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\tvar window = new Automne.frameWindow({\n\t\t\t\t\t\t\t\t\t\t\tid:\t\t\t\t'websitesWindow',\n\t\t\t\t\t\t\t\t\t\t\tframeURL:\t\t'" . PATH_MAIN_WR . "/admin-v3/websites.php',\n\t\t\t\t\t\t\t\t\t\t\tallowFrameNav:\ttrue,\n\t\t\t\t\t\t\t\t\t\t\twidth:\t\t\t750,\n\t\t\t\t\t\t\t\t\t\t\theight:\t\t\t580\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\twindow.show();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t"; } else { $jscontent = "\n\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\ttitle: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_INCORRECT_DOMAIN) . "', \n\t\t\t\t\t\tmsg: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_INCORRECT_WEBSITE_CONFIG_ADMIN, array($httpHost, @parse_url(CMS_websitesCatalog::getMainURL(), PHP_URL_HOST))) . "',\n\t\t\t\t\t\tbuttons:\tExt.MessageBox.OK,\n\t\t\t\t\t\ticon: \t\tExt.MessageBox.ERROR\n\t\t\t\t\t});\n\t\t\t\t"; } } else { $jscontent = "\n\t\t\t\tAutomne.message.popup({\n\t\t\t\t\tmsg: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_FOLLOW_EXTERNAL_LINK) . "',\n\t\t\t\t\tbuttons:\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\ticon: \t\tExt.MessageBox.INFO,\n\t\t\t\t\tfn: \t\tfunction (button) {\n\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\twindow.open('{$pageUrl}');\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t"; } $view->addJavascript($jscontent); if ($from) { $cms_page = CMS_tree::getPageByID($from); $pageId = $cms_page->getID();
/** * Attach a page to the tree (references it in the linx_tree tables) * Static function. * * @param mixed $page The page to attach * @param mixed $ancestor The father to attach to * @param boolean $publicTree Do we want to fetch the public tree or the edited one ? * @return boolean true on success, false on failure * @access private */ static function attachPageToTree($page, $ancestor, $publicTree = false) { //check argument is a page if (!is_a($page, "CMS_page") && !sensitiveIO::isPositiveInteger($page)) { CMS_grandFather::raiseError("Page must be instance of CMS_page or positive integer"); return false; } $pageId = is_object($page) ? $page->getID() : $page; //check argument is a page if (!is_a($ancestor, "CMS_page") && !sensitiveIO::isPositiveInteger($ancestor)) { CMS_grandFather::raiseError("Ancestor must be instance of CMS_page or positive integer"); return false; } $ancestorId = is_object($ancestor) ? $ancestor->getID() : $ancestor; $table = $publicTree ? "linx_tree_public" : "linx_tree_edited"; //check that the page ain't already in the tree if (CMS_tree::hasAncestor($pageId, $publicTree)) { return true; } if ($publicTree) { //get the edited sibling order of the page if any $sql = "\n\t\t\t\tselect\n\t\t\t\t\torder_ltr as eo\n\t\t\t\tfrom\n\t\t\t\t\tlinx_tree_edited\n\t\t\t\twhere\n\t\t\t\t\tsibling_ltr='" . sensitiveIO::sanitizeSQLString($pageId) . "'\n\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { $sibling_order = $q->getValue("eo"); } if (!sensitiveIO::isPositiveInteger($sibling_order)) { //get the current sibling order of the ancestor $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tmax(order_ltr) as mo\n\t\t\t\t\tfrom\n\t\t\t\t\t\t" . $table . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tfather_ltr='" . sensitiveIO::sanitizeSQLString($ancestorId) . "'\n\t\t\t\t"; $q = new CMS_query($sql); $sibling_order = $q->getValue("mo") + 1; } } else { //get the current sibling order of the ancestor $sql = "\n\t\t\t\tselect\n\t\t\t\t\tmax(order_ltr) as mo\n\t\t\t\tfrom\n\t\t\t\t\t" . $table . "\n\t\t\t\twhere\n\t\t\t\t\tfather_ltr='" . sensitiveIO::sanitizeSQLString($ancestorId) . "'\n\t\t\t"; $q = new CMS_query($sql); $sibling_order = $q->getValue("mo") + 1; } //add page to the table $sql = "\n\t\t\tinsert into\n\t\t\t\t" . $table . "\n\t\t\tset\n\t\t\t\tfather_ltr='" . sensitiveIO::sanitizeSQLString($ancestorId) . "',\n\t\t\t\tsibling_ltr='" . sensitiveIO::sanitizeSQLString($pageId) . "',\n\t\t\t\torder_ltr='" . $sibling_order . "'\n\t\t"; $q = new CMS_query($sql); return true; }