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 and higher
13 1358 Luisehahne
 * @version         $Id$
14
 * @filesource		$HeadURL:  $
15
 * @lastmodified    $Date:  $
16
 *
17
 */
18
19
require('../../config.php');
20
require_once(WB_PATH.'/framework/class.admin.php');
21
$admin = new admin('Pages', 'pages');
22
// Include the WB functions file
23
require_once(WB_PATH.'/framework/functions.php');
24
// eggsurplus: add child pages for a specific page
25
?>
26
<script type="text/javascript" src="<?php print ADMIN_URL; ?>/pages/eggsurplus.js"></script>
27
<?php
28
/*
29
urlencode function and rawurlencode are mostly based on RFC 1738.
30
However, since 2005 the current RFC in use for URIs standard is RFC 3986.
31
Here is a function to encode URLs according to RFC 3986.
32
*/
33
function url_encode($string) {
34
    $string = html_entity_decode($string,ENT_QUOTES,'UTF-8');
35
    $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
36
    $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
37
    return str_replace($entities, $replacements, rawurlencode($string));
38
}
39
// fixes A URI contains impermissible characters or quotes around the URI are not closed.
40
$MESSAGE['PAGES_DELETE_CONFIRM'] = url_encode( ( $MESSAGE['PAGES_DELETE_CONFIRM']) );
41
42
function set_node ($parent,& $par)
43
{
44
    $retval = '';
45
46
	if($par['num_subs'] )
47
	{
48
    $retval .= "\n".'<ul id="p'.$parent.'"';
49
	if ($parent != 0)
50
	{
51
		$retval .= ' class="page_list"';
52
		if (isset ($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1')
53
		{
54
			 $retval .= ' style="display:block"';
55
		}
56
	}
57
	$retval .= ">\n";
58
 	}
59
60
	return $retval;
61
}
62
63
function make_list($parent = 0, $editable_pages = 0) {
64
	// Get objects and vars from outside this function
65
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $par;
66
67
    print set_node ($parent,$par);
68
69
	// $database = new database();
70
71
	// Get page list from database
72
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ';
73
    $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
74
    $sql .= 'ORDER BY `position` ASC';
75
	$get_pages = $database->query($sql);
76
77
	// Insert values into main page list
78
	if($get_pages->numRows() > 0)
79
	{
80
		while($page = $get_pages->fetchRow())
81
		{
82
			// Get user perms
83
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
84
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
85
			$in_group = FALSE;
86
			foreach($admin->get_groups_id() as $cur_gid)
87
            {
88
				if (in_array($cur_gid, $admin_groups))
89
                {
90
					$in_group = TRUE;
91
				}
92
			}
93
			if(($in_group) || is_numeric(array_search($admin->get_user_id(), $admin_users)))
94
            {
95
				if($page['visibility'] == 'deleted')
96
                {
97
					if(PAGE_TRASH == 'inline')
98
                    {
99
						$can_modify = true;
100
						$editable_pages = $editable_pages+1;
101
					} else {
102
						$can_modify = false;
103
					}
104
				} elseif($page['visibility'] != 'deleted')
105
                {
106
					$can_modify = true;
107
					$editable_pages = $editable_pages+1;
108
				}
109
			} else {
110
				if($page['visibility'] == 'private')
111
                {
112
					continue;
113
				}
114
				else {
115
					$can_modify = false;
116
				}
117
			}
118
119
			// Work out if we should show a plus or not
120
            $sql = 'SELECT `page_id`,`admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$page['page_id'].' ';
121
            $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
122
            // $sql .= ' ORDER BY `position` ASC';
123
        	$get_page_subs = $database->query($sql);
124
			$num_subs = $get_page_subs->numRows();
125
			$par['num_subs'] = $num_subs;
126
/*
127
			if(PAGE_TRASH != 'inline')
128
            {
129
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
130
			} else {
131
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
132
			}
133
*/
134
			if($get_page_subs->numRows() > 0)
135
            {
136
				$display_plus = true;
137
			} else {
138
				$display_plus = false;
139
			}
140
			// Work out how many pages there are for this parent
141
			$num_pages = $get_pages->numRows();
142
			?>
143
			<li class="p<?php echo $page['parent']; ?>">
144
			<table summary="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>" class="pages_view" cellpadding="0" cellspacing="0">
145
			<tr>
146
				<td valign="middle" width="20" style="padding-left: <?php if($page['level'] > 0){ echo $page['level']*20; } else { echo '7'; } ?>px;">
147
					<?php
148
					if($display_plus == true) {
149
					?>
150
					<a href="javascript:toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
151
						<img src="<?php echo THEME_URL; ?>/images/<?php if(isset($_COOKIE['p'.$page['page_id']]) && $_COOKIE['p'.$page['page_id']] == '1'){ echo 'minus'; } else { echo 'plus'; } ?>_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id']; ?>');" name="plus_minus_<?php echo $page['page_id']; ?>" alt="+" />
152
					</a>
153
					<?php
154
					}
155
					?>
156
				</td>
157
				<?php if($admin->get_permission('pages_modify') == true && $can_modify == true) { ?>
158
				<td class="list_menu_title">
159
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
160
						<?php if($page['visibility'] == 'public') { ?>
161
							<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
162
						<?php } elseif($page['visibility'] == 'private') { ?>
163
							<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
164
						<?php } elseif($page['visibility'] == 'registered') { ?>
165
							<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
166
						<?php } elseif($page['visibility'] == 'hidden') { ?>
167
							<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
168
						<?php } elseif($page['visibility'] == 'none') { ?>
169
							<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
170
						<?php } elseif($page['visibility'] == 'deleted') { ?>
171
							<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
172
						<?php }
173
						echo '<span class="modify_link">'.($page['menu_title']).'</span>'; ?>
174
					</a>
175
				</td>
176
				<?php } else { ?>
177
				<td class="list_menu_title">
178
					<?php if($page['visibility'] == 'public') { ?>
179
						<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
180
					<?php } elseif($page['visibility'] == 'private') { ?>
181
						<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
182
					<?php } elseif($page['visibility'] == 'registered') { ?>
183
						<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
184
					<?php } elseif($page['visibility'] == 'hidden') { ?>
185
						<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
186
					<?php } elseif($page['visibility'] == 'none') { ?>
187
						<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
188
					<?php } elseif($page['visibility'] == 'deleted') { ?>
189
						<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
190
					<?php }
191
					echo ($page['menu_title']); ?>
192
				</td>
193
				<?php } ?>
194
				<td class="list_page_title">
195
					<?php echo ($page['page_title']); ?>
196
				</td>
197
				<td class="list_page_id">
198
					<?php echo $page['page_id']; ?>
199
				</td>
200
201
				<td class="list_actions">
202
					<?php if($page['visibility'] != 'deleted' && $page['visibility'] != 'none') { ?>
203
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
204
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" alt="<?php echo $TEXT['VIEW']; ?>" />
205
					</a>
206
					<?php } ?>
207
				</td>
208
				<td class="list_actions">
209
					<?php if($page['visibility'] != 'deleted') { ?>
210
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
211
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
212
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" alt="<?php echo $TEXT['SETTINGS']; ?>" />
213
						</a>
214
						<?php } ?>
215
					<?php } else { ?>
216
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
217
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" alt="<?php echo $TEXT['RESTORE']; ?>" />
218
						</a>
219
					<?php } ?>
220
				</td>
221
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
222
				<td class="list_actions">
223
				<?php
224
				// Work-out if we should show the "manage dates" link
225
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true)
226
                {
227
228
                    $sql = 'SELECT `publ_start`, `publ_end` FROM `'.TABLE_PREFIX.'sections` ';
229
                    $sql .= 'WHERE `page_id` = '.$page['page_id'].' AND `module` != \'menu_link\' ';
230
                    $query_sections = $database->query($sql);
231
232
					// $query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
233
234
					if($query_sections->numRows() > 0)
235
                    {
236
						$mdate_display=false;
237
						while($mdate_res = $query_sections->fetchRow())
238
                        {
239
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0')
240
                            {
241
								$mdate_display=true;
242
								break;
243
							}
244
						}
245
						if($mdate_display==1)
246
                        {
247
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
248
							?>
249
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
250
							<img src="<?php echo THEME_URL."/images/$file"; ?>" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
251
							</a>
252
						<?php } else { ?>
253
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
254
							<img src="<?php echo THEME_URL; ?>/images/noclock_16.png" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>
255
						<?php } ?>
256
					<?php } ?>
257
				<?php } ?>
258
				</td>
259
				<td class="list_actions">
260
				<?php if($page['position'] != 1) { ?>
261
					<?php if($page['visibility'] != 'deleted') { ?>
262
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
263
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
264
							<img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="<?php echo $TEXT['MOVE_UP']; ?>" />
265
						</a>
266
						<?php } ?>
267
					<?php } ?>
268
				<?php } ?>
269
				</td>
270
				<td class="list_actions">
271
				<?php if($page['position'] != $num_pages) { ?>
272
					<?php if($page['visibility'] != 'deleted') { ?>
273
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
274
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
275
							<img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="<?php echo $TEXT['MOVE_DOWN']; ?>" />
276
						</a>
277
						<?php } ?>
278
					<?php } ?>
279
				<?php } ?>
280
				</td>
281
				<td class="list_actions">
282
					<?php if($admin->get_permission('pages_delete') == true && $can_modify == true) { ?>
283
					<a href="javascript:confirm_link('<?php echo $MESSAGE['PAGES_DELETE_CONFIRM']; ?>?','<?php echo ADMIN_URL; ?>/pages/delete.php?page_id=<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
284
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['DELETE']; ?>" />
285
					</a>
286
					<?php } ?>
287
				</td>
288
				<?php
289
				// eggsurplus: Add action to add a page as a child
290
				?>
291
				<td class="list_actions">
292
					<?php if(($admin->get_permission('pages_add')) == (true && $can_modify == true) && ($page['visibility'] != 'deleted')) { ?>
293
					<a href="javascript:add_child_page('<?php echo $page['page_id']; ?>');" title="<?php echo $HEADING['ADD_PAGE']; ?>">
294
						<img src="<?php echo THEME_URL; ?>/images/siteadd.png" name="addpage_<?php echo $page['page_id']; ?>" alt="Add Child Page" />
295
					</a>
296
					<?php } ?>
297
				</td>
298
				<?php
299
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
300
				?>
301
302
			</tr>
303
			</table>
304
			<?php
305
			if ( $page['parent'] == 0)
306
            {
307
				$page_tmp_id = $page['page_id'];
308
			}
309
			// Get subs
310
			$editable_pages=make_list($page['page_id'], $editable_pages);
311
            print '</li>'."\n";
312
		}
313
	}
314
	$output = ($par['num_subs'] )? '</ul>'."\n" : '';
315
    $par['num_subs'] = (empty($output) ) ?  1 : $par['num_subs'];
316
    print $output;
317
	return $editable_pages;
318
}
319
320
// Generate pages list
321
if($admin->get_permission('pages_view') == true) {
322
	?>
323
	<div class="jsadmin hide"></div>
324
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0" width="100%">
325
	<tr>
326
		<td>
327
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
328
		</td>
329
		<td align="right"></td>
330
	</tr>
331
	</table>
332
	<div class="pages_list">
333
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0">
334
	<tr class="pages_list_header">
335
		<td class="header_list_menu_title">
336
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE']; ?>:
337
		</td>
338
		<td class="header_list_page_title">
339
			<?php echo $TEXT['PAGE_TITLE']; ?>:
340
		</td>
341
		<td class="header_list_page_id">
342
			ID:
343
		</td>
344
		<td class="header_list_actions">
345
			<?php echo $TEXT['ACTIONS']; ?>:
346
		</td>
347
	</tr>
348
	</table>
349
	<?php
350
    // Work-out if we should check for existing page_code
351
    $field_sql = $database->query("DESCRIBE ".TABLE_PREFIX."pages page_code");
352
    $field_set = $field_sql->numRows();
353
354
    $par = array();
355
	$par['num_subs'] = 1;
356
	$editable_pages = make_list(0, 0);
357
} else {
358
	$editable_pages = 0;
359
}
360
 ?></div><?php
361
if(intval($editable_pages) == 0 ) {
362
	?>
363
	<div class="empty_list">
364
		<?php echo $TEXT['NONE_FOUND']; ?>
365
	</div>
366
	<?php
367
}
368
// Setup template object
369
$template = new Template(THEME_PATH.'/templates');
370
$template->set_file('page', 'pages.htt');
371
$template->set_block('page', 'main_block', 'main');
372
// Insert values into the add page form
373
$template->set_var('FTAN', $admin->getFTAN());
374
375
// Group list 1
376
377
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
378
	$get_groups = $database->query($query);
379
	$template->set_block('main_block', 'group_list_block', 'group_list');
380
	// Insert admin group and current group first
381
	$admin_group_name = $get_groups->fetchRow();
382
	$template->set_var(array(
383
									'ID' => 1,
384
									'TOGGLE' => '1',
385
									'DISABLED' => ' disabled="disabled"',
386
									'LINK_COLOR' => '000000',
387
									'CURSOR' => 'default',
388
									'NAME' => $admin_group_name['name'],
389
									'CHECKED' => ' checked="checked"'
390
									)
391
							);
392
	$template->parse('group_list', 'group_list_block', true);
393
394
	while($group = $get_groups->fetchRow()) {
395
		// check if the user is a member of this group
396
		$flag_disabled = '';
397
		$flag_checked =  '';
398
		$flag_cursor =   'pointer';
399
		$flag_color =    '';
400
		if (in_array($group["group_id"], $admin->get_groups_id())) {
401
			$flag_disabled = ''; //' disabled';
402
			$flag_checked =  ' checked="checked"';
403
			$flag_cursor =   'default';
404
			$flag_color =    '000000';
405
		}
406
407
		// Check if the group is allowed to edit pages
408
		$system_permissions = explode(',', $group['system_permissions']);
409
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
410
			$template->set_var(array(
411
											'ID' => $group['group_id'],
412
											'TOGGLE' => $group['group_id'],
413
											'CHECKED' => $flag_checked,
414
											'DISABLED' => $flag_disabled,
415
											'LINK_COLOR' => $flag_color,
416
											'CURSOR' => $flag_checked,
417
											'NAME' => $group['name'],
418
											)
419
									);
420
			$template->parse('group_list', 'group_list_block', true);
421
		}
422
	}
423
// Group list 2
424
425
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
426
427
	$get_groups = $database->query($query);
428
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
429
	// Insert admin group and current group first
430
	$admin_group_name = $get_groups->fetchRow();
431
	$template->set_var(array(
432
									'ID' => 1,
433
									'TOGGLE' => '1',
434
									'DISABLED' => ' disabled="disabled"',
435
									'LINK_COLOR' => '000000',
436
									'CURSOR' => 'default',
437
									'NAME' => $admin_group_name['name'],
438
									'CHECKED' => ' checked="checked"'
439
									)
440
							);
441
	$template->parse('group_list2', 'group_list_block2', true);
442
443
	while($group = $get_groups->fetchRow()) {
444
		// check if the user is a member of this group
445
		$flag_disabled = '';
446
		$flag_checked =  '';
447
		$flag_cursor =   'pointer';
448
		$flag_color =    '';
449
		if (in_array($group["group_id"], $admin->get_groups_id())) {
450
			$flag_disabled = ''; //' disabled';
451
			$flag_checked =  ' checked="checked"';
452
			$flag_cursor =   'default';
453
			$flag_color =    '000000';
454
		}
455
456
		$template->set_var(array(
457
										'ID' => $group['group_id'],
458
										'TOGGLE' => $group['group_id'],
459
										'CHECKED' => $flag_checked,
460
										'DISABLED' => $flag_disabled,
461
										'LINK_COLOR' => $flag_color,
462
										'CURSOR' => $flag_cursor,
463
										'NAME' => $group['name'],
464
										)
465
								);
466
		$template->parse('group_list2', 'group_list_block2', true);
467
	}
468
469
470
// Parent page list
471
// $database = new database();
472
function parent_list($parent)
473
{
474
	global $admin, $database, $template, $field_set;
475
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
476
	$get_pages = $database->query($query);
477
	while($page = $get_pages->fetchRow()) {
478
		if($admin->page_is_visible($page)==false)
479
			continue;
480
		// if parent = 0 set flag_icon
481
		$template->set_var('FLAG_ROOT_ICON',' none ');
482
		if( $page['parent'] == 0 && $field_set) {
483
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
484
		}
485
		// Stop users from adding pages with a level of more than the set page level limit
486
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
487
			// Get user perms
488
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
489
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
490
491
			$in_group = FALSE;
492
			foreach($admin->get_groups_id() as $cur_gid) {
493
				if (in_array($cur_gid, $admin_groups)) {
494
					$in_group = TRUE;
495
				}
496
			}
497
			if(($in_group) || is_numeric(array_search($admin->get_user_id(), $admin_users))) {
498
				$can_modify = true;
499
			} else {
500
				$can_modify = false;
501
			}
502
			// Title -'s prefix
503
			$title_prefix = '';
504
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
505
				$template->set_var(array(
506
										'ID' => $page['page_id'],
507
										'TITLE' => ($title_prefix.$page['menu_title']),
508
										'MENU-TITLE' => ($title_prefix.$page['menu_title']),
509
										'PAGE-TITLE' => ($title_prefix.$page['page_title'])
510
										));
511
				if($can_modify == true) {
512
					$template->set_var('DISABLED', '');
513
				} else {
514
					$template->set_var('DISABLED', ' disabled="disabled" class="disabled"');
515
				}
516
				$template->parse('page_list2', 'page_list_block2', true);
517
		}
518
		parent_list($page['page_id']);
519
	}
520
}
521
$template->set_block('main_block', 'page_list_block2', 'page_list2');
522
if($admin->get_permission('pages_add_l0') == true) {
523
	$template->set_var(array(
524
									'ID' => '0',
525
									'TITLE' => $TEXT['NONE'],
526
									'SELECTED' => ' selected="selected"',
527
									'DISABLED' => ''
528
									)
529
							);
530
	$template->parse('page_list2', 'page_list_block2', true);
531
}
532
parent_list(0);
533
534
// Explode module permissions
535
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
536
// Modules list
537
$template->set_block('main_block', 'module_list_block', 'module_list');
538
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
539
if($result->numRows() > 0) {
540
	while ($module = $result->fetchRow()) {
541
		// Check if user is allowed to use this module
542
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
543
			$template->set_var('VALUE', $module['directory']);
544
			$template->set_var('NAME', $module['name']);
545
			if($module['directory'] == 'wysiwyg') {
546
				$template->set_var('SELECTED', ' selected="selected"');
547
			} else {
548
				$template->set_var('SELECTED', '');
549
			}
550
			$template->parse('module_list', 'module_list_block', true);
551
		}
552
	}
553
}
554
555
// Insert urls
556
$template->set_var(array(
557
								'THEME_URL' => THEME_URL,
558
								'WB_URL' => WB_URL,
559
								'WB_PATH' => WB_PATH,
560
								'ADMIN_URL' => ADMIN_URL,
561
								)
562
						);
563
564
// Insert language headings
565
$template->set_var(array(
566
								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
567
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
568
								)
569
						);
570
// Insert language text and messages
571
$template->set_var(array(
572
								'TEXT_TITLE' => $TEXT['TITLE'],
573
								'TEXT_TYPE' => $TEXT['TYPE'],
574
								'TEXT_PARENT' => $TEXT['PARENT'],
575
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
576
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
577
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
578
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
579
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
580
								'TEXT_NONE' => $TEXT['NONE'],
581
								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
582
								'TEXT_ADD' => $TEXT['ADD'],
583
								'TEXT_RESET' => $TEXT['RESET'],
584
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
585
								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
586
								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
587
								'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
588
								)
589
						);
590
591
// Insert permissions values
592
if($admin->get_permission('pages_add') != true) {
593
	$template->set_var('DISPLAY_ADD', 'hide');
594
} elseif($admin->get_permission('pages_add_l0') != true && $editable_pages == 0) {
595
	$template->set_var('DISPLAY_ADD', 'hide');
596
}
597
if($admin->get_permission('pages_intro') != true || INTRO_PAGE != 'enabled') {
598
	$template->set_var('DISPLAY_INTRO', 'hide');
599
}
600
601
602
// Parse template object
603
$template->parse('main', 'main_block', false);
604
$template->pparse('output', 'page');
605
606
// include the required file for Javascript admin
607
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
608
{
609
	include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
610
}
611
612
// Print admin
613
$admin->print_footer();
614
615 1009 Ruebenwurz
?>