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