1 |
1165
|
Luisehahne
|
<?php
|
2 |
1233
|
Luisehahne
|
/**
|
3 |
|
|
*
|
4 |
1269
|
Luisehahne
|
* @category frontend
|
5 |
|
|
* @package functions
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
1349
|
Luisehahne
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9 |
1269
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
11 |
|
|
* @platform WebsiteBaker 2.8.x
|
12 |
1349
|
Luisehahne
|
* @requirements PHP 5.2.2 and higher
|
13 |
1269
|
Luisehahne
|
* @version $Id$
|
14 |
1270
|
Luisehahne
|
* @filesource $HeadURL$
|
15 |
|
|
* @lastmodified $Date$
|
16 |
1233
|
Luisehahne
|
*
|
17 |
1269
|
Luisehahne
|
*/
|
18 |
1165
|
Luisehahne
|
|
19 |
|
|
if(!defined('WB_URL')) {
|
20 |
|
|
header('Location: ../index.php');
|
21 |
|
|
exit(0);
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
// references to objects and variables that changed their names
|
25 |
|
|
|
26 |
|
|
$admin = &$wb;
|
27 |
|
|
|
28 |
|
|
$default_link=&$wb->default_link;
|
29 |
|
|
|
30 |
|
|
$page_trail=&$wb->page_trail;
|
31 |
|
|
$page_description=&$wb->page_description;
|
32 |
|
|
$page_keywords=&$wb->page_keywords;
|
33 |
|
|
$page_link=&$wb->link;
|
34 |
|
|
|
35 |
|
|
// extra_sql is not used anymore - this is basically a register_globals exploit prevention...
|
36 |
|
|
$extra_sql=&$wb->extra_sql;
|
37 |
|
|
$extra_where_sql=&$wb->extra_where_sql;
|
38 |
|
|
|
39 |
|
|
$include_head_link_css = '';
|
40 |
|
|
$include_body_links = '';
|
41 |
|
|
$include_head_links = '';
|
42 |
1181
|
Luisehahne
|
// workout to included frontend.css, fronten.js and frontend_body.js in snippets
|
43 |
1165
|
Luisehahne
|
$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'";
|
44 |
|
|
$query_result=$database->query($query);
|
45 |
|
|
if ($query_result->numRows()>0) {
|
46 |
|
|
while ($row = $query_result->fetchRow()) {
|
47 |
|
|
$module_dir = $row['directory'];
|
48 |
|
|
if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
|
49 |
|
|
include(WB_PATH.'/modules/'.$module_dir.'/include.php');
|
50 |
|
|
/* check if frontend.css file needs to be included into the <head></head> of index.php
|
51 |
|
|
*/
|
52 |
|
|
if( file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend.css')) {
|
53 |
|
|
$include_head_link_css .= '<link href="'.WB_URL.'/modules/'.$module_dir.'/frontend.css"';
|
54 |
|
|
$include_head_link_css .= ' rel="stylesheet" type="text/css" media="screen" />'."\n";
|
55 |
|
|
$include_head_file = 'frontend.css';
|
56 |
|
|
}
|
57 |
|
|
// check if frontend.js file needs to be included into the <body></body> of index.php
|
58 |
|
|
if(file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend.js')) {
|
59 |
|
|
$include_head_links .= '<script src="'.WB_URL.'/modules/'.$module_dir.'/frontend.js" type="text/javascript"></script>'."\n";
|
60 |
|
|
$include_head_file = 'frontend.js';
|
61 |
|
|
}
|
62 |
|
|
// check if frontend_body.js file needs to be included into the <body></body> of index.php
|
63 |
|
|
if(file_exists(WB_PATH .'/modules/'.$module_dir.'/frontend_body.js')) {
|
64 |
|
|
$include_body_links .= '<script src="'.WB_URL.'/modules/'.$module_dir.'/frontend_body.js" type="text/javascript"></script>'."\n";
|
65 |
|
|
$include_body_file = 'frontend_body.js';
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
// Frontend functions
|
72 |
1310
|
Luisehahne
|
if (!function_exists('page_link'))
|
73 |
|
|
{
|
74 |
1165
|
Luisehahne
|
function page_link($link) {
|
75 |
|
|
global $wb;
|
76 |
|
|
return $wb->page_link($link);
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
|
80 |
1310
|
Luisehahne
|
if (!function_exists('get_page_link'))
|
81 |
|
|
{
|
82 |
|
|
function get_page_link( $id )
|
83 |
|
|
{
|
84 |
|
|
global $database;
|
85 |
|
|
// Get link
|
86 |
|
|
$sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$id;
|
87 |
|
|
$link = $database->get_one( $sql );
|
88 |
|
|
return $link;
|
89 |
|
|
}
|
90 |
|
|
}
|
91 |
|
|
|
92 |
1165
|
Luisehahne
|
//function to highlight search results
|
93 |
|
|
if(!function_exists('search_highlight')) {
|
94 |
|
|
function search_highlight($foo='', $arr_string=array()) {
|
95 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
96 |
|
|
static $string_ul_umlaut = FALSE;
|
97 |
|
|
static $string_ul_regex = FALSE;
|
98 |
|
|
if($string_ul_umlaut===FALSE || $string_ul_regex===FALSE)
|
99 |
|
|
require(WB_PATH.'/search/search_convert.php');
|
100 |
|
|
$foo = entities_to_umlauts($foo, 'UTF-8');
|
101 |
|
|
array_walk($arr_string, create_function('&$v,$k','$v = preg_quote($v, \'~\');'));
|
102 |
|
|
$search_string = implode("|", $arr_string);
|
103 |
|
|
$string = str_replace($string_ul_umlaut, $string_ul_regex, $search_string);
|
104 |
|
|
// the highlighting
|
105 |
|
|
// match $string, but not inside <style>...</style>, <script>...</script>, <!--...--> or HTML-Tags
|
106 |
1171
|
Ruud
|
// Also droplet tags are now excluded from highlighting.
|
107 |
1165
|
Luisehahne
|
// split $string into pieces - "cut away" styles, scripts, comments, HTML-tags and eMail-addresses
|
108 |
|
|
// we have to cut <pre> and <code> as well.
|
109 |
|
|
// for HTML-Tags use <(?:[^<]|<.*>)*> which will match strings like <input ... value="<b>value</b>" >
|
110 |
1181
|
Luisehahne
|
$matches = preg_split("~(\[\[.*\]\]|<style.*</style>|<script.*</script>|<pre.*</pre>|<code.*</code>|<!--.*-->|<(?:[^<]|<.*>)*>|\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}\b)~iUs",$foo,-1,(PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY));
|
111 |
1165
|
Luisehahne
|
if(is_array($matches) && $matches != array()) {
|
112 |
|
|
$foo = "";
|
113 |
|
|
foreach($matches as $match) {
|
114 |
1181
|
Luisehahne
|
if($match{0}!="<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}$/i', $match) && !preg_match('~\[\[.*\]\]~', $match)) {
|
115 |
1165
|
Luisehahne
|
$match = str_replace(array('<', '>', '&', '"', ''', ' '), array('<', '>', '&', '"', '\'', "\xC2\xA0"), $match);
|
116 |
|
|
$match = preg_replace('~('.$string.')~ui', '_span class=_highlight__$1_/span_',$match);
|
117 |
|
|
$match = str_replace(array('&', '<', '>', '"', '\'', "\xC2\xA0"), array('&', '<', '>', '"', ''', ' '), $match);
|
118 |
|
|
$match = str_replace(array('_span class=_highlight__', '_/span_'), array('<span class="highlight">', '</span>'), $match);
|
119 |
|
|
}
|
120 |
|
|
$foo .= $match;
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
1310
|
Luisehahne
|
|
124 |
1165
|
Luisehahne
|
if(DEFAULT_CHARSET != 'utf-8') {
|
125 |
|
|
$foo = umlauts_to_entities($foo, 'UTF-8');
|
126 |
|
|
}
|
127 |
|
|
return $foo;
|
128 |
|
|
}
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
// Old menu call invokes new menu function
|
132 |
|
|
if (!function_exists('page_menu')) {
|
133 |
|
|
function page_menu($parent = 0, $menu_number = 1, $item_template = '<li[class]>[a] [menu_title] [/a]</li>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
|
134 |
|
|
global $wb;
|
135 |
|
|
$wb->menu_number=$menu_number;
|
136 |
|
|
$wb->menu_item_template=$item_template;
|
137 |
|
|
$wb->menu_item_footer='';
|
138 |
|
|
$wb->menu_parent = $parent;
|
139 |
1310
|
Luisehahne
|
$wb->menu_header = $menu_header;
|
140 |
1165
|
Luisehahne
|
$wb->menu_footer = $menu_footer;
|
141 |
|
|
$wb->menu_default_class = $default_class;
|
142 |
|
|
$wb->menu_current_class = $current_class;
|
143 |
1310
|
Luisehahne
|
$wb->menu_recurse = $recurse+2;
|
144 |
1165
|
Luisehahne
|
$wb->menu();
|
145 |
|
|
unset($wb->menu_parent);
|
146 |
|
|
unset($wb->menu_number);
|
147 |
|
|
unset($wb->menu_item_template);
|
148 |
|
|
unset($wb->menu_item_footer);
|
149 |
|
|
unset($wb->menu_header);
|
150 |
|
|
unset($wb->menu_footer);
|
151 |
|
|
unset($wb->menu_default_class);
|
152 |
|
|
unset($wb->menu_current_class);
|
153 |
|
|
unset($wb->menu_start_level);
|
154 |
|
|
unset($wb->menu_collapse);
|
155 |
|
|
unset($wb->menu_recurse);
|
156 |
|
|
}
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
if (!function_exists('show_menu')) {
|
160 |
|
|
function show_menu($menu_number = NULL, $start_level=NULL, $recurse = NULL, $collapse = NULL, $item_template = NULL, $item_footer = NULL, $menu_header = NULL, $menu_footer = NULL, $default_class = NULL, $current_class = NULL, $parent = NULL) {
|
161 |
|
|
global $wb;
|
162 |
|
|
if (isset($menu_number))
|
163 |
|
|
$wb->menu_number=$menu_number;
|
164 |
|
|
if (isset($start_level))
|
165 |
|
|
$wb->menu_start_level=$start_level;
|
166 |
|
|
if (isset($recurse))
|
167 |
|
|
$wb->menu_recurse=$recurse;
|
168 |
|
|
if (isset($collapse))
|
169 |
|
|
$wb->menu_collapse=$collapse;
|
170 |
|
|
if (isset($item_template))
|
171 |
|
|
$wb->menu_item_template=$item_template;
|
172 |
|
|
if (isset($item_footer))
|
173 |
|
|
$wb->menu_item_footer=$item_footer;
|
174 |
|
|
if (isset($menu_header))
|
175 |
|
|
$wb->menu_header=$menu_header;
|
176 |
|
|
if (isset($menu_footer))
|
177 |
|
|
$wb->menu_footer=$menu_footer;
|
178 |
|
|
if (isset($default_class))
|
179 |
|
|
$wb->menu_default_class=$default_class;
|
180 |
|
|
if (isset($current_class))
|
181 |
|
|
$wb->menu_current_class=$current_class;
|
182 |
|
|
if (isset($parent))
|
183 |
|
|
$wb->menu_parent=$parent;
|
184 |
|
|
$wb->menu();
|
185 |
|
|
unset($wb->menu_recurse);
|
186 |
|
|
unset($wb->menu_parent);
|
187 |
|
|
unset($wb->menu_start_level);
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
if (!function_exists('page_content')) {
|
192 |
|
|
function page_content($block = 1) {
|
193 |
|
|
// Get outside objects
|
194 |
|
|
global $TEXT,$MENU,$HEADING,$MESSAGE;
|
195 |
|
|
global $globals;
|
196 |
|
|
global $database;
|
197 |
|
|
global $wb;
|
198 |
|
|
$admin = & $wb;
|
199 |
1235
|
Luisehahne
|
if ($wb->page_access_denied==true)
|
200 |
|
|
{
|
201 |
1165
|
Luisehahne
|
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
|
202 |
1269
|
Luisehahne
|
return;
|
203 |
1165
|
Luisehahne
|
}
|
204 |
1235
|
Luisehahne
|
if ($wb->page_no_active_sections==true)
|
205 |
|
|
{
|
206 |
1165
|
Luisehahne
|
echo $MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'];
|
207 |
1269
|
Luisehahne
|
return;
|
208 |
1165
|
Luisehahne
|
}
|
209 |
1235
|
Luisehahne
|
if(isset($globals) AND is_array($globals))
|
210 |
|
|
{
|
211 |
|
|
foreach($globals AS $global_name)
|
212 |
|
|
{
|
213 |
|
|
global $$global_name;
|
214 |
|
|
}
|
215 |
|
|
}
|
216 |
1165
|
Luisehahne
|
// Make sure block is numeric
|
217 |
|
|
if(!is_numeric($block)) { $block = 1; }
|
218 |
|
|
// Include page content
|
219 |
1181
|
Luisehahne
|
if(!defined('PAGE_CONTENT') OR $block!=1)
|
220 |
|
|
{
|
221 |
1310
|
Luisehahne
|
$page_id = intval($wb->page_id);
|
222 |
1181
|
Luisehahne
|
// set session variable to save page_id only if PAGE_CONTENT is empty
|
223 |
|
|
$_SESSION['PAGE_ID'] = !isset($_SESSION['PAGE_ID']) ? $page_id : $_SESSION['PAGE_ID'];
|
224 |
|
|
// set to new value if page_id changed and not 0
|
225 |
1310
|
Luisehahne
|
if(($page_id != 0) && ($_SESSION['PAGE_ID'] <> $page_id))
|
226 |
1181
|
Luisehahne
|
{
|
227 |
|
|
$_SESSION['PAGE_ID'] = $page_id;
|
228 |
|
|
}
|
229 |
|
|
|
230 |
1165
|
Luisehahne
|
// First get all sections for this page
|
231 |
|
|
$query_sections = $database->query("SELECT section_id,module,publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
|
232 |
|
|
// If none were found, check if default content is supposed to be shown
|
233 |
|
|
if($query_sections->numRows() == 0) {
|
234 |
|
|
if ($wb->default_block_content=='none') {
|
235 |
|
|
return;
|
236 |
|
|
}
|
237 |
|
|
if (is_numeric($wb->default_block_content)) {
|
238 |
|
|
$page_id=$wb->default_block_content;
|
239 |
|
|
} else {
|
240 |
|
|
$page_id=$wb->default_page_id;
|
241 |
|
|
}
|
242 |
|
|
$query_sections = $database->query("SELECT section_id,module,publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
|
243 |
|
|
// Still no cotent found? Give it up, there's just nothing to show!
|
244 |
|
|
if($query_sections->numRows() == 0) {
|
245 |
|
|
return;
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
|
|
// Loop through them and include their module file
|
249 |
|
|
while($section = $query_sections->fetchRow()) {
|
250 |
|
|
// skip this section if it is out of publication-date
|
251 |
|
|
$now = time();
|
252 |
|
|
if( !(($now<=$section['publ_end'] || $section['publ_end']==0) && ($now>=$section['publ_start'] || $section['publ_start']==0)) ) {
|
253 |
|
|
continue;
|
254 |
|
|
}
|
255 |
|
|
$section_id = $section['section_id'];
|
256 |
|
|
$module = $section['module'];
|
257 |
|
|
// make a anchor for every section.
|
258 |
|
|
if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
|
259 |
|
|
echo '<a class="section_anchor" id="'.SEC_ANCHOR.$section_id.'" name="'.SEC_ANCHOR.$section_id.'"></a>';
|
260 |
|
|
}
|
261 |
1337
|
Luisehahne
|
// check if module exists - feature: write in errorlog
|
262 |
|
|
if(file_exists(WB_PATH.'/modules/'.$module.'/view.php')) {
|
263 |
1165
|
Luisehahne
|
// fetch content -- this is where to place possible output-filters (before highlighting)
|
264 |
1337
|
Luisehahne
|
ob_start(); // fetch original content
|
265 |
|
|
require(WB_PATH.'/modules/'.$module.'/view.php');
|
266 |
|
|
$content = ob_get_contents();
|
267 |
|
|
ob_end_clean();
|
268 |
|
|
} else {
|
269 |
|
|
continue;
|
270 |
|
|
}
|
271 |
1165
|
Luisehahne
|
|
272 |
|
|
// highlights searchresults
|
273 |
|
|
if(isset($_GET['searchresult']) && is_numeric($_GET['searchresult']) && !isset($_GET['nohighlight']) && isset($_GET['sstring']) && !empty($_GET['sstring'])) {
|
274 |
|
|
$arr_string = explode(" ", $_GET['sstring']);
|
275 |
|
|
if($_GET['searchresult']==2) { // exact match
|
276 |
|
|
$arr_string[0] = str_replace("_", " ", $arr_string[0]);
|
277 |
|
|
}
|
278 |
|
|
echo search_highlight($content, $arr_string);
|
279 |
|
|
} else {
|
280 |
|
|
echo $content;
|
281 |
|
|
}
|
282 |
|
|
}
|
283 |
1235
|
Luisehahne
|
}
|
284 |
|
|
else
|
285 |
|
|
{
|
286 |
|
|
|
287 |
1165
|
Luisehahne
|
require(PAGE_CONTENT);
|
288 |
|
|
}
|
289 |
|
|
}
|
290 |
|
|
}
|
291 |
|
|
|
292 |
|
|
if (!function_exists('show_content')) {
|
293 |
|
|
function show_content($block=1) {
|
294 |
|
|
page_content($block);
|
295 |
|
|
}
|
296 |
|
|
}
|
297 |
|
|
|
298 |
|
|
if (!function_exists('show_breadcrumbs'))
|
299 |
|
|
{
|
300 |
1233
|
Luisehahne
|
function show_breadcrumbs($sep = ' » ',$level = 0, $links = true, $depth = -1, $title = 'You are here: ')
|
301 |
1165
|
Luisehahne
|
{
|
302 |
|
|
global $wb;
|
303 |
1233
|
Luisehahne
|
$page_id = $wb->page_id;
|
304 |
|
|
|
305 |
|
|
if ($page_id != 0)
|
306 |
1165
|
Luisehahne
|
{
|
307 |
|
|
global $database;
|
308 |
1233
|
Luisehahne
|
$counter = 0;
|
309 |
|
|
// get links as array
|
310 |
|
|
$bread_crumbs = $wb->page_trail;
|
311 |
|
|
$count = sizeof($bread_crumbs);
|
312 |
|
|
// level can't be greater than sum of links
|
313 |
|
|
$level = ($count <= $level ) ? $count-1 : $level;
|
314 |
|
|
// set level from which to show, delete indexes in array
|
315 |
|
|
$crumbs = array_slice($bread_crumbs, $level );
|
316 |
|
|
$depth = ($depth <= 0) ? sizeof($crumbs) : $depth;
|
317 |
|
|
// if empty array, set orginal links
|
318 |
|
|
$crumbs = (!empty($crumbs)) ? $crumbs : $wb->page_trail;
|
319 |
|
|
$total_crumbs = ( ($depth <= 0) OR ($depth > sizeof($crumbs)) ) ? sizeof($crumbs) : $depth;
|
320 |
1242
|
Luisehahne
|
print '<div class="breadcrumb"><span class="title">'.$title.'</span>';
|
321 |
1235
|
Luisehahne
|
// print_r($crumbs);
|
322 |
|
|
foreach ($crumbs as $temp)
|
323 |
|
|
{
|
324 |
1233
|
Luisehahne
|
if($counter == $depth) { break; }
|
325 |
1235
|
Luisehahne
|
// set links and separator
|
326 |
|
|
$query_menu = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = $temp");
|
327 |
1233
|
Luisehahne
|
$page = $query_menu->fetchRow();
|
328 |
1235
|
Luisehahne
|
|
329 |
|
|
$show_crumb = (($links == true) AND ($temp != $page_id))
|
330 |
|
|
? '<a href="'.page_link($page['link']).'" class="link">'.$page['menu_title'].'</a>'
|
331 |
|
|
: '<span class="crumb">'.MENU_TITLE.'</span>';
|
332 |
|
|
|
333 |
|
|
// Permission
|
334 |
|
|
switch ($page['visibility'])
|
335 |
|
|
{
|
336 |
|
|
case 'none' :
|
337 |
|
|
case 'hidden' :
|
338 |
|
|
// if show, you know there is an error in a hidden page
|
339 |
1242
|
Luisehahne
|
print $show_crumb.' ';
|
340 |
1235
|
Luisehahne
|
break;
|
341 |
|
|
default :
|
342 |
|
|
print $show_crumb;
|
343 |
|
|
break;
|
344 |
|
|
}
|
345 |
|
|
|
346 |
|
|
if ( ( $counter <> $total_crumbs-1 ) )
|
347 |
|
|
{
|
348 |
1233
|
Luisehahne
|
print '<span class="separator">'.$sep.'</span>';
|
349 |
|
|
}
|
350 |
1165
|
Luisehahne
|
$counter++;
|
351 |
1235
|
Luisehahne
|
}
|
352 |
1165
|
Luisehahne
|
print "</div>\n";
|
353 |
|
|
}
|
354 |
|
|
}
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
// Function for page title
|
358 |
|
|
if (!function_exists('page_title')) {
|
359 |
|
|
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
|
360 |
|
|
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
|
361 |
|
|
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
|
362 |
|
|
echo str_replace($vars, $values, $template);
|
363 |
|
|
}
|
364 |
|
|
}
|
365 |
|
|
|
366 |
|
|
// Function for page description
|
367 |
|
|
if (!function_exists('page_description')) {
|
368 |
|
|
function page_description() {
|
369 |
|
|
global $wb;
|
370 |
|
|
if ($wb->page_description!='') {
|
371 |
|
|
echo $wb->page_description;
|
372 |
|
|
} else {
|
373 |
|
|
echo WEBSITE_DESCRIPTION;
|
374 |
|
|
}
|
375 |
|
|
}
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
// Function for page keywords
|
379 |
|
|
if (!function_exists('page_keywords')) {
|
380 |
|
|
function page_keywords() {
|
381 |
|
|
global $wb;
|
382 |
|
|
if ($wb->page_keywords!='') {
|
383 |
|
|
echo $wb->page_keywords;
|
384 |
|
|
} else {
|
385 |
|
|
echo WEBSITE_KEYWORDS;
|
386 |
|
|
}
|
387 |
|
|
}
|
388 |
|
|
}
|
389 |
|
|
|
390 |
|
|
// Function for page header
|
391 |
|
|
if (!function_exists('page_header')) {
|
392 |
|
|
function page_header($date_format = 'Y') {
|
393 |
|
|
echo WEBSITE_HEADER;
|
394 |
|
|
}
|
395 |
|
|
}
|
396 |
|
|
|
397 |
|
|
// Function for page footer
|
398 |
|
|
if (!function_exists('page_footer')) {
|
399 |
|
|
function page_footer($date_format = 'Y') {
|
400 |
|
|
global $starttime;
|
401 |
|
|
$vars = array('[YEAR]', '[PROCESS_TIME]');
|
402 |
|
|
$processtime=array_sum(explode(" ",microtime()))-$starttime;
|
403 |
|
|
$values = array(gmdate($date_format),$processtime);
|
404 |
|
|
echo str_replace($vars, $values, WEBSITE_FOOTER);
|
405 |
|
|
}
|
406 |
|
|
}
|
407 |
|
|
|
408 |
1181
|
Luisehahne
|
function bind_jquery ($file_id='jquery')
|
409 |
|
|
{
|
410 |
1310
|
Luisehahne
|
|
411 |
1181
|
Luisehahne
|
$jquery_links = '';
|
412 |
|
|
/* include the Javascript jquery api */
|
413 |
|
|
if( $file_id == 'jquery' AND file_exists(WB_PATH .'/include/jquery/jquery-min.js'))
|
414 |
|
|
{
|
415 |
|
|
$wbpath = str_replace('\\','/',WB_PATH); // fixed localhost problem with ie
|
416 |
|
|
$jquery_links .= "<script type=\"text/javascript\">\n"
|
417 |
|
|
."var URL = '".WB_URL."';\n"
|
418 |
1252
|
Luisehahne
|
/* ."var WB_PATH = '".$wbpath."';\n" */
|
419 |
1181
|
Luisehahne
|
."var WB_URL = '".WB_URL."';\n"
|
420 |
|
|
."var TEMPLATE_DIR = '".TEMPLATE_DIR."';\n"
|
421 |
|
|
."</script>\n";
|
422 |
|
|
|
423 |
|
|
$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-min.js" type="text/javascript"></script>'."\n";
|
424 |
|
|
$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-insert.js" type="text/javascript"></script>'."\n";
|
425 |
|
|
/* workout to insert ui.css and theme */
|
426 |
|
|
$jquery_theme = WB_PATH.'/modules/jquery/jquery_theme.js';
|
427 |
|
|
$jquery_links .= file_exists($jquery_theme)
|
428 |
|
|
? '<script src="'.WB_URL.'/modules/jquery/jquery_theme.js" type="text/javascript"></script>'."\n"
|
429 |
|
|
: '<script src="'.WB_URL.'/include/jquery/jquery_theme.js" type="text/javascript"></script>'."\n";
|
430 |
|
|
/* workout to insert plugins functions, set in templatedir */
|
431 |
|
|
$jquery_frontend_file = TEMPLATE_DIR.'/jquery_frontend.js';
|
432 |
|
|
$jquery_links .= file_exists(str_replace( WB_URL, WB_PATH, $jquery_frontend_file))
|
433 |
|
|
? '<script src="'.$jquery_frontend_file.'" type="text/javascript"></script>'."\n"
|
434 |
|
|
: '';
|
435 |
|
|
}
|
436 |
|
|
return $jquery_links;
|
437 |
|
|
}
|
438 |
|
|
|
439 |
|
|
|
440 |
1165
|
Luisehahne
|
// Function to add optional module Javascript into the <body> section of the frontend
|
441 |
1181
|
Luisehahne
|
if(!function_exists('register_frontend_modfiles_body'))
|
442 |
|
|
{
|
443 |
|
|
function register_frontend_modfiles_body($file_id="js")
|
444 |
|
|
{
|
445 |
1165
|
Luisehahne
|
// sanity check of parameter passed to the function
|
446 |
|
|
$file_id = strtolower($file_id);
|
447 |
1181
|
Luisehahne
|
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
|
448 |
|
|
{
|
449 |
1165
|
Luisehahne
|
return;
|
450 |
|
|
}
|
451 |
|
|
|
452 |
1181
|
Luisehahne
|
// define constant indicating that the register_frontent_files was invoked
|
453 |
|
|
if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);
|
454 |
1165
|
Luisehahne
|
global $wb, $database, $include_body_links;
|
455 |
|
|
// define default baselink and filename for optional module javascript files
|
456 |
|
|
$body_links = "";
|
457 |
|
|
|
458 |
1181
|
Luisehahne
|
/* include the Javascript jquery api */
|
459 |
|
|
$body_links .= bind_jquery($file_id);
|
460 |
1165
|
Luisehahne
|
|
461 |
1181
|
Luisehahne
|
if($file_id !== "css" && $file_id == "js" && $file_id !== "jquery")
|
462 |
|
|
{
|
463 |
|
|
$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend_body.js" type="text/javascript"></script>';
|
464 |
|
|
$base_file = "frontend_body.js";
|
465 |
1165
|
Luisehahne
|
|
466 |
1181
|
Luisehahne
|
// ensure that frontend_body.js is only added once per module type
|
467 |
|
|
if(!empty($include_body_links))
|
468 |
|
|
{
|
469 |
|
|
if(strpos($body_links, $include_body_links) === false)
|
470 |
|
|
{
|
471 |
|
|
$body_links .= $include_body_links;
|
472 |
|
|
}
|
473 |
|
|
$include_body_links = '';
|
474 |
|
|
}
|
475 |
1165
|
Luisehahne
|
|
476 |
1181
|
Luisehahne
|
// gather information for all models embedded on actual page
|
477 |
|
|
$page_id = $wb->page_id;
|
478 |
|
|
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
479 |
|
|
WHERE page_id=$page_id AND module<>'wysiwyg'");
|
480 |
1165
|
Luisehahne
|
|
481 |
1181
|
Luisehahne
|
while($row = $query_modules->fetchRow())
|
482 |
|
|
{
|
483 |
|
|
// check if page module directory contains a frontend_body.js file
|
484 |
1250
|
Luisehahne
|
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file"))
|
485 |
|
|
{
|
486 |
1181
|
Luisehahne
|
// create link with frontend_body.js source for the current module
|
487 |
|
|
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
|
488 |
1165
|
Luisehahne
|
|
489 |
1181
|
Luisehahne
|
// define constant indicating that the register_frontent_files_body was invoked
|
490 |
1250
|
Luisehahne
|
if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) { define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);}
|
491 |
1181
|
Luisehahne
|
|
492 |
|
|
// ensure that frontend_body.js is only added once per module type
|
493 |
1250
|
Luisehahne
|
if(strpos($body_links, $tmp_link) === false)
|
494 |
|
|
{
|
495 |
1181
|
Luisehahne
|
$body_links .= $tmp_link;
|
496 |
|
|
}
|
497 |
|
|
}
|
498 |
|
|
}
|
499 |
|
|
}
|
500 |
|
|
|
501 |
|
|
print $body_links."\n"; ;
|
502 |
1165
|
Luisehahne
|
}
|
503 |
|
|
}
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the frontend
|
507 |
1181
|
Luisehahne
|
if(!function_exists('register_frontend_modfiles'))
|
508 |
|
|
{
|
509 |
|
|
function register_frontend_modfiles($file_id="css")
|
510 |
|
|
{
|
511 |
1165
|
Luisehahne
|
// sanity check of parameter passed to the function
|
512 |
|
|
$file_id = strtolower($file_id);
|
513 |
1181
|
Luisehahne
|
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
|
514 |
|
|
{
|
515 |
1165
|
Luisehahne
|
return;
|
516 |
|
|
}
|
517 |
|
|
|
518 |
|
|
global $wb, $database, $include_head_link_css, $include_head_links;
|
519 |
|
|
// define default baselink and filename for optional module javascript and stylesheet files
|
520 |
|
|
$head_links = "";
|
521 |
|
|
|
522 |
1181
|
Luisehahne
|
switch ($file_id)
|
523 |
|
|
{
|
524 |
|
|
case 'css':
|
525 |
1165
|
Luisehahne
|
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"';
|
526 |
|
|
$base_link.= ' rel="stylesheet" type="text/css" media="screen" />';
|
527 |
|
|
$base_file = "frontend.css";
|
528 |
1181
|
Luisehahne
|
if(!empty($include_head_link_css))
|
529 |
|
|
{
|
530 |
|
|
$head_links .= !strpos($head_links, $include_head_link_css) ? $include_head_link_css : '';
|
531 |
|
|
$include_head_link_css = '';
|
532 |
|
|
}
|
533 |
|
|
break;
|
534 |
|
|
case 'jquery':
|
535 |
|
|
$head_links .= bind_jquery($file_id);
|
536 |
|
|
break;
|
537 |
|
|
case 'js':
|
538 |
1165
|
Luisehahne
|
$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
|
539 |
|
|
$base_file = "frontend.js";
|
540 |
1181
|
Luisehahne
|
if(!empty($include_head_links))
|
541 |
|
|
{
|
542 |
|
|
$head_links .= !strpos($head_links, $include_head_links) ? $include_head_links : '';
|
543 |
|
|
$include_head_links = '';
|
544 |
|
|
}
|
545 |
|
|
break;
|
546 |
|
|
default:
|
547 |
|
|
break;
|
548 |
1165
|
Luisehahne
|
}
|
549 |
|
|
|
550 |
1181
|
Luisehahne
|
if( $file_id != 'jquery')
|
551 |
|
|
{
|
552 |
|
|
// gather information for all models embedded on actual page
|
553 |
|
|
$page_id = $wb->page_id;
|
554 |
|
|
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
555 |
|
|
WHERE page_id=$page_id AND module<>'wysiwyg'");
|
556 |
1165
|
Luisehahne
|
|
557 |
1181
|
Luisehahne
|
while($row = $query_modules->fetchRow())
|
558 |
|
|
{
|
559 |
|
|
// check if page module directory contains a frontend.js or frontend.css file
|
560 |
|
|
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file"))
|
561 |
|
|
{
|
562 |
|
|
// create link with frontend.js or frontend.css source for the current module
|
563 |
|
|
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
|
564 |
1165
|
Luisehahne
|
|
565 |
1181
|
Luisehahne
|
// define constant indicating that the register_frontent_files was invoked
|
566 |
|
|
if($file_id == 'css')
|
567 |
|
|
{
|
568 |
|
|
if(!defined('MOD_FRONTEND_CSS_REGISTERED')) define('MOD_FRONTEND_CSS_REGISTERED', true);
|
569 |
|
|
} else
|
570 |
|
|
{
|
571 |
|
|
if(!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true);
|
572 |
|
|
}
|
573 |
|
|
// ensure that frontend.js or frontend.css is only added once per module type
|
574 |
|
|
if(strpos($head_links, $tmp_link) === false)
|
575 |
|
|
{
|
576 |
|
|
$head_links .= $tmp_link."\n";
|
577 |
|
|
}
|
578 |
|
|
};
|
579 |
|
|
}
|
580 |
|
|
// include the Javascript email protection function
|
581 |
|
|
if( $file_id != 'css' && file_exists(WB_PATH .'/modules/droplets/js/mdcr.js'))
|
582 |
|
|
{
|
583 |
|
|
$head_links .= '<script src="'.WB_URL.'/modules/droplets/js/mdcr.js" type="text/javascript"></script>'."\n";
|
584 |
|
|
}
|
585 |
|
|
elseif( $file_id != 'css' && file_exists(WB_PATH .'/modules/output_filter/js/mdcr.js'))
|
586 |
|
|
{
|
587 |
|
|
$head_links .= '<script src="'.WB_URL.'/modules/output_filter/js/mdcr.js" type="text/javascript"></script>'."\n";
|
588 |
|
|
}
|
589 |
|
|
}
|
590 |
|
|
print $head_links;
|
591 |
|
|
}
|
592 |
1165
|
Luisehahne
|
}
|
593 |
|
|
|
594 |
|
|
// Begin WB < 2.4.x template compatibility code
|
595 |
|
|
// Make extra_sql accessable through private_sql
|
596 |
|
|
$private_sql = $extra_sql;
|
597 |
|
|
$private_where_sql = $extra_where_sql;
|
598 |
|
|
// Query pages for menu
|
599 |
|
|
$menu1 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '0' AND $extra_where_sql ORDER BY position ASC");
|
600 |
|
|
// Check if current pages is a parent page and if we need its submenu
|
601 |
|
|
if(PARENT == 0) {
|
602 |
|
|
// Get the pages submenu
|
603 |
|
|
$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PAGE_ID."' AND $extra_where_sql ORDER BY position ASC");
|
604 |
|
|
} else {
|
605 |
|
|
// Get the pages submenu
|
606 |
|
|
$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PARENT."' AND $extra_where_sql ORDER BY position ASC");
|
607 |
|
|
}
|
608 |
|
|
// End WB < 2.4.x template compatibility code
|
609 |
|
|
// Include template file
|
610 |
|
|
|
611 |
|
|
|
612 |
1166
|
Luisehahne
|
?>
|