/** * Deletes a page from the tree (it will not be deleted, only detached). * Static function. * * @param CMS_page $page The page to delete * @param boolean $publicTree Do we want to fetch the public tree or the edited one ? * @return boolean true on success, false on failure * @access public */ static function detachPageFromTree(&$page, $publicTree = false) { //check argument is a page if (!is_a($page, "CMS_page")) { CMS_grandFather::raiseError("Page must be instance of CMS_page"); return false; } //check that the page to detach ain't the root. $root = CMS_tree::getRoot(); if ($root->getID() == $page->getID()) { CMS_grandFather::raiseError("Can't detach root"); return false; } $table = $publicTree ? "linx_tree_public" : "linx_tree_edited"; $father = CMS_tree::getAncestor($page, 1); if (!$father) { //page is not in the tree return true; } //get the current sibling order of the page $sql = "\n\t\t\tselect\n\t\t\t\torder_ltr\n\t\t\tfrom\n\t\t\t\t" . $table . "\n\t\t\twhere\n\t\t\t\tfather_ltr='" . $father->getID() . "'\n\t\t"; $q = new CMS_query($sql); $current_sibling_order = $q->getValue("order_ltr"); //delete page from the table $sql = "\n\t\t\tdelete from\n\t\t\t\t" . $table . "\n\t\t\twhere\n\t\t\t\tsibling_ltr='" . $page->getID() . "'\n\t\t"; $q = new CMS_query($sql); //compact siblings orders of father CMS_tree::compactSiblingOrder($father, $publicTree); return true; }