Project

General

Profile

« Previous | Next » 

Revision 1009

Added by Matthias over 15 years ago

-Moved styles from admin/pages/sections.php to sections.htt in backend themes (Thanks to Luisehahne)

- Moved javascript files from admin/pages/index.php to external js files (Thanks to Luisehahne)

- Major improovements and changes to all backend files to get more valide Code output (Thanks to Luisehahne)

View differences:

index.php
1
<?php
2

  
3
// $Id$
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

  
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('viewers').style.display = 'block';
45
	} else if(document.add.visibility.value == 'registered') {
46
		document.getElementById('viewers').style.display = 'block';
47
	} else {
48
		document.getElementById('viewers').style.display = 'none';
49
	}
50
}
51
function toggle_visibility(id){
52
	if(document.getElementById(id).style.display == "block") {
53
		document.getElementById(id).style.display = "none";
54
		writeSessionCookie (id, "0");//Addition for remembering expanded state of pages
55
	} else {
56
		document.getElementById(id).style.display = "block";
57
		writeSessionCookie (id, "1");//Addition for remembering expanded state of pages
58
	}
59
}
60
var plus = new Image;
61
plus.src = "<?php echo THEME_URL; ?>/images/plus_16.png";
62
var minus = new Image;
63
minus.src = "<?php echo THEME_URL; ?>/images/minus_16.png";
64
function toggle_plus_minus(id) {
65
	var img_src = document.images['plus_minus_' + id].src;
66
	if(img_src == plus.src) {
67
		document.images['plus_minus_' + id].src = minus.src;
68
	} else {
69
		document.images['plus_minus_' + id].src = plus.src;
70
	}
71
}
72
</script>
73

  
74
<?php
75

  
76
function make_list($parent, $editable_pages) {
77
	// Get objects and vars from outside this function
78
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING;
79
	?>
80
	<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"'; }} ?>>
81
	<?php	
82
	// Get page list from database
83
	$database = new database();
84
	if(PAGE_TRASH != 'inline') {
85
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
86
	} else {
87
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
88
	}
89
	$get_pages = $database->query($query);
90
	
91
	// Insert values into main page list
92
	if($get_pages->numRows() > 0)	{
93
		while($page = $get_pages->fetchRow()) {
94
			// Get user perms
95
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
96
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
97

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

  
280
	}
281
	?>
282
	</ul>
283
	<?php
284
	return $editable_pages;
285
}
286

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

  
341
// Setup template object
342
$template = new Template(THEME_PATH.'/templates');
343
$template->set_file('page', 'pages.htt');
344
$template->set_block('page', 'main_block', 'main');
345

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

  
365
// Insert values into the add page form
366

  
367
// Group list 1
368

  
369
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
370

  
371
	$get_groups = $database->query($query);
372
	$template->set_block('main_block', 'group_list_block', 'group_list');
373
	// Insert admin group and current group first
374
	$admin_group_name = $get_groups->fetchRow();
375
	$template->set_var(array(
376
									'ID' => 1,
377
									'TOGGLE' => '',
378
									'DISABLED' => ' disabled',
379
									'LINK_COLOR' => '000000',
380
									'CURSOR' => 'default',
381
									'NAME' => $admin_group_name['name'],
382
									'CHECKED' => ' checked'
383
									)
384
							);
385
	$template->parse('group_list', 'group_list_block', true);
386

  
387
	while($group = $get_groups->fetchRow()) {
388
		// check if the user is a member of this group
389
		$flag_disabled = '';
390
		$flag_checked =  '';
391
		$flag_cursor =   'pointer';
392
		$flag_color =    '';
393
		if (in_array($group["group_id"], $admin->get_groups_id())) {
394
			$flag_disabled = ''; //' disabled';
395
			$flag_checked =  ' checked';
396
			$flag_cursor =   'default';
397
			$flag_color =    '000000';
398
		}
399

  
400
		// Check if the group is allowed to edit pages
401
		$system_permissions = explode(',', $group['system_permissions']);
402
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
403
			$template->set_var(array(
404
											'ID' => $group['group_id'],
405
											'TOGGLE' => $group['group_id'],
406
											'CHECKED' => $flag_checked,
407
											'DISABLED' => $flag_disabled,
408
											'LINK_COLOR' => $flag_color,
409
											'CURSOR' => $flag_checked,
410
											'NAME' => $group['name'],
411
											)
412
									);
413
			$template->parse('group_list', 'group_list_block', true);
414
		}
415
	}
416
// Group list 2
417

  
418
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
419

  
420
	$get_groups = $database->query($query);
421
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
422
	// Insert admin group and current group first
423
	$admin_group_name = $get_groups->fetchRow();
424
	$template->set_var(array(
425
									'ID' => 1,
426
									'TOGGLE' => '',
427
									'DISABLED' => ' disabled',
428
									'LINK_COLOR' => '000000',
429
									'CURSOR' => 'default',
430
									'NAME' => $admin_group_name['name'],
431
									'CHECKED' => ' checked'
432
									)
433
							);
434
	$template->parse('group_list2', 'group_list_block2', true);
435

  
436
	while($group = $get_groups->fetchRow()) {
437
		// check if the user is a member of this group
438
		$flag_disabled = '';
439
		$flag_checked =  '';
440
		$flag_cursor =   'pointer';
441
		$flag_color =    '';
442
		if (in_array($group["group_id"], $admin->get_groups_id())) {
443
			$flag_disabled = ''; //' disabled';
444
			$flag_checked =  ' checked';
445
			$flag_cursor =   'default';
446
			$flag_color =    '000000';
447
		}
448

  
449
		$template->set_var(array(
450
										'ID' => $group['group_id'],
451
										'TOGGLE' => $group['group_id'],
452
										'CHECKED' => $flag_checked,
453
										'DISABLED' => $flag_disabled,
454
										'LINK_COLOR' => $flag_color,
455
										'CURSOR' => $flag_cursor,
456
										'NAME' => $group['name'],
457
										)
458
								);
459
		$template->parse('group_list2', 'group_list_block2', true);
460
	}
461

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

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

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

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

  
577

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

  
582
// Print admin 
583
$admin->print_footer();
584

  
585
?>
1
<?php
2

  
3
// $Id$
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

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

  
239
// Generate pages list
240
if($admin->get_permission('pages_view') == true) {
241
	?>
242
	<div class="jsadmin hide"></div>
243
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
244
	<tr>
245
		<td>
246
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
247
		</td>
248
		<td align="right">
249
			<?php
250
				// Check if there are any pages that are in trash, and if we should show a link to the trash page
251
				if(PAGE_TRASH == 'separate') {
252
					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
253
					if($query_trash->numRows() > 0) {
254
						?>
255
						<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
256
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
257
						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
258
						<?php
259
					}
260
				}
261
			?>
262
		</td>
263
	</tr>
264
	</table>
265
	<div class="pages_list">
266
	<table cellpadding="0" cellspacing="0" border="0">
267
	<tr>
268
		<td width="20px">
269
			&nbsp;
270
		</td>
271
		<td width="314px">
272
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['PAGE_TITLE']; ?>:
273
		</td>
274
		<td width="256px" align="left">
275
			<?php echo $TEXT['MENU_TITLE']; ?>:
276
		</td>
277
		<td width="130px" align="center">
278
			<?php echo $TEXT['ACTIONS']; ?>:
279
		</td>		
280
	</tr>
281
	</table>
282
	<?php
283
	$page_tmp_id = 0;
284
	$editable_pages = make_list(0, 0);
285
	?>
286
	</div>
287
	<div class="empty_list">
288
		<?php echo $TEXT['NONE_FOUND']; ?>
289
	</div>
290
	<?php
291
} else {
292
	$editable_pages = 0;
293
}
294

  
295
// Setup template object
296
$template = new Template(THEME_PATH.'/templates');
297
$template->set_file('page', 'pages.htt');
298
$template->set_block('page', 'main_block', 'main');
299

  
300
// Figure out if the no pages found message should be shown or not
301
if($editable_pages == 0) {
302
	?>
303
	<style type="text/css">
304
	.pages_list {
305
		display: none;
306
	}
307
	</style>
308
	<?php
309
} else {
310
	?>
311
	<style type="text/css">
312
	.empty_list {
313
		display: none;
314
	}
315
	</style>
316
	<?php
317
}
318

  
319
// Insert values into the add page form
320

  
321
// Group list 1
322

  
323
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
324
	$get_groups = $database->query($query);
325
	$template->set_block('main_block', 'group_list_block', 'group_list');
326
	// Insert admin group and current group first
327
	$admin_group_name = $get_groups->fetchRow();
328
	$template->set_var(array(
329
									'ID' => 1,
330
									'TOGGLE' => '',
331
									'DISABLED' => ' disabled="disabled"',
332
									'LINK_COLOR' => '000000',
333
									'CURSOR' => 'default',
334
									'NAME' => $admin_group_name['name'],
335
									'CHECKED' => ' checked'
336
									)
337
							);
338
	$template->parse('group_list', 'group_list_block', true);
339

  
340
	while($group = $get_groups->fetchRow()) {
341
		// check if the user is a member of this group
342
		$flag_disabled = '';
343
		$flag_checked =  '';
344
		$flag_cursor =   'pointer';
345
		$flag_color =    '';
346
		if (in_array($group["group_id"], $admin->get_groups_id())) {
347
			$flag_disabled = ''; //' disabled';
348
			$flag_checked =  ' checked="checked"';
349
			$flag_cursor =   'default';
350
			$flag_color =    '000000';
351
		}
352

  
353
		// Check if the group is allowed to edit pages
354
		$system_permissions = explode(',', $group['system_permissions']);
355
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
356
			$template->set_var(array(
357
											'ID' => $group['group_id'],
358
											'TOGGLE' => $group['group_id'],
359
											'CHECKED' => $flag_checked,
360
											'DISABLED' => $flag_disabled,
361
											'LINK_COLOR' => $flag_color,
362
											'CURSOR' => $flag_checked,
363
											'NAME' => $group['name'],
364
											)
365
									);
366
			$template->parse('group_list', 'group_list_block', true);
367
		}
368
	}
369
// Group list 2
370

  
371
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
372

  
373
	$get_groups = $database->query($query);
374
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
375
	// Insert admin group and current group first
376
	$admin_group_name = $get_groups->fetchRow();
377
	$template->set_var(array(
378
									'ID' => 1,
379
									'TOGGLE' => '',
380
									'DISABLED' => ' disabled="disabled"',
381
									'LINK_COLOR' => '000000',
382
									'CURSOR' => 'default',
383
									'NAME' => $admin_group_name['name'],
384
									'CHECKED' => ' checked'
385
									)
386
							);
387
	$template->parse('group_list2', 'group_list_block2', true);
388

  
389
	while($group = $get_groups->fetchRow()) {
390
		// check if the user is a member of this group
391
		$flag_disabled = '';
392
		$flag_checked =  '';
393
		$flag_cursor =   'pointer';
394
		$flag_color =    '';
395
		if (in_array($group["group_id"], $admin->get_groups_id())) {
396
			$flag_disabled = ''; //' disabled';
397
			$flag_checked =  ' checked="checked"';
398
			$flag_cursor =   'default';
399
			$flag_color =    '000000';
400
		}
401

  
402
		$template->set_var(array(
403
										'ID' => $group['group_id'],
404
										'TOGGLE' => $group['group_id'],
405
										'CHECKED' => $flag_checked,
406
										'DISABLED' => $flag_disabled,
407
										'LINK_COLOR' => $flag_color,
408
										'CURSOR' => $flag_cursor,
409
										'NAME' => $group['name'],
410
										)
411
								);
412
		$template->parse('group_list2', 'group_list_block2', true);
413
	}
414

  
415
// Parent page list
416
$database = new database();
417
function parent_list($parent) {
418
	global $admin, $database, $template;
419
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
420
	$get_pages = $database->query($query);
421
	while($page = $get_pages->fetchRow()) {
422
		if($admin->page_is_visible($page)==false)
423
			continue;
424
		// if parent = 0 set flag_icon
425
		$template->set_var('FLAG_ROOT_ICON',' none ');
426
		if( $page['parent'] == 0 ) {
427
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
428
		}
429
		// Stop users from adding pages with a level of more than the set page level limit
430
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
431
			// Get user perms
432
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
433
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
434
			
435
			$in_group = FALSE;
436
			foreach($admin->get_groups_id() as $cur_gid) {
437
				if (in_array($cur_gid, $admin_groups)) {
438
					$in_group = TRUE;
439
				}
440
			}
441
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
442
				$can_modify = true;
443
			} else {
444
				$can_modify = false;
445
			}
446
			// Title -'s prefix
447
			$title_prefix = '';
448
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
449
				$template->set_var(array(
450
												'ID' => $page['page_id'],
451
												'TITLE' => ($title_prefix.$page['page_title'])
452
												)
453
										);
454
				if($can_modify == true) {
455
					$template->set_var('DISABLED', '');
456
				} else {
457
					$template->set_var('DISABLED', ' disabled="disabled" class="disabled"');
458
				}
459
				$template->parse('page_list2', 'page_list_block2', true);
460
		}
461
		parent_list($page['page_id']);
462
	}
463
}
464
$template->set_block('main_block', 'page_list_block2', 'page_list2');
465
if($admin->get_permission('pages_add_l0') == true) {
466
	$template->set_var(array(
467
									'ID' => '0',
468
									'TITLE' => $TEXT['NONE'],
469
									'SELECTED' => ' selected="selected"',
470
									'DISABLED' => ''
471
									)
472
							);
473
	$template->parse('page_list2', 'page_list_block2', true);
474
}
475
parent_list(0);
476

  
477
// Explode module permissions
478
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
479
// Modules list
480
$template->set_block('main_block', 'module_list_block', 'module_list');
481
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
482
if($result->numRows() > 0) {
483
	while ($module = $result->fetchRow()) {
484
		// Check if user is allowed to use this module
485
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
486
			$template->set_var('VALUE', $module['directory']);
487
			$template->set_var('NAME', $module['name']);
488
			if($module['directory'] == 'wysiwyg') {
489
				$template->set_var('SELECTED', ' selected="selected"');
490
			} else {
491
				$template->set_var('SELECTED', '');
492
			}
493
			$template->parse('module_list', 'module_list_block', true);
494
		}
495
	}
496
}
497

  
498
// Insert urls
499
$template->set_var(array(
500
								'THEME_URL' => THEME_URL,
501
								'WB_URL' => WB_URL,
502
								'WB_PATH' => WB_PATH,
503
								'ADMIN_URL' => ADMIN_URL,
504
								)
505
						);
506

  
507
// Insert language headings
508
$template->set_var(array(
509
								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
510
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
511
								)
512
						);
513
// Insert language text and messages
514
$template->set_var(array(
515
								'TEXT_TITLE' => $TEXT['TITLE'],
516
								'TEXT_TYPE' => $TEXT['TYPE'],
517
								'TEXT_PARENT' => $TEXT['PARENT'],
518
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
519
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
520
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
521
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
522
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
523
								'TEXT_NONE' => $TEXT['NONE'],
524
								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
525
								'TEXT_ADD' => $TEXT['ADD'],
526
								'TEXT_RESET' => $TEXT['RESET'],
527
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
528
								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
529
								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
530
								'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
531
								)
532
						);
533

  
534
// Insert permissions values
535
if($admin->get_permission('pages_add') != true) {
536
	$template->set_var('DISPLAY_ADD', 'hide');
537
} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
538
	$template->set_var('DISPLAY_ADD', 'hide');
539
}
540
if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
541
	$template->set_var('DISPLAY_INTRO', 'hide');
542
}
543

  
544

  
545
// Parse template object
546
$template->parse('main', 'main_block', false);
547
$template->pparse('output', 'page');
548

  
549
// Print admin 
550
$admin->print_footer();
551

  
552
?>

Also available in: Unified diff