Project

General

Profile

1
<?php
2

    
3
// $Id: fck_wbmodules.php 1359 2010-12-28 09:06:16Z Luisehahne $
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
// Include the config file
27
require('../../../../../../config.php');
28
// Create new admin object
29
require(WB_PATH.'/framework/class.admin.php');
30
$admin = new admin('Pages', 'pages_modify', false);
31

    
32
// Setup the template
33
$template = new Template(WB_PATH.'/modules/fckeditor/fckeditor/editor/plugins/WBModules');
34
$template->set_file('page', 'wbmodules.htt');
35
$template->set_block('page', 'main_block', 'main');
36

    
37
// Function to generate page list
38
function gen_page_list($parent) {
39
	global $template, $database, $admin;
40
	$get_pages = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' order by position");
41
	while($page = $get_pages->fetchRow()) {
42
		// method page_is_visible was introduced with WB 2.7
43
		if(method_exists($admin, 'page_is_visible') && !$admin->page_is_visible($page))
44
			continue;
45
		$title = stripslashes($page['menu_title']);
46
		// Add leading -'s so we can tell what level a page is at
47
		$leading_dashes = '';
48
		for($i = 0; $i < $page['level']; $i++) {
49
			$leading_dashes .= '- ';
50
		}
51
		$template->set_var('TITLE', $leading_dashes.' '.$title);
52
		$template->set_var('LINK', '[wblink'.$page['page_id'].']');
53
		/**
54
			Note: FCK uses the header defined in /fckeditor/fckeditor/editor/fckdialog.html
55
			Therefore the WB charset defined in the template: wbmodules.html will be overwritten
56
			Routine kept for now, maybe it is possible to define custom plugin charsets in a future FCK releases (doc)
57
		*/
58
		// work out the specified WB charset 
59
		if(defined('DEFAULT_CHARSET')) { 
60
			$template->set_var('CHARSET', DEFAULT_CHARSET);
61
		} else { 
62
			$template->set_var('CHARSET', 'utf-8');
63
		}
64
		$template->parse('page_list', 'page_list_block', true);
65
		gen_page_list($page['page_id']);
66
	}
67
}
68

    
69
// Get pages and put them into the pages list
70
$template->set_block('main_block', 'page_list_block', 'page_list');
71
$get_pages = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '0' order by position");
72
if($get_pages->numRows() > 0) {
73
	// Loop through pages
74
	while($page = $get_pages->fetchRow()) {
75
		// method page_is_visible was introduced with WB 2.7
76
		if(method_exists($admin, 'page_is_visible') && !$admin->page_is_visible($page))
77
			continue;
78
		$title = stripslashes($page['menu_title']);
79
		$template->set_var('TITLE', $title);
80
		$template->set_var('LINK', '[wblink'.$page['page_id'].']');
81
		$template->parse('page_list', 'page_list_block', true);
82
		gen_page_list($page['page_id']);
83
	}
84
} else {
85
	$template->set_var('TITLE', 'None found');
86
	$template->set_var('LINK', 'None found');
87
	$template->parse('page_list', 'page_list_block', false);
88
}
89

    
90
// Parse the template object
91
$template->parse('main', 'main_block', false);
92
$template->pparse('output', 'page');
93

    
94
?>
(1-1/7)