1 |
1358
|
Luisehahne
|
<?php
|
2 |
1839
|
darkviper
|
|
3 |
|
|
/**
|
4 |
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
5 |
1358
|
Luisehahne
|
*
|
6 |
1839
|
darkviper
|
* This program is free software: you can redistribute it and/or modify
|
7 |
|
|
* it under the terms of the GNU General Public License as published by
|
8 |
|
|
* the Free Software Foundation, either version 3 of the License, or
|
9 |
|
|
* (at your option) any later version.
|
10 |
1358
|
Luisehahne
|
*
|
11 |
1839
|
darkviper
|
* This program is distributed in the hope that it will be useful,
|
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
|
|
* GNU General Public License for more details.
|
15 |
|
|
*
|
16 |
|
|
* You should have received a copy of the GNU General Public License
|
17 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
1358
|
Luisehahne
|
*/
|
19 |
1839
|
darkviper
|
/**
|
20 |
|
|
* calling file to create ACP-Pagetree
|
21 |
|
|
*
|
22 |
|
|
* @category WbACP
|
23 |
|
|
* @package WbACP_Pages
|
24 |
|
|
* @author Werner v.d. Decken <wkl@isteam.de>
|
25 |
|
|
* @copyright Werner v.d. Decken <wkl@isteam.de>
|
26 |
|
|
* @license http://www.gnu.org/licenses/gpl.html GPL License
|
27 |
|
|
* @version 1.0.0
|
28 |
|
|
* @revision $Revision$
|
29 |
|
|
* @link $HeadURL$
|
30 |
|
|
* @lastmodified $Date$
|
31 |
|
|
* @since file added on 2012-12-21
|
32 |
|
|
* @todo rebuild this file to go into coding standards (sideeffects!!!)
|
33 |
|
|
*/
|
34 |
1358
|
Luisehahne
|
|
35 |
1839
|
darkviper
|
// --- start helper functions ------------------------------------------------------------
|
36 |
|
|
/**
|
37 |
|
|
* create a list of groups
|
38 |
|
|
* @param type $sPermission which permission the groups should have
|
39 |
|
|
* @return array
|
40 |
|
|
*/
|
41 |
|
|
function admin_pages_makeGroupList($sPermission)
|
42 |
|
|
{
|
43 |
|
|
$aNewGroups = array();
|
44 |
|
|
$sql = 'SELECT `group_id` ID, `name` NAME, \'\' CHECKED, \'\' DISABLED '
|
45 |
|
|
. 'FROM `'.TABLE_PREFIX.'groups` '
|
46 |
|
|
. 'WHERE FIND_IN_SET(\'pages_'.$sPermission.'\', `system_permissions`) '
|
47 |
|
|
. 'ORDER BY `NAME` ASC'
|
48 |
|
|
;
|
49 |
|
|
if(($oGroups = WbDatabase::getInstance()->query($sql))) {
|
50 |
|
|
while($aGroup = $oGroups->fetchRow(MYSQL_ASSOC)) {
|
51 |
|
|
if($aGroup['ID'] == 1) {
|
52 |
|
|
$aGroup['CHECKED'] = ' checked="checked"';
|
53 |
|
|
$aGroup['DISABLED'] = ' disabled="disabled"';
|
54 |
|
|
// move it to topmost position of list
|
55 |
|
|
array_unshift($aNewGroups, $aGroup);
|
56 |
|
|
}else {
|
57 |
|
|
if(in_array($aGroup['ID'], $GLOBALS['admin']->get_groups_id())) {
|
58 |
|
|
$aGroup['CHECKED'] = ' checked="checked"';
|
59 |
|
|
}
|
60 |
|
|
// move it at the end of list
|
61 |
|
|
$aNewGroups[] = $aGroup;
|
62 |
|
|
}
|
63 |
1837
|
Luisehahne
|
}
|
64 |
1358
|
Luisehahne
|
}
|
65 |
1839
|
darkviper
|
return $aNewGroups;
|
66 |
|
|
} // end of admin_pages_makeGroupList()
|
67 |
|
|
// --- end helper functions --------------------------------------------------------------
|
68 |
|
|
// #######################################################################################
|
69 |
|
|
// --- start script ----------------------------------------------------------------------
|
70 |
1358
|
Luisehahne
|
|
71 |
1839
|
darkviper
|
// read configuration and initialize the system
|
72 |
|
|
if(!defined('WB_URL')) {
|
73 |
|
|
$sCfgFile = realpath(dirname(__FILE__).'/../../config.php');
|
74 |
|
|
if(is_readable($sCfgFile)) {
|
75 |
|
|
include($sCfgFile);
|
76 |
|
|
}else {
|
77 |
|
|
throw new RuntimeException('unable to read configuration file!!!');
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
// import languange translations
|
81 |
|
|
global $TEXT, $MESSAGE, $HEADING;
|
82 |
|
|
// define additional constants
|
83 |
|
|
if(!defined('ADMIN_REL')) { define('ADMIN_REL', WB_REL.'/'.ADMIN_DIRECTORY); }
|
84 |
|
|
if(!defined('THEME_REL')) {
|
85 |
|
|
$sTmp = preg_replace('/^'.preg_quote(WB_URL, '/').'/siU', '', THEME_URL);
|
86 |
|
|
define('THEME_REL', WB_REL.$sTmp);
|
87 |
|
|
}
|
88 |
|
|
// create the needed admin object
|
89 |
1837
|
Luisehahne
|
$database = WbDatabase::getInstance();
|
90 |
1839
|
darkviper
|
if(!class_exists('admin', false)) { include(WB_PATH.'/framework/class.admin.php'); }
|
91 |
|
|
$admin = new admin('Pages', 'pages');
|
92 |
|
|
$admin->clearIDKEY();
|
93 |
|
|
// include the WB functions file
|
94 |
|
|
if(!function_exists('get_page_title')) { include(WB_PATH.'/framework/functions.php'); }
|
95 |
|
|
// add module depending Javascript (eggsurplus: add child pages for a specific page)
|
96 |
|
|
$sOutput = '<script type="text/javascript" src="'.ADMIN_REL.'/pages/eggsurplus.js" '
|
97 |
|
|
. 'charset="utf-8"></script>'.PHP_EOL
|
98 |
|
|
. '<script type="text/javascript" charset="utf-8">'.PHP_EOL
|
99 |
|
|
. "\t".'var pages_delete_confirm =\''.$MESSAGE['PAGES_DELETE_CONFIRM'].'\';'.PHP_EOL
|
100 |
|
|
. "\t".'var THEME_URL = \''.THEME_REL.'\';'.PHP_EOL
|
101 |
|
|
. "\t".'var WB_URL = \''.WB_REL.'\';'.PHP_EOL
|
102 |
|
|
. '</script>'.PHP_EOL;
|
103 |
|
|
echo $sOutput;
|
104 |
|
|
// create page tree and display it -------------------------------------------------------
|
105 |
|
|
$oPageTree = new a_pages_PageTree();
|
106 |
|
|
$oPageTree->displayTree();
|
107 |
1837
|
Luisehahne
|
|
108 |
1839
|
darkviper
|
// Setup template object, parse vars to it, then parse it --------------------------------
|
109 |
|
|
$oTpl = new Template(dirname($admin->correct_theme_source('pages.htt')),'keep');
|
110 |
|
|
// $oTpl->debug = true;
|
111 |
|
|
$oTpl->set_file('page', 'pages.htt');
|
112 |
|
|
$oTpl->set_block('page', 'main_block', 'main');
|
113 |
|
|
// Insert values into the add page form
|
114 |
|
|
$oTpl->set_var('FTAN', $admin->getFTAN());
|
115 |
|
|
|
116 |
|
|
// --- admin groups list -----------------------------------------------------------------
|
117 |
|
|
$aAdminGroups = admin_pages_makeGroupList('modify');
|
118 |
|
|
// write block into template
|
119 |
|
|
$oTpl->set_block('main_block', 'admingroups_list_block', 'admingroups_list');
|
120 |
|
|
foreach($aAdminGroups as $aValue) {
|
121 |
|
|
$oTpl->set_var($aValue);
|
122 |
|
|
$oTpl->parse('admingroups_list', 'admingroups_list_block', true);
|
123 |
1837
|
Luisehahne
|
}
|
124 |
1839
|
darkviper
|
unset($aAdminGroups);
|
125 |
|
|
|
126 |
|
|
// --- viewer groups list ----------------------------------------------------------------
|
127 |
|
|
$aViewerGroups = admin_pages_makeGroupList('view');
|
128 |
|
|
// write block into template
|
129 |
|
|
$oTpl->set_block('main_block', 'viewergroups_list_block', 'viewergroups_list');
|
130 |
|
|
foreach($aViewerGroups as $aValue) {
|
131 |
|
|
$oTpl->set_var($aValue);
|
132 |
|
|
$oTpl->parse('viewergroups_list', 'viewergroups_list_block', true);
|
133 |
1358
|
Luisehahne
|
}
|
134 |
1839
|
darkviper
|
unset($aViewerGroups);
|
135 |
|
|
|
136 |
|
|
// --- build parent pages list -----------------------------------------------------------
|
137 |
|
|
$aParents = $oPageTree->getParentList();
|
138 |
1953
|
darkviper
|
$aNewEntry = array();
|
139 |
|
|
$aNewEntry['page_id'] = 0;
|
140 |
|
|
$aNewEntry['menu_title'] = $TEXT['NONE'];
|
141 |
|
|
$aNewEntry['disabled'] = 0;
|
142 |
|
|
$aNewEntry['parent'] = 99;
|
143 |
|
|
$aNewEntry['flag_root_icon'] = '';
|
144 |
|
|
$aNewEntry['level'] = 0;
|
145 |
|
|
$aNewEntry['language'] = '';
|
146 |
|
|
array_unshift($aParents, $aNewEntry);
|
147 |
1839
|
darkviper
|
reset($aParents);
|
148 |
|
|
$oTpl->set_block('main_block', 'parents_list_block', 'parents_list');
|
149 |
|
|
// walk through all items
|
150 |
|
|
while (list(, $aItem) = each($aParents)) {
|
151 |
|
|
if($admin->get_permission('pages_add')) {
|
152 |
1953
|
darkviper
|
$aNewEntry = array();
|
153 |
|
|
$aNewEntry['ID'] = $aItem['page_id'];
|
154 |
|
|
$aNewEntry['PARENT'] = $aItem['parent'];
|
155 |
|
|
$aNewEntry['LEVEL'] = $aItem['level'];
|
156 |
|
|
$aNewEntry['LANGUAGE'] = $aItem['language'];
|
157 |
|
|
$aNewEntry['FLAG_ROOT_ICON'] = '';
|
158 |
1839
|
darkviper
|
// modify item
|
159 |
1953
|
darkviper
|
$aNewEntry['DISABLED'] = ($aItem['disabled'] ? ' disabled="disabled" class="disabled"' : '');
|
160 |
|
|
if(!$aItem['parent']) {
|
161 |
|
|
$aNewEntry['FLAG_ROOT_ICON'] = ' style="background-image: url('.THEME_REL.'/images/flags/'
|
162 |
1839
|
darkviper
|
. strtolower($aItem['LANGUAGE']).'.png);"';
|
163 |
|
|
}
|
164 |
1953
|
darkviper
|
$aNewEntry['TITLE'] = str_repeat('- ', $aItem['level']).$aItem['menu_title'];
|
165 |
1839
|
darkviper
|
// write block into template
|
166 |
1953
|
darkviper
|
$oTpl->set_var($aNewEntry);
|
167 |
1839
|
darkviper
|
$oTpl->parse('parents_list', 'parents_list_block', true);
|
168 |
1358
|
Luisehahne
|
}
|
169 |
|
|
}
|
170 |
1839
|
darkviper
|
unset($aParents);
|
171 |
|
|
// --- build modules list ----------------------------------------------------------------
|
172 |
|
|
$bMatch = false;
|
173 |
|
|
$aModulePermissions = '\''.implode(',', $_SESSION['MODULE_PERMISSIONS']).'\'';
|
174 |
|
|
$sql = 'SELECT `directory` DIRECTORY, `name` NAME, \'\' SELECTED FROM `'.TABLE_PREFIX.'addons` '
|
175 |
|
|
. 'WHERE `type`=\'module\' AND `function`=\'page\' ';
|
176 |
|
|
if($admin->get_user_id() != 1) {
|
177 |
|
|
$sql .= 'AND NOT FIND_IN_SET(`DIRECTORY`, '.$aModulePermissions.') ';
|
178 |
|
|
}
|
179 |
|
|
$sql .= 'ORDER BY `name` ASC';
|
180 |
|
|
if(($oModules = $database->query($sql))) {
|
181 |
|
|
$oTpl->set_block('main_block', 'module_list_block', 'module_list');
|
182 |
|
|
while ($aModule = $oModules->fetchRow(MYSQL_ASSOC)) {
|
183 |
|
|
$bMatch = true;
|
184 |
|
|
// Check if user is allowed to use this module
|
185 |
|
|
$aModule['SELECTED'] = ($aModule['DIRECTORY'] == 'wysiwyg' ? ' selected="selected"' : '');
|
186 |
|
|
$oTpl->set_var($aModule);
|
187 |
|
|
$oTpl->parse('module_list', 'module_list_block', true);
|
188 |
1358
|
Luisehahne
|
}
|
189 |
|
|
}
|
190 |
1839
|
darkviper
|
if(!$bMatch) {
|
191 |
|
|
$aModule = array('DIRECTORY' => '',
|
192 |
|
|
'NAME' => $TEXT['NONE'],
|
193 |
|
|
'SELECTED' => ''
|
194 |
|
|
);
|
195 |
|
|
$oTpl->set_var($aModule);
|
196 |
|
|
$oTpl->parse('module_list', 'module_list_block', true);
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
// --- Insert global replacements --------------------------------------------------------
|
200 |
1358
|
Luisehahne
|
// Insert urls
|
201 |
1839
|
darkviper
|
$oTpl->set_var(array(
|
202 |
|
|
'WB_URL' => WB_REL,
|
203 |
|
|
'ADMIN_URL' => ADMIN_REL,
|
204 |
|
|
'THEME_URL' => THEME_REL,
|
205 |
|
|
'WB_REL' => WB_REL,
|
206 |
|
|
'ADMIN_REL' => ADMIN_REL,
|
207 |
|
|
'THEME_REL' => THEME_REL
|
208 |
|
|
)
|
209 |
|
|
);
|
210 |
1358
|
Luisehahne
|
// Insert language text and messages
|
211 |
1839
|
darkviper
|
$oTpl->set_var(array(
|
212 |
|
|
'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
|
213 |
|
|
'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'],
|
214 |
|
|
'TEXT_TITLE' => $TEXT['TITLE'],
|
215 |
|
|
'TEXT_TYPE' => $TEXT['TYPE'],
|
216 |
|
|
'TEXT_PARENT' => $TEXT['PARENT'],
|
217 |
|
|
'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
|
218 |
|
|
'TEXT_PUBLIC' => $TEXT['PUBLIC'],
|
219 |
|
|
'TEXT_PRIVATE' => $TEXT['PRIVATE'],
|
220 |
|
|
'TEXT_REGISTERED' => $TEXT['REGISTERED'],
|
221 |
|
|
'TEXT_HIDDEN' => $TEXT['HIDDEN'],
|
222 |
|
|
'TEXT_NONE' => $TEXT['NONE'],
|
223 |
|
|
'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
|
224 |
|
|
'TEXT_ADD' => $TEXT['ADD'],
|
225 |
|
|
'TEXT_RESET' => $TEXT['RESET'],
|
226 |
|
|
'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
|
227 |
|
|
'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
|
228 |
|
|
'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
|
229 |
|
|
'INTRO_LINK' => $MESSAGE['PAGES_INTRO_LINK'],
|
230 |
|
|
)
|
231 |
|
|
);
|
232 |
1358
|
Luisehahne
|
// Insert permissions values
|
233 |
1839
|
darkviper
|
if($admin->get_permission('pages_add') != true) {
|
234 |
|
|
$oTpl->set_var('DISPLAY_ADD', 'hide');
|
235 |
|
|
} elseif($admin->get_permission('pages_add_l0') != true && !$oPageTree->getWriteablePages()) {
|
236 |
|
|
$oTpl->set_var('DISPLAY_ADD', 'hide');
|
237 |
|
|
}
|
238 |
|
|
if($admin->get_permission('pages_intro') != true || INTRO_PAGE != 'enabled') {
|
239 |
|
|
$oTpl->set_var('DISPLAY_INTRO', 'hide');
|
240 |
|
|
}
|
241 |
1358
|
Luisehahne
|
// Parse template object
|
242 |
1839
|
darkviper
|
$oTpl->parse('main', 'main_block', false);
|
243 |
|
|
$oTpl->pparse('output', 'page');
|
244 |
|
|
// include the required file for Javascript admin
|
245 |
|
|
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php')) {
|
246 |
|
|
include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
|
247 |
|
|
}
|
248 |
|
|
// Print admin
|
249 |
|
|
$admin->print_footer();
|