Project

General

Profile

1
<?php
2

    
3
// $Id: index.php 537 2008-01-14 16:36:49Z doc $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2008, 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

    
32
?>
33
<!-- Addition for remembering expanded state of pages -->
34
<script language="JavaScript">
35
function writeSessionCookie (cookieName, cookieValue) {
36
    document.cookie = escape(cookieName) + "=" + escape(cookieValue) + ";";
37
}
38
</script>
39
<!-- End addition -->
40

    
41
<script type="text/javascript" language="javascript">
42
function toggle_viewers() {
43
	if(document.add.visibility.value == 'private') {
44
		document.getElementById('private_viewers').style.display = 'block';
45
		document.getElementById('registered_viewers').style.display = 'none';
46
	} else if(document.add.visibility.value == 'registered') {
47
		document.getElementById('private_viewers').style.display = 'none';
48
		document.getElementById('registered_viewers').style.display = 'block';
49
	} else {
50
		document.getElementById('private_viewers').style.display = 'none';
51
		document.getElementById('registered_viewers').style.display = 'none';
52
	}
53
}
54
function toggle_visibility(id){
55
	if(document.getElementById(id).style.display == "block") {
56
		document.getElementById(id).style.display = "none";
57
		writeSessionCookie (id, "0");//Addition for remembering expanded state of pages
58
	} else {
59
		document.getElementById(id).style.display = "block";
60
		writeSessionCookie (id, "1");//Addition for remembering expanded state of pages
61
	}
62
}
63
var plus = new Image;
64
plus.src = "<?php echo ADMIN_URL; ?>/images/plus_16.png";
65
var minus = new Image;
66
minus.src = "<?php echo ADMIN_URL; ?>/images/minus_16.png";
67
function toggle_plus_minus(id) {
68
	var img_src = document.images['plus_minus_' + id].src;
69
	if(img_src == plus.src) {
70
		document.images['plus_minus_' + id].src = minus.src;
71
	} else {
72
		document.images['plus_minus_' + id].src = plus.src;
73
	}
74
}
75
</script>
76

    
77
<style type="text/css">
78
.pages_list img {
79
	display: block;
80
}
81
ul, li {
82
	list-style: none;
83
	margin: 0;
84
	padding: 0;
85
}
86
.page_list {
87
	display: none;
88
}
89
</style>
90

    
91
<noscript>
92
	<style type="text/css">
93
	.page_list {
94
		display: block;
95
	}
96
	</style>
97
</noscript>
98
<?php
99

    
100
function make_list($parent, $editable_pages) {
101
	// Get objects and vars from outside this function
102
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING;
103
	?>
104
	<ul id="p<?php echo $parent; ?>" <?php if($parent != 0) { echo 'class="page_list" '; if($_COOKIE["p".$parent] =="1"){echo'style="display:block;"'; }} ?>>
105
	<?php	
106
	// Get page list from database
107
	$database = new database();
108
	if(PAGE_TRASH != 'inline') {
109
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
110
	} else {
111
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
112
	}
113
	$get_pages = $database->query($query);
114
	
115
	// Insert values into main page list
116
	if($get_pages->numRows() > 0)	{
117
		while($page = $get_pages->fetchRow()) {
118
			// Get user perms
119
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
120
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
121
			if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
122
				if($page['visibility'] == 'deleted') {
123
					if(PAGE_TRASH == 'inline') {
124
						$can_modify = true;
125
						$editable_pages = $editable_pages+1;
126
					} else {
127
						$can_modify = false;
128
					}
129
				} elseif($page['visibility'] != 'deleted') {
130
					$can_modify = true;
131
					$editable_pages = $editable_pages+1;
132
				}
133
			} else {
134
				if($page['visibility'] == 'private') {
135
					continue;
136
				}
137
				else {
138
					$can_modify = false;
139
				}
140
			}
141
						
142
			// Work out if we should show a plus or not
143
			if(PAGE_TRASH != 'inline') {
144
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
145
			} else {
146
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
147
			}
148
			if($get_page_subs->numRows() > 0) {
149
				$display_plus = true;
150
			} else {
151
				$display_plus = false;
152
			}
153
			
154
			// Work out how many pages there are for this parent
155
			$num_pages = $get_pages->numRows();
156
			?>
157
			
158
			<li id="p<?php echo $page['parent']; ?>" style="padding: 2px 0px 2px 0px;">
159
			<table width="720" cellpadding="1" cellspacing="0" border="0" style="background-color: #F0F0F0;">
160
			<tr>
161
				<td width="20" style="padding-left: <?php echo $page['level']*20; ?>px;">
162
					<?php
163
					if($display_plus == true) {
164
					?>
165
					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
166
						<img src="<?php echo ADMIN_URL; ?>/images/<?php if($_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="+" />
167
					</a>
168
					<?php
169
					}
170
					?>
171
				</td>
172
				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
173
				<td>
174
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
175
						<?php if($page['visibility'] == 'public') { ?>
176
							<img src="<?php echo ADMIN_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" border="0" align="left" style="margin-right: 5px" />
177
						<?php } elseif($page['visibility'] == 'private') { ?>
178
							<img src="<?php echo ADMIN_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" border="0" align="left" style="margin-right: 5px" />
179
						<?php } elseif($page['visibility'] == 'registered') { ?>
180
							<img src="<?php echo ADMIN_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" border="0" align="left" style="margin-right: 5px" />
181
						<?php } elseif($page['visibility'] == 'hidden') { ?>
182
							<img src="<?php echo ADMIN_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" border="0" align="left" style="margin-right: 5px" />
183
						<?php } elseif($page['visibility'] == 'none') { ?>
184
							<img src="<?php echo ADMIN_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" border="0" align="left" style="margin-right: 5px" />
185
						<?php } elseif($page['visibility'] == 'deleted') { ?>
186
							<img src="<?php echo ADMIN_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" border="0" align="left" style="margin-right: 5px" />
187
						<?php } 
188
						echo ($page['page_title']); ?>
189
					</a>				
190
				</td>
191
				<?php } else { ?>
192
				<td>
193
					<?php if($page['visibility'] == 'public') { ?>
194
						<img src="<?php echo ADMIN_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" border="0" align="left" style="margin-right: 5px" />
195
					<?php } elseif($page['visibility'] == 'private') { ?>
196
						<img src="<?php echo ADMIN_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" border="0" align="left" style="margin-right: 5px" />
197
					<?php } elseif($page['visibility'] == 'registered') { ?>
198
						<img src="<?php echo ADMIN_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" border="0" align="left" style="margin-right: 5px" />
199
					<?php } elseif($page['visibility'] == 'hidden') { ?>
200
						<img src="<?php echo ADMIN_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" border="0" align="left" style="margin-right: 5px" />
201
					<?php } elseif($page['visibility'] == 'none') { ?>
202
						<img src="<?php echo ADMIN_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" border="0" align="left" style="margin-right: 5px" />
203
					<?php } elseif($page['visibility'] == 'deleted') { ?>
204
						<img src="<?php echo ADMIN_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" border="0" align="left" style="margin-right: 5px" />
205
					<?php } 
206
					echo ($page['page_title']); ?>
207
				</td>
208
				<?php } ?>
209
				<td align="left" width="232">
210
					<font color="#999999"><?php echo ($page['menu_title']); ?></font>
211
				</td>
212
				<td width="20">
213
					<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
214
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
215
						<img src="<?php echo ADMIN_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
216
					</a>
217
					<?php } ?>
218
				</td>
219
				<td width="20">
220
					<?php if($page['visibility'] != 'deleted') { ?>
221
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
222
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
223
							<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
224
						</a>
225
						<?php } ?>
226
					<?php } else { ?>
227
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
228
							<img src="<?php echo ADMIN_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
229
						</a>
230
					<?php } ?>
231
				</td>
232
				
233
				<!-- 'MANAGE SECTIONS' BUTTON -->
234
				<td width="20">
235
					<?php
236
					// Work-out if we should show the "manage sections" link
237
					$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '" . $page['page_id'] . "' AND module = 'menu_link'");
238
					if(($query_sections->numRows() == 0) && (MANAGE_SECTIONS == 'enabled')) {
239
					?>
240
						<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
241
						<img src="<?php echo ADMIN_URL; ?>/images/sections_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />	
242
						</a>
243
					<?php } ?>
244
				</td>
245
				
246
				
247
				<td width="20">
248
				<?php if($page['position'] != 1) { ?>
249
					<?php if($page['visibility'] != 'deleted') { ?>
250
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
251
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
252
							<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" border="0" alt="^" />
253
						</a>
254
						<?php } ?>
255
					<?php } ?>
256
				<?php } ?>
257
				</td>
258
				<td width="20">
259
				<?php if($page['position'] != $num_pages) { ?>
260
					<?php if($page['visibility'] != 'deleted') { ?>
261
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
262
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
263
							<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" border="0" alt="v" />
264
						</a>
265
						<?php } ?>
266
					<?php } ?>
267
				<?php } ?>
268
				</td>
269
				<td width="20">
270
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
271
					<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']; ?>">
272
						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
273
					</a>
274
					<?php } ?>
275
				</td>
276
			</tr>
277
			</table>
278
			</li>
279
							
280
			<?php
281
			// Get subs
282
			$editable_pages=make_list($page['page_id'], $editable_pages);
283
		}
284

    
285
	}
286
	?>
287
	</ul>
288
	<?php
289
	return $editable_pages;
290
}
291

    
292
// Generate pages list
293
if($admin->get_permission('pages_view') == true) {
294
	?>
295
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
296
	<tr>
297
		<td>
298
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
299
		</td>
300
		<td align="right">
301
			<?php
302
				// Check if there are any pages that are in trash, and if we should show a link to the trash page
303
				if(PAGE_TRASH == 'separate') {
304
					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
305
					if($query_trash->numRows() > 0) {
306
						?>
307
						<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
308
						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
309
						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
310
						<?php
311
					}
312
				}
313
			?>
314
		</td>
315
	</tr>
316
	</table>
317
	<div class="pages_list">
318
	<table cellpadding="1" cellspacing="0" width="720" border="0">
319
	<tr>
320
		<td width="20">
321
			&nbsp;
322
		</td>
323
		<td>
324
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['PAGE_TITLE']; ?>:
325
		</td>
326
		<td width="235" align="left">
327
			<?php echo $TEXT['MENU_TITLE']; ?>:
328
		</td>
329
		<td width="125" align="center">
330
			<?php echo $TEXT['ACTIONS']; ?>:
331
		</td>		
332
	</tr>
333
	</table>
334
	<?php
335
	$editable_pages = make_list(0, 0);
336
	?>
337
	</div>
338
	<div class="empty_list">
339
		<?php echo $TEXT['NONE_FOUND']; ?>
340
	</div>
341
	<?php
342
} else {
343
	$editable_pages = 0;
344
}
345

    
346
// Setup template object
347
$template = new Template(ADMIN_PATH.'/pages');
348
$template->set_file('page', 'template.html');
349
$template->set_block('page', 'main_block', 'main');
350

    
351
// Figure out if the no pages found message should be shown or not
352
if($editable_pages == 0) {
353
	?>
354
	<style type="text/css">
355
	.pages_list {
356
		display: none;
357
	}
358
	</style>
359
	<?php
360
} else {
361
	?>
362
	<style type="text/css">
363
	.empty_list {
364
		display: none;
365
	}
366
	</style>
367
	<?php
368
}
369

    
370
// Insert values into the add page form
371

    
372
// Group list 1
373
	if($admin->get_group_id() == 1) {
374
		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
375
	} else {
376
		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
377
	}
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' => '',
385
									'DISABLED' => ' disabled',
386
									'LINK_COLOR' => '000000',
387
									'CURSOR' => 'default',
388
									'NAME' => $admin_group_name['name'],
389
									'CHECKED' => ' checked'
390
									)
391
							);
392
	$template->parse('group_list', 'group_list_block', true);
393
	if($admin->get_group_id() != 1) {
394
		$template->set_var(array(
395
										'ID' => $admin->get_group_id(),
396
										'TOGGLE' => '',
397
										'DISABLED' => ' disabled',
398
										'LINK_COLOR' => '000000',
399
										'CURSOR' => 'default',
400
										'NAME' => $admin->get_group_name(),
401
										'CHECKED' => ' checked'
402
										)
403
								);
404
		$template->parse('group_list', 'group_list_block', true);
405
	}
406
	while($group = $get_groups->fetchRow()) {
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' => '',
414
											'DISABLED' => '',
415
											'LINK_COLOR' => '',
416
											'CURSOR' => 'pointer',
417
											'NAME' => $group['name'],
418
											'CHECKED' => ''
419
											)
420
									);
421
			$template->parse('group_list', 'group_list_block', true);
422
		}
423
	}
424
// Group list 2
425
	if($admin->get_group_id() == 1) {
426
		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
427
	} else {
428
		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
429
	}
430
	$get_groups = $database->query($query);
431
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
432
	// Insert admin group and current group first
433
	$admin_group_name = $get_groups->fetchRow();
434
	$template->set_var(array(
435
									'ID' => 1,
436
									'TOGGLE' => '',
437
									'DISABLED' => ' disabled',
438
									'LINK_COLOR' => '000000',
439
									'CURSOR' => 'default',
440
									'NAME' => $admin_group_name['name'],
441
									'CHECKED' => ' checked'
442
									)
443
							);
444
	$template->parse('group_list2', 'group_list_block2', true);
445
	if($admin->get_group_id() != 1) {
446
		$template->set_var(array(
447
										'ID' => $admin->get_group_id(),
448
										'TOGGLE' => '',
449
										'DISABLED' => ' disabled',
450
										'LINK_COLOR' => '000000',
451
										'CURSOR' => 'default',
452
										'NAME' => $admin->get_group_name(),
453
										'CHECKED' => ' checked'
454
										)
455
								);
456
		$template->parse('group_list2', 'group_list_block2', true);
457
	}
458
	while($group = $get_groups->fetchRow()) {
459
		$template->set_var(array(
460
										'ID' => $group['group_id'],
461
										'TOGGLE' => $group['group_id'],
462
										'CHECKED' => '',
463
										'DISABLED' => '',
464
										'LINK_COLOR' => '',
465
										'CURSOR' => 'pointer',
466
										'NAME' => $group['name'],
467
										'CHECKED' => ''
468
										)
469
								);
470
		$template->parse('group_list2', 'group_list_block2', true);
471
	}
472

    
473
// Parent page list
474
$database = new database();
475
function parent_list($parent) {
476
	global $admin, $database, $template;
477
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
478
	$get_pages = $database->query($query);
479
	while($page = $get_pages->fetchRow()) {
480
		// Stop users from adding pages with a level of more than the set page level limit
481
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
482
			// Get user perms
483
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
484
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
485
			if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
486
				$can_modify = true;
487
			} else {
488
				$can_modify = false;
489
			}
490
			// Title -'s prefix
491
			$title_prefix = '';
492
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
493
				$template->set_var(array(
494
												'ID' => $page['page_id'],
495
												'TITLE' => ($title_prefix.$page['page_title'])
496
												)
497
										);
498
				if($can_modify == true) {
499
					$template->set_var('DISABLED', '');
500
				} else {
501
					$template->set_var('DISABLED', ' disabled="disabled" style="color: #aaa;"');
502
				}
503
				$template->parse('page_list2', 'page_list_block2', true);
504
		}
505
		parent_list($page['page_id']);
506
	}
507
}
508
$template->set_block('main_block', 'page_list_block2', 'page_list2');
509
if($admin->get_permission('pages_add_l0') == true) {
510
	$template->set_var(array(
511
									'ID' => '0',
512
									'TITLE' => $TEXT['NONE'],
513
									'SELECTED' => ' selected',
514
									'DISABLED' => ''
515
									)
516
							);
517
	$template->parse('page_list2', 'page_list_block2', true);
518
}
519
parent_list(0);
520

    
521
// Explode module permissions
522
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
523
// Modules list
524
$template->set_block('main_block', 'module_list_block', 'module_list');
525
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
526
if($result->numRows() > 0) {
527
	while ($module = $result->fetchRow()) {
528
		// Check if user is allowed to use this module
529
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
530
			$template->set_var('VALUE', $module['directory']);
531
			$template->set_var('NAME', $module['name']);
532
			if($module['directory'] == 'wysiwyg') {
533
				$template->set_var('SELECTED', ' selected');
534
			} else {
535
				$template->set_var('SELECTED', '');
536
			}
537
			$template->parse('module_list', 'module_list_block', true);
538
		}
539
	}
540
}
541

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

    
569
// Insert permissions values
570
if($admin->get_permission('pages_add') != true) {
571
	$template->set_var('DISPLAY_ADD', 'hide');
572
} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
573
	$template->set_var('DISPLAY_ADD', 'hide');
574
}
575
if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
576
	$template->set_var('DISPLAY_INTRO', 'hide');
577
}
578

    
579

    
580
// Parse template object
581
$template->parse('main', 'main_block', false);
582
$template->pparse('output', 'page');
583

    
584
// Print admin 
585
$admin->print_footer();
586

    
587
?>
(4-4/19)