1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package pages
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9
|
* @link http://www.websitebaker2.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.x
|
12
|
* @requirements PHP 5.2.2 and higher
|
13
|
* @version $Id: settings.php 1681 2012-05-02 23:01:05Z darkviper $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/settings.php $
|
15
|
* @lastmodified $Date: 2012-05-03 01:01:05 +0200 (Thu, 03 May 2012) $
|
16
|
*
|
17
|
*/
|
18
|
// Create new admin object
|
19
|
require('../../config.php');
|
20
|
require_once(WB_PATH.'/framework/class.admin.php');
|
21
|
$admin = new admin('Pages', 'pages_settings');
|
22
|
|
23
|
/*-- Parent page list ------------------------------------------------------------------*/
|
24
|
function parent_list($parent)
|
25
|
{
|
26
|
global $admin, $database, $oTpl, $aCurrentPage, $field_set;
|
27
|
$sDisabled = ' disabled="disabled"';
|
28
|
$sSelected = ' selected="selected"';
|
29
|
|
30
|
$sql = 'SELECT `page_id`, `level`, `parent`, `menu_title`, `page_title`, '
|
31
|
. '`language`, `admin_groups`, `admin_users`, `visibility`, '
|
32
|
. '`viewing_groups`, `viewing_users` '
|
33
|
. 'FROM `'.TABLE_PREFIX.'pages` '
|
34
|
. 'WHERE `parent`='.$parent.' '
|
35
|
. 'ORDER BY `position` ASC';
|
36
|
$get_pages = $database->query($sql);
|
37
|
|
38
|
while($page = $get_pages->fetchRow(MYSQL_ASSOC))
|
39
|
{
|
40
|
if(!$admin->page_is_visible($page)) { continue; }
|
41
|
// if parent = 0 set flag_icon
|
42
|
$oTpl->set_var('FLAG_ROOT_ICON',' none ');
|
43
|
if( $page['parent'] == 0 && $field_set) {
|
44
|
$oTpl->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
|
45
|
}
|
46
|
// If the current page cannot be parent, then its children neither
|
47
|
$list_next_level = true;
|
48
|
// Stop users from adding pages with a level of more than the set page level limit
|
49
|
if($page['level']+1 < PAGE_LEVEL_LIMIT)
|
50
|
{
|
51
|
// Get user permisions
|
52
|
$can_modify = ($admin->ami_group_member($page['admin_groups']) ||
|
53
|
$admin->is_group_match($admin->get_user_id(), $page['admin_users']));
|
54
|
// Title -'s prefix
|
55
|
$title_prefix = '';
|
56
|
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - '; }
|
57
|
$oTpl->set_var(array(
|
58
|
'ID' => $page['page_id'],
|
59
|
'TITLE' => ($title_prefix.$page['menu_title']),
|
60
|
'MENU-TITLE' => ($title_prefix.$page['menu_title']),
|
61
|
'PAGE-TITLE' => ($title_prefix.$page['page_title']),
|
62
|
'FLAG_ICON' => ' none ',
|
63
|
));
|
64
|
if($aCurrentPage['parent'] == $page['page_id']) {
|
65
|
$oTpl->set_var('SELECTED', $sSelected);
|
66
|
} elseif($aCurrentPage['page_id'] == $page['page_id']) {
|
67
|
$oTpl->set_var('SELECTED', $sDisabled.' class="disabled"');
|
68
|
$list_next_level=false;
|
69
|
} elseif($can_modify != true) {
|
70
|
$oTpl->set_var('SELECTED', $sDisabled.' class="disabled"');
|
71
|
} else {
|
72
|
$oTpl->set_var('SELECTED', '');
|
73
|
}
|
74
|
$oTpl->parse('parent_page_list', 'parent_page_list_block', true);
|
75
|
}
|
76
|
if ($list_next_level) {
|
77
|
parent_list($page['page_id']);
|
78
|
}
|
79
|
}
|
80
|
} // end of function parent_list
|
81
|
/* -------------------------------------------------------------------------------------*/
|
82
|
$mLang = ModLanguage::getInstance();
|
83
|
$mLang->setLanguage(dirname(__FILE__).'/languages/', LANGUAGE, DEFAULT_LANGUAGE);
|
84
|
$sDisabled = ' disabled="disabled"';
|
85
|
$sSelected = ' selected="selected"';
|
86
|
$sChecked = ' checked="checked"';
|
87
|
|
88
|
// Get page id
|
89
|
$page_id = $_GET['page_id'] ? intval($_GET['page_id']) : 0;
|
90
|
if(!$page_id) {
|
91
|
header("Location: index.php");
|
92
|
exit(0);
|
93
|
}
|
94
|
/*-- get all details of current page ---------------------------------------------------*/
|
95
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
|
96
|
if( ($oPages = $database->query($sql)) ) {
|
97
|
$aCurrentPage = $oPages->fetchRow(MYSQL_ASSOC);
|
98
|
// Work-out if we should check for existing page_code
|
99
|
$field_set = isset($aCurrentPage['page_code']);
|
100
|
if( !$admin->ami_group_member($aCurrentPage['admin_groups']) &&
|
101
|
!$admin->is_group_match($admin->get_user_id(), $aCurrentPage['admin_users']) )
|
102
|
{
|
103
|
$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
|
104
|
}
|
105
|
}else {
|
106
|
$admin->print_header();
|
107
|
$admin->print_error($database->get_error());
|
108
|
}
|
109
|
if(!isset($aCurrentPage['page_code'])) {
|
110
|
$database->field_add(TABLE_PREFIX.'pages', 'page_code', 'INT NOT NULL DEFAULT \'0\'');
|
111
|
}
|
112
|
if($oPages->numRows() == 0) {
|
113
|
$admin->print_header();
|
114
|
$admin->print_error($MESSAGE['PAGES_NOT_FOUND']);
|
115
|
}
|
116
|
// Get display name of person who last modified the page
|
117
|
$user=$admin->get_user_details($aCurrentPage['modified_by']);
|
118
|
// Convert the unix ts for modified_when to human a readable form
|
119
|
if($aCurrentPage['modified_when'] != 0) {
|
120
|
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $aCurrentPage['modified_when']+TIMEZONE);
|
121
|
}else {
|
122
|
$modified_ts = 'Unknown';
|
123
|
}
|
124
|
// Setup template object, parse vars to it, then parse it
|
125
|
// Create new template object
|
126
|
$oTpl = new Template(dirname($admin->correct_theme_source('pages_settings.htt')), 'keep');
|
127
|
$oTpl->set_file('page', 'pages_settings.htt');
|
128
|
$oTpl->set_block('page', 'main_block', 'main');
|
129
|
$oTpl->set_var('FTAN', $admin->getFTAN());
|
130
|
$oTpl->set_var(array(
|
131
|
'PAGE_ID' => $aCurrentPage['page_id'],
|
132
|
'PAGE_IDKEY' => $admin->getIDKEY($aCurrentPage['page_id']),
|
133
|
'PAGE_TITLE' => ($aCurrentPage['page_title']),
|
134
|
'MENU_TITLE' => ($aCurrentPage['menu_title']),
|
135
|
'DESCRIPTION' => ($aCurrentPage['description']),
|
136
|
'KEYWORDS' => ($aCurrentPage['keywords']),
|
137
|
'MODIFIED_BY' => $user['display_name'],
|
138
|
'MODIFIED_BY_USERNAME' => $user['username'],
|
139
|
'MODIFIED_WHEN' => $modified_ts,
|
140
|
'ADMIN_URL' => ADMIN_URL,
|
141
|
'WB_URL' => WB_URL,
|
142
|
'THEME_URL' => THEME_URL
|
143
|
));
|
144
|
/*-- workout if we should show the "manage sections" link ------------------------------*/
|
145
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` '
|
146
|
. 'WHERE `page_id`='.$page_id.' AND `module`=\'menu_link\'';
|
147
|
$bIsMenuLink = (intval($database->get_one($sql)) != 0);
|
148
|
$oTpl->set_block('main_block', 'show_manage_sections_block', 'show_manage_sections');
|
149
|
if(!$bIsMenuLink && (MANAGE_SECTIONS == true)) {
|
150
|
$oTpl->parse('show_manage_sections', 'show_manage_sections_block', true);
|
151
|
}else {
|
152
|
$oTpl->set_block('show_manage_sections', '');
|
153
|
}
|
154
|
|
155
|
/*-- collect page-icons for select boxes -----------------------------------------------*/
|
156
|
$sAllowedImageTypes = '\.jpg|\.jpeg|\.png|\.gif';
|
157
|
$aPageIcons = array();
|
158
|
$aIcon = array();
|
159
|
$sTemplate = ($aCurrentPage['template'] == '' ? DEFAULT_TEMPLATE : $aCurrentPage['template']);
|
160
|
$sIconDir = str_replace('\\', '/', ((defined('PAGE_ICON_DIR') && PAGE_ICON_DIR != '') ? PAGE_ICON_DIR : MEDIA_DIRECTORY));
|
161
|
$sIconDir = str_replace('/*', '/'.$sTemplate, $sIconDir);
|
162
|
$oTpl->set_var('ICON_DIR', WB_REL.$sIconDir);
|
163
|
if(is_readable(WB_PATH.$sIconDir)) {
|
164
|
$oIterator = new DirectoryIterator(WB_PATH.$sIconDir);
|
165
|
foreach ($oIterator as $fileinfo) {
|
166
|
if(preg_match('/'.$sAllowedImageTypes.'$/i', $fileinfo->getFilename())) {
|
167
|
$sItem = str_replace(WB_PATH, '', str_replace('\\', '/', $fileinfo->getPathname()));
|
168
|
// $sItem = WB_REL.$sItem;
|
169
|
$aPageIcons[] = array('VALUE'=>$sItem, 'NAME'=>$fileinfo->getFilename());
|
170
|
}
|
171
|
}
|
172
|
}
|
173
|
/*-- show page-icon select box ---------------------------------------------------------*/
|
174
|
$oTpl->set_block('main_block', 'page_icon_list_block', 'page_icon_list');
|
175
|
foreach($aPageIcons as $value) {
|
176
|
$aIcon = $value;
|
177
|
$aIcon['SELECTED'] = ($aCurrentPage['page_icon'] == $aIcon['VALUE'] ? $sSelected : '');
|
178
|
$oTpl->set_var($aIcon);
|
179
|
$oTpl->parse('page_icon_list', 'page_icon_list_block', true);
|
180
|
}
|
181
|
/*-- show menu-icon-0 select box -------------------------------------------------------*/
|
182
|
$oTpl->set_block('main_block', 'menu_icon0_list_block', 'menu_icon0_list');
|
183
|
foreach($aPageIcons as $value) {
|
184
|
$aIcon = $value;
|
185
|
$aIcon['SELECTED'] = ($aCurrentPage['menu_icon_0'] == $aIcon['VALUE'] ? $sSelected : '');
|
186
|
$oTpl->set_var($aIcon);
|
187
|
$oTpl->parse('menu_icon0_list', 'menu_icon0_list_block', true);
|
188
|
}
|
189
|
/*-- show menu-icon-1 select box -------------------------------------------------------*/
|
190
|
$oTpl->set_block('main_block', 'menu_icon1_list_block', 'menu_icon1_list');
|
191
|
foreach($aPageIcons as $value) {
|
192
|
$aIcon = $value;
|
193
|
$aIcon['SELECTED'] = ($aCurrentPage['menu_icon_1'] == $aIcon['VALUE'] ? $sSelected : '');
|
194
|
$oTpl->set_var($aIcon);
|
195
|
$oTpl->parse('menu_icon1_list', 'menu_icon1_list_block', true);
|
196
|
}
|
197
|
|
198
|
/*-- show visibility select box --------------------------------------------------------*/
|
199
|
$aVisibility = array();
|
200
|
$aVisibility['PUBLIC_SELECTED'] = ($aCurrentPage['visibility'] == 'public' ? $sSelected : '');
|
201
|
$aVisibility['PRIVATE_SELECTED'] = ($aCurrentPage['visibility'] == 'private' ? $sSelected : '');
|
202
|
$aVisibility['REGISTERED_SELECTED'] = ($aCurrentPage['visibility'] == 'registered' ? $sSelected : '');
|
203
|
$aVisibility['HIDDEN_SELECTED'] = ($aCurrentPage['visibility'] == 'hidden' ? $sSelected : '');
|
204
|
$aVisibility['NO_VIS_SELECTED'] = ($aCurrentPage['visibility'] == 'none' ? $sSelected : '');
|
205
|
$oTpl->set_var($aVisibility);
|
206
|
|
207
|
/*-- admin group list block ------------------------------------------------------------*/
|
208
|
$aAdminGroups = explode(',', '1,'.$aCurrentPage['admin_groups']);
|
209
|
$sAdminGroups = implode(',', array_unique($aAdminGroups));
|
210
|
$sql = 'SELECT `group_id` `ID`, `name` `NAME`, `system_permissions` `permissions` '
|
211
|
. 'FROM `'.TABLE_PREFIX.'groups` '
|
212
|
. 'ORDER BY (`ID` NOT IN('.$sAdminGroups.')), `NAME`';
|
213
|
if( ($oGroups = $database->query($sql)))
|
214
|
{
|
215
|
$oTpl->set_block('main_block', 'admin_group_list_block', 'admin_group_list');
|
216
|
while( $aGroup = $oGroups->fetchRow(MYSQL_ASSOC))
|
217
|
{
|
218
|
if($aGroup['ID'] == 1) {
|
219
|
// never uncheck admin group
|
220
|
$aGroup['CHECKED'] = $sChecked;
|
221
|
$aGroup['DISABLED'] = $sDisabled;
|
222
|
}else {
|
223
|
// skip groups without system_permissions
|
224
|
if(!$admin->is_group_match('pages_modify', $aGroup['permissions'])) { continue; }
|
225
|
// check already selected groups
|
226
|
$bChecked = $admin->is_group_match($aGroup['ID'], $aCurrentPage['admin_groups']);
|
227
|
// disable selected groups where current user is not member of
|
228
|
$bDisabled = !$admin->ami_group_member($aGroup['ID']);
|
229
|
$aGroup['CHECKED'] = $bChecked ? $sChecked : '';
|
230
|
$aGroup['DISABLED'] = ($bChecked && $bDisabled) ? $sDisabled : '';
|
231
|
}
|
232
|
unset($aGroup['permissions']);
|
233
|
$oTpl->set_var($aGroup);
|
234
|
$oTpl->parse('admin_group_list', 'admin_group_list_block', true);
|
235
|
}
|
236
|
}
|
237
|
|
238
|
/*-- viewer group list block -----------------------------------------------------------*/
|
239
|
$aViewingGroups = explode(',', '1,'.$aCurrentPage['viewing_groups']);
|
240
|
$sViewingGroups = implode(',', array_unique($aViewingGroups));
|
241
|
$oTpl->set_block('main_block', 'viewer_group_list_block', 'viewer_group_list');
|
242
|
$sql = 'SELECT `group_id` `ID`, `name` `NAME` '
|
243
|
. 'FROM `'.TABLE_PREFIX.'groups` '
|
244
|
. 'ORDER BY (`ID` NOT IN('.$sViewingGroups.')), `NAME`';
|
245
|
if(($oGroups = $database->query($sql))) {
|
246
|
while($aGroup = $oGroups->fetchRow(MYSQL_ASSOC)) {
|
247
|
if($aGroup['ID'] == 1) {
|
248
|
// never uncheck admin group
|
249
|
$aGroup['CHECKED'] = $sChecked;
|
250
|
$aGroup['DISABLED'] = $sDisabled;
|
251
|
}else {
|
252
|
// check already selected groups
|
253
|
$bChecked = $admin->is_group_match($aGroup['ID'], $aCurrentPage['viewing_groups']);
|
254
|
// disable selected groups where current user is not member of
|
255
|
$bDisabled = !$admin->ami_group_member($aGroup['ID']);
|
256
|
$aGroup['CHECKED'] = $bChecked ? $sChecked : '';
|
257
|
$aGroup['DISABLED'] = ($bChecked && $bDisabled) ? $sDisabled : '';
|
258
|
}
|
259
|
$oTpl->set_var($aGroup);
|
260
|
$oTpl->parse('viewer_group_list', 'viewer_group_list_block', true);
|
261
|
}
|
262
|
}
|
263
|
|
264
|
/*-- admin user list block -------------------------------------------------------------*/
|
265
|
$aAdminUsers = ($aCurrentPage['admin_users'] == ''
|
266
|
? array()
|
267
|
: explode(',', $aCurrentPage['admin_users']));
|
268
|
$aAdminUsers = explode(',', $aCurrentPage['admin_users']);
|
269
|
$oTpl->set_block('main_block', 'admin_user_list_block', 'admin_user_list');
|
270
|
$sAllowedAdminUsers = trim(implode(',',$aAdminUsers));
|
271
|
$sAllowedAdminUsers = $sAllowedAdminUsers ? $sAllowedAdminUsers : '-1';
|
272
|
$sql = 'SELECT `user_id`, `display_name` '
|
273
|
. 'FROM `'.TABLE_PREFIX.'users` '
|
274
|
. 'WHERE `active`=1 '
|
275
|
. 'ORDER BY (`user_id` NOT IN('.$sAllowedAdminUsers.')), `display_name`';
|
276
|
if( ($oUsers = $database->query($sql)) ) {
|
277
|
while($aUser = $oUsers->fetchRow(MYSQL_ASSOC)) {
|
278
|
if($aUser['user_id'] == 1) { continue; }
|
279
|
$oTpl->set_var(array(
|
280
|
'ID' => $aUser['user_id'],
|
281
|
'NAME' => $aUser['display_name'],
|
282
|
'SELECTED' => (in_array($aUser['user_id'], $aAdminUsers) ? $sSelected : ''),
|
283
|
));
|
284
|
$oTpl->parse('admin_user_list', 'admin_user_list_block', true);
|
285
|
}
|
286
|
}
|
287
|
|
288
|
/*-- viewer users list block -----------------------------------------------------------*/
|
289
|
$aViewingUsers = ($aCurrentPage['viewing_users'] == ''
|
290
|
? array()
|
291
|
: explode(',', $aCurrentPage['viewing_users']));
|
292
|
$aViewingUsers = explode(',', $aCurrentPage['viewing_users']);
|
293
|
$oTpl->set_block('main_block', 'viewer_user_list_block', 'viewer_user_list');
|
294
|
$sAllowedViewingUsers = trim(implode(',',$aViewingUsers));
|
295
|
$sAllowedViewingUsers = $sAllowedViewingUsers ? $sAllowedViewingUsers : '-1';
|
296
|
$sql = 'SELECT `user_id`, `display_name` '
|
297
|
. 'FROM `'.TABLE_PREFIX.'users` '
|
298
|
. 'WHERE `active`=1 '
|
299
|
. 'ORDER BY (`user_id` NOT IN('.$sAllowedViewingUsers.')), `display_name`';
|
300
|
if( ($oUsers = $database->query($sql)) ) {
|
301
|
while($aUser = $oUsers->fetchRow(MYSQL_ASSOC)) {
|
302
|
if($aUser['user_id'] == 1) { continue; }
|
303
|
$oTpl->set_var(array(
|
304
|
'ID' => $aUser['user_id'],
|
305
|
'NAME' => $aUser['display_name'],
|
306
|
'SELECTED' => (in_array($aUser['user_id'], $aViewingUsers) ? $sSelected : ''),
|
307
|
));
|
308
|
$oTpl->parse('viewer_user_list', 'viewer_user_list_block', true);
|
309
|
}
|
310
|
}
|
311
|
|
312
|
/*-- size user lists -------------------------------------------------------------------*/
|
313
|
$aSkaleSizeOfList = array(0 => 5, 12 => 10, 25 => 20, 50 => 30, 75 => 40, 100 => 50);
|
314
|
$iListSize = 6;
|
315
|
if($oUsers) {
|
316
|
$iNumberOfUsers = $oUsers->numRows();
|
317
|
foreach($aSkaleSizeOfList as $key => $val){
|
318
|
if($iNumberOfUsers > $key) {
|
319
|
$iListSize = $val;
|
320
|
}else { break; }
|
321
|
}
|
322
|
}
|
323
|
$oTpl->set_var('USER_LIST_SIZE', $iListSize);
|
324
|
|
325
|
/*-- show private viewers block --------------------------------------------------------*/
|
326
|
if($aCurrentPage['visibility'] == 'private' OR $aCurrentPage['visibility'] == 'registered')
|
327
|
{
|
328
|
$oTpl->set_var('DISPLAY_VIEWERS', '');
|
329
|
} else {
|
330
|
$oTpl->set_var('DISPLAY_VIEWERS', 'display:none;');
|
331
|
}
|
332
|
/*-- start multilanguage page_code 20090904 --------------------------------------------*/
|
333
|
// Work-out if page languages feature is enabled
|
334
|
$oTpl->set_block('main_block', 'show_page_code_block', 'show_page_code');
|
335
|
if( (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) &&
|
336
|
isset($aCurrentPage['page_code']) &&
|
337
|
file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php') )
|
338
|
{
|
339
|
// workout field is set but module missing
|
340
|
$oTpl->set_var('TEXT_PAGE_CODE',
|
341
|
'<a href="'.WB_URL.'/modules/mod_multilingual/update_keys.php?page_id='.
|
342
|
$page_id.'">'.$mLang->TEXT_PAGE_CODE.'</a>'
|
343
|
);
|
344
|
/*-- begin recursive function page_code list ---------------------------------------*/
|
345
|
function page_code_list($parent)
|
346
|
{
|
347
|
global $admin, $database, $oTpl, $aCurrentPage, $pageCode;
|
348
|
$default_language = DEFAULT_LANGUAGE;
|
349
|
|
350
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` '
|
351
|
. 'WHERE `parent`='.$parent.' AND `language`=\''.$default_language.'\' '
|
352
|
. 'ORDER BY `position` ASC';
|
353
|
$get_pages = $database->query($sql);
|
354
|
|
355
|
while($page = $get_pages->fetchRow(MYSQL_ASSOC))
|
356
|
{
|
357
|
if(($admin->page_is_visible($page)==false) && ($page['visibility'] <> 'none') ) { continue; }
|
358
|
|
359
|
$oTpl->set_var('FLAG_CODE_ICON',' none ');
|
360
|
if( $page['parent'] == 0 )
|
361
|
{
|
362
|
$oTpl->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
|
363
|
}
|
364
|
|
365
|
// If the current page cannot be parent, then its children neither
|
366
|
$list_next_level = true;
|
367
|
// Stop users from adding pages with a level of more than the set page level limit
|
368
|
if($page['level']+1 < PAGE_LEVEL_LIMIT)
|
369
|
{
|
370
|
$can_modify = ($admin->ami_group_member($page['admin_groups']) ||
|
371
|
$admin->is_group_match($admin->get_user_id(), $page['admin_users']));
|
372
|
$title_prefix = '';
|
373
|
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - '; }
|
374
|
// $space = str_repeat(' ', 3); $space.'<'..'>'
|
375
|
$oTpl->set_var(array(
|
376
|
'VALUE' => intval($page['page_code']),
|
377
|
'PAGE_VALUE' => $title_prefix.$page['menu_title'],
|
378
|
'PAGE_CODE' => $title_prefix.$page['page_id']
|
379
|
)
|
380
|
);
|
381
|
if($aCurrentPage['page_code'] == $page['page_code'])
|
382
|
{
|
383
|
$oTpl->set_var('SELECTED', ' selected="selected"');
|
384
|
} elseif($aCurrentPage['page_code'] == $page['page_code'])
|
385
|
{
|
386
|
$oTpl->set_var('SELECTED', ' disabled="disabled" class="disabled"');
|
387
|
$list_next_level=false;
|
388
|
} elseif($can_modify != true)
|
389
|
{
|
390
|
$oTpl->set_var('SELECTED', ' disabled="disabled" class="disabled"');
|
391
|
} else {
|
392
|
$oTpl->set_var('SELECTED', '');
|
393
|
}
|
394
|
$oTpl->parse('page_code_list', 'page_code_list_block', true);
|
395
|
}
|
396
|
if ($list_next_level)
|
397
|
page_code_list($page['page_id']);
|
398
|
}
|
399
|
}
|
400
|
/*-- end recursive function page_code list -----------------------------------------*/
|
401
|
// Insert code_page values from page to modify
|
402
|
$oTpl->set_block('show_page_code_block', 'page_code_list_block', 'page_code_list');
|
403
|
if($admin->get_permission('pages_add_l0') == true OR $aCurrentPage['level'] == 0) {
|
404
|
$selected = ($aCurrentPage['parent'] == 0 ? $sSelected : '');
|
405
|
$oTpl->set_var(array(
|
406
|
'VALUE' => 0,
|
407
|
'PAGE_CODE' => $mLang->TEXT_NONE,
|
408
|
'PAGE_VALUE' => '',
|
409
|
'SELECTED' => $selected
|
410
|
)
|
411
|
);
|
412
|
$oTpl->parse('page_code_list', 'page_code_list_block', true);
|
413
|
}
|
414
|
// get pagecode form this page_id
|
415
|
page_code_list(0);
|
416
|
$oTpl->parse('show_page_code', 'show_page_code_block', true);
|
417
|
}else {
|
418
|
$oTpl->set_block('show_page_code', '');
|
419
|
}
|
420
|
/*-- end multilanguage page_code 20090904 ----------------------------------------------*/
|
421
|
|
422
|
/*-- show list of parent pages ---------------------------------------------------------*/
|
423
|
$oTpl->set_block('main_block', 'parent_page_list_block', 'parent_page_list');
|
424
|
if($admin->get_permission('pages_add_l0') == true OR $aCurrentPage['level'] == 0) {
|
425
|
$oTpl->set_var(array(
|
426
|
'ID' => '0',
|
427
|
'TITLE' => $mLang->TEXT_NONE,
|
428
|
'SELECTED' => ($aCurrentPage['parent'] == 0 ? $sSelected : ''),
|
429
|
) );
|
430
|
$oTpl->parse('parent_page_list', 'parent_page_list_block', true);
|
431
|
}
|
432
|
parent_list(0);
|
433
|
$oTpl->set_var('DISPLAY_MODIFIED', ($modified_ts == 'Unknown' ? 'hide' : ''));
|
434
|
|
435
|
/*-- show list of templates ------------------------------------------------------------*/
|
436
|
$oTpl->set_block('main_block', 'template_list_block', 'template_list');
|
437
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
|
438
|
. 'WHERE `type`=\'template\' AND `function`=\'template\' '
|
439
|
. 'ORDER BY `name`';
|
440
|
if(($res_templates = $database->query($sql))) {
|
441
|
while($rec_template = $res_templates->fetchRow(MYSQL_ASSOC)) {
|
442
|
// Check if the user has perms to use this template
|
443
|
if($rec_template['directory'] == $aCurrentPage['template'] OR
|
444
|
$admin->get_permission($rec_template['directory'], 'template'))
|
445
|
{
|
446
|
$oTpl->set_var('VALUE', $rec_template['directory']);
|
447
|
$oTpl->set_var('NAME', $rec_template['name']);
|
448
|
if($rec_template['directory'] == $aCurrentPage['template']) {
|
449
|
$oTpl->set_var('SELECTED', $sSelected);
|
450
|
} else {
|
451
|
$oTpl->set_var('SELECTED', '');
|
452
|
}
|
453
|
$oTpl->parse('template_list', 'template_list_block', true);
|
454
|
}
|
455
|
}
|
456
|
}
|
457
|
|
458
|
/*-- show menu select box --------------------------------------------------------------*/
|
459
|
$oTpl->set_block('main_block', 'show_menu_list_block', 'show_menu_list');
|
460
|
if(MULTIPLE_MENUS)
|
461
|
{
|
462
|
/*-- get menusettings from template info file --------------------------------------*/
|
463
|
function getTemplateInfo($sTpl = '') {
|
464
|
if(!$sTpl) { $sTpl = DEFAULT_TEMPLATE; }
|
465
|
$sTplFile = WB_PATH.'/templates/'.$sTpl.'/info.php';
|
466
|
if(is_readable($sTplFile)) { require_once($sTplFile); }
|
467
|
$menu = isset($menu) ? $menu : array();
|
468
|
return $menu;
|
469
|
}
|
470
|
$aMenu = getTemplateInfo($aCurrentPage['template']);
|
471
|
// set menu[1] as default if there's no entry in info.php
|
472
|
$aMenu[1] = (!isset($aMenu[1]) OR ($aMenu[1] == '')) ? $TEXT['MAIN'] : $aMenu[1];
|
473
|
$oTpl->set_block('show_menu_list_block', 'menu_list_block', 'menu_list');
|
474
|
foreach($aMenu as $iIndex => $sMenuName) {
|
475
|
$aVars = array();
|
476
|
$aVars['NAME'] = $sMenuName;
|
477
|
$aVars['VALUE'] = $iIndex;
|
478
|
$aVars['SELECTED'] = ($aCurrentPage['menu'] == $iIndex) ? $sSelected : '';
|
479
|
$oTpl->set_var($aVars);
|
480
|
$oTpl->parse('menu_list', 'menu_list_block', true);
|
481
|
}
|
482
|
$oTpl->parse('show_menu_list', 'show_menu_list_block', true);
|
483
|
}else {
|
484
|
$oTpl->set_block('show_menu_list', '');
|
485
|
}
|
486
|
|
487
|
/*-- show language select box ----------------------------------------------------------*/
|
488
|
$sql = 'SELECT `directory`, `name` FROM `'.TABLE_PREFIX.'addons` '
|
489
|
. 'WHERE `type`=\'language\' ';
|
490
|
if( !defined('PAGE_LANGUAGES') || !PAGE_LANGUAGES) {
|
491
|
// display only default and current language if site is single language only
|
492
|
$sql .= 'AND `directory`=\''.DEFAULT_LANGUAGE.'\' ';
|
493
|
if($aCurrentPage['language'] != DEFAULT_LANGUAGE) {
|
494
|
$sql .= 'AND `directory`=\''.$aCurrentPage['language'].'\' ';
|
495
|
}
|
496
|
}
|
497
|
$sql .= 'ORDER BY `name`';
|
498
|
if( ($oLanguages = $database->query($sql)) )
|
499
|
{
|
500
|
$aAvailLanguages = array();
|
501
|
while($aLanguage = $oLanguages->fetchRow(MYSQL_ASSOC)) {
|
502
|
$aAvailLanguages[$aLanguage['directory']] = $aLanguage['name'];
|
503
|
}
|
504
|
natsort($aAvailLanguages);
|
505
|
$oTpl->set_block('main_block', 'language_list_block', 'language_list');
|
506
|
foreach($aAvailLanguages as $key => $val) {
|
507
|
$oTpl->set_var(array(
|
508
|
'VALUE' => $key,
|
509
|
'NAME' => $val,
|
510
|
'FLAG_LANG_ICONS' => 'url('.THEME_URL.'/images/flags/'.strtolower($key).'.png)',
|
511
|
'SELECTED' => ($aCurrentPage['language'] == $key ? $sSelected : ''),
|
512
|
));
|
513
|
$oTpl->parse('language_list', 'language_list_block', true);
|
514
|
}
|
515
|
}
|
516
|
|
517
|
/*-- show search activated box ---------------------------------------------------------*/
|
518
|
$oTpl->set_var('SEARCHING_SELECTED_ON', ($aCurrentPage['searching'] == 0) ? '' : $sSelected);
|
519
|
$oTpl->set_var('SEARCHING_SELECTED_OFF', ($aCurrentPage['searching'] == 0) ? $sSelected : '');
|
520
|
|
521
|
/*-- show target select box ------------------------------------------------------------*/
|
522
|
$oTpl->set_var('TOP_SELECTED', ($aCurrentPage['target'] == '_top' ? $sSelected : ''));
|
523
|
$oTpl->set_var('SELF_SELECTED', ($aCurrentPage['target'] == '_self' ? $sSelected : ''));
|
524
|
$oTpl->set_var('BLANK_SELECTED', ($aCurrentPage['target'] == '_blank' ? $sSelected : ''));
|
525
|
|
526
|
/*-- insert all needed vars from language files ----------------------------------------*/
|
527
|
$oTpl->set_var($mLang->getLangArray());
|
528
|
/*-- finalize the page -----------------------------------------------------------------*/
|
529
|
$oTpl->parse('main', 'main_block', false);
|
530
|
$oTpl->pparse('output', 'page');
|
531
|
// Print admin footer
|
532
|
$admin->print_footer();
|