Project

General

Profile

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