1
|
<?php
|
2
|
|
3
|
// $Id: fck_wbmodules.php 1140 2009-09-15 09:49:49Z aldus $
|
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
|
|
29
|
// Create new admin object
|
30
|
require(WB_PATH.'/framework/class.admin.php');
|
31
|
$admin = new admin('Pages', 'pages_modify', false);
|
32
|
|
33
|
// Setup the template
|
34
|
$template = new Template(WB_PATH.'/modules/fckeditor/fckeditor/editor/plugins/WBModules');
|
35
|
$template->set_file('page', 'wbmodules.htt');
|
36
|
$template->set_block('page', 'main_block', 'main');
|
37
|
|
38
|
// Function to generate page list
|
39
|
function gen_page_list($parent) {
|
40
|
global $template, $database, $admin;
|
41
|
$get_pages = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' order by position");
|
42
|
while($page = $get_pages->fetchRow()) {
|
43
|
// method page_is_visible was introduced with WB 2.7
|
44
|
if(method_exists($admin, 'page_is_visible') && !$admin->page_is_visible($page))
|
45
|
continue;
|
46
|
$title = stripslashes($page['menu_title']);
|
47
|
// Add leading -'s so we can tell what level a page is at
|
48
|
$leading_dashes = '';
|
49
|
for($i = 0; $i < $page['level']; $i++) {
|
50
|
$leading_dashes .= '- ';
|
51
|
}
|
52
|
$template->set_var('TITLE', $leading_dashes.' '.$title);
|
53
|
$template->set_var('LINK', '[wblink'.$page['page_id'].']');
|
54
|
/**
|
55
|
Note: FCK uses the header defined in /fckeditor/fckeditor/editor/fckdialog.html
|
56
|
Therefore the WB charset defined in the template: wbmodules.html will be overwritten
|
57
|
Routine kept for now, maybe it is possible to define custom plugin charsets in a future FCK releases (doc)
|
58
|
*/
|
59
|
// work out the specified WB charset
|
60
|
if(defined('DEFAULT_CHARSET')) {
|
61
|
$template->set_var('CHARSET', DEFAULT_CHARSET);
|
62
|
} else {
|
63
|
$template->set_var('CHARSET', 'utf-8');
|
64
|
}
|
65
|
$template->parse('page_list', 'page_list_block', true);
|
66
|
gen_page_list($page['page_id']);
|
67
|
}
|
68
|
}
|
69
|
|
70
|
// Get pages and put them into the pages list
|
71
|
$template->set_block('main_block', 'page_list_block', 'page_list');
|
72
|
$database = new database();
|
73
|
$get_pages = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '0' order by position");
|
74
|
if($get_pages->numRows() > 0) {
|
75
|
// Loop through pages
|
76
|
while($page = $get_pages->fetchRow()) {
|
77
|
// method page_is_visible was introduced with WB 2.7
|
78
|
if(method_exists($admin, 'page_is_visible') && !$admin->page_is_visible($page))
|
79
|
continue;
|
80
|
$title = stripslashes($page['menu_title']);
|
81
|
$template->set_var('TITLE', $title);
|
82
|
$template->set_var('LINK', '[wblink'.$page['page_id'].']');
|
83
|
$template->parse('page_list', 'page_list_block', true);
|
84
|
gen_page_list($page['page_id']);
|
85
|
}
|
86
|
} else {
|
87
|
$template->set_var('TITLE', 'None found');
|
88
|
$template->set_var('LINK', 'None found');
|
89
|
$template->parse('page_list', 'page_list_block', false);
|
90
|
}
|
91
|
|
92
|
// Parse the template object
|
93
|
$template->parse('main', 'main_block', false);
|
94
|
$template->pparse('output', 'page');
|
95
|
|
96
|
?>
|