Project

General

Profile

1
<?php
2

    
3
// $Id: index.php 1187 2009-11-25 06:01:26Z Luisehahne $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
require('../../config.php');
27
require_once(WB_PATH.'/framework/class.admin.php');
28
$admin = new admin('Pages', 'pages');
29
// Include the WB functions file
30
require_once(WB_PATH.'/framework/functions.php');
31
// eggsurplus: add child pages for a specific page
32
?>
33
<script type="text/javascript" src="<?php print ADMIN_URL; ?>/pages/eggsurplus.js"></script>
34
<?php
35

    
36

    
37
function make_list($parent, $editable_pages) {
38
	// Get objects and vars from outside this function
39
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $page_tmp_id;
40
	?>
41
	<ul id="p<?php echo $parent; ?>" <?php if($parent != 0) { echo 'class="page_list" '; if(isset($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1'){ echo 'style="display:block"'; }} ?>>
42
	<?php
43
	// Get page list from database
44
	$database = new database();
45
	if(PAGE_TRASH != 'inline') {
46
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
47
	} else {
48
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
49
	}
50
	$get_pages = $database->query($query);
51
	// Insert values into main page list
52
	if($get_pages->numRows() > 0) {
53
		while($page = $get_pages->fetchRow()) {
54
			// Get user perms
55
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
56
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
57
			$in_group = FALSE;
58
			foreach($admin->get_groups_id() as $cur_gid) {
59
				if (in_array($cur_gid, $admin_groups)) {
60
					$in_group = TRUE;
61
				}
62
			}
63
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
64
				if($page['visibility'] == 'deleted') {
65
					if(PAGE_TRASH == 'inline') {
66
						$can_modify = true;
67
						$editable_pages = $editable_pages+1;
68
					} else {
69
						$can_modify = false;
70
					}
71
				} elseif($page['visibility'] != 'deleted') {
72
					$can_modify = true;
73
					$editable_pages = $editable_pages+1;
74
				}
75
			} else {
76
				if($page['visibility'] == 'private') {
77
					continue;
78
				}
79
				else {
80
					$can_modify = false;
81
				}
82
			}
83
			// Work out if we should show a plus or not
84
			if(PAGE_TRASH != 'inline') {
85
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
86
			} else {
87
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
88
			}
89
			if($get_page_subs->numRows() > 0) {
90
				$display_plus = true;
91
			} else {
92
				$display_plus = false;
93
			}
94
			// Work out how many pages there are for this parent
95
			$num_pages = $get_pages->numRows();
96
			?>
97
			<li class="p<?php echo $page['parent']; ?>">
98
			<table class="pages_view" border="0" cellpadding="0" cellspacing="0">
99
			<tr>
100
				<td valign="middle" width="20" style="padding-left: <?php if($page['level'] > 0){ echo $page['level']*20; } else { echo '7'; } ?>px;">
101
					<?php
102
					if($display_plus == true) {
103
					?>
104
					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
105
						<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']; ?>" border="0" alt="+" />
106
					</a>
107
					<?php
108
					}
109
					?>
110
				</td>
111
				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
112
				<td class="list_menu_title">
113
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
114
						<?php if($page['visibility'] == 'public') { ?>
115
							<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
116
						<?php } elseif($page['visibility'] == 'private') { ?>
117
							<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
118
						<?php } elseif($page['visibility'] == 'registered') { ?>
119
							<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
120
						<?php } elseif($page['visibility'] == 'hidden') { ?>
121
							<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
122
						<?php } elseif($page['visibility'] == 'none') { ?>
123
							<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
124
						<?php } elseif($page['visibility'] == 'deleted') { ?>
125
							<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
126
						<?php }
127
						echo '<span class="modify_link">'.($page['menu_title']).'</span>'; ?>
128
					</a>
129
				</td>
130
				<?php } else { ?>
131
				<td class="list_menu_title">
132
					<?php if($page['visibility'] == 'public') { ?>
133
						<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
134
					<?php } elseif($page['visibility'] == 'private') { ?>
135
						<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
136
					<?php } elseif($page['visibility'] == 'registered') { ?>
137
						<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
138
					<?php } elseif($page['visibility'] == 'hidden') { ?>
139
						<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
140
					<?php } elseif($page['visibility'] == 'none') { ?>
141
						<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
142
					<?php } elseif($page['visibility'] == 'deleted') { ?>
143
						<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
144
					<?php } 
145
					echo ($page['menu_title']); ?>
146
				</td>
147
				<?php } ?>
148
				<td class="list_page_title">
149
					<?php echo ($page['page_title']); ?>
150
				</td>
151
				<td class="list_page_id">
152
					<?php echo $page['page_id']; ?>
153
				</td>
154
				<td class="list_actions">
155
					<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
156
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
157
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
158
					</a>
159
					<?php } ?>
160
				</td>
161
				<td class="list_actions">
162
					<?php if($page['visibility'] != 'deleted') { ?>
163
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
164
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
165
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
166
						</a>
167
						<?php } ?>
168
					<?php } else { ?>
169
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
170
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
171
						</a>
172
					<?php } ?>
173
				</td>
174
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
175
				<td class="list_actions">
176
				<?php
177
				// Work-out if we should show the "manage dates" link
178
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true) {
179
					$query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
180
					if($query_sections->numRows() > 0) {
181
						$mdate_display=false;
182
						while($mdate_res = $query_sections->fetchRow()) {
183
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0') {
184
								$mdate_display=true;
185
								break;
186
							}
187
						}
188
						if($mdate_display==1) {
189
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
190
							?>
191
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
192
							<img src="<?php echo THEME_URL."/images/$file"; ?>" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />	
193
							</a>
194
						<?php } else { ?>
195
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
196
							<img src="<?php echo THEME_URL; ?>/images/noclock_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>	
197
						<?php } ?>
198
					<?php } ?>
199
				<?php } ?>
200
				</td>
201
				<td class="list_actions">
202
				<?php if($page['position'] != 1) { ?>
203
					<?php if($page['visibility'] != 'deleted') { ?>
204
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
205
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
206
							<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="<?php echo $TEXT['MOVE_UP']; ?>" />
207
						</a>
208
						<?php } ?>
209
					<?php } ?>
210
				<?php } ?>
211
				</td>
212
				<td class="list_actions">
213
				<?php if($page['position'] != $num_pages) { ?>
214
					<?php if($page['visibility'] != 'deleted') { ?>
215
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
216
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
217
							<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="<?php echo $TEXT['MOVE_DOWN']; ?>" />
218
						</a>
219
						<?php } ?>
220
					<?php } ?>
221
				<?php } ?>
222
				</td>
223
				<td class="list_actions">
224
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
225
					<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']; ?>">
226
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="<?php echo $TEXT['DELETE']; ?>" />
227
					</a>
228
					<?php } ?>
229
				</td>
230
				<?php
231
				// eggsurplus: Add action to add a page as a child
232
				?>
233
				<td class="list_actions">
234
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
235
					<a href="javascript:add_child_page('<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['ADD']; ?>">
236
						<img src="<?php echo THEME_URL; ?>/images/plus_16.png" name="addpage_<?php echo $page['page_id']; ?>" border="0" alt="Add Child Page" />
237
					</a>
238
					<?php } ?>
239
				</td>
240
				<?php
241
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
242
				?>
243

    
244
			</tr>
245
			</table>
246
			</li>
247
			<?php
248
			if ( $page['parent'] = 0) {
249
				$page_tmp_id = $page['page_id'];
250
			}
251
			// Get subs
252
			$editable_pages=make_list($page['page_id'], $editable_pages);
253
		}
254
	}
255
	?>
256
	</ul>
257
	<?php
258
	return $editable_pages;
259
}
260

    
261
// Generate pages list
262
if($admin->get_permission('pages_view') == true) {
263
	?>
264
	<div class="jsadmin hide"></div>
265
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
266
	<tr>
267
		<td>
268
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
269
		</td>
270
		<td align="right">
271
			<?php
272
				// Check if there are any pages that are in trash, and if we should show a link to the trash page
273
				if(PAGE_TRASH == 'separate') {
274
					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
275
					if($query_trash->numRows() > 0) {
276
						?>
277
						<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
278
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
279
						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
280
						<?php
281
					}
282
				}
283
			?>
284
		</td>
285
	</tr>
286
	</table>
287
	<div class="pages_list">
288
	<table cellpadding="0" cellspacing="0" border="0">
289
	<tr>
290
		<td class="header_list_menu_title">
291
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE']; ?>:
292
		</td>
293
		<td class="header_list_page_title">
294
			<?php echo $TEXT['PAGE_TITLE']; ?>:
295
		</td>
296
		<td class="header_list_page_id">
297
			ID:
298
		</td>		
299
		<td class="header_list_actions">
300
			<?php echo $TEXT['ACTIONS']; ?>:
301
		</td>
302
	</tr>
303
	</table>
304
	<?php
305
    // Work-out if we should check for existing page_code
306
    $field_sql = $database->query("DESCRIBE ".TABLE_PREFIX."pages page_code");
307
    $field_set = $field_sql->numRows();
308

    
309
	$page_tmp_id = 0;
310
	$editable_pages = make_list(0, 0);
311
	?>
312
	</div>
313
	<div class="empty_list">
314
		<?php echo $TEXT['NONE_FOUND']; ?>
315
	</div>
316
	<?php
317
} else {
318
	$editable_pages = 0;
319
}
320

    
321
// Setup template object
322
$template = new Template(THEME_PATH.'/templates');
323
$template->set_file('page', 'pages.htt');
324
$template->set_block('page', 'main_block', 'main');
325

    
326
// Figure out if the no pages found message should be shown or not
327
if($editable_pages == 0) {
328
	?>
329
	<style type="text/css">
330
	.pages_list {
331
		display: none;
332
	}
333
	</style>
334
	<?php
335
} else {
336
	?>
337
	<style type="text/css">
338
	.empty_list {
339
		display: none;
340
	}
341
	</style>
342
	<?php
343
}
344

    
345
// Insert values into the add page form
346

    
347
// Group list 1
348

    
349
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
350
	$get_groups = $database->query($query);
351
	$template->set_block('main_block', 'group_list_block', 'group_list');
352
	// Insert admin group and current group first
353
	$admin_group_name = $get_groups->fetchRow();
354
	$template->set_var(array(
355
									'ID' => 1,
356
									'TOGGLE' => '',
357
									'DISABLED' => ' disabled="disabled"',
358
									'LINK_COLOR' => '000000',
359
									'CURSOR' => 'default',
360
									'NAME' => $admin_group_name['name'],
361
									'CHECKED' => ' checked="checked"'
362
									)
363
							);
364
	$template->parse('group_list', 'group_list_block', true);
365

    
366
	while($group = $get_groups->fetchRow()) {
367
		// check if the user is a member of this group
368
		$flag_disabled = '';
369
		$flag_checked =  '';
370
		$flag_cursor =   'pointer';
371
		$flag_color =    '';
372
		if (in_array($group["group_id"], $admin->get_groups_id())) {
373
			$flag_disabled = ''; //' disabled';
374
			$flag_checked =  ' checked="checked"';
375
			$flag_cursor =   'default';
376
			$flag_color =    '000000';
377
		}
378

    
379
		// Check if the group is allowed to edit pages
380
		$system_permissions = explode(',', $group['system_permissions']);
381
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
382
			$template->set_var(array(
383
											'ID' => $group['group_id'],
384
											'TOGGLE' => $group['group_id'],
385
											'CHECKED' => $flag_checked,
386
											'DISABLED' => $flag_disabled,
387
											'LINK_COLOR' => $flag_color,
388
											'CURSOR' => $flag_checked,
389
											'NAME' => $group['name'],
390
											)
391
									);
392
			$template->parse('group_list', 'group_list_block', true);
393
		}
394
	}
395
// Group list 2
396

    
397
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
398

    
399
	$get_groups = $database->query($query);
400
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
401
	// Insert admin group and current group first
402
	$admin_group_name = $get_groups->fetchRow();
403
	$template->set_var(array(
404
									'ID' => 1,
405
									'TOGGLE' => '',
406
									'DISABLED' => ' disabled="disabled"',
407
									'LINK_COLOR' => '000000',
408
									'CURSOR' => 'default',
409
									'NAME' => $admin_group_name['name'],
410
									'CHECKED' => ' checked="checked"'
411
									)
412
							);
413
	$template->parse('group_list2', 'group_list_block2', true);
414

    
415
	while($group = $get_groups->fetchRow()) {
416
		// check if the user is a member of this group
417
		$flag_disabled = '';
418
		$flag_checked =  '';
419
		$flag_cursor =   'pointer';
420
		$flag_color =    '';
421
		if (in_array($group["group_id"], $admin->get_groups_id())) {
422
			$flag_disabled = ''; //' disabled';
423
			$flag_checked =  ' checked="checked"';
424
			$flag_cursor =   'default';
425
			$flag_color =    '000000';
426
		}
427

    
428
		$template->set_var(array(
429
										'ID' => $group['group_id'],
430
										'TOGGLE' => $group['group_id'],
431
										'CHECKED' => $flag_checked,
432
										'DISABLED' => $flag_disabled,
433
										'LINK_COLOR' => $flag_color,
434
										'CURSOR' => $flag_cursor,
435
										'NAME' => $group['name'],
436
										)
437
								);
438
		$template->parse('group_list2', 'group_list_block2', true);
439
	}
440

    
441

    
442
// Parent page list
443
$database = new database();
444
function parent_list($parent) {
445
	global $admin, $database, $template, $field_set;
446
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
447
	$get_pages = $database->query($query);
448
	while($page = $get_pages->fetchRow()) {
449
		if($admin->page_is_visible($page)==false)
450
			continue;
451
		// if parent = 0 set flag_icon
452
		$template->set_var('FLAG_ROOT_ICON',' none ');
453
		if( $page['parent'] == 0 && $field_set) {
454
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
455
		}
456
		// Stop users from adding pages with a level of more than the set page level limit
457
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
458
			// Get user perms
459
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
460
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
461
			
462
			$in_group = FALSE;
463
			foreach($admin->get_groups_id() as $cur_gid) {
464
				if (in_array($cur_gid, $admin_groups)) {
465
					$in_group = TRUE;
466
				}
467
			}
468
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
469
				$can_modify = true;
470
			} else {
471
				$can_modify = false;
472
			}
473
			// Title -'s prefix
474
			$title_prefix = '';
475
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
476
				$template->set_var(array(
477
												'ID' => $page['page_id'],
478
												'TITLE' => ($title_prefix.$page['menu_title']),
479
												'MENU-TITLE' => ($title_prefix.$page['menu_title']),
480
												'PAGE-TITLE' => ($title_prefix.$page['page_title'])
481
												)
482
										);
483
				if($can_modify == true) {
484
					$template->set_var('DISABLED', '');
485
				} else {
486
					$template->set_var('DISABLED', ' disabled="disabled" class="disabled"');
487
				}
488
				$template->parse('page_list2', 'page_list_block2', true);
489
		}
490
		parent_list($page['page_id']);
491
	}
492
}
493
$template->set_block('main_block', 'page_list_block2', 'page_list2');
494
if($admin->get_permission('pages_add_l0') == true) {
495
	$template->set_var(array(
496
									'ID' => '0',
497
									'TITLE' => $TEXT['NONE'],
498
									'SELECTED' => ' selected="selected"',
499
									'DISABLED' => ''
500
									)
501
							);
502
	$template->parse('page_list2', 'page_list_block2', true);
503
}
504
parent_list(0);
505

    
506
// Explode module permissions
507
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
508
// Modules list
509
$template->set_block('main_block', 'module_list_block', 'module_list');
510
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
511
if($result->numRows() > 0) {
512
	while ($module = $result->fetchRow()) {
513
		// Check if user is allowed to use this module
514
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
515
			$template->set_var('VALUE', $module['directory']);
516
			$template->set_var('NAME', $module['name']);
517
			if($module['directory'] == 'wysiwyg') {
518
				$template->set_var('SELECTED', ' selected="selected"');
519
			} else {
520
				$template->set_var('SELECTED', '');
521
			}
522
			$template->parse('module_list', 'module_list_block', true);
523
		}
524
	}
525
}
526

    
527
// Insert urls
528
$template->set_var(array(
529
								'THEME_URL' => THEME_URL,
530
								'WB_URL' => WB_URL,
531
								'WB_PATH' => WB_PATH,
532
								'ADMIN_URL' => ADMIN_URL,
533
								)
534
						);
535

    
536
// Insert language headings
537
$template->set_var(array(
538
								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
539
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
540
								)
541
						);
542
// Insert language text and messages
543
$template->set_var(array(
544
								'TEXT_TITLE' => $TEXT['TITLE'],
545
								'TEXT_TYPE' => $TEXT['TYPE'],
546
								'TEXT_PARENT' => $TEXT['PARENT'],
547
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
548
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
549
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
550
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
551
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
552
								'TEXT_NONE' => $TEXT['NONE'],
553
								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
554
								'TEXT_ADD' => $TEXT['ADD'],
555
								'TEXT_RESET' => $TEXT['RESET'],
556
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
557
								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
558
								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
559
								'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
560
								)
561
						);
562

    
563
// Insert permissions values
564
if($admin->get_permission('pages_add') != true) {
565
	$template->set_var('DISPLAY_ADD', 'hide');
566
} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
567
	$template->set_var('DISPLAY_ADD', 'hide');
568
}
569
if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
570
	$template->set_var('DISPLAY_INTRO', 'hide');
571
}
572

    
573

    
574
// Parse template object
575
$template->parse('main', 'main_block', false);
576
$template->pparse('output', 'page');
577

    
578
// Print admin 
579
$admin->print_footer();
580

    
581
?>
(5-5/21)