function root_parent($id) { return CAT_Helper_Page::getRootParent($id); }
// If needed, get new order if ($options['parent'] != $old_parent) { require CAT_PATH . '/framework/class.order.php'; $order = new order(CAT_TABLE_PREFIX . 'pages', 'position', 'page_id', 'parent'); // Get new order $options['position'] = $order->get_new($options['parent']); // Clean new order $order->clean($options['parent']); } else { $options['position'] = $old_position; } // Work out level and root parent if ($options['parent'] != '0') { $options['level'] = CAT_Helper_Page::properties($options['parent'], 'level') + 1; } $options['root_parent'] = $options['level'] == 1 ? $options['parent'] : CAT_Helper_Page::getRootParent($options['parent']); // changes the values in the options array CAT_Helper_Page::sanitizeLink($options); CAT_Helper_Page::sanitizeTemplate($options); CAT_Helper_Page::sanitizeLanguage($options); // Check if page already exists; checks access file, directory, and database if ($options['link'] !== $old_link) { if (CAT_Helper_Page::exists($options['link'])) { $ajax = array('message' => $backend->lang()->translate('A page with the same or similar link exists'), 'success' => false); print json_encode($ajax); exit; } } // we use reset() to reload the page tree CAT_Helper_Page::reset(); // Get page trail
/** * 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 = new order(CAT_TABLE_PREFIX . 'pages', 'position', 'page_id', 'parent'); // First clean order $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) {