Project

General

Profile

« Previous | Next » 

Revision 106

Added by stefan about 19 years ago

Renamed compatibility.php to frontend.functions.php.
Moved frontend functions from class frontend to frontend.functions.php.
Removed instances of strip_slashes_dummy. Replaced $this by $wb in a couple of places.
Created file initialize.php, where all initializations now take place (moved from class wb constructor).

View differences:

class.frontend.php
75 75
				$content = fread($handle, filesize($filename));
76 76
				fclose($handle);
77 77
				$this->preprocess($content);
78
				echo $this->strip_slashes_dummy($content);
78
				echo ($content);
79 79
				return false;
80 80
			}
81 81
		}
......
143 143
			// Page ID
144 144
			define('PAGE_ID', $this->page['page_id']);
145 145
			// Page Title
146
			define('PAGE_TITLE', $this->strip_slashes_dummy($this->page['page_title']));
146
			define('PAGE_TITLE', ($this->page['page_title']));
147 147
			$this->page_title=PAGE_TITLE;
148 148
			// Menu Title
149
			$menu_title = $this->strip_slashes_dummy($this->page['menu_title']);
149
			$menu_title = ($this->page['menu_title']);
150 150
			if($menu_title != '') {
151 151
				define('MENU_TITLE', $menu_title);
152 152
			} else {
......
278 278
	}
279 279
	
280 280
	function menu() {
281
	   if (!isset($this->menu_number)) {
282
	   	$this->menu_number = 1;
281
		global $wb;
282
	   if (!isset($wb->menu_number)) {
283
	   	$wb->menu_number = 1;
283 284
	   }
284
	   if (!isset($this->menu_start_level)) {
285
	   	$this->menu_start_level = 0;
285
	   if (!isset($wb->menu_start_level)) {
286
	   	$wb->menu_start_level = 0;
286 287
	   }
287
	   if (!isset($this->menu_recurse)) {
288
	   	$this->menu_recurse = -1;
288
	   if (!isset($wb->menu_recurse)) {
289
	   	$wb->menu_recurse = -1;
289 290
	   }
290
	   if (!isset($this->menu_collapse)) {
291
	   	$this->menu_collapse = true;
291
	   if (!isset($wb->menu_collapse)) {
292
	   	$wb->menu_collapse = true;
292 293
	   }
293
	   if (!isset($this->menu_item_template)) {
294
	   	$this->menu_item_template = '<li><span[class]>[a][menu_title][/a]</span>';
294
	   if (!isset($wb->menu_item_template)) {
295
	   	$wb->menu_item_template = '<li><span[class]>[a][menu_title][/a]</span>';
295 296
	   }
296
	   if (!isset($this->menu_item_footer)) {
297
	   	$this->menu_item_footer = '</li>';
297
	   if (!isset($wb->menu_item_footer)) {
298
	   	$wb->menu_item_footer = '</li>';
298 299
	   }
299
	   if (!isset($this->menu_header)) {
300
	   	$this->menu_header = '<ul>';
300
	   if (!isset($wb->menu_header)) {
301
	   	$wb->menu_header = '<ul>';
301 302
	   }
302
	   if (!isset($this->menu_footer)) {
303
	   	$this->menu_footer = '<ul>';
303
	   if (!isset($wb->menu_footer)) {
304
	   	$wb->menu_footer = '<ul>';
304 305
	   }
305
	   if (!isset($this->menu_default_class)) {
306
	   	$this->menu_default_class = ' class="menu_default"';
306
	   if (!isset($wb->menu_default_class)) {
307
	   	$wb->menu_default_class = ' class="menu_default"';
307 308
	   }
308
	   if (!isset($this->menu_current_class)) {
309
	   	$this->menu_current_class = ' class="menu_current"';
309
	   if (!isset($wb->menu_current_class)) {
310
	   	$wb->menu_current_class = ' class="menu_current"';
310 311
	   }
311
       if (!isset($this->menu_parent)) {
312
     	$this->menu_parent = 0;
312
       if (!isset($wb->menu_parent)) {
313
     	$wb->menu_parent = 0;
313 314
	   }
314
	   $this->show_menu();
315
	   $wb->show_menu();
315 316
	   if ($start_level>0) {
316
	       $key_array=array_keys($this->page_trail);
317
	       $key_array=array_keys($wb->page_trail);
317 318
	       $real_start=$key_array[$start_level-1];
318 319
	       if (isset($real_start))
319 320
	       {
320
	       		$this->menu_parent=$real_start;
321
	          $this->show_menu();
321
	       	$wb->menu_parent=$real_start;
322
	        $wb->show_menu();
322 323
	       }
323 324
	       return;
324 325
	   }
......
327 328
	
328 329
	function show_menu() {
329 330
	   global $database;
330
	   if ($this->menu_recurse==0)
331
	   global $wb;
332
	   if ($wb->menu_recurse==0)
331 333
	       return;
332 334
	   // Check if we should add menu number check to query
333 335
	   if($menu_parent == 0) {
334
	       $menu_number = "menu = '$this->menu_number'";
336
	       $menu_number = "menu = '$wb->menu_number'";
335 337
	   } else {
336 338
	      $menu_number = '1';
337 339
	   }
338 340
	   // Query pages
339 341
	   $query_menu = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility FROM ".
340
	TABLE_PREFIX."pages WHERE parent = '$this->menu_parent' AND $menu_number AND $this->extra_where_sql ORDER BY position ASC");
342
	TABLE_PREFIX."pages WHERE parent = '$wb->menu_parent' AND $menu_number AND $wb->extra_where_sql ORDER BY position ASC");
341 343
	   // Check if there are any pages to show
342 344
	   if($query_menu->numRows() > 0) {
343 345
	   	  // Print menu header
344
	   	  echo "\n".$this->menu_header;
346
	   	  echo "\n".$wb->menu_header;
345 347
	      // Loop through pages
346 348
	      while($page = $query_menu->fetchRow()) {
347 349
	      	 // Check if this page should be shown
......
349 351
	         $vars = array('[class]','[a]', '[/a]', '[menu_title]', '[page_title]');
350 352
	         // Work-out class
351 353
	         if($page['page_id'] == PAGE_ID) {
352
	            $class = $this->menu_current_class;
354
	            $class = $wb->menu_current_class;
353 355
	         } else {
354
	            $class = $this->menu_default_class;
356
	            $class = $wb->menu_default_class;
355 357
	         }
356 358
	         // Check if link is same as first page link, and if so change to WB URL
357
	         if($page['link'] == $this->default_link AND !INTRO_PAGE) {
359
	         if($page['link'] == $wb->default_link AND !INTRO_PAGE) {
358 360
	            $link = WB_URL;
359 361
	         } else {
360
	            $link = $this->page_link($page['link']);
362
	            $link = $wb->page_link($page['link']);
361 363
	         }
362 364
	         // Create values
363
	         $values = array($class,'<a href="'.$link.'" target="'.$page['target'].'" '.$class.'>', '</a>', $this->strip_slashes_dummy($page['menu_title']), $this->strip_slashes_dummy($page['page_title']));
365
	         $values = array($class,'<a href="'.$link.'" target="'.$page['target'].'" '.$class.'>', '</a>', ($page['menu_title']), ($page['page_title']));
364 366
	         // Replace vars with value and print
365
	         echo "\n".str_replace($vars, $values, $this->menu_item_template);
367
	         echo "\n".str_replace($vars, $values, $wb->menu_item_template);
366 368
	         // Generate sub-menu
367
	         if($this->menu_collapse==false OR ($this->menu_collapse==true AND isset($this->page_trail[$page['page_id']]))) {
368
	            $this->menu_recurse--;
369
	            $this->menu_parent=$page['page_id'];
370
	            $this->show_menu();
369
	         if($wb->menu_collapse==false OR ($wb->menu_collapse==true AND isset($wb->page_trail[$page['page_id']]))) {
370
	            $wb->menu_recurse--;
371
	            $wb->menu_parent=$page['page_id'];
372
	            $wb->show_menu();
371 373
	         }
372
	         echo "\n".$this->menu_item_footer;
374
	         echo "\n".$wb->menu_item_footer;
373 375
	      }
374 376
	      // Print menu footer
375
	      echo "\n".$this->menu_footer;
377
	      echo "\n".$wb->menu_footer;
376 378
	   }
377 379
	}
378 380

  
379
	function content($block = 1) {
380
		// Get outside objects
381
		global $TEXT,$MENU,$HEADING,$MESSAGE;
382
		global $globals;
383
		global $database;
384
		$admin = & $this;
385
		if ($this->page_access_denied==true) {
386
            echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
387
			exit();
388
		}
389
		if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
390
		// Make sure block is numeric
391
		if(!is_numeric($block)) { $block = 1; }
392
		// Include page content
393
		if(!defined('PAGE_CONTENT') OR $block!=1) {
394
			if ($this->page_id==0) {
395
				if ($this->default_block_content=='none') {
396
					return;
397
				}
398
				if (is_numeric($this->default_block_content)) {
399
					$page_id=$this->default_block_content;
400
				} else {
401
					$page_id=$this->default_page-id;
402
				}				
403
			} else {
404
				$page_id=$this->page_id;
405
			}
406
			// First get all sections for this page
407
			$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
408
			if($query_sections->numRows() > 0) {
409
				// Loop through them and include there modules file
410
				while($section = $query_sections->fetchRow()) {
411
					$section_id = $section['section_id'];
412
					$module = $section['module'];
413
					require(WB_PATH.'/modules/'.$module.'/view.php');
414
				}
415
			}
416
		} else {
417
			require(PAGE_CONTENT);
418
		}
419
	}
420 381

  
421
	function breadcrumbs($sep=' > ',$tier=1,$links=true) {
422
		$page_id=&$this->page_id;
423
		if ($page_id!=0)
424
		{
425
	 		global $database;
426
			$bca=&$this->page_trail;
427
			if (sizeof($bca)==0)
428
			        create_breadcrumbs($page_id);
429
			$counter=0;
430
			foreach ($bca as $temp)
431
			{
432
		        if ($counter>=(tier-1));
433
		        {
434
					if ($counter>=$tier) echo $sep;
435
					$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
436
					$page=$query_menu->fetchRow();
437
					if ($links==true AND $temp!=$page_id)
438
						echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
439
					else
440
					        echo stripslashes($page['menu_title']);
441
		        }
442
                $counter++;
443
			}
444
		}
445
	}
446

  
447
	// Function for page title
448
	function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
449
		$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
450
		$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
451
		echo str_replace($vars, $values, $template);
452
	}
453

  
454
	// Function for page description
455
	function page_description() {
456
		echo WEBSITE_DESCRIPTION;
457
	}
458
	// Function for page keywords
459
	function page_keywords() {
460
		echo WEBSITE_KEYWORDS;
461
	}
462
	// Function for page header
463
	function page_header($date_format = 'Y') {
464
		echo WEBSITE_HEADER;
465
	}
466

  
467
	// Function for page footer
468
	function page_footer($date_format = 'Y') {
469
		global $starttime;
470
   		$vars = array('[YEAR]', '[PROCESSTIME]');
471
   		$processtime=(microtime()>$starttime)?microtime()-$starttime:microtime()-$starttime+1;
472
		$values = array(date($date_format),$processtime);
473
		echo str_replace($vars, $values, WEBSITE_FOOTER);
474
	}
475

  
476 382
	// Function to show the "Under Construction" page
477 383
	function print_under_construction() {
478 384
		global $MESSAGE;

Also available in: Unified diff