function getPageTree($parent) { global $admin, $database, $InternPagesSelectBox, $PagesTitleSelectBox; $sql = 'SELECT * FROM `' . TABLE_PREFIX . 'pages` '; $sql .= 'WHERE `parent`= ' . (int) $parent . ' '; $sql .= PAGE_TRASH != 'inline' ? 'AND `visibility` != \'deleted\' ' : ' '; $sql .= 'ORDER BY `position` ASC'; if ($resPage = $database->query($sql)) { while (!false == ($page = $resPage->fetchRow())) { if (!$admin->page_is_visible($page)) { continue; } $menu_title = cleanup($page['menu_title']); $page_title = cleanup($page['page_title']); // Stop users from adding pages with a level of more than the set page level limit if ($page['level'] + 1 <= PAGE_LEVEL_LIMIT) { $title_prefix = ''; for ($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; } $InternPagesSelectBox .= "new Array( '" . $title_prefix . $menu_title . "', '[wblink" . $page['page_id'] . "]'), "; $PagesTitleSelectBox .= "new Array( '" . $page_title . "', '[wblink" . $page['page_id'] . "]'), "; } getPageTree($page['page_id']); } } }
function getPageTree($parent) { global $admin, $database, $InternPagesSelectBox, $PagesTitleSelectBox; $sql = 'SELECT * FROM `' . TABLE_PREFIX . 'pages` ' . 'WHERE `parent`= ' . (int) $parent . ' AND ' . '`level`<=' . PAGE_LEVEL_LIMIT . ' ' . (PAGE_TRASH != 'inline' ? 'AND `visibility` != \'deleted\' ' : ' ') . 'ORDER BY `position` ASC'; if ($resPage = $database->query($sql)) { while (!(false == ($page = $resPage->fetchRow(MYSQLI_ASSOC)))) { if (!$admin->page_is_visible($page)) { continue; } $menu_title = cleanup($page['menu_title']); $page_title = cleanup($page['page_title']); $title_prefix = str_repeat(' - ', $page['level']); $InternPagesSelectBox .= "new Array( '" . $title_prefix . $menu_title . "', '[wblink" . $page['page_id'] . "]'), "; $PagesTitleSelectBox .= "new Array( '" . $page_title . "', '[wblink" . $page['page_id'] . "]'), "; if ($page['level'] < PAGE_LEVEL_LIMIT) { getPageTree($page['page_id']); } } } }
/** * Builds an array, with all pages having one certain page as parent-node. Recursive down the tree * * @param $start integer MENU_ID of the page where to start */ function getPageTree($start) { global $db; $multipages = createDBCArray("sitepage", "SPID", "MENU_ID=$start AND DELETED=0"); $menuPages = createDBCArray("sitemap", "MENU_ID", "PARENT_ID = $start AND DELETED=0"); $result = $multipages; if (! is_array($result)) $result = array(); for ($i = 0; $i < count($menuPages); $i++) { $result = array_merge($result, getPageTree($menuPages[$i])); } if (is_array($result)) $result = array_unique($result); return $result; }
function destroyTree() { global $destroyexecuted, $form, $db; $variations = createDBCArray("variations", "VARIATION_ID", "1"); if (!$destroyexecuted) { $destroyexecuted = true; $delstart = value("del", "NUMERIC"); $parentId = getDBCell("sitemap", "PARENT_ID", "MENU_ID = $delstart"); $destroyArray = getPageTree($delstart); if (value("destroypages") == "0") { // geht nicht $meldung = "Please select also the check Destroy Tree. Only then the system will delete the tree."; $form->addToTopText($meldung); } else { if (value("destroycluster") == "0") { // nur pages löschen for ($i = 0; $i < count($destroyArray); $i++) { for ($j = 0; $j < count($variations); $j++) { expireSitepage($destroyArray[$i], 10, $variations[$j]); } $sql1 = "DELETE FROM sitepage WHERE SPID = $destroyArray[$i]"; $menuid = getDBCell("sitepage", "MENU_ID", "SPID = " . $destroyArray[$i]); $deletequery = new query($db, $sql1); if ($menuid != "0" and $menuid != 0 and $menuid != "") { $sql2 = "DELETE FROM sitemap WHERE MENU_ID = $menuid"; $sql3 = "DELETE FROM sitepage_names WHERE SPID = " . $destroyArray[$i]; $sql4 = "DELETE FROM sitepage_owner WHERE SPID = " . $destroyArray[$i]; $deletequery = new query($db, $sql3); $deletequery = new query($db, $sql4); $deletequery = new query($db, $sql2); } $deletequery->free(); } } else { // pages und cluster for ($i = 0; $i < count($destroyArray); $i++) { for ($j = 0; $j < count($variations); $j++) { expireSitepage($destroyArray[$i], 10, $variations[$j]); } $clnid = getDBCell("sitepage", "CLNID", "SPID = $destroyArray[$i]"); // only delete cluster if it is not used as channel article. if (!getDBCell("channel_articles", "CHID", "ARTICLE_ID = ".$clnid)) { $usage = 0; $usage += countRows("sitepage", "CLNID", "CLNID = $clnid AND DELETED=0"); $usage += countRows("cluster_content", "FKID", "FKID = $clnid"); $usage += countRows("cluster_template_items", "FDIK", "FKID = $clnid"); if ($usage < 2) { $sql = "UPDATE cluster_node SET DELETED = 1 WHERE CLNID = $clnid"; $query = new query($db, $sql); } } $sql1 = "DELETE FROM sitepage WHERE SPID = $destroyArray[$i]"; $menuid = getDBCell("sitepage", "MENU_ID", "SPID = " . $destroyArray[$i]); $deletequery = new query($db, $sql1); if ($menuid != "0" and $menuid != 0 and $menuid != "") { $sql2 = "DELETE FROM sitemap WHERE MENU_ID = $menuid"; $sql3 = "DELETE FROM sitepage_names WHERE SPID = " . $destroyArray[$i]; $sql4 = "DELETE FROM sitepage_owner WHERE SPID = " . $destroyArray[$i]; $deletequery = new query($db, $sql3); $deletequery = new query($db, $sql4); $deletequery = new query($db, $sql2); } $deletequery->free(); } } } sortTableRows("sitemap", "MENU_ID", "POSITION", "PARENT_ID = $parentId"); } }