Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher and higher
13
 * @version         $Id: index.php 1402 2011-01-22 04:41:07Z Luisehahne $
14
 * @filesource		$HeadURL:  $
15
 * @lastmodified    $Date:  $
16
 *
17
 */
18

    
19
require('../../config.php');
20
require_once(WB_PATH.'/framework/class.admin.php');
21
$admin = new admin('Pages', 'pages');
22

    
23
$admin->clearIDKEY();
24

    
25
// Include the WB functions file
26
require_once(WB_PATH.'/framework/functions.php');
27
// eggsurplus: add child pages for a specific page
28
?>
29
<script type="text/javascript" src="<?php print ADMIN_URL; ?>/pages/eggsurplus.js"></script>
30
<?php
31
/*
32
urlencode function and rawurlencode are mostly based on RFC 1738.
33
However, since 2005 the current RFC in use for URIs standard is RFC 3986.
34
Here is a function to encode URLs according to RFC 3986.
35
*/
36
function url_encode($string) {
37
    $string = html_entity_decode($string,ENT_QUOTES,'UTF-8');
38
    $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
39
    $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
40
    return str_replace($entities, $replacements, rawurlencode($string));
41
}
42
// fixes A URI contains impermissible characters or quotes around the URI are not closed.
43
$MESSAGE['PAGES_DELETE_CONFIRM'] = url_encode( ( $MESSAGE['PAGES_DELETE_CONFIRM']) );
44

    
45
function set_node ($parent,& $par)
46
{
47
    $retval = '';
48

    
49
	if($par['num_subs'] )
50
	{
51
    $retval .= "\n".'<ul id="p'.$parent.'"';
52
	if ($parent != 0)
53
	{
54
		$retval .= ' class="page_list"';
55
		if (isset ($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1')
56
		{
57
			 $retval .= ' style="display:block"';
58
		}
59
	}
60
	$retval .= ">\n";
61
 	}
62

    
63
	return $retval;
64
}
65

    
66
function make_list($parent = 0, $editable_pages = 0) {
67
	// Get objects and vars from outside this function
68
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $par;
69

    
70
    print set_node ($parent,$par);
71

    
72
	// Get page list from database
73
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ';
74
    $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
75
    $sql .= 'ORDER BY `position` ASC';
76
	$get_pages = $database->query($sql);
77

    
78
	// Insert values into main page list
79
	if($get_pages->numRows() > 0)
80
	{
81
		while($page = $get_pages->fetchRow())
82
		{
83
			// Get user perms
84
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
85
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
86
			$in_group = FALSE;
87
			foreach($admin->get_groups_id() as $cur_gid)
88
            {
89
				if (in_array($cur_gid, $admin_groups))
90
                {
91
					$in_group = TRUE;
92
				}
93
			}
94
			if(($in_group) || is_numeric(array_search($admin->get_user_id(), $admin_users)))
95
            {
96
				if($page['visibility'] == 'deleted')
97
                {
98
					if(PAGE_TRASH == 'inline')
99
                    {
100
						$can_modify = true;
101
						$editable_pages = $editable_pages+1;
102
					} else {
103
						$can_modify = false;
104
					}
105
				} elseif($page['visibility'] != 'deleted')
106
                {
107
					$can_modify = true;
108
					$editable_pages = $editable_pages+1;
109
				}
110
			} else {
111
				if($page['visibility'] == 'private')
112
                {
113
					continue;
114
				}
115
				else {
116
					$can_modify = false;
117
				}
118
			}
119

    
120
			// Work out if we should show a plus or not
121
            $sql = 'SELECT `page_id`,`admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$page['page_id'].' ';
122
            $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
123
            // $sql .= ' ORDER BY `position` ASC';
124
        	$get_page_subs = $database->query($sql);
125
			$num_subs = $get_page_subs->numRows();
126
			$par['num_subs'] = $num_subs;
127
/*
128
			if(PAGE_TRASH != 'inline')
129
            {
130
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
131
			} else {
132
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
133
			}
134
*/
135
			if($get_page_subs->numRows() > 0)
136
            {
137
				$display_plus = true;
138
			} else {
139
				$display_plus = false;
140
			}
141
			// Work out how many pages there are for this parent
142
			$num_pages = $get_pages->numRows();
143
			?>
144
			<li class="p<?php echo $page['parent']; ?>">
145
			<table summary="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>" class="pages_view" cellpadding="0" cellspacing="0">
146
			<tr>
147
				<td valign="middle" width="20" style="padding-left: <?php if($page['level'] > 0){ echo $page['level']*20; } else { echo '7'; } ?>px;">
148
					<?php
149
					if($display_plus == true) {
150
					?>
151
					<a href="javascript:toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
152
						<img src="<?php echo THEME_URL; ?>/images/<?php if(isset($_COOKIE['p'.$page['page_id']]) && $_COOKIE['p'.$page['page_id']] == '1'){ echo 'minus'; } else { echo 'plus'; } ?>_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id']; ?>');" name="plus_minus_<?php echo $page['page_id']; ?>" alt="+" />
153
					</a>
154
					<?php
155
					}
156
					?>
157
				</td>
158
				<?php if($admin->get_permission('pages_modify') == true && $can_modify == true) { ?>
159
				<td class="list_menu_title">
160
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo /*$admin->getIDKEY($page['page_id'])*/ $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
161
						<?php if($page['visibility'] == 'public') { ?>
162
							<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
163
						<?php } elseif($page['visibility'] == 'private') { ?>
164
							<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
165
						<?php } elseif($page['visibility'] == 'registered') { ?>
166
							<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
167
						<?php } elseif($page['visibility'] == 'hidden') { ?>
168
							<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
169
						<?php } elseif($page['visibility'] == 'none') { ?>
170
							<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
171
						<?php } elseif($page['visibility'] == 'deleted') { ?>
172
							<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
173
						<?php }
174
						echo '<span class="modify_link">'.($page['menu_title']).'</span>'; ?>
175
					</a>
176
				</td>
177
				<?php } else { ?>
178
				<td class="list_menu_title">
179
					<?php if($page['visibility'] == 'public') { ?>
180
						<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
181
					<?php } elseif($page['visibility'] == 'private') { ?>
182
						<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
183
					<?php } elseif($page['visibility'] == 'registered') { ?>
184
						<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
185
					<?php } elseif($page['visibility'] == 'hidden') { ?>
186
						<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
187
					<?php } elseif($page['visibility'] == 'none') { ?>
188
						<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
189
					<?php } elseif($page['visibility'] == 'deleted') { ?>
190
						<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
191
					<?php }
192
					echo ($page['menu_title']); ?>
193
				</td>
194
				<?php } ?>
195
				<td class="list_page_title">
196
					<?php echo ($page['page_title']); ?>
197
				</td>
198
				<td class="list_page_id">
199
					<?php echo $page['page_id']; ?>
200
				</td>
201

    
202
				<td class="list_actions">
203
					<?php if($page['visibility'] != 'deleted' && $page['visibility'] != 'none') { ?>
204
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
205
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" alt="<?php echo $TEXT['VIEW']; ?>" />
206
					</a>
207
					<?php } ?>
208
				</td>
209
				<td class="list_actions">
210
					<?php if($page['visibility'] != 'deleted') { ?>
211
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
212
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo /*$admin->getIDKEY($page['page_id'])*/ $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
213
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" alt="<?php echo $TEXT['SETTINGS']; ?>" />
214
						</a>
215
						<?php } ?>
216
					<?php } else { ?>
217
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo /*$admin->getIDKEY($page['page_id'])*/ $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
218
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" alt="<?php echo $TEXT['RESTORE']; ?>" />
219
						</a>
220
					<?php } ?>
221
				</td>
222
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
223
				<td class="list_actions">
224
				<?php
225
				// Work-out if we should show the "manage dates" link
226
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true)
227
                {
228
                    $sql = 'SELECT `publ_start`, `publ_end` FROM `'.TABLE_PREFIX.'sections` ';
229
                    $sql .= 'WHERE `page_id` = '.$page['page_id'].' AND `module` != \'menu_link\' ';
230
                    $query_sections = $database->query($sql);
231

    
232
					// $query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
233

    
234
					if($query_sections->numRows() > 0)
235
                    {
236
						$mdate_display=false;
237
						while($mdate_res = $query_sections->fetchRow())
238
                        {
239
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0')
240
                            {
241
								$mdate_display=true;
242
								break;
243
							}
244
						}
245
						if($mdate_display==1)
246
                        {
247
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
248
							?>
249
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo /*$admin->getIDKEY($page['page_id'])*/ $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
250
							<img src="<?php echo THEME_URL."/images/$file"; ?>" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
251
							</a>
252
						<?php } else { ?>
253
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo /*$admin->getIDKEY($page['page_id'])*/ $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
254
							<img src="<?php echo THEME_URL; ?>/images/noclock_16.png" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>
255
						<?php } ?>
256
					<?php } ?>
257
				<?php } ?>
258
				</td>
259
				<td class="list_actions">
260
				<?php if($page['position'] != 1) { ?>
261
					<?php if($page['visibility'] != 'deleted') { ?>
262
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
263
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
264
							<img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="<?php echo $TEXT['MOVE_UP']; ?>" />
265
						</a>
266
						<?php } ?>
267
					<?php } ?>
268
				<?php } ?>
269
				</td>
270
				<td class="list_actions">
271
				<?php if($page['position'] != $num_pages) { ?>
272
					<?php if($page['visibility'] != 'deleted') { ?>
273
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
274
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
275
							<img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="<?php echo $TEXT['MOVE_DOWN']; ?>" />
276
						</a>
277
						<?php } ?>
278
					<?php } ?>
279
				<?php } ?>
280
				</td>
281
				<td class="list_actions">
282
					<?php if($admin->get_permission('pages_delete') == true && $can_modify == true) { // add IdKey ?>
283
					<a href="javascript:confirm_link('<?php echo $MESSAGE['PAGES_DELETE_CONFIRM']; ?>?','<?php echo ADMIN_URL; ?>/pages/delete.php?page_id=<?php echo /*$admin->getIDKEY($page['page_id'])*/ $page['page_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
284
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['DELETE']; ?>" />
285
					</a>
286
					<?php } ?>
287
				</td>
288
				<?php
289
				// eggsurplus: Add action to add a page as a child
290
				?>
291
				<td class="list_actions">
292
					<?php if(($admin->get_permission('pages_add')) == (true && $can_modify == true) && ($page['visibility'] != 'deleted')) { ?>
293
					<a href="javascript:add_child_page('<?php echo $page['page_id']; ?>');" title="<?php echo $HEADING['ADD_PAGE']; ?>">
294
						<img src="<?php echo THEME_URL; ?>/images/siteadd.png" name="addpage_<?php echo $page['page_id']; ?>" alt="Add Child Page" />
295
					</a>
296
					<?php } ?>
297
				</td>
298
				<?php
299
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
300
				?>
301

    
302
			</tr>
303
			</table>
304
			<?php
305
			if ( $page['parent'] == 0)
306
            {
307
				$page_tmp_id = $page['page_id'];
308
			}
309
			// Get subs
310
			$editable_pages=make_list($page['page_id'], $editable_pages);
311
            print '</li>'."\n";
312
		}
313
	}
314
	$output = ($par['num_subs'] )? '</ul>'."\n" : '';
315
    $par['num_subs'] = (empty($output) ) ?  1 : $par['num_subs'];
316
    print $output;
317
	return $editable_pages;
318
}
319

    
320
// Generate pages list
321
if($admin->get_permission('pages_view') == true) {
322
	?>
323
	<div class="jsadmin hide"></div>
324
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0" width="100%">
325
	<tr>
326
		<td>
327
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
328
		</td>
329
		<td align="right"></td>
330
	</tr>
331
	</table>
332
	<div class="pages_list">
333
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0">
334
	<tr class="pages_list_header">
335
		<td class="header_list_menu_title">
336
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE']; ?>:
337
		</td>
338
		<td class="header_list_page_title">
339
			<?php echo $TEXT['PAGE_TITLE']; ?>:
340
		</td>
341
		<td class="header_list_page_id">
342
			ID:
343
		</td>
344
		<td class="header_list_actions">
345
			<?php echo $TEXT['ACTIONS']; ?>:
346
		</td>
347
	</tr>
348
	</table>
349
	<?php
350
    // Work-out if we should check for existing page_code
351
    $field_sql = $database->query("DESCRIBE ".TABLE_PREFIX."pages page_code");
352
    $field_set = $field_sql->numRows();
353
    $par = array();
354
	$par['num_subs'] = 1;
355
	$editable_pages = make_list(0, 0);
356
} else {
357
	$editable_pages = 0;
358
}
359
 ?></div><?php
360

    
361
if(intval($editable_pages) == 0 ) {
362
	?>
363
	<div class="empty_list">
364
		<?php echo $TEXT['NONE_FOUND']; ?>
365
	</div>
366
	<?php
367
}
368
// Setup template object
369
$template = new Template(THEME_PATH.'/templates');
370
$template->set_file('page', 'pages.htt');
371
$template->set_block('page', 'main_block', 'main');
372
// Insert values into the add page form
373
$template->set_var('FTAN', $admin->getFTAN());
374

    
375
// Group list 1
376

    
377
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
378
	$get_groups = $database->query($query);
379
	$template->set_block('main_block', 'group_list_block', 'group_list');
380
	// Insert admin group and current group first
381
	$admin_group_name = $get_groups->fetchRow();
382
	$template->set_var(array(
383
									'ID' => 1,
384
									'TOGGLE' => '1',
385
									'DISABLED' => ' disabled="disabled"',
386
									'LINK_COLOR' => '000000',
387
									'CURSOR' => 'default',
388
									'NAME' => $admin_group_name['name'],
389
									'CHECKED' => ' checked="checked"'
390
									)
391
							);
392
	$template->parse('group_list', 'group_list_block', true);
393

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

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

    
425
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
426

    
427
	$get_groups = $database->query($query);
428
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
429
	// Insert admin group and current group first
430
	$admin_group_name = $get_groups->fetchRow();
431
	$template->set_var(array(
432
									'ID' => 1,
433
									'TOGGLE' => '1',
434
									'DISABLED' => ' disabled="disabled"',
435
									'LINK_COLOR' => '000000',
436
									'CURSOR' => 'default',
437
									'NAME' => $admin_group_name['name'],
438
									'CHECKED' => ' checked="checked"'
439
									)
440
							);
441
	$template->parse('group_list2', 'group_list_block2', true);
442

    
443
	while($group = $get_groups->fetchRow()) {
444
		// check if the user is a member of this group
445
		$flag_disabled = '';
446
		$flag_checked =  '';
447
		$flag_cursor =   'pointer';
448
		$flag_color =    '';
449
		if (in_array($group["group_id"], $admin->get_groups_id())) {
450
			$flag_disabled = ''; //' disabled';
451
			$flag_checked =  ' checked="checked"';
452
			$flag_cursor =   'default';
453
			$flag_color =    '000000';
454
		}
455

    
456
		$template->set_var(array(
457
										'ID' => $group['group_id'],
458
										'TOGGLE' => $group['group_id'],
459
										'CHECKED' => $flag_checked,
460
										'DISABLED' => $flag_disabled,
461
										'LINK_COLOR' => $flag_color,
462
										'CURSOR' => $flag_cursor,
463
										'NAME' => $group['name'],
464
										)
465
								);
466
		$template->parse('group_list2', 'group_list_block2', true);
467
	}
468

    
469

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

    
534
// Explode module permissions
535
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
536
// Modules list
537
$template->set_block('main_block', 'module_list_block', 'module_list');
538
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
539
if($result->numRows() > 0) {
540
	while ($module = $result->fetchRow()) {
541
		// Check if user is allowed to use this module
542
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
543
			$template->set_var('VALUE', $module['directory']);
544
			$template->set_var('NAME', $module['name']);
545
			if($module['directory'] == 'wysiwyg') {
546
				$template->set_var('SELECTED', ' selected="selected"');
547
			} else {
548
				$template->set_var('SELECTED', '');
549
			}
550
			$template->parse('module_list', 'module_list_block', true);
551
		}
552
	}
553
}
554

    
555
// Insert urls
556
$template->set_var(array(
557
								'THEME_URL' => THEME_URL,
558
								'WB_URL' => WB_URL,
559
								'WB_PATH' => WB_PATH,
560
								'ADMIN_URL' => ADMIN_URL,
561
								)
562
						);
563

    
564
// Insert language headings
565
$template->set_var(array(
566
								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
567
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
568
								)
569
						);
570
// Insert language text and messages
571
$template->set_var(array(
572
								'TEXT_TITLE' => $TEXT['TITLE'],
573
								'TEXT_TYPE' => $TEXT['TYPE'],
574
								'TEXT_PARENT' => $TEXT['PARENT'],
575
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
576
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
577
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
578
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
579
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
580
								'TEXT_NONE' => $TEXT['NONE'],
581
								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
582
								'TEXT_ADD' => $TEXT['ADD'],
583
								'TEXT_RESET' => $TEXT['RESET'],
584
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
585
								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
586
								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
587
								'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
588
								)
589
						);
590

    
591
// Insert permissions values
592
if($admin->get_permission('pages_add') != true) {
593
	$template->set_var('DISPLAY_ADD', 'hide');
594
} elseif($admin->get_permission('pages_add_l0') != true && $editable_pages == 0) {
595
	$template->set_var('DISPLAY_ADD', 'hide');
596
}
597
if($admin->get_permission('pages_intro') != true || INTRO_PAGE != 'enabled') {
598
	$template->set_var('DISPLAY_INTRO', 'hide');
599
}
600

    
601

    
602
// Parse template object
603
$template->parse('main', 'main_block', false);
604
$template->pparse('output', 'page');
605

    
606
// include the required file for Javascript admin
607
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
608
{
609
	include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
610
}
611

    
612
// Print admin
613
$admin->print_footer();
614

    
615
?>
(5-5/21)