1 |
1363
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category framework
|
5 |
|
|
* @package frontend.functions
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
|
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9 |
|
|
* @link http://www.websitebaker2.org/
|
10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
11 |
|
|
* @platform WebsiteBaker 2.8.x
|
12 |
1373
|
Luisehahne
|
* * @requirements PHP 5.2.2 and higher
|
13 |
1363
|
Luisehahne
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL$
|
15 |
|
|
* @lastmodified $Date$
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
|
|
|
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 |
|
|
// workout to included frontend.css, fronten.js and frontend_body.js in snippets
|
43 |
|
|
$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 |
|
|
if (!function_exists('page_link'))
|
73 |
|
|
{
|
74 |
|
|
function page_link($link) {
|
75 |
|
|
global $wb;
|
76 |
|
|
return $wb->page_link($link);
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
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 |
|
|
//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 |
|
|
// Also droplet tags are now excluded from highlighting.
|
107 |
|
|
// 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 |
|
|
$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 |
|
|
if(is_array($matches) && $matches != array()) {
|
112 |
|
|
$foo = "";
|
113 |
|
|
foreach($matches as $match) {
|
114 |
|
|
if($match{0}!="<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}$/i', $match) && !preg_match('~\[\[.*\]\]~', $match)) {
|
115 |
|
|
$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 |
|
|
|
124 |
|
|
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 |
|
|
$wb->menu_header = $menu_header;
|
140 |
|
|
$wb->menu_footer = $menu_footer;
|
141 |
|
|
$wb->menu_default_class = $default_class;
|
142 |
|
|
$wb->menu_current_class = $current_class;
|
143 |
|
|
$wb->menu_recurse = $recurse+2;
|
144 |
|
|
$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 |
|
|
if ($wb->page_access_denied==true)
|
200 |
|
|
{
|
201 |
|
|
echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
|
202 |
|
|
return;
|
203 |
|
|
}
|
204 |
|
|
if ($wb->page_no_active_sections==true)
|
205 |
|
|
{
|
206 |
|
|
echo $MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'];
|
207 |
|
|
return;
|
208 |
|
|
}
|
209 |
|
|
if(isset($globals) AND is_array($globals))
|
210 |
|
|
{
|
211 |
|
|
foreach($globals AS $global_name)
|
212 |
|
|
{
|
213 |
|
|
global $$global_name;
|
214 |
|
|
}
|
215 |
|
|
}
|
216 |
|
|
// Make sure block is numeric
|
217 |
|
|
if(!is_numeric($block)) { $block = 1; }
|
218 |
|
|
// Include page content
|
219 |
|
|
if(!defined('PAGE_CONTENT') OR $block!=1)
|
220 |
|
|
{
|
221 |
|
|
$page_id = intval($wb->page_id);
|
222 |
|
|
// 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 |
|
|
if(($page_id != 0) && ($_SESSION['PAGE_ID'] <> $page_id))
|
226 |
|
|
{
|
227 |
|
|
$_SESSION['PAGE_ID'] = $page_id;
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
// 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 |
|
|
// check if module exists - feature: write in errorlog
|
262 |
|
|
if(file_exists(WB_PATH.'/modules/'.$module.'/view.php')) {
|
263 |
|
|
// fetch content -- this is where to place possible output-filters (before highlighting)
|
264 |
|
|
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 |
|
|
|
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 |
|
|
}
|
284 |
|
|
else
|
285 |
|
|
{
|
286 |
|
|
|
287 |
|
|
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 |
|
|
function show_breadcrumbs($sep = ' » ',$level = 0, $links = true, $depth = -1, $title = '')
|
301 |
|
|
{
|
302 |
|
|
global $wb,$database,$MENU;
|
303 |
|
|
$page_id = $wb->page_id;
|
304 |
|
|
$title = (trim($title) == '') ? $MENU['BREADCRUMB'] : $title;
|
305 |
|
|
if ($page_id != 0)
|
306 |
|
|
{
|
307 |
|
|
$counter = 0;
|
308 |
|
|
// get links as array
|
309 |
|
|
$bread_crumbs = $wb->page_trail;
|
310 |
|
|
$count = sizeof($bread_crumbs);
|
311 |
|
|
// level can't be greater than sum of links
|
312 |
|
|
$level = ($count <= $level ) ? $count-1 : $level;
|
313 |
|
|
// set level from which to show, delete indexes in array
|
314 |
|
|
$crumbs = array_slice($bread_crumbs, $level );
|
315 |
|
|
$depth = ($depth <= 0) ? sizeof($crumbs) : $depth;
|
316 |
|
|
// if empty array, set orginal links
|
317 |
|
|
$crumbs = (!empty($crumbs)) ? $crumbs : $wb->page_trail;
|
318 |
|
|
$total_crumbs = ( ($depth <= 0) || ($depth > sizeof($crumbs)) ) ? sizeof($crumbs) : $depth;
|
319 |
|
|
print '<div class="breadcrumb"><span class="title">'.$title.'</span>';
|
320 |
|
|
// print_r($crumbs);
|
321 |
|
|
foreach ($crumbs as $temp)
|
322 |
|
|
{
|
323 |
|
|
if($counter == $depth) { break; }
|
324 |
|
|
// set links and separator
|
325 |
|
|
$query_menu = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = $temp");
|
326 |
|
|
$page = $query_menu->fetchRow();
|
327 |
|
|
|
328 |
|
|
$show_crumb = (($links == true) && ($temp != $page_id))
|
329 |
|
|
? '<a href="'.page_link($page['link']).'" class="link">'.$page['menu_title'].'</a>'
|
330 |
|
|
: '<span class="crumb">'.$page['menu_title'].'</span>';
|
331 |
|
|
|
332 |
|
|
// Permission
|
333 |
|
|
switch ($page['visibility'])
|
334 |
|
|
{
|
335 |
|
|
case 'none' :
|
336 |
|
|
case 'hidden' :
|
337 |
|
|
// if show, you know there is an error in a hidden page
|
338 |
|
|
print $show_crumb.' ';
|
339 |
|
|
break;
|
340 |
|
|
default :
|
341 |
|
|
print $show_crumb;
|
342 |
|
|
break;
|
343 |
|
|
}
|
344 |
|
|
|
345 |
|
|
if ( ( $counter <> $total_crumbs-1 ) )
|
346 |
|
|
{
|
347 |
|
|
print '<span class="separator">'.$sep.'</span>';
|
348 |
|
|
}
|
349 |
|
|
$counter++;
|
350 |
|
|
}
|
351 |
|
|
print "</div>\n";
|
352 |
|
|
}
|
353 |
|
|
}
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
// Function for page title
|
357 |
|
|
if (!function_exists('page_title')) {
|
358 |
|
|
function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
|
359 |
|
|
$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
|
360 |
|
|
$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
|
361 |
|
|
echo str_replace($vars, $values, $template);
|
362 |
|
|
}
|
363 |
|
|
}
|
364 |
|
|
|
365 |
|
|
// Function for page description
|
366 |
|
|
if (!function_exists('page_description')) {
|
367 |
|
|
function page_description() {
|
368 |
|
|
global $wb;
|
369 |
|
|
if ($wb->page_description!='') {
|
370 |
|
|
echo $wb->page_description;
|
371 |
|
|
} else {
|
372 |
|
|
echo WEBSITE_DESCRIPTION;
|
373 |
|
|
}
|
374 |
|
|
}
|
375 |
|
|
}
|
376 |
|
|
|
377 |
|
|
// Function for page keywords
|
378 |
|
|
if (!function_exists('page_keywords')) {
|
379 |
|
|
function page_keywords() {
|
380 |
|
|
global $wb;
|
381 |
|
|
if ($wb->page_keywords!='') {
|
382 |
|
|
echo $wb->page_keywords;
|
383 |
|
|
} else {
|
384 |
|
|
echo WEBSITE_KEYWORDS;
|
385 |
|
|
}
|
386 |
|
|
}
|
387 |
|
|
}
|
388 |
|
|
|
389 |
|
|
// Function for page header
|
390 |
|
|
if (!function_exists('page_header')) {
|
391 |
|
|
function page_header($date_format = 'Y') {
|
392 |
|
|
echo WEBSITE_HEADER;
|
393 |
|
|
}
|
394 |
|
|
}
|
395 |
|
|
|
396 |
|
|
// Function for page footer
|
397 |
|
|
if (!function_exists('page_footer')) {
|
398 |
|
|
function page_footer($date_format = 'Y') {
|
399 |
|
|
global $starttime;
|
400 |
|
|
$vars = array('[YEAR]', '[PROCESS_TIME]');
|
401 |
|
|
$processtime=array_sum(explode(" ",microtime()))-$starttime;
|
402 |
|
|
$values = array(gmdate($date_format),$processtime);
|
403 |
|
|
echo str_replace($vars, $values, WEBSITE_FOOTER);
|
404 |
|
|
}
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
function bind_jquery ($file_id='jquery')
|
408 |
|
|
{
|
409 |
|
|
|
410 |
|
|
$jquery_links = '';
|
411 |
|
|
/* include the Javascript jquery api */
|
412 |
|
|
if( $file_id == 'jquery' AND file_exists(WB_PATH .'/include/jquery/jquery-min.js'))
|
413 |
|
|
{
|
414 |
|
|
$wbpath = str_replace('\\','/',WB_PATH); // fixed localhost problem with ie
|
415 |
|
|
$jquery_links .= "<script type=\"text/javascript\">\n"
|
416 |
|
|
."var URL = '".WB_URL."';\n"
|
417 |
|
|
/* ."var WB_PATH = '".$wbpath."';\n" */
|
418 |
|
|
."var WB_URL = '".WB_URL."';\n"
|
419 |
|
|
."var TEMPLATE_DIR = '".TEMPLATE_DIR."';\n"
|
420 |
|
|
."</script>\n";
|
421 |
|
|
|
422 |
|
|
$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-min.js" type="text/javascript"></script>'."\n";
|
423 |
|
|
$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-insert.js" type="text/javascript"></script>'."\n";
|
424 |
1369
|
Luisehahne
|
$jquery_links .= '<script src="'.WB_URL.'/include/jquery/jquery-include.js" type="text/javascript"></script>'."\n";
|
425 |
1363
|
Luisehahne
|
/* 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 |
|
|
// Function to add optional module Javascript into the <body> section of the frontend
|
441 |
|
|
if(!function_exists('register_frontend_modfiles_body'))
|
442 |
|
|
{
|
443 |
|
|
function register_frontend_modfiles_body($file_id="js")
|
444 |
|
|
{
|
445 |
|
|
// sanity check of parameter passed to the function
|
446 |
|
|
$file_id = strtolower($file_id);
|
447 |
|
|
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
|
448 |
|
|
{
|
449 |
|
|
return;
|
450 |
|
|
}
|
451 |
|
|
|
452 |
|
|
// 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 |
|
|
global $wb, $database, $include_body_links;
|
455 |
|
|
// define default baselink and filename for optional module javascript files
|
456 |
|
|
$body_links = "";
|
457 |
|
|
|
458 |
|
|
/* include the Javascript jquery api */
|
459 |
|
|
$body_links .= bind_jquery($file_id);
|
460 |
|
|
|
461 |
|
|
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 |
|
|
|
466 |
|
|
// 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 |
|
|
|
476 |
|
|
// gather information for all models embedded on actual page
|
477 |
|
|
$page_id = $wb->page_id;
|
478 |
1368
|
Luisehahne
|
$sql = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
|
479 |
|
|
$sql .= 'WHERE `page_id` = '.(int)$page_id.' AND `module` <> \'wysiwyg\'';
|
480 |
|
|
if( ($query_modules = $database->query($sql)) )
|
481 |
|
|
{
|
482 |
|
|
while($row = $query_modules->fetchRow())
|
483 |
|
|
{
|
484 |
|
|
// check if page module directory contains a frontend_body.js file
|
485 |
|
|
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file"))
|
486 |
|
|
{
|
487 |
|
|
// create link with frontend_body.js source for the current module
|
488 |
|
|
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
|
489 |
1363
|
Luisehahne
|
|
490 |
1368
|
Luisehahne
|
// define constant indicating that the register_frontent_files_body was invoked
|
491 |
|
|
if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) { define('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED', true);}
|
492 |
1363
|
Luisehahne
|
|
493 |
1368
|
Luisehahne
|
// ensure that frontend_body.js is only added once per module type
|
494 |
|
|
if(strpos($body_links, $tmp_link) === false)
|
495 |
|
|
{
|
496 |
|
|
$body_links .= $tmp_link;
|
497 |
|
|
}
|
498 |
|
|
}
|
499 |
|
|
}
|
500 |
|
|
}
|
501 |
1363
|
Luisehahne
|
}
|
502 |
|
|
|
503 |
|
|
print $body_links."\n"; ;
|
504 |
|
|
}
|
505 |
|
|
}
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the frontend
|
509 |
|
|
if(!function_exists('register_frontend_modfiles'))
|
510 |
|
|
{
|
511 |
|
|
function register_frontend_modfiles($file_id="css")
|
512 |
|
|
{
|
513 |
|
|
// sanity check of parameter passed to the function
|
514 |
|
|
$file_id = strtolower($file_id);
|
515 |
|
|
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery")
|
516 |
|
|
{
|
517 |
|
|
return;
|
518 |
|
|
}
|
519 |
|
|
|
520 |
|
|
global $wb, $database, $include_head_link_css, $include_head_links;
|
521 |
|
|
// define default baselink and filename for optional module javascript and stylesheet files
|
522 |
|
|
$head_links = "";
|
523 |
|
|
|
524 |
|
|
switch ($file_id)
|
525 |
|
|
{
|
526 |
|
|
case 'css':
|
527 |
|
|
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"';
|
528 |
|
|
$base_link.= ' rel="stylesheet" type="text/css" media="screen" />';
|
529 |
|
|
$base_file = "frontend.css";
|
530 |
|
|
if(!empty($include_head_link_css))
|
531 |
|
|
{
|
532 |
|
|
$head_links .= !strpos($head_links, $include_head_link_css) ? $include_head_link_css : '';
|
533 |
|
|
$include_head_link_css = '';
|
534 |
|
|
}
|
535 |
|
|
break;
|
536 |
|
|
case 'jquery':
|
537 |
|
|
$head_links .= bind_jquery($file_id);
|
538 |
|
|
break;
|
539 |
|
|
case 'js':
|
540 |
|
|
$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
|
541 |
|
|
$base_file = "frontend.js";
|
542 |
|
|
if(!empty($include_head_links))
|
543 |
|
|
{
|
544 |
|
|
$head_links .= !strpos($head_links, $include_head_links) ? $include_head_links : '';
|
545 |
|
|
$include_head_links = '';
|
546 |
|
|
}
|
547 |
|
|
break;
|
548 |
|
|
default:
|
549 |
|
|
break;
|
550 |
|
|
}
|
551 |
|
|
|
552 |
|
|
if( $file_id != 'jquery')
|
553 |
|
|
{
|
554 |
|
|
// gather information for all models embedded on actual page
|
555 |
|
|
$page_id = $wb->page_id;
|
556 |
1368
|
Luisehahne
|
$sql = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
|
557 |
|
|
$sql .= 'WHERE `page_id` = '.(int)$page_id.' AND `module` <> \'wysiwyg\'';
|
558 |
|
|
if( ($query_modules = $database->query($sql)) )
|
559 |
|
|
{
|
560 |
|
|
while($row = $query_modules->fetchRow())
|
561 |
|
|
{
|
562 |
|
|
// check if page module directory contains a frontend.js or frontend.css file
|
563 |
|
|
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file"))
|
564 |
|
|
{
|
565 |
|
|
// create link with frontend.js or frontend.css source for the current module
|
566 |
|
|
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
|
567 |
1363
|
Luisehahne
|
|
568 |
1368
|
Luisehahne
|
// define constant indicating that the register_frontent_files was invoked
|
569 |
|
|
if($file_id == 'css')
|
570 |
|
|
{
|
571 |
|
|
if(!defined('MOD_FRONTEND_CSS_REGISTERED')) define('MOD_FRONTEND_CSS_REGISTERED', true);
|
572 |
|
|
} else
|
573 |
|
|
{
|
574 |
|
|
if(!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true);
|
575 |
|
|
}
|
576 |
|
|
// ensure that frontend.js or frontend.css is only added once per module type
|
577 |
|
|
if(strpos($head_links, $tmp_link) === false)
|
578 |
|
|
{
|
579 |
|
|
$head_links .= $tmp_link."\n";
|
580 |
|
|
}
|
581 |
|
|
};
|
582 |
|
|
}
|
583 |
|
|
}
|
584 |
|
|
// include the Javascript email protection function
|
585 |
|
|
if( $file_id != 'css' && file_exists(WB_PATH .'/modules/droplets/js/mdcr.js'))
|
586 |
|
|
{
|
587 |
|
|
$head_links .= '<script src="'.WB_URL.'/modules/droplets/js/mdcr.js" type="text/javascript"></script>'."\n";
|
588 |
|
|
}
|
589 |
|
|
elseif( $file_id != 'css' && file_exists(WB_PATH .'/modules/output_filter/js/mdcr.js'))
|
590 |
|
|
{
|
591 |
|
|
$head_links .= '<script src="'.WB_URL.'/modules/output_filter/js/mdcr.js" type="text/javascript"></script>'."\n";
|
592 |
|
|
}
|
593 |
1363
|
Luisehahne
|
}
|
594 |
|
|
print $head_links;
|
595 |
|
|
}
|
596 |
|
|
}
|
597 |
|
|
|
598 |
|
|
// Begin WB < 2.4.x template compatibility code
|
599 |
|
|
// Make extra_sql accessable through private_sql
|
600 |
|
|
$private_sql = $extra_sql;
|
601 |
|
|
$private_where_sql = $extra_where_sql;
|
602 |
|
|
// Query pages for menu
|
603 |
|
|
$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");
|
604 |
|
|
// Check if current pages is a parent page and if we need its submenu
|
605 |
|
|
if(PARENT == 0) {
|
606 |
|
|
// Get the pages submenu
|
607 |
|
|
$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");
|
608 |
|
|
} else {
|
609 |
|
|
// Get the pages submenu
|
610 |
|
|
$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");
|
611 |
|
|
}
|
612 |
|
|
// End WB < 2.4.x template compatibility code
|
613 |
|
|
// Include template file
|
614 |
|
|
|
615 |
|
|
|
616 |
1166
|
Luisehahne
|
?>
|