function get_page_trail($id) { return CAT_Helper_Page::getPageTrail($id); }
while ($sub = $query_subs->fetchRow(MYSQL_ASSOC)) { // Double-check to see if it contains old link if (substr($sub['link'], 0, $old_link_len) == $old_link) { // Get new link $replace_this = $old_link; $old_sub_link_len = strlen($sub['link']); $new_sub_link = $options['link'] . '/' . substr($sub['link'], $old_link_len + 1, $old_sub_link_len); // Work out level $new_sub_level = count(explode('/', $new_sub_link)) - 2; $root_parent = $options['root_parent'] == '0' ? $page_id : $options['root_parent']; // Update link and level $database->query(sprintf("UPDATE `%spages` SET link='%s', level='%s', root_parent='%s' WHERE page_id='%s' LIMIT 1", CAT_TABLE_PREFIX, $new_sub_link, $new_sub_level, $root_parent, $sub['page_id'])); // we use reset() to reload the page tree CAT_Helper_Page::reset(); // update trail $database->query(sprintf("UPDATE `%spages` SET page_trail='%s' WHERE page_id='%s' LIMIT 1", CAT_TABLE_PREFIX, CAT_Helper_Page::getPageTrail($sub['page_id']), $sub['page_id'])); // Re-write the access file for this page $old_subpage_file = CAT_PATH . PAGES_DIRECTORY . $new_sub_link . PAGE_EXTENSION; // remove old file if (file_exists($old_subpage_file)) { unlink($old_subpage_file); } // create new CAT_Helper_Page::createAccessFile($new_sub_link, $sub['page_id']); } } } // check if source directory is empty now $source_dir = pathinfo(CAT_PATH . PAGES_DIRECTORY . $old_link, PATHINFO_DIRNAME); if (CAT_Helper_Directory::is_empty($source_dir, true)) { CAT_Helper_Directory::removeDirectory($source_dir);
/** * creates a menu of siblings for given page_id * * @access public * @param integer $page_id * @return string **/ public static function siblingsMenu($id = NULL, $max_level = 999, $show_current = false, array &$options = array()) { global $page_id; if ($id === NULL) { $id = $page_id; } if ($id === 0) { $id = CAT_Helper_Page::getRootParent($page_id); } self::analyzeOptions($options); $level = CAT_Helper_Page::properties($id, 'level'); $menu = CAT_Helper_Page::getPagesForLevel($level, self::$menu_no); $selected = $id; // if current page is not in the menu... if (!self::isInMenu($id, $menu)) { $trail = CAT_Helper_Page::getPageTrail($page_id, false, true); foreach ($trail as $id) { if (false !== ($i = self::isInMenu($id, $menu))) { $menu[$i]['is_open'] = true; $menu[$i]['is_current'] = true; $selected = $menu[$i]['page_id']; break; } } } //return CAT_Helper_ListBuilder::getInstance(false)->config(array('__auto_link' => true))->tree($menu,0,$selected); return self::$list->buildList($menu, array('root_id' => 0, 'selected' => $selected)); }
$order->clean($options['parent']); // Get new order $options['position'] = $order->get_new($options['parent']); // ================================ // ! Insert page into pages table // ================================ $page_id = CAT_Helper_Page::addPage($options); if (!$page_id) { $ajax = array('message' => $backend->lang()->translate('Unable to create the page: ') . $backend->db()->getError(), 'success' => false); print json_encode($ajax); exit; } // Work out root parent $root_parent = CAT_Helper_Page::getRootParent($page_id); // Work out page trail $page_trail = CAT_Helper_Page::getPageTrail($page_id); $result = CAT_Helper_Page::updatePage($page_id, array('root_parent' => $root_parent, 'page_trail' => $page_trail)); if (!$result) { // try to recover = delete page CAT_Helper_Page::deletePage($page_id); $ajax = array('message' => $backend->db()->getError(), 'success' => false); print json_encode($ajax); exit; } // ==================== // ! Create access file // ==================== $result = CAT_Helper_Page::createAccessFile($options['link'], $page_id, $options['level']); if (!$result) { // try to recover = delete page CAT_Helper_Page::deletePage($page_id);