<?php ################################################## # # Copyright (c) 2004-2006 OIC Group, Inc. # Written and Designed by James Hunt # # This file is part of Exponent # # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } if ($user) { $sections = NavigationModule::levelTemplate(0, 0); $standalones = $db->selectObjects('section', 'parent = -1'); $template = new template('NavigationModule', '_linker'); $template->assign('sections', $sections); $template->assign('standalones', $standalones); $template->assign('haveStandalones', count($standalones)); $template->output(); }
function levelTemplate($parent, $depth = 0, $parents = array()) { if ($parent != 0) { $parents[] = $parent; } global $db, $user; $nodes = array(); if (!isset($_SESSION['nav_cache']['kids'][$parent])) { $kids = $db->selectObjects('section', 'parent=' . $parent); $_SESSION['nav_cache']['kids'][$parent] = $kids; } else { $kids = $_SESSION['nav_cache']['kids'][$parent]; } if (!defined('SYS_SORTING')) { include_once BASE . 'subsystems/sorting.php'; } usort($kids, 'exponent_sorting_byRankAscending'); for ($i = 0; $i < count($kids); $i++) { $child = $kids[$i]; //foreach ($kids as $child) { if ($child->public == 1 || exponent_permissions_check('view', exponent_core_makeLocation('NavigationModule', '', $child->id))) { $child->numParents = count($parents); $child->depth = $depth; $child->first = $i == 0 ? 1 : 0; $child->last = $i == count($kids) - 1 ? 1 : 0; $child->parents = $parents; $child->canManage = $user && $user->is_acting_admin == 1 ? 1 : 0; $child->canManageRank = $child->canManage; // Generate the link attribute base on alias type. if ($child->alias_type == 1) { // External link. Set the link to the configured website URL. // This is guaranteed to be a full URL because of the // section::updateExternalAlias() method in datatypes/section.php $child->link = $child->external_link; } else { if ($child->alias_type == 2) { // Internal link. // Need to check and see if the internal_id is pointing at an external link. $dest = $db->selectObject('section', 'id=' . $child->internal_id); if ($dest->alias_type == 1) { // This internal alias is pointing at an external alias. // Use the external_link of the destination section for the link $child->link = $dest->external_link; } else { // Pointing at a regular section. This is guaranteed to be // a regular section because aliases cannot be turned into sections, // (and vice-versa) and because the section::updateInternalLink // does 'alias to alias' dereferencing before the section is saved // (see datatypes/section.php) $child->link = exponent_core_makeLink(array('section' => $child->internal_id)); } } else { // Normal link. Just create the URL from the section's id. $child->link = exponent_core_makeLink(array('section' => $child->id)); } } $child->numChildren = $db->countObjects('section', 'parent=' . $child->id); $nodes[] = $child; $nodes = array_merge($nodes, NavigationModule::levelTemplate($child->id, $depth + 1, $parents)); } } return $nodes; }
################################################## # # Copyright (c) 2004-2006 OIC Group, Inc. # Written and Designed by James Hunt # # This file is part of Exponent # # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } if (exponent_permissions_checkOnModule('manage', 'NavigationModule')) { exponent_flow_set(SYS_FLOW_PROTECTED, SYS_FLOW_ACTION); $template = new template('NavigationModule', '_manager', $loc); $template->assign('sections', NavigationModule::levelTemplate(0, 0)); // Templates $tpls = $db->selectObjects('section_template', 'parent=0'); $template->assign('templates', $tpls); $template->output(); } else { echo SITE_403_HTML; }