1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package pages
|
6
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8
|
* @link http://www.websitebaker.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.x
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: settings.php 2091 2014-01-20 14:16:54Z darkviper $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/settings.php $
|
14
|
* @lastmodified $Date: 2014-01-20 15:16:54 +0100 (Mon, 20 Jan 2014) $
|
15
|
*
|
16
|
*/
|
17
|
// Create new admin object
|
18
|
if(!defined('WB_URL'))
|
19
|
{
|
20
|
$config_file = realpath('../../config.php');
|
21
|
if(file_exists($config_file) && !defined('WB_URL'))
|
22
|
{
|
23
|
require($config_file);
|
24
|
}
|
25
|
}
|
26
|
|
27
|
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
|
28
|
|
29
|
$admin = new admin('Pages', 'pages_settings');
|
30
|
/*-- Parent page list ------------------------------------------------------------------*/
|
31
|
function parent_list($parent)
|
32
|
{
|
33
|
global $admin, $database, $oTpl, $aCurrentPage, $field_set;
|
34
|
$sDisabled = ' disabled="disabled"';
|
35
|
$sSelected = ' selected="selected"';
|
36
|
|
37
|
$sql = 'SELECT `page_id`, `level`, `link`, `parent`, `menu_title`, `page_title`, '
|
38
|
. '`language`, `admin_groups`, `admin_users`, `visibility`, '
|
39
|
. '`viewing_groups`, `viewing_users` '
|
40
|
. 'FROM `'.TABLE_PREFIX.'pages` '
|
41
|
. 'WHERE `parent`='.$parent.' '
|
42
|
. 'ORDER BY `position` ASC';
|
43
|
$get_pages = $database->query($sql);
|
44
|
|
45
|
while($page = $get_pages->fetchRow(MYSQL_ASSOC))
|
46
|
{
|
47
|
if(!$admin->page_is_visible($page)) { continue; }
|
48
|
// if parent = 0 set flag_icon
|
49
|
$oTpl->set_var('FLAG_ROOT_ICON',' none ');
|
50
|
if( $page['parent'] == 0 && $field_set) {
|
51
|
$oTpl->set_var('FLAG_ROOT_ICON','url('.WB_REL.'/'.str_replace(WB_URL, '', THEME_URL).'/images/flags/'.strtolower($page['language']).'.png)');
|
52
|
}
|
53
|
// If the current page cannot be parent, then its children neither
|
54
|
$list_next_level = true;
|
55
|
// Stop users from adding pages with a level of more than the set page level limit
|
56
|
if($page['level']+1 < PAGE_LEVEL_LIMIT)
|
57
|
{
|
58
|
// Get user permisions
|
59
|
$can_modify = ($admin->ami_group_member($page['admin_groups']) ||
|
60
|
$admin->is_group_match($admin->get_user_id(), $page['admin_users']));
|
61
|
// Title -'s prefix
|
62
|
$title_prefix = '';
|
63
|
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - '; }
|
64
|
$oTpl->set_var(array(
|
65
|
'ID' => $page['page_id'],
|
66
|
'TITLE' => ($title_prefix.$page['menu_title']),
|
67
|
'MENU-TITLE' => ($title_prefix.$page['menu_title']),
|
68
|
'PAGE-TITLE' => ($title_prefix.$page['page_title']),
|
69
|
'FLAG_ICON' => ' none ',
|
70
|
));
|
71
|
if($aCurrentPage['parent'] == $page['page_id']) {
|
72
|
$oTpl->set_var('SELECTED', $sSelected);
|
73
|
} elseif($aCurrentPage['page_id'] == $page['page_id']) {
|
74
|
$oTpl->set_var('SELECTED', $sDisabled.' class="disabled"');
|
75
|
$list_next_level=false;
|
76
|
} elseif($can_modify != true) {
|
77
|
$oTpl->set_var('SELECTED', $sDisabled.' class="disabled"');
|
78
|
} else {
|
79
|
$oTpl->set_var('SELECTED', '');
|
80
|
}
|
81
|
$oTpl->parse('parent_page_list', 'parent_page_list_block', true);
|
82
|
}
|
83
|
if ($list_next_level) {
|
84
|
parent_list($page['page_id']);
|
85
|
}
|
86
|
}
|
87
|
} // end of function parent_list
|
88
|
/* -------------------------------------------------------------------------------------*/
|
89
|
// $mLang = ModLanguage::getInstance();
|
90
|
// $mLang->setLanguage(dirname(__FILE__).'/languages/', LANGUAGE, DEFAULT_LANGUAGE);
|
91
|
$mLang = Translate::getInstance();
|
92
|
$mLang->enableAddon('admin\pages');
|
93
|
$oDb = WbDatabase::getInstance();
|
94
|
$sDisabled = ' disabled="disabled"';
|
95
|
$sSelected = ' selected="selected"';
|
96
|
$sChecked = ' checked="checked"';
|
97
|
|
98
|
// Get page id
|
99
|
$page_id = $_GET['page_id'] ? intval($_GET['page_id']) : 0;
|
100
|
if(!$page_id) {
|
101
|
header("Location: index.php");
|
102
|
exit(0);
|
103
|
}
|
104
|
/*-- get all details of current page ---------------------------------------------------*/
|
105
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
|
106
|
if( ($oPages = $database->query($sql)) ) {
|
107
|
$aCurrentPage = $oPages->fetchRow(MYSQL_ASSOC);
|
108
|
// Work-out if we should set seo_title
|
109
|
$aCurrentPage['seo_title'] = basename($aCurrentPage['link']);
|
110
|
// Work-out if we should check for existing page_code
|
111
|
$field_set = isset($aCurrentPage['page_code']);
|
112
|
if( !$admin->ami_group_member($aCurrentPage['admin_groups']) &&
|
113
|
!$admin->is_group_match($admin->get_user_id(), $aCurrentPage['admin_users']) )
|
114
|
{
|
115
|
$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
|
116
|
}
|
117
|
} else {
|
118
|
$admin->print_header();
|
119
|
$admin->print_error($database->get_error());
|
120
|
}
|
121
|
if(!isset($aCurrentPage['page_code'])) {
|
122
|
$database->field_add(TABLE_PREFIX.'pages', 'page_code', 'INT NOT NULL DEFAULT \'0\'');
|
123
|
}
|
124
|
if($oPages->numRows() == 0) {
|
125
|
$admin->print_header();
|
126
|
$admin->print_error($MESSAGE['PAGES_NOT_FOUND']);
|
127
|
}
|
128
|
/* -------------------------------------------------------------------------------------*/
|
129
|
|
130
|
/*-- test if multilanguage page_code -----------------------------------------------------*/
|
131
|
function getLangInUsedDbResult ( $sLangKey='' ) {
|
132
|
global $admin,$aCurrentPage;
|
133
|
$aPage = array();
|
134
|
$aRetval = array();
|
135
|
$oDb = WbDatabase::getInstance();
|
136
|
if( (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && class_exists('m_MultiLingual_Lib'))
|
137
|
{
|
138
|
$sql = 'SELECT DISTINCT `language`,'
|
139
|
. '`page_id`,`level`,`parent`,`root_parent`,`page_code`,`link`,'
|
140
|
. '`visibility`,`viewing_groups`,`viewing_users`,`position`,`page_title` '
|
141
|
. 'FROM `'.$oDb->TablePrefix.'pages` '
|
142
|
. 'WHERE `level`= 0 '
|
143
|
. 'AND `root_parent`=`page_id` '
|
144
|
. 'AND (`visibility`!=\'none\' '
|
145
|
. 'AND `visibility`!=\'hidden\') '
|
146
|
. ( ($sLangKey!='') ? ' AND `language` = \''.$sLangKey.'\' ' : '')
|
147
|
// . ( (defined('MULTIPLE_MENUS') && MULTIPLE_MENUS == 'true') ? ' AND `menu` = \''.$aCurrentPage['menu'].'\' ' : '')
|
148
|
. 'GROUP BY `language` '
|
149
|
. 'ORDER BY `position`';
|
150
|
if($oRes = $oDb->query($sql)){
|
151
|
while($aPage = $oRes->fetchRow(MYSQL_ASSOC))
|
152
|
{
|
153
|
if(!$admin->page_is_visible($aPage)) {continue;}
|
154
|
$aRetval[$aPage['language']] = $aPage;
|
155
|
}
|
156
|
}
|
157
|
}
|
158
|
return ( sizeof($aRetval) ? $aRetval : false);
|
159
|
}
|
160
|
/* -------------------------------------------------------------------------------------*/
|
161
|
// Get display name of person who last modified the page
|
162
|
$user=$admin->get_user_details($aCurrentPage['modified_by']);
|
163
|
// Convert the unix ts for modified_when to human a readable form
|
164
|
if($aCurrentPage['modified_when'] != 0) {
|
165
|
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $aCurrentPage['modified_when']+TIMEZONE);
|
166
|
} else {
|
167
|
$modified_ts = 'Unknown';
|
168
|
}
|
169
|
// Setup template object, parse vars to it, then parse it
|
170
|
// Create new template object
|
171
|
$oTpl = new Template(dirname($admin->correct_theme_source('pages_settings.htt')),'keep' );
|
172
|
$oTpl->set_file('page', 'pages_settings.htt');
|
173
|
$oTpl->set_block('page', 'main_block', 'main');
|
174
|
$oTpl->set_var('FTAN', $admin->getFTAN());
|
175
|
// $sShowIconDirText = $mLang->TEXT_EXPAND'].' ';
|
176
|
$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name` = \'page_extendet\'';
|
177
|
// if($page_extend = $database->get_one($sql)) {}
|
178
|
$page_extend = (defined('PAGE_EXTENDET') ? filter_var(PAGE_EXTENDET, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) : false);
|
179
|
$sShowIconDirText = ($page_extend==true) ? $mLang->TEXT_HIDE_ADVANCED : $mLang->TEXT_SHOW_ADVANCED;
|
180
|
|
181
|
$oTpl->set_var(array(
|
182
|
'PAGE_ID' => $aCurrentPage['page_id'],
|
183
|
'PAGE_IDKEY' => $admin->getIDKEY($aCurrentPage['page_id']),
|
184
|
'PAGE_TITLE' => ($aCurrentPage['page_title']),
|
185
|
'PAGE_LINK' => ($aCurrentPage['link']),
|
186
|
'MENU_TITLE' => ($aCurrentPage['menu_title']),
|
187
|
'SEO_TITLE' => ($aCurrentPage['seo_title']=='') ? $aCurrentPage['menu_title'] : $aCurrentPage['seo_title'],
|
188
|
'DESCRIPTION' => ($aCurrentPage['description']),
|
189
|
'KEYWORDS' => ($aCurrentPage['keywords']),
|
190
|
'MODIFIED_BY' => $user['display_name'],
|
191
|
'MODIFIED_BY_USERNAME' => $user['username'],
|
192
|
'MODIFIED_WHEN' => $modified_ts,
|
193
|
'TEXT_SAVE_BACK' => $mLang->TEXT_SAVE.' & '.$mLang->TEXT_BACK,
|
194
|
'TEXT_EXTENDED' => $sShowIconDirText,
|
195
|
'VISIBILITY' => 'visibility',
|
196
|
'ADMIN_URL' => ADMIN_URL,
|
197
|
'WB_URL' => WB_URL,
|
198
|
'THEME_URL' => THEME_URL
|
199
|
));
|
200
|
|
201
|
if( $admin->get_permission('pages_modify') )
|
202
|
{
|
203
|
$oTpl->set_var(array(
|
204
|
'MODIFY_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/modify.php?page_id='.$aCurrentPage['page_id'].'">',
|
205
|
'MODIFY_LINK_AFTER' => '</a>',
|
206
|
'DISPLAY_MANAGE_MODIFY' => 'link',
|
207
|
));
|
208
|
} else {
|
209
|
$oTpl->set_var(array(
|
210
|
'MODIFY_LINK_BEFORE' => '<span class="bold grey">',
|
211
|
'MODIFY_LINK_AFTER' => '</span>',
|
212
|
'DISPLAY_MANAGE_MODIFY' => 'link',
|
213
|
));
|
214
|
}
|
215
|
|
216
|
|
217
|
/*-- workout if we should show the "manage sections" link ------------------------------*/
|
218
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` '
|
219
|
. 'WHERE `page_id`='.$page_id.' AND `module`=\'menu_link\'';
|
220
|
$bIsMenuLink = (intval($database->get_one($sql)) != 0);
|
221
|
// $oTpl->set_block('main_block', 'show_manage_sections_block', 'show_manage_sections');
|
222
|
// if(!$bIsMenuLink && (MANAGE_SECTIONS == true) && $admin->get_permission('pages_add') )
|
223
|
if((MANAGE_SECTIONS == true) && $admin->get_permission('pages_add') )
|
224
|
{
|
225
|
// $oTpl->parse('show_manage_sections', 'show_manage_sections_block', true);
|
226
|
$oTpl->set_var(array(
|
227
|
'SECTIONS_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/sections.php?page_id='.$aCurrentPage['page_id'].'">',
|
228
|
'SECTIONS_LINK_AFTER' => '</a>',
|
229
|
'DISPLAY_MANAGE_SECTIONS' => 'link',
|
230
|
));
|
231
|
} else {
|
232
|
// $oTpl->set_block('show_manage_sections', '');
|
233
|
$oTpl->set_var(array(
|
234
|
'SECTIONS_LINK_BEFORE' => '<span class="bold grey">',
|
235
|
'SECTIONS_LINK_AFTER' => '</span>',
|
236
|
'DISPLAY_MANAGE_SECTIONS' => 'link',
|
237
|
));
|
238
|
}
|
239
|
|
240
|
/*-- collect page-icons for select boxes -----------------------------------------------*/
|
241
|
$sAllowedImageTypes = '\.jpg|\.jpeg|\.png|\.gif';
|
242
|
$aPageIcons = array();
|
243
|
$aIcon = array();
|
244
|
$sTemplate = ($aCurrentPage['template'] == '' ? DEFAULT_TEMPLATE : $aCurrentPage['template']);
|
245
|
$sIconDir = str_replace('\\', '/', ((defined('PAGE_ICON_DIR') && PAGE_ICON_DIR != '') ? PAGE_ICON_DIR : MEDIA_DIRECTORY));
|
246
|
$sIconDir = str_replace('/*', '/'.$sTemplate, $sIconDir);
|
247
|
$bMenuIconDirHide = (($page_extend==true) ? 'display:block;' : 'display:none;');
|
248
|
$bPageIconDirHide = (($page_extend==true) ? 'display:block;' : 'display:none;');
|
249
|
// $bPageIconDirHide = (($page_extend==true)||($admin->get_permission('media_view') == true) ? 'display:block;' : 'display:none;');
|
250
|
|
251
|
// $oTpl->set_var('ICON_DIR', WB_REL.$sIconDir);
|
252
|
$sHelp = replaceVars($mLang->HELP_PAGE_IMAGE_DIR, array('icon_dir'=>WB_REL.$sIconDir ) );
|
253
|
|
254
|
$sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` '
|
255
|
. 'WHERE `page_id`='.$page_id.' ';
|
256
|
$sAccesFile = (($database->get_one($sql)));
|
257
|
$sFilename = replaceVars($mLang->HELP_SEO_TITLE, array('filename'=>PAGES_DIRECTORY.$sAccesFile.PAGE_EXTENSION ) );
|
258
|
|
259
|
$oTpl->set_var('PAGE_ICONDIR_HIDE', $bPageIconDirHide);
|
260
|
$oTpl->set_var('PAGE_EXTENDET_HIDE', $bMenuIconDirHide);
|
261
|
$oTpl->set_var('p_page_icon_dir', p($sHelp,$mLang->TEXT_PAGE_ICON_DIR));
|
262
|
$oTpl->set_var('p_menu_icon0_dir', p($sHelp,$mLang->TEXT_MENU_ICON_0_DIR));
|
263
|
$oTpl->set_var('p_menu_icon1_dir', p($sHelp,$mLang->TEXT_MENU_ICON_1_DIR));
|
264
|
$oTpl->set_var('p_menu_page_code', p($mLang->HELP_PAGE_CODE,$mLang->TEXT_PAGE_CODE));
|
265
|
$oTpl->set_var('p_menu_filename', p($sFilename,$mLang->TEXT_SEO_TITLE));
|
266
|
|
267
|
if(is_readable(WB_PATH.$sIconDir)) {
|
268
|
$oIterator = new DirectoryIterator(WB_PATH.$sIconDir);
|
269
|
foreach ($oIterator as $fileinfo) {
|
270
|
if(preg_match('/'.$sAllowedImageTypes.'$/i', $fileinfo->getFilename())) {
|
271
|
$sItem = str_replace(str_replace('\\', '/', WB_PATH), '',
|
272
|
str_replace('\\', '/', $fileinfo->getPathname()));
|
273
|
// $sItem = WB_REL.$sItem;
|
274
|
$aPageIcons[] = array('VALUE'=>$sItem, 'NAME'=>$fileinfo->getFilename());
|
275
|
}
|
276
|
}
|
277
|
}
|
278
|
/*-- show page-icon select box ---------------------------------------------------------*/
|
279
|
$oTpl->set_block('main_block', 'page_icon_list_block', 'page_icon_list');
|
280
|
if(sizeof($aPageIcons)>0){
|
281
|
foreach($aPageIcons as $value) {
|
282
|
$aIcon = $value;
|
283
|
$aIcon['SELECTED'] = ($aCurrentPage['page_icon'] == $aIcon['VALUE'] ? $sSelected : '');
|
284
|
$oTpl->set_var($aIcon);
|
285
|
$oTpl->parse('page_icon_list', 'page_icon_list_block', true);
|
286
|
}
|
287
|
} else {
|
288
|
$oTpl->parse('page_icon_list', '');
|
289
|
}
|
290
|
/*-- show menu-icon-0 select box -------------------------------------------------------*/
|
291
|
$oTpl->set_block('main_block', 'menu_icon0_list_block', 'menu_icon0_list');
|
292
|
if(sizeof($aPageIcons)>0){
|
293
|
foreach($aPageIcons as $value) {
|
294
|
$aIcon = $value;
|
295
|
$aIcon['SELECTED'] = ($aCurrentPage['menu_icon_0'] == $aIcon['VALUE'] ? $sSelected : '');
|
296
|
$oTpl->set_var($aIcon);
|
297
|
$oTpl->parse('menu_icon0_list', 'menu_icon0_list_block', true);
|
298
|
}
|
299
|
} else {
|
300
|
$oTpl->parse('menu_icon0_list', '');
|
301
|
}
|
302
|
/*-- show menu-icon-1 select box -------------------------------------------------------*/
|
303
|
$oTpl->set_block('main_block', 'menu_icon1_list_block', 'menu_icon1_list');
|
304
|
if(sizeof($aPageIcons)>0){
|
305
|
foreach($aPageIcons as $value) {
|
306
|
$aIcon = $value;
|
307
|
$aIcon['SELECTED'] = ($aCurrentPage['menu_icon_1'] == $aIcon['VALUE'] ? $sSelected : '');
|
308
|
$oTpl->set_var($aIcon);
|
309
|
$oTpl->parse('menu_icon1_list', 'menu_icon1_list_block', true);
|
310
|
}
|
311
|
} else {
|
312
|
$oTpl->parse('menu_icon1_list', '');
|
313
|
}
|
314
|
/*-- show visibility select box --------------------------------------------------------*/
|
315
|
$aVisibility = array();
|
316
|
$sLangKey = '';
|
317
|
if( sizeof(getLangInUsedDbResult())>1 ) {
|
318
|
$sLangKey = DEFAULT_LANGUAGE;
|
319
|
$aLangStartPageId = array();
|
320
|
$aLangStartPageId = getLangInUsedDbResult($sLangKey);
|
321
|
$iLangStartPageId = $aLangStartPageId[$sLangKey]['page_id'];
|
322
|
}
|
323
|
|
324
|
$aVisibility['PUBLIC_SELECTED'] = ($aCurrentPage['visibility'] == 'public' ? $sSelected : '');
|
325
|
$aVisibility['PRIVATE_SELECTED'] = ($aCurrentPage['visibility'] == 'private' ? $sSelected : '');
|
326
|
$aVisibility['REGISTERED_SELECTED'] = ($aCurrentPage['visibility'] == 'registered' ? $sSelected : '');
|
327
|
$aVisibility['HIDDEN_SELECTED'] = ($aCurrentPage['visibility'] == 'hidden' ? $sSelected : '');
|
328
|
$aVisibility['NO_VIS_SELECTED'] = ($aCurrentPage['visibility'] == 'none' ? $sSelected : '');
|
329
|
if( ($aCurrentPage['language'] == $sLangKey) && ($aCurrentPage['page_id']==$iLangStartPageId) ) {
|
330
|
$aVisibility['HIDDEN_SELECTED'] = ($aCurrentPage['visibility'] == 'hidden' ? $sDisabled : $sDisabled);
|
331
|
$aVisibility['NO_VIS_SELECTED'] = ($aCurrentPage['visibility'] == 'none' ? $sDisabled : $sDisabled);
|
332
|
}
|
333
|
$oTpl->set_var($aVisibility);
|
334
|
/*-- admin group list block ------------------------------------------------------------*/
|
335
|
$aAdminGroups = explode(',', '1,'.$aCurrentPage['admin_groups']);
|
336
|
$sAdminGroups = implode(',', array_unique($aAdminGroups));
|
337
|
$sql = 'SELECT `group_id` `ID`, `name` `NAME`, `system_permissions` `permissions` '
|
338
|
. 'FROM `'.TABLE_PREFIX.'groups` '
|
339
|
. 'ORDER BY (`ID` NOT IN('.$sAdminGroups.')), `NAME`';
|
340
|
if( ($oGroups = $database->query($sql)))
|
341
|
{
|
342
|
$oTpl->set_block('main_block', 'admin_group_list_block', 'admin_group_list');
|
343
|
while( $aGroup = $oGroups->fetchRow(MYSQL_ASSOC))
|
344
|
{
|
345
|
if($aGroup['ID'] == 1) {
|
346
|
// never uncheck admin group
|
347
|
$aGroup['CHECKED'] = $sChecked;
|
348
|
$aGroup['DISABLED'] = $sDisabled;
|
349
|
}else {
|
350
|
// skip groups without system_permissions
|
351
|
if(!$admin->is_group_match('pages_modify', $aGroup['permissions'])) { continue; }
|
352
|
// check already selected groups
|
353
|
$bChecked = $admin->is_group_match($aGroup['ID'], $aCurrentPage['admin_groups']);
|
354
|
// disable selected groups where current user is not member of
|
355
|
$bDisabled = !$admin->ami_group_member('1');
|
356
|
$aGroup['CHECKED'] = $bChecked ? $sChecked : '';
|
357
|
$aGroup['DISABLED'] = ($bChecked && $bDisabled) ? $sDisabled : '';
|
358
|
}
|
359
|
unset($aGroup['permissions']);
|
360
|
$oTpl->set_var($aGroup);
|
361
|
$oTpl->parse('admin_group_list', 'admin_group_list_block', true);
|
362
|
}
|
363
|
}
|
364
|
|
365
|
/*-- viewer group list block -----------------------------------------------------------*/
|
366
|
$aViewingGroups = explode(',', '1,'.$aCurrentPage['viewing_groups']);
|
367
|
$sViewingGroups = implode(',', array_unique($aViewingGroups));
|
368
|
$oTpl->set_block('main_block', 'viewer_group_list_block', 'viewer_group_list');
|
369
|
$sql = 'SELECT `group_id` `ID`, `name` `NAME` '
|
370
|
. 'FROM `'.TABLE_PREFIX.'groups` '
|
371
|
. 'ORDER BY (`ID` NOT IN('.$sViewingGroups.')), `NAME`';
|
372
|
if(($oGroups = $database->query($sql))) {
|
373
|
while($aGroup = $oGroups->fetchRow(MYSQL_ASSOC)) {
|
374
|
if($aGroup['ID'] == 1) {
|
375
|
// never uncheck admin group
|
376
|
$aGroup['CHECKED'] = $sChecked;
|
377
|
$aGroup['DISABLED'] = $sDisabled;
|
378
|
}else {
|
379
|
// check already selected groups
|
380
|
$bChecked = $admin->is_group_match($aGroup['ID'], $aCurrentPage['viewing_groups']);
|
381
|
// disable selected groups where current user is not member of
|
382
|
$bDisabled = !$admin->ami_group_member('1');
|
383
|
$aGroup['CHECKED'] = $bChecked ? $sChecked : '';
|
384
|
$aGroup['DISABLED'] = ($bChecked && $bDisabled) ? $sDisabled : '';
|
385
|
}
|
386
|
$oTpl->set_var($aGroup);
|
387
|
$oTpl->parse('viewer_group_list', 'viewer_group_list_block', true);
|
388
|
}
|
389
|
}
|
390
|
|
391
|
/*-- admin user list block -------------------------------------------------------------*/
|
392
|
// admin_group_show_list_block
|
393
|
$oTpl->set_block('main_block', 'admin_group_show_list_block', 'admin_group_show_list');
|
394
|
|
395
|
$aAdminUsers = ($aCurrentPage['admin_users'] == ''
|
396
|
? array()
|
397
|
: explode(',', $aCurrentPage['admin_users']));
|
398
|
$aAdminUsers = explode(',', $aCurrentPage['admin_users']);
|
399
|
$oTpl->set_block('admin_group_show_list_block', 'admin_user_list_block', 'admin_user_list');
|
400
|
$sAllowedAdminUsers = trim(implode(',',$aAdminUsers));
|
401
|
$sAllowedAdminUsers = $sAllowedAdminUsers ? $sAllowedAdminUsers : '-1';
|
402
|
$sql = 'SELECT `user_id`, `display_name`,`username` '
|
403
|
. 'FROM `'.TABLE_PREFIX.'users` '
|
404
|
. 'WHERE `active`=1 '
|
405
|
. 'ORDER BY (`user_id` NOT IN('.$sAllowedAdminUsers.')), `display_name`';
|
406
|
if( ($oUsers = $database->query($sql)) ) {
|
407
|
while($aUser = $oUsers->fetchRow(MYSQL_ASSOC)) {
|
408
|
if($aUser['user_id'] == 1) { continue; }
|
409
|
$oTpl->set_var(array(
|
410
|
'ID' => $aUser['user_id'],
|
411
|
'NAME' => $aUser['display_name'].' ('.$aUser['username'].')',
|
412
|
'SELECTED' => (in_array($aUser['user_id'], $aAdminUsers) ? $sSelected : ''),
|
413
|
));
|
414
|
$oTpl->parse('admin_user_list', 'admin_user_list_block', true);
|
415
|
}
|
416
|
}
|
417
|
if($admin->ami_group_member('1')) {
|
418
|
$oTpl->parse('admin_group_show_list', 'admin_group_show_list_block', true);
|
419
|
|
420
|
} else {
|
421
|
$oTpl->parse('admin_group_show_list', '', true);
|
422
|
}
|
423
|
|
424
|
/*-- viewer users list block -----------------------------------------------------------*/
|
425
|
$aViewingUsers = ($aCurrentPage['viewing_users'] == ''
|
426
|
? array()
|
427
|
: explode(',', $aCurrentPage['viewing_users']));
|
428
|
$aViewingUsers = explode(',', $aCurrentPage['viewing_users']);
|
429
|
$oTpl->set_block('main_block', 'viewer_user_list_block', 'viewer_user_list');
|
430
|
$sAllowedViewingUsers = trim(implode(',',$aViewingUsers));
|
431
|
$sAllowedViewingUsers = $sAllowedViewingUsers ? $sAllowedViewingUsers : '-1';
|
432
|
$sql = 'SELECT `user_id`, `display_name`,`username` '
|
433
|
. 'FROM `'.TABLE_PREFIX.'users` '
|
434
|
. 'WHERE `active`=1 '
|
435
|
. 'ORDER BY (`user_id` NOT IN('.$sAllowedViewingUsers.')), `display_name`';
|
436
|
if( ($oUsers = $database->query($sql)) ) {
|
437
|
while($aUser = $oUsers->fetchRow(MYSQL_ASSOC)) {
|
438
|
if($aUser['user_id'] == 1) { continue; }
|
439
|
$oTpl->set_var(array(
|
440
|
'ID' => $aUser['user_id'],
|
441
|
'NAME' => $aUser['display_name'].' ('.$aUser['username'].')',
|
442
|
'SELECTED' => (in_array($aUser['user_id'], $aViewingUsers) ? $sSelected : ''),
|
443
|
));
|
444
|
$oTpl->parse('viewer_user_list', 'viewer_user_list_block', true);
|
445
|
}
|
446
|
}
|
447
|
|
448
|
/*-- size user lists -------------------------------------------------------------------*/
|
449
|
$aSkaleSizeOfList = array(0 => 5, 12 => 10, 25 => 20, 50 => 30, 75 => 40, 100 => 50);
|
450
|
$iListSize = 6;
|
451
|
if($oUsers) {
|
452
|
$iNumberOfUsers = $oUsers->numRows();
|
453
|
foreach($aSkaleSizeOfList as $key => $val){
|
454
|
if($iNumberOfUsers > $key) {
|
455
|
$iListSize = $val;
|
456
|
}else { break; }
|
457
|
}
|
458
|
}
|
459
|
$oTpl->set_var('USER_LIST_SIZE', $iListSize);
|
460
|
|
461
|
/*-- show private viewers block --------------------------------------------------------*/
|
462
|
if($aCurrentPage['visibility'] == 'private' OR $aCurrentPage['visibility'] == 'registered')
|
463
|
{
|
464
|
$oTpl->set_var('DISPLAY_VIEWERS', '');
|
465
|
} else {
|
466
|
$oTpl->set_var('DISPLAY_VIEWERS', 'display:none;');
|
467
|
}
|
468
|
/*-- start multilanguage page_code -----------------------------------------------------*/
|
469
|
// $sLangKey='';
|
470
|
$oTpl->set_block('main_block', 'show_page_code_block', 'show_page_code');
|
471
|
if( (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) &&
|
472
|
isset($aCurrentPage['page_code']) && sizeof(getLangInUsedDbResult())>1 )
|
473
|
{
|
474
|
$aTplBlockData = array();
|
475
|
// workout field is set but module missing
|
476
|
$aTplBlockData['PAGE_CODE_LABEL_TEXT'] = $mLang->TEXT_PAGE_CODE;
|
477
|
$aTplBlockData['PAGE_CODE_UPDATE_URL'] = WB_REL.'/modules/MultiLingual/update_keys.php?page_id='.$page_id;
|
478
|
// read the tree of the found root element
|
479
|
$oPageList = new a_pages_SmallRawPageTree();
|
480
|
$aLangCodePagesList = $oPageList->getParentList($iLangStartPageId);
|
481
|
// create option list for the select box
|
482
|
$oTpl->set_block('show_page_code_block', 'page_code_list_block', 'page_code_list');
|
483
|
$aTplItemData = array();
|
484
|
$bPageCodeIsSelected = false;
|
485
|
// add 'no selection' option at top
|
486
|
if($admin->get_permission('pages_add_l0') OR !$aCurrentPage['level'])
|
487
|
{
|
488
|
$sThemeRel = WB_REL.'/'.str_replace(WB_URL, '', THEME_URL).'/images/flags/'.strtolower($sLangKey).'.png';
|
489
|
$aTplItemData['PAGE_CODE_ICON_URL'] = 'url('.$sThemeRel.')';
|
490
|
$aTplItemData['PAGE_CODE_VALUE'] = $iLangStartPageId;
|
491
|
$aTplItemData['PAGE_CODE_PAGE_TITLE'] = $sLangKey;
|
492
|
$bPageCodeIsSelected = ($aCurrentPage['page_code'] == 0);
|
493
|
$aTplItemData['PAGE_CODE_SELECTED'] = ($bPageCodeIsSelected ? $sSelected : '');
|
494
|
$oTpl->set_var($aTplItemData);
|
495
|
$oTpl->parse('page_code_list', 'page_code_list_block', true);
|
496
|
$aTplItemData = array();
|
497
|
}
|
498
|
$iLastEntryLevel = 0;
|
499
|
$bSkipChildren = false;
|
500
|
// loop through all items
|
501
|
while (list(, $aPage) = each($aLangCodePagesList))
|
502
|
{
|
503
|
// skip child pages where current user has no rights for
|
504
|
if($bSkipChildren && ($aPage['level'] > $iLastEntryLevel)) { continue; }
|
505
|
$bSkipChildren = false;
|
506
|
$iLastEntryLevel = $aPage['level'];
|
507
|
//skip entry if it's not visible
|
508
|
if(($admin->page_is_visible($aPage)==false) && ($aPage['visibility'] <> 'none') ) { continue; }
|
509
|
// insert language flag on level 0
|
510
|
$sThemeRel = WB_REL.'/'.str_replace(WB_URL, '', THEME_URL).'/images/flags/'.strtolower($sLangKey).'.png';
|
511
|
$aTplItemData['PAGE_CODE_ICON_URL'] = ($aPage['level'] ? 'none' : 'url('.$sThemeRel.')');
|
512
|
// create indent chars
|
513
|
$sTitlePrefix = str_repeat('-- ', $aPage['level']).' ';
|
514
|
$aTplItemData['PAGE_CODE_PAGE_TITLE'] = $sTitlePrefix . $aPage['menu_title'];
|
515
|
$aTplItemData['PAGE_CODE_VALUE'] = intval($aPage['page_id']);
|
516
|
// set SELECTED status of this entry
|
517
|
if( $aPage['page_id'] == $aCurrentPage['page_code']
|
518
|
&& $aCurrentPage['page_code'] != 0
|
519
|
&& !$bPageCodeIsSelected
|
520
|
)
|
521
|
{ //
|
522
|
$aTplItemData['PAGE_CODE_SELECTED'] = $sSelected;
|
523
|
$bPageCodeIsSelected = true;
|
524
|
} elseif(!$aPage['iswriteable'])
|
525
|
{ //
|
526
|
$aTplItemData['PAGE_CODE_SELECTED'] = $sDisabled.' class="disabled"';
|
527
|
$bSkipChildren = true;
|
528
|
} else {
|
529
|
$aTplItemData['PAGE_CODE_SELECTED'] = '';
|
530
|
}
|
531
|
// output item data
|
532
|
$oTpl->set_var($aTplItemData);
|
533
|
$oTpl->parse('page_code_list', 'page_code_list_block', true);
|
534
|
$aTplItemData = array();
|
535
|
}
|
536
|
// output block data
|
537
|
$oTpl->set_var($aTplBlockData);
|
538
|
$oTpl->parse('show_page_code', 'show_page_code_block', true);
|
539
|
}else {
|
540
|
$oTpl->set_block('show_page_code', '');
|
541
|
}
|
542
|
/*-- end multilanguage page_code -------------------------------------------------------*/
|
543
|
|
544
|
/*-- show list of parent pages ---------------------------------------------------------*/
|
545
|
$oTpl->set_block('main_block', 'parent_page_list_block', 'parent_page_list');
|
546
|
if($admin->get_permission('pages_add_l0') == true OR $aCurrentPage['level'] == 0) {
|
547
|
$oTpl->set_var(array(
|
548
|
'ID' => '0',
|
549
|
'TITLE' => $mLang->TEXT_NONE,
|
550
|
'SELECTED' => ($aCurrentPage['parent'] == 0 ? $sSelected : ''),
|
551
|
) );
|
552
|
$oTpl->parse('parent_page_list', 'parent_page_list_block', true);
|
553
|
}
|
554
|
|
555
|
parent_list(0);
|
556
|
$oTpl->set_var('DISPLAY_MODIFIED', ($modified_ts == 'Unknown' ? 'hide' : ''));
|
557
|
|
558
|
/*-- show list of templates ------------------------------------------------------------*/
|
559
|
$oTpl->set_block('main_block', 'template_list_block', 'template_list');
|
560
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
|
561
|
. 'WHERE `type`=\'template\' AND `function`=\'template\' '
|
562
|
. 'ORDER BY `name`';
|
563
|
if(($res_templates = $database->query($sql))) {
|
564
|
while($rec_template = $res_templates->fetchRow(MYSQL_ASSOC)) {
|
565
|
// Check if the user has perms to use this template
|
566
|
if($rec_template['directory'] == $aCurrentPage['template'] OR
|
567
|
$admin->get_permission($rec_template['directory'], 'template'))
|
568
|
{
|
569
|
$oTpl->set_var('VALUE', $rec_template['directory']);
|
570
|
$oTpl->set_var('NAME', $rec_template['name']);
|
571
|
if($rec_template['directory'] == $aCurrentPage['template']) {
|
572
|
$oTpl->set_var('SELECTED', $sSelected);
|
573
|
} else {
|
574
|
$oTpl->set_var('SELECTED', '');
|
575
|
}
|
576
|
$oTpl->parse('template_list', 'template_list_block', true);
|
577
|
}
|
578
|
}
|
579
|
}
|
580
|
|
581
|
/*-- show menu select box --------------------------------------------------------------*/
|
582
|
$oTpl->set_block('main_block', 'show_menu_list_block', 'show_menu_list');
|
583
|
if(MULTIPLE_MENUS)
|
584
|
{
|
585
|
/*-- get menusettings from template info file --------------------------------------*/
|
586
|
function getTemplateInfo($sTpl = '') {
|
587
|
if(!$sTpl) { $sTpl = DEFAULT_TEMPLATE; }
|
588
|
$sTplFile = WB_PATH.'/templates/'.$sTpl.'/info.php';
|
589
|
if(is_readable($sTplFile)) { require_once($sTplFile); }
|
590
|
$menu = isset($menu) ? $menu : array();
|
591
|
return $menu;
|
592
|
}
|
593
|
$aMenu = getTemplateInfo($aCurrentPage['template']);
|
594
|
// set menu[1] as default if there's no entry in info.php
|
595
|
$aMenu[1] = (!isset($aMenu[1]) OR ($aMenu[1] == '')) ? $mLang->TEXT_MAIN : $aMenu[1];
|
596
|
$oTpl->set_block('show_menu_list_block', 'menu_list_block', 'menu_list');
|
597
|
foreach($aMenu as $iIndex => $sMenuName) {
|
598
|
$aVars = array();
|
599
|
$aVars['NAME'] = $sMenuName;
|
600
|
$aVars['VALUE'] = $iIndex;
|
601
|
$aVars['SELECTED'] = ($aCurrentPage['menu'] == $iIndex) ? $sSelected : '';
|
602
|
$oTpl->set_var($aVars);
|
603
|
$oTpl->parse('menu_list', 'menu_list_block', true);
|
604
|
}
|
605
|
$oTpl->parse('show_menu_list', 'show_menu_list_block', true);
|
606
|
}else {
|
607
|
$oTpl->set_block('show_menu_list', '');
|
608
|
}
|
609
|
|
610
|
/*-- show language select box ----------------------------------------------------------*/
|
611
|
|
612
|
if( ($oLanguages = $admin->getAvailableLanguagesObjectInstance()) )
|
613
|
{
|
614
|
$aAvailLanguages = array();
|
615
|
while($aLanguage = $oLanguages->fetchRow(MYSQL_ASSOC)) {
|
616
|
$aAvailLanguages[$aLanguage['directory']] = $aLanguage['name'];
|
617
|
}
|
618
|
natsort($aAvailLanguages);
|
619
|
$oTpl->set_block('main_block', 'language_list_block', 'language_list');
|
620
|
foreach($aAvailLanguages as $key => $val) {
|
621
|
$oTpl->set_var(array(
|
622
|
'VALUE' => $key,
|
623
|
'NAME' => $val,
|
624
|
'FLAG_LANG_ICONS' => 'url('.THEME_URL.'/images/flags/'.strtolower($key).'.png)',
|
625
|
'SELECTED' => ($aCurrentPage['language'] == $key ? $sSelected : ''),
|
626
|
));
|
627
|
$oTpl->parse('language_list', 'language_list_block', true);
|
628
|
}
|
629
|
}
|
630
|
|
631
|
/*-- show search activated box ---------------------------------------------------------*/
|
632
|
$oTpl->set_var('SEARCHING_SELECTED_ON', ($aCurrentPage['searching'] == 0) ? '' : $sSelected);
|
633
|
$oTpl->set_var('SEARCHING_SELECTED_OFF', ($aCurrentPage['searching'] == 0) ? $sSelected : '');
|
634
|
|
635
|
/*-- show target select box ------------------------------------------------------------*/
|
636
|
$oTpl->set_var('TOP_SELECTED', ($aCurrentPage['target'] == '_top' ? $sSelected : ''));
|
637
|
$oTpl->set_var('SELF_SELECTED', ($aCurrentPage['target'] == '_self' ? $sSelected : ''));
|
638
|
$oTpl->set_var('BLANK_SELECTED', ($aCurrentPage['target'] == '_blank' ? $sSelected : ''));
|
639
|
|
640
|
/*-- show_extended_input_block ---------------------------------------------------------*/
|
641
|
$oTpl->set_block('main_block', 'show_extended_input_block', 'extended_input');
|
642
|
if($admin->get_permission('settings_advanced') == true) {
|
643
|
$oTpl->parse('extended_input', 'show_extended_input_block', true);
|
644
|
} else {
|
645
|
$oTpl->parse('extended_input', '', true);
|
646
|
}
|
647
|
/*-- insert all needed vars from language files ----------------------------------------*/
|
648
|
$oTpl->set_var($mLang->getLangArray());
|
649
|
/*-- finalize the page -----------------------------------------------------------------*/
|
650
|
$oTpl->parse('main', 'main_block', false);
|
651
|
$oTpl->pparse('output', 'page');
|
652
|
// Print admin footer
|
653
|
$mLang->disableAddon();
|
654
|
$admin->print_footer();
|
655
|
|
656
|
function p($text,$lang)
|
657
|
{
|
658
|
global $admin;
|
659
|
$retVal = 'onmouseover="return overlib(';
|
660
|
$retVal .= '\''.$text.'\',';
|
661
|
$retVal .= 'CAPTION,\''.$lang.'\',';
|
662
|
$retVal .= 'FGCOLOR,\'#ffffff\',';
|
663
|
$retVal .= 'BGCOLOR,\'#557c9e\',';
|
664
|
$retVal .= 'BORDER,1,';
|
665
|
// $retVal .= 'WIDTH,';
|
666
|
// $retVal .= 'HEIGHT,';
|
667
|
// $retVal .= 'STICKY,';
|
668
|
$retVal .= 'CAPTIONSIZE,\'13px\',';
|
669
|
$retVal .= 'CLOSETEXT,\'X\',';
|
670
|
$retVal .= 'CLOSESIZE,\'14px\',';
|
671
|
$retVal .= 'CLOSECOLOR,\'#ffffff\',';
|
672
|
$retVal .= 'TEXTSIZE,\'12px\',';
|
673
|
$retVal .= 'VAUTO,';
|
674
|
$retVal .= 'HAUTO,';
|
675
|
// $retVal .= 'MOUSEOFF,';
|
676
|
$retVal .= 'WRAP,';
|
677
|
$retVal .= 'CELLPAD,5';
|
678
|
$retVal .= ')" onmouseout="return nd()"';
|
679
|
// $retVal .= '';
|
680
|
return $retVal;
|
681
|
}
|
682
|
|
683
|
/**
|
684
|
* replace varnames with values in a string
|
685
|
*
|
686
|
* @param string $subject: stringvariable with vars placeholder
|
687
|
* @param array $replace: values to replace vars placeholder
|
688
|
* @return string
|
689
|
*/
|
690
|
function replaceVars($subject = '', $replace = null )
|
691
|
{
|
692
|
if(is_array($replace)==true)
|
693
|
{
|
694
|
foreach ($replace as $key => $value) {
|
695
|
$subject = str_replace("{{".$key."}}", $value, $subject);
|
696
|
}
|
697
|
}
|
698
|
return $subject;
|
699
|
}
|