Index: trunk/wb/framework/frontend.functions.php
===================================================================
--- trunk/wb/framework/frontend.functions.php	(revision 111)
+++ trunk/wb/framework/frontend.functions.php	(revision 112)
@@ -46,126 +46,156 @@
 $extra_sql=&$wb->extra_sql;
 $extra_where_sql=&$wb->extra_where_sql;
 
-// compatibility code
-function page_link($link) {
-	global $wb;
-	return $wb->page_link($link);
+$query="SELECT directory FROM ".TABLE_PREFIX."modules";
+$query_result=$database->query($query);
+if ($query_result->numRows()>0) {
+	while ($row = $query_result->fetchRow()) {
+		$module_dir = $row['directory'];
+		if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
+			include(WB_PATH.'/modules/'.$module_dir.'/include.php');
+		}
+	}
 }
 
+// Frontend functions
+if (!function_exists('page_link')) {
+	function page_link($link) {
+		global $wb;
+		return $wb->page_link($link);
+	}
+}
+
 // Old menu call invokes new menu function
-function page_menu($parent = 0, $menu_number = 1, $item_template = '<li><span[class]>[a][menu_title][/a]</span>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
-	global $wb;
-	$wb->menu_number=$menu_number;
-	$wb->menu_item_template=$item_template;
-	$wb->menu_parent = $parent;
-	$wb->menu_header = $menu_header; 
-	$wb->menu_footer = $menu_footer;
-	$wb->menu_default_class = $default_class;
-	$wb->menu_current_class = $current_class;
-	$wb->menu_recurse = $recurse+2; 	
-	$wb->menu();
+if (!function_exists('page_menu')) {
+	function page_menu($parent = 0, $menu_number = 1, $item_template = '<li><span[class]>[a][menu_title][/a]</span>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
+		global $wb;
+		$wb->menu_number=$menu_number;
+		$wb->menu_item_template=$item_template;
+		$wb->menu_parent = $parent;
+		$wb->menu_header = $menu_header; 
+		$wb->menu_footer = $menu_footer;
+		$wb->menu_default_class = $default_class;
+		$wb->menu_current_class = $current_class;
+		$wb->menu_recurse = $recurse+2; 	
+		$wb->menu();
+	}
 }
 
-function page_content($block = 1) {
-	// Get outside objects
-	global $TEXT,$MENU,$HEADING,$MESSAGE;
-	global $globals;
-	global $database;
-	$admin = & $this;
-	global $wb;
-	if ($wb->page_access_denied==true) {
-        echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
-		exit();
-	}
-	if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
-	// Make sure block is numeric
-	if(!is_numeric($block)) { $block = 1; }
-	// Include page content
-	if(!defined('PAGE_CONTENT') OR $block!=1) {
-		if ($wb->page_id==0) {
-			if ($wb->default_block_content=='none') {
-				return;
+if (!function_exists('page_content')) {
+	function page_content($block = 1) {
+		// Get outside objects
+		global $TEXT,$MENU,$HEADING,$MESSAGE;
+		global $globals;
+		global $database;
+		global $wb;
+		$admin = & $wb;
+		if ($wb->page_access_denied==true) {
+	        echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
+			exit();
+		}
+		if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
+		// Make sure block is numeric
+		if(!is_numeric($block)) { $block = 1; }
+		// Include page content
+		if(!defined('PAGE_CONTENT') OR $block!=1) {
+			if ($wb->page_id==0) {
+				if ($wb->default_block_content=='none') {
+					return;
+				}
+				if (is_numeric($wb->default_block_content)) {
+					$page_id=$wb->default_block_content;
+				} else {
+					$page_id=$wb->default_page-id;
+				}				
+			} else {
+				$page_id=$wb->page_id;
 			}
-			if (is_numeric($wb->default_block_content)) {
-				$page_id=$wb->default_block_content;
-			} else {
-				$page_id=$wb->default_page-id;
-			}				
+			// First get all sections for this page
+			$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
+			if($query_sections->numRows() > 0) {
+				// Loop through them and include there modules file
+				while($section = $query_sections->fetchRow()) {
+					$section_id = $section['section_id'];
+					$module = $section['module'];
+					require(WB_PATH.'/modules/'.$module.'/view.php');
+				}
+			}
 		} else {
-			$page_id=$wb->page_id;
+			require(PAGE_CONTENT);
 		}
-		// First get all sections for this page
-		$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
-		if($query_sections->numRows() > 0) {
-			// Loop through them and include there modules file
-			while($section = $query_sections->fetchRow()) {
-				$section_id = $section['section_id'];
-				$module = $section['module'];
-				require(WB_PATH.'/modules/'.$module.'/view.php');
-			}
-		}
-	} else {
-		require(PAGE_CONTENT);
 	}
 }
 
-function show_content($block=1) {
-	page_content($block);
+if (!function_exists('show_content')) {
+	function show_content($block=1) {
+		page_content($block);
+	}
 }
 
-function show_breadcrumbs($sep=' > ',$tier=1,$links=true) {
-	$page_id=&$wb->page_id;
-	if ($page_id!=0)
-	{
- 		global $database;
-		$bca=&$wb->page_trail;
-		if (sizeof($bca)==0)
-		        create_breadcrumbs($page_id);
-		$counter=0;
-		foreach ($bca as $temp)
+if (!function_exists('show_breadcrumbs')) {
+	function show_breadcrumbs($sep=' > ',$tier=1,$links=true) {
+		global $wb;
+		$page_id=$wb->page_id;
+		if ($page_id!=0)
 		{
-	        if ($counter>=(tier-1));
-	        {
-				if ($counter>=$tier) echo $sep;
-				$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
-				$page=$query_menu->fetchRow();
-				if ($links==true AND $temp!=$page_id)
-					echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
-				else
-				        echo stripslashes($page['menu_title']);
-	        }
-            $counter++;
+	 		global $database;
+			$bca=$wb->page_trail;
+			$counter=0;
+			foreach ($bca as $temp)
+			{
+		        if ($counter>=(tier-1));
+		        {
+					if ($counter>=$tier) echo $sep;
+					$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
+					$page=$query_menu->fetchRow();
+					if ($links==true AND $temp!=$page_id)
+						echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
+					else
+					        echo stripslashes($page['menu_title']);
+		        }
+	            $counter++;
+			}
 		}
 	}
 }
 
 // Function for page title
-function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
-	$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
-	$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
-	echo str_replace($vars, $values, $template);
+if (!function_exists('page_title')) {
+	function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
+		$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
+		$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
+		echo str_replace($vars, $values, $template);
+	}
 }
 
 // Function for page description
-function page_description() {
-	echo WEBSITE_DESCRIPTION;
+if (!function_exists('page_description')) {
+	function page_description() {
+		echo WEBSITE_DESCRIPTION;
+	}
 }
 // Function for page keywords
-function page_keywords() {
-	echo WEBSITE_KEYWORDS;
+if (!function_exists('page_keywords')) {
+	function page_keywords() {
+		echo WEBSITE_KEYWORDS;
+	}
 }
 // Function for page header
-function page_header($date_format = 'Y') {
-	echo WEBSITE_HEADER;
+if (!function_exists('page_header')) {
+	function page_header($date_format = 'Y') {
+		echo WEBSITE_HEADER;
+	}
 }
 
 // Function for page footer
-function page_footer($date_format = 'Y') {
-	global $starttime;
-	$vars = array('[YEAR]', '[PROCESSTIME]');
-	$processtime=(microtime()>$starttime)?microtime()-$starttime:microtime()-$starttime+1;
-	$values = array(date($date_format),$processtime);
-	echo str_replace($vars, $values, WEBSITE_FOOTER);
+if (!function_exists('page_footer')) {
+	function page_footer($date_format = 'Y') {
+		global $starttime;
+		$vars = array('[YEAR]', '[PROCESSTIME]');
+		$processtime=array_sum(explode(" ",microtime()))-$starttime;
+		$values = array(date($date_format),$processtime);
+		echo str_replace($vars, $values, WEBSITE_FOOTER);
+	}
 }
 
 // Begin WB < 2.4.x template compatibility code
