Location: PHPKode > projects > CHASERS > chasers_gpl_snapshot1a/menu.php
<?php

/*
<LICENSE>
This file is part of CHASERS.
CHASERS is Copyright (c) 2003-2008 Downtown Emergency Service Center (DESC).
All rights reserved.
For more information, about DESC, see http://www.desc.org/.
For more information about CHASERS, see http://chasers.desc.org/.

CHASERS is free software: you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License 
as published by the Free Software Foundation.

CHASERS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with CHASERS.  If not, see <http://www.gnu.org/licenses/>.

</LICENSE>
*/

$quiet = true;
require 'includes.php';
require_once 'chasers_admin.php';

$action = $_REQUEST['action'];

/*
 * Removing menu(s) should be done primarily through the $CG_MENU_TYPES
 * array (see {object}_config.php). Removing code further below isn't necessary once 
 * a menu has been commented out or removed from this array.
 *
 * Conversely, if a menu is added, a function of the form chasers_menu_.$type must 
 * be created. This function should return an array containing, by section, content
 * and any applicable errors:
 *
 * array($menu,$errors);
 *
 * where $menu is an array of the form
 * 
 * array('sec_title_1'=>content,
 *       'sec_title_2'=>content,
 *        ...);
 *
 * WARNING: Since all menus are potentially loaded on a single page, when defining
 *          an action, it is best to prefix it with the menu type. Thus, an action 
 *          on the housing menu section would be housing{action}, etc.
 *
 */

$title = 'CHASERS Menu';

$main_menu = array();
$out = '';

foreach ($CG_MENU_TYPES as $t => $d) {

	$error = false;
	//generate main menu
	$text = orr($d['link_text'],$d['title']);
	$link = !has_perm(orr($d['perm'],'any'))
		? dead_link($text)
		: hlink($_SERVER['PHP_SELF'].'#'.$t,$text);
	$main_menu[] = $link;

	$menu = array();

	if (! has_perm(orr($CG_MENU_TYPES[$t]['perm'],'any'))) {

		// check permissions
		continue;

	} else {

		$func = 'chasers_menu_'.$t;
		if (function_exists($func)) {
			list($menu,$error) = call_user_func($func);
		}

	}


	$out .= html_heading_2(anchor($t).$CG_MENU_TYPES[$t]['title']);

	if ($error) {
		$out .= div($error,'',' class="error"');
	}

	foreach ($menu as $label => $content) {	
		$out .= html_fieldset($label,$content);
	}
	$out .= hlink($_SERVER['PHP_SELF'].'#','back to top');
}

chasers_top_header();


// main menu on each page
$main_menu = div(implode(bold(' | '),$main_menu),
		     '',' style="border: solid 1px #afafaf; margin: 15px; padding: 5px; background-color: #fff; text-align: center"');


out($main_menu);

headtitle($title);


out(div($out));

out($main_menu);
page_close();

?>
Return current item: CHASERS