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