Revision 112
Added by stefan about 19 years ago
frontend.functions.php | ||
---|---|---|
46 | 46 |
$extra_sql=&$wb->extra_sql; |
47 | 47 |
$extra_where_sql=&$wb->extra_where_sql; |
48 | 48 |
|
49 |
// compatibility code |
|
50 |
function page_link($link) { |
|
51 |
global $wb; |
|
52 |
return $wb->page_link($link); |
|
49 |
$query="SELECT directory FROM ".TABLE_PREFIX."modules"; |
|
50 |
$query_result=$database->query($query); |
|
51 |
if ($query_result->numRows()>0) { |
|
52 |
while ($row = $query_result->fetchRow()) { |
|
53 |
$module_dir = $row['directory']; |
|
54 |
if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) { |
|
55 |
include(WB_PATH.'/modules/'.$module_dir.'/include.php'); |
|
56 |
} |
|
57 |
} |
|
53 | 58 |
} |
54 | 59 |
|
60 |
// Frontend functions |
|
61 |
if (!function_exists('page_link')) { |
|
62 |
function page_link($link) { |
|
63 |
global $wb; |
|
64 |
return $wb->page_link($link); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
55 | 68 |
// Old menu call invokes new menu function |
56 |
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) { |
|
57 |
global $wb; |
|
58 |
$wb->menu_number=$menu_number; |
|
59 |
$wb->menu_item_template=$item_template; |
|
60 |
$wb->menu_parent = $parent; |
|
61 |
$wb->menu_header = $menu_header; |
|
62 |
$wb->menu_footer = $menu_footer; |
|
63 |
$wb->menu_default_class = $default_class; |
|
64 |
$wb->menu_current_class = $current_class; |
|
65 |
$wb->menu_recurse = $recurse+2; |
|
66 |
$wb->menu(); |
|
69 |
if (!function_exists('page_menu')) { |
|
70 |
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) { |
|
71 |
global $wb; |
|
72 |
$wb->menu_number=$menu_number; |
|
73 |
$wb->menu_item_template=$item_template; |
|
74 |
$wb->menu_parent = $parent; |
|
75 |
$wb->menu_header = $menu_header; |
|
76 |
$wb->menu_footer = $menu_footer; |
|
77 |
$wb->menu_default_class = $default_class; |
|
78 |
$wb->menu_current_class = $current_class; |
|
79 |
$wb->menu_recurse = $recurse+2; |
|
80 |
$wb->menu(); |
|
81 |
} |
|
67 | 82 |
} |
68 | 83 |
|
69 |
function page_content($block = 1) { |
|
70 |
// Get outside objects |
|
71 |
global $TEXT,$MENU,$HEADING,$MESSAGE; |
|
72 |
global $globals; |
|
73 |
global $database; |
|
74 |
$admin = & $this; |
|
75 |
global $wb; |
|
76 |
if ($wb->page_access_denied==true) { |
|
77 |
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS']; |
|
78 |
exit(); |
|
79 |
} |
|
80 |
if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } } |
|
81 |
// Make sure block is numeric |
|
82 |
if(!is_numeric($block)) { $block = 1; } |
|
83 |
// Include page content |
|
84 |
if(!defined('PAGE_CONTENT') OR $block!=1) { |
|
85 |
if ($wb->page_id==0) { |
|
86 |
if ($wb->default_block_content=='none') { |
|
87 |
return; |
|
84 |
if (!function_exists('page_content')) { |
|
85 |
function page_content($block = 1) { |
|
86 |
// Get outside objects |
|
87 |
global $TEXT,$MENU,$HEADING,$MESSAGE; |
|
88 |
global $globals; |
|
89 |
global $database; |
|
90 |
global $wb; |
|
91 |
$admin = & $wb; |
|
92 |
if ($wb->page_access_denied==true) { |
|
93 |
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS']; |
|
94 |
exit(); |
|
95 |
} |
|
96 |
if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } } |
|
97 |
// Make sure block is numeric |
|
98 |
if(!is_numeric($block)) { $block = 1; } |
|
99 |
// Include page content |
|
100 |
if(!defined('PAGE_CONTENT') OR $block!=1) { |
|
101 |
if ($wb->page_id==0) { |
|
102 |
if ($wb->default_block_content=='none') { |
|
103 |
return; |
|
104 |
} |
|
105 |
if (is_numeric($wb->default_block_content)) { |
|
106 |
$page_id=$wb->default_block_content; |
|
107 |
} else { |
|
108 |
$page_id=$wb->default_page-id; |
|
109 |
} |
|
110 |
} else { |
|
111 |
$page_id=$wb->page_id; |
|
88 | 112 |
} |
89 |
if (is_numeric($wb->default_block_content)) { |
|
90 |
$page_id=$wb->default_block_content; |
|
91 |
} else { |
|
92 |
$page_id=$wb->default_page-id; |
|
93 |
} |
|
113 |
// First get all sections for this page |
|
114 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
115 |
if($query_sections->numRows() > 0) { |
|
116 |
// Loop through them and include there modules file |
|
117 |
while($section = $query_sections->fetchRow()) { |
|
118 |
$section_id = $section['section_id']; |
|
119 |
$module = $section['module']; |
|
120 |
require(WB_PATH.'/modules/'.$module.'/view.php'); |
|
121 |
} |
|
122 |
} |
|
94 | 123 |
} else { |
95 |
$page_id=$wb->page_id;
|
|
124 |
require(PAGE_CONTENT);
|
|
96 | 125 |
} |
97 |
// First get all sections for this page |
|
98 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position"); |
|
99 |
if($query_sections->numRows() > 0) { |
|
100 |
// Loop through them and include there modules file |
|
101 |
while($section = $query_sections->fetchRow()) { |
|
102 |
$section_id = $section['section_id']; |
|
103 |
$module = $section['module']; |
|
104 |
require(WB_PATH.'/modules/'.$module.'/view.php'); |
|
105 |
} |
|
106 |
} |
|
107 |
} else { |
|
108 |
require(PAGE_CONTENT); |
|
109 | 126 |
} |
110 | 127 |
} |
111 | 128 |
|
112 |
function show_content($block=1) { |
|
113 |
page_content($block); |
|
129 |
if (!function_exists('show_content')) { |
|
130 |
function show_content($block=1) { |
|
131 |
page_content($block); |
|
132 |
} |
|
114 | 133 |
} |
115 | 134 |
|
116 |
function show_breadcrumbs($sep=' > ',$tier=1,$links=true) { |
|
117 |
$page_id=&$wb->page_id; |
|
118 |
if ($page_id!=0) |
|
119 |
{ |
|
120 |
global $database; |
|
121 |
$bca=&$wb->page_trail; |
|
122 |
if (sizeof($bca)==0) |
|
123 |
create_breadcrumbs($page_id); |
|
124 |
$counter=0; |
|
125 |
foreach ($bca as $temp) |
|
135 |
if (!function_exists('show_breadcrumbs')) { |
|
136 |
function show_breadcrumbs($sep=' > ',$tier=1,$links=true) { |
|
137 |
global $wb; |
|
138 |
$page_id=$wb->page_id; |
|
139 |
if ($page_id!=0) |
|
126 | 140 |
{ |
127 |
if ($counter>=(tier-1)); |
|
128 |
{ |
|
129 |
if ($counter>=$tier) echo $sep; |
|
130 |
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp"); |
|
131 |
$page=$query_menu->fetchRow(); |
|
132 |
if ($links==true AND $temp!=$page_id) |
|
133 |
echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>'; |
|
134 |
else |
|
135 |
echo stripslashes($page['menu_title']); |
|
136 |
} |
|
137 |
$counter++; |
|
141 |
global $database; |
|
142 |
$bca=$wb->page_trail; |
|
143 |
$counter=0; |
|
144 |
foreach ($bca as $temp) |
|
145 |
{ |
|
146 |
if ($counter>=(tier-1)); |
|
147 |
{ |
|
148 |
if ($counter>=$tier) echo $sep; |
|
149 |
$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp"); |
|
150 |
$page=$query_menu->fetchRow(); |
|
151 |
if ($links==true AND $temp!=$page_id) |
|
152 |
echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>'; |
|
153 |
else |
|
154 |
echo stripslashes($page['menu_title']); |
|
155 |
} |
|
156 |
$counter++; |
|
157 |
} |
|
138 | 158 |
} |
139 | 159 |
} |
140 | 160 |
} |
141 | 161 |
|
142 | 162 |
// Function for page title |
143 |
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') { |
|
144 |
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]'); |
|
145 |
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer); |
|
146 |
echo str_replace($vars, $values, $template); |
|
163 |
if (!function_exists('page_title')) { |
|
164 |
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') { |
|
165 |
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]'); |
|
166 |
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer); |
|
167 |
echo str_replace($vars, $values, $template); |
|
168 |
} |
|
147 | 169 |
} |
148 | 170 |
|
149 | 171 |
// Function for page description |
150 |
function page_description() { |
|
151 |
echo WEBSITE_DESCRIPTION; |
|
172 |
if (!function_exists('page_description')) { |
|
173 |
function page_description() { |
|
174 |
echo WEBSITE_DESCRIPTION; |
|
175 |
} |
|
152 | 176 |
} |
153 | 177 |
// Function for page keywords |
154 |
function page_keywords() { |
|
155 |
echo WEBSITE_KEYWORDS; |
|
178 |
if (!function_exists('page_keywords')) { |
|
179 |
function page_keywords() { |
|
180 |
echo WEBSITE_KEYWORDS; |
|
181 |
} |
|
156 | 182 |
} |
157 | 183 |
// Function for page header |
158 |
function page_header($date_format = 'Y') { |
|
159 |
echo WEBSITE_HEADER; |
|
184 |
if (!function_exists('page_header')) { |
|
185 |
function page_header($date_format = 'Y') { |
|
186 |
echo WEBSITE_HEADER; |
|
187 |
} |
|
160 | 188 |
} |
161 | 189 |
|
162 | 190 |
// Function for page footer |
163 |
function page_footer($date_format = 'Y') { |
|
164 |
global $starttime; |
|
165 |
$vars = array('[YEAR]', '[PROCESSTIME]'); |
|
166 |
$processtime=(microtime()>$starttime)?microtime()-$starttime:microtime()-$starttime+1; |
|
167 |
$values = array(date($date_format),$processtime); |
|
168 |
echo str_replace($vars, $values, WEBSITE_FOOTER); |
|
191 |
if (!function_exists('page_footer')) { |
|
192 |
function page_footer($date_format = 'Y') { |
|
193 |
global $starttime; |
|
194 |
$vars = array('[YEAR]', '[PROCESSTIME]'); |
|
195 |
$processtime=array_sum(explode(" ",microtime()))-$starttime; |
|
196 |
$values = array(date($date_format),$processtime); |
|
197 |
echo str_replace($vars, $values, WEBSITE_FOOTER); |
|
198 |
} |
|
169 | 199 |
} |
170 | 200 |
|
171 | 201 |
// Begin WB < 2.4.x template compatibility code |
Also available in: Unified diff
Implemented hook for new module type "snippet".