Project

General

Profile

1
<?php
2

    
3
// Include the config file
4
require('../../../../../../config.php');
5

    
6
// Create new admin object
7
require(WB_PATH.'/framework/class.admin.php');
8
$admin = new admin('Pages', 'pages_modify', false);
9

    
10
// Setup the template
11
$template = new Template(WB_PATH.'/modules/fckeditor/fckeditor/editor/plugins/WBModules');
12
$template->set_file('page', 'wbmodules.html');
13
$template->set_block('page', 'main_block', 'main');
14

    
15
// Function to generate page list
16
function gen_page_list($parent) {
17
	global $template, $database, $admin;
18
	$get_pages = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent'");
19
	while($page = $get_pages->fetchRow()) {
20
		if(!$admin->page_is_visible($page))
21
			continue;
22
		$title = stripslashes($page['menu_title']);
23
		// Add leading -'s so we can tell what level a page is at
24
		$leading_dashes = '';
25
		for($i = 0; $i < $page['level']; $i++) {
26
			$leading_dashes .= '- ';
27
		}
28
		$template->set_var('TITLE', $leading_dashes.' '.$title);
29
		$template->set_var('LINK', '[wblink'.$page['page_id'].']');
30
		/**
31
			Note: FCK uses the header defined in /fckeditor/fckeditor/editor/fckdialog.html
32
			Therefore the WB charset defined in the template: wbmodules.html will be overwritten
33
			Routine kept for now, maybe it is possible to define custom plugin charsets in a future FCK releases (doc)
34
		*/
35
		// work out the specified WB charset 
36
		if(defined('DEFAULT_CHARSET')) { 
37
			$template->set_var('CHARSET', DEFAULT_CHARSET);
38
		} else { 
39
			$template->set_var('CHARSET', 'utf-8');
40
		}
41
		$template->parse('page_list', 'page_list_block', true);
42
		gen_page_list($page['page_id']);
43
	}
44
}
45

    
46
// Get pages and put them into the pages list
47
$template->set_block('main_block', 'page_list_block', 'page_list');
48
$database = new database();
49
$get_pages = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '0'");
50
if($get_pages->numRows() > 0) {
51
	// Loop through pages
52
	while($page = $get_pages->fetchRow()) {
53
		if(!$admin->page_is_visible($page))
54
			continue;
55
		$title = stripslashes($page['menu_title']);
56
		$template->set_var('TITLE', $title);
57
		$template->set_var('LINK', '[wblink'.$page['page_id'].']');
58
		$template->parse('page_list', 'page_list_block', true);
59
		gen_page_list($page['page_id']);
60
	}
61
} else {
62
	$template->set_var('TITLE', 'None found');
63
	$template->set_var('LINK', 'None found');
64
	$template->parse('page_list', 'page_list_block', false);
65
}
66

    
67
// Parse the template object
68
$template->parse('main', 'main_block', false);
69
$template->pparse('output', 'page');
70

    
71
?>
(1-1/7)