Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2012, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher and higher
12
 * @version         $Id: index.php 1831 2012-12-04 22:42:12Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/index.php $
14
 * @lastmodified    $Date: 2012-12-04 23:42:12 +0100 (Tue, 04 Dec 2012) $
15
 *
16
 */
17

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

    
22
$admin->clearIDKEY();
23

    
24
// Include the WB functions file
25
require_once(WB_PATH.'/framework/functions.php');
26
// eggsurplus: add child pages for a specific page
27
/**/
28

    
29
 ?>
30
<script type="text/javascript" src="<?php print ADMIN_URL;  ?>/pages/eggsurplus.js"></script>
31
<?php
32
// fixes A URI contains impermissible characters or quotes around the URI are not closed.
33
$MESSAGE['PAGES_DELETE_CONFIRM'] = url_encode(  $MESSAGE['PAGES_DELETE_CONFIRM'] );
34

    
35
function set_node ($parent,& $par)
36
{
37
    $retval = '';
38

    
39
	if($par['num_subs'] )
40
	{
41
    $retval .= "\n".'<ul id="p'.$parent.'"';
42
	if ($parent != 0)
43
	{
44
		$retval .= ' class="page_list"';
45
		if (isset ($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1')
46
		{
47
			 $retval .= ' style="display:block"';
48
		}
49
	}
50
	$retval .= ">\n";
51
 	}
52

    
53
	return $retval;
54
}
55

    
56
function make_list($parent = 0, $editable_pages = 0) {
57
	// Get objects and vars from outside this function
58
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $par;
59
	static $row,$iLevel,$iOldLevel;
60
	static $aRowLevel = array();
61
    print set_node ($parent,$par);
62

    
63
	// Get page list from database
64
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ';
65
    $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
66
    $sql .= 'ORDER BY `position` ASC';
67
	$get_pages = $database->query($sql);
68
	// Work out how many pages there are for this parent
69
	$num_pages = $get_pages->numRows();
70

    
71
	// Insert values into main page list
72
	if($get_pages->numRows() > 0)
73
	{
74
		while($page = $get_pages->fetchRow())
75
		{
76

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

    
115
			// Work out if we should show a plus or not
116
            $sql = 'SELECT `page_id`,`admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$page['page_id'].' ';
117
            $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
118
            // $sql .= ' ORDER BY `position` ASC';
119
        	$get_page_subs = $database->query($sql);
120
			$num_subs = $get_page_subs->numRows();
121
			$par['num_subs'] = $num_subs;
122
/*
123
			if(PAGE_TRASH != 'inline')
124
            {
125
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
126
			} else {
127
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
128
			}
129
*/
130
			if($get_page_subs->numRows() > 0)
131
            {
132
				$display_plus = true;
133
			} else {
134
				$display_plus = false;
135
			}
136

    
137
			 ?>
138
			<li class="p<?php echo $page['parent'];  ?>">
139
			<table class="pages_view">
140
            <tbody>
141
			<tr class="row_<?php echo $row  ?>">
142
				<td valign="middle" width="20" style="padding-left: <?php echo $page['level']==0 ? 0 : ($page['level']*25)-pow($page['level'],2);  ?>px;">
143
					<?php
144
					if($display_plus == true) {
145
					 ?>
146
					<a href="javascript:toggle_visibility('p<?php echo $page['page_id'];  ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE'];  ?>">
147
					<span>
148
					<img src="<?php echo THEME_URL;  ?>/images/<?php echo ( isset($_COOKIE['p'.$page['page_id']]) && $_COOKIE['p'.$page['page_id']] == '1') ?'minus' : 'plus';   ?>_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id'];  ?>');" name="plus_minus_<?php echo $page['page_id'];  ?>" alt="+" />
149
					</span>
150

    
151
					</a>
152
					<?php
153
					}
154
					 ?>
155
				</td>
156
				<?php if($admin->get_permission('pages_modify') == true && $can_modify == true) {  ?>
157
				<td class="list_menu_title">
158
					<a href="<?php echo ADMIN_URL;  ?>/pages/modify.php?page_id=<?php echo  $page['page_id'];  ?>" title="<?php echo $TEXT['MODIFY'];  ?>">
159
					<span>
160
						<?php if($page['visibility'] == 'public') {  ?>
161
							<img src="<?php echo THEME_URL;  ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['PUBLIC'];  ?>" class="page_list_rights" />
162
						<?php } elseif($page['visibility'] == 'private') {  ?>
163
							<img src="<?php echo THEME_URL;  ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['PRIVATE'];  ?>" class="page_list_rights" />
164
						<?php } elseif($page['visibility'] == 'registered') {  ?>
165
							<img src="<?php echo THEME_URL;  ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['REGISTERED'];  ?>" class="page_list_rights" />
166
						<?php } elseif($page['visibility'] == 'hidden') {  ?>
167
							<img src="<?php echo THEME_URL;  ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['HIDDEN'];  ?>" class="page_list_rights" />
168
						<?php } elseif($page['visibility'] == 'none') {  ?>
169
							<img src="<?php echo THEME_URL;  ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['NONE'];  ?>" class="page_list_rights" />
170
						<?php } elseif($page['visibility'] == 'deleted') {  ?>
171
							<img src="<?php echo THEME_URL;  ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['DELETED'];  ?>" class="page_list_rights" />
172
						<?php }
173
						echo '<span class="modify_link">'.($page['menu_title']).'</span>';  ?>
174
					</span>
175
					</a>
176
				</td>
177
				<?php } else {  ?>
178
				<td class="list_menu_title">
179
					<span>
180
					<?php if($page['visibility'] == 'public') {  ?>
181
						<img src="<?php echo THEME_URL;  ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['PUBLIC'];  ?>" class="page_list_rights" />
182
					<?php } elseif($page['visibility'] == 'private') {  ?>
183
						<img src="<?php echo THEME_URL;  ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['PRIVATE'];  ?>" class="page_list_rights" />
184
					<?php } elseif($page['visibility'] == 'registered') {  ?>
185
						<img src="<?php echo THEME_URL;  ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['REGISTERED'];  ?>" class="page_list_rights" />
186
					<?php } elseif($page['visibility'] == 'hidden') {  ?>
187
						<img src="<?php echo THEME_URL;  ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['HIDDEN'];  ?>" class="page_list_rights" />
188
					<?php } elseif($page['visibility'] == 'none') {  ?>
189
						<img src="<?php echo THEME_URL;  ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['NONE'];  ?>" class="page_list_rights" />
190
					<?php } elseif($page['visibility'] == 'deleted') {  ?>
191
						<img src="<?php echo THEME_URL;  ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['DELETED'];  ?>" class="page_list_rights" />
192
					<?php }
193
					echo '<span class="bold grey">'.($page['menu_title']).'</span>';  ?>
194
					</span>
195
				</td>
196
				<?php }  ?>
197
				<td class="list_page_title">
198
					<?php echo ($page['page_title']);  ?>
199
				</td>
200
				<td class="list_page_id right">
201
					<?php echo $page['page_id'];  ?>
202
				</td>
203

    
204
				<td class="list_actions">
205
					<?php if($page['visibility'] != 'deleted' && $page['visibility'] != 'none') {  ?>
206
					<a href="<?php echo $admin->page_link($page['link']);  ?>" target="_blank" title="<?php echo $TEXT['VIEW'];  ?>">
207
						<img src="<?php echo THEME_URL;  ?>/images/view_16.png" alt="<?php echo $TEXT['VIEW'];  ?>" />
208
					</a>
209
					<?php }  ?>
210
				</td>
211
				<td class="list_actions">
212
					<?php if($page['visibility'] != 'deleted') {  ?>
213
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) {  ?>
214
						<a href="<?php echo ADMIN_URL;  ?>/pages/settings.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $TEXT['SETTINGS'];  ?>">
215
							<img src="<?php echo THEME_URL;  ?>/images/modify_16.png" alt="<?php echo $TEXT['SETTINGS'];  ?>" />
216
						</a>
217
						<?php }  ?>
218
					<?php } else {  ?>
219
						<a href="<?php echo ADMIN_URL;  ?>/pages/restore.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $TEXT['RESTORE'];  ?>">
220
							<img src="<?php echo THEME_URL;  ?>/images/restore_16.png" alt="<?php echo $TEXT['RESTORE'];  ?>" />
221
						</a>
222
					<?php }  ?>
223
				</td>
224
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
225
				<td class="list_actions">
226
				<?php
227
				// Work-out if we should show the "manage dates" link
228
				if( (MANAGE_SECTIONS == true) && $admin->get_permission('pages_add')==true && $can_modify==true)
229
                {
230
                    $sql = 'SELECT `publ_start`, `publ_end` FROM `'.TABLE_PREFIX.'sections` ';
231
                    $sql .= 'WHERE `page_id` = '.$page['page_id'].' AND `module` != \'menu_link\' ';
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
					if( ($query_sections = $database->query($sql)) )
234
                    {
235
						$mdate_display=false;
236
						while($mdate_res = $query_sections->fetchRow())
237
                        {
238
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0')
239
                            {
240
								$mdate_display=true;
241
								break;
242
							}
243
						}
244
						if($mdate_display==1)
245
                        {
246
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
247
							 ?>
248
							<a href="<?php echo ADMIN_URL;  ?>/pages/sections.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $HEADING['MANAGE_SECTIONS'];  ?>">
249
							<img src="<?php echo THEME_URL."/images/$file";  ?>" alt="<?php echo $HEADING['MANAGE_SECTIONS'];  ?>" />
250
							</a>
251
						<?php } else {  ?>
252
							<a href="<?php echo ADMIN_URL;  ?>/pages/sections.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $HEADING['MANAGE_SECTIONS'];  ?>">
253
							<img src="<?php echo THEME_URL;  ?>/images/noclock_16.png" alt="<?php echo $HEADING['MANAGE_SECTIONS'];  ?>" /></a>
254
						<?php }  ?>
255
					<?php }  ?>
256
				<?php }  ?>
257
				</td>
258
				<td class="list_actions">
259
				<?php if($page['position'] != 1) {  ?>
260
					<?php if($page['visibility'] != 'deleted') {  ?>
261
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) {  ?>
262
						<a href="<?php echo ADMIN_URL;  ?>/pages/move_up.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $TEXT['MOVE_UP'];  ?>">
263
							<img src="<?php echo THEME_URL;  ?>/images/up_16.png" alt="<?php echo $TEXT['MOVE_UP'];  ?>" />
264
						</a>
265
						<?php }  ?>
266
					<?php }  ?>
267
				<?php }  ?>
268
				</td>
269
				<td class="list_actions">
270
				<?php if($page['position'] != $num_pages) {  ?>
271
					<?php if($page['visibility'] != 'deleted') {  ?>
272
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) {  ?>
273
						<a href="<?php echo ADMIN_URL;  ?>/pages/move_down.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $TEXT['MOVE_DOWN'];  ?>">
274
							<img src="<?php echo THEME_URL;  ?>/images/down_16.png" alt="<?php echo $TEXT['MOVE_DOWN'];  ?>" />
275
						</a>
276
						<?php }  ?>
277
					<?php }  ?>
278
				<?php }  ?>
279
				</td>
280
				<td class="list_actions">
281
					<?php if($admin->get_permission('pages_delete') == true && $can_modify == true) { // add IdKey  ?>
282
					<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']);  ?>');" title="<?php echo $TEXT['DELETE'];  ?>">
283
						<img src="<?php echo THEME_URL;  ?>/images/delete_16.png" alt="<?php echo $TEXT['DELETE'];  ?>" />
284
					</a>
285
					<?php }  ?>
286
				</td>
287
				<?php
288
				// eggsurplus: Add action to add a page as a child
289
				 ?>
290
				<td class="list_actions">
291
					<?php if(($admin->get_permission('pages_add')) == true && ($can_modify == true) && ($page['visibility'] != 'deleted')) {  ?>
292
					<a href="javascript:add_child_page('<?php echo $page['page_id'];  ?>');" title="<?php echo $HEADING['ADD_CHILD_PAGE'];  ?>">
293
						<img src="<?php echo THEME_URL;  ?>/images/siteadd.png" name="addpage_<?php echo $page['page_id'];  ?>" alt="Add Child Page" />
294
					</a>
295
					<?php }  ?>
296
				</td>
297
				<?php
298
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
299
				 ?>
300
				<td class="list_page_id center">
301
					<?php echo $page['language'];  ?>
302
				</td>
303
			</tr>
304
            </tbody>
305
			</table>
306
			<?php
307
			if ( $page['parent'] == 0)
308
            {
309
				$page_tmp_id = $page['page_id'];
310
			}
311
			// Get subs
312
			$editable_pages=make_list($page['page_id'], $editable_pages);
313
            print '</li>'."\n";
314
		}
315
	}
316
	$output = ($par['num_subs'] )? '</ul>'."\n" : '';
317
    $par['num_subs'] = (empty($output) ) ?  1 : $par['num_subs'];
318
    print $output;
319
	return $editable_pages;
320
}
321

    
322
// Generate pages list
323
if($admin->get_permission('pages_view') == true) {
324
	 ?>
325
	<div class="jsadmin hide"></div>
326
	<table>
327
    <tbody>
328
	<tr>
329
		<td>
330
			<h2 class="left"><?php echo $HEADING['MODIFY_DELETE_PAGE'];  ?></h2>
331
		</td>
332
		<td align="right"></td>
333
	</tr>
334
    </tbody>
335
	</table>
336
	<div class="pages_list">
337
	<table>
338
    <tbody>
339
	<tr class="pages_list_header">
340
		<td class="header_list_menu_title">
341
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE'];  ?>:
342
		</td>
343
		<td class="header_list_page_title">
344
			<?php echo $TEXT['PAGE_TITLE'];  ?>:
345
		</td>
346
		<td class="header_list_page_id">
347
			PID
348
		</td>
349
		<td class="header_list_actions">
350
			<?php echo $TEXT['ACTIONS'];  ?>:
351
		</td>
352
		<td class="list_page_id">
353
		
354
		</td>
355
	</tr>
356
    </tbody>
357
	</table>
358
	<?php
359
	// Work-out if we should check for existing page_code
360
	$field_set = $database->field_exists(TABLE_PREFIX.'pages', 'page_code');
361

    
362
    $par = array();
363
	$par['num_subs'] = 1;
364
	$editable_pages = make_list(0, 0);
365
} else {
366
	$editable_pages = 0;
367
}
368
  ?></div><?php
369

    
370
if(intval($editable_pages) == 0 ) {
371
	 ?>
372
	<div class="empty_list">
373
		<?php echo $TEXT['NONE_FOUND'];  ?>
374
	</div>
375
	<?php
376
}
377
// Setup template object, parse vars to it, then parse it
378
// Create new template object
379
$template = new Template(dirname($admin->correct_theme_source('pages.htt')),'keep');
380
// $template->debug = true;
381
$template->set_file('page', 'pages.htt');
382
$template->set_block('page', 'main_block', 'main');
383
// Insert values into the add page form
384
$template->set_var('FTAN', $admin->getFTAN());
385

    
386
// Group list 1
387

    
388
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
389
	$get_groups = $database->query($query);
390
	$template->set_block('main_block', 'group_list_block', 'group_list');
391
	// Insert admin group and current group first
392
	$admin_group_name = $get_groups->fetchRow();
393
	$template->set_var(array(
394
									'ID' => 1,
395
									'TOGGLE' => '1',
396
									'DISABLED' => ' disabled="disabled"',
397
									'LINK_COLOR' => '000000',
398
									'CURSOR' => 'default',
399
									'NAME' => $admin_group_name['name'],
400
									'CHECKED' => ' checked="checked"'
401
									)
402
							);
403
	$template->parse('group_list', 'group_list_block', true);
404

    
405
	while($group = $get_groups->fetchRow()) {
406
		// check if the user is a member of this group
407
		$flag_disabled = '';
408
		$flag_checked =  '';
409
		$flag_cursor =   'pointer';
410
		$flag_color =    '';
411
		if (in_array($group["group_id"], $admin->get_groups_id())) {
412
			$flag_disabled = ''; //' disabled';
413
			$flag_checked =  ' checked="checked"';
414
			$flag_cursor =   'default';
415
			$flag_color =    '000000';
416
		}
417

    
418
		// Check if the group is allowed to edit pages
419
		$system_permissions = explode(',', $group['system_permissions']);
420
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
421
			$template->set_var(array(
422
											'ID' => $group['group_id'],
423
											'TOGGLE' => $group['group_id'],
424
											'CHECKED' => $flag_checked,
425
											'DISABLED' => $flag_disabled,
426
											'LINK_COLOR' => $flag_color,
427
											'CURSOR' => $flag_checked,
428
											'NAME' => $group['name'],
429
											)
430
									);
431
			$template->parse('group_list', 'group_list_block', true);
432
		}
433
	}
434
// Group list 2
435

    
436
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
437

    
438
	$get_groups = $database->query($query);
439
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
440
	// Insert admin group and current group first
441
	$admin_group_name = $get_groups->fetchRow();
442
	$template->set_var(array(
443
									'ID' => 1,
444
									'TOGGLE' => '1',
445
									'DISABLED' => ' disabled="disabled"',
446
									'LINK_COLOR' => '000000',
447
									'CURSOR' => 'default',
448
									'NAME' => $admin_group_name['name'],
449
									'CHECKED' => ' checked="checked"'
450
									)
451
							);
452
	$template->parse('group_list2', 'group_list_block2', true);
453

    
454
	while($group = $get_groups->fetchRow()) {
455
		// check if the user is a member of this group
456
		$flag_disabled = '';
457
		$flag_checked =  '';
458
		$flag_cursor =   'pointer';
459
		$flag_color =    '';
460
		if (in_array($group["group_id"], $admin->get_groups_id())) {
461
			$flag_disabled = ''; //' disabled';
462
			$flag_checked =  ' checked="checked"';
463
			$flag_cursor =   'default';
464
			$flag_color =    '000000';
465
		}
466

    
467
		$template->set_var(array(
468
										'ID' => $group['group_id'],
469
										'TOGGLE' => $group['group_id'],
470
										'CHECKED' => $flag_checked,
471
										'DISABLED' => $flag_disabled,
472
										'LINK_COLOR' => $flag_color,
473
										'CURSOR' => $flag_cursor,
474
										'NAME' => $group['name'],
475
										)
476
								);
477
		$template->parse('group_list2', 'group_list_block2', true);
478
	}
479

    
480

    
481
// Parent page list
482
// $database = new database();
483
function parent_list($parent)
484
{
485
	global $admin, $database, $template, $field_set;
486
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
487
	$get_pages = $database->query($query);
488
	while($page = $get_pages->fetchRow()) {
489
		if($admin->page_is_visible($page)==false)
490
			continue;
491
		// if parent = 0 set flag_icon
492
		$template->set_var('FLAG_ROOT_ICON',' none ');
493
		if( $page['parent'] == 0 && $field_set) {
494
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
495
		}
496
		// Stop users from adding pages with a level of more than the set page level limit
497
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
498
			// Get user perms
499
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
500
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
501

    
502
			$in_group = FALSE;
503
			foreach($admin->get_groups_id() as $cur_gid) {
504
				if (in_array($cur_gid, $admin_groups)) {
505
					$in_group = TRUE;
506
				}
507
			}
508
			if(($in_group) || is_numeric(array_search($admin->get_user_id(), $admin_users))) {
509
				$can_modify = true;
510
			} else {
511
				$can_modify = false;
512
			}
513
			// Title -'s prefix
514
			$title_prefix = '';
515
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - &nbsp;'; }
516
				$template->set_var(array(
517
										'ID' => $page['page_id'],
518
										'TITLE' => ($title_prefix.$page['menu_title']),
519
										'MENU-TITLE' => ($title_prefix.$page['menu_title']),
520
										'PAGE-TITLE' => ($title_prefix.$page['page_title'])
521
										));
522
				if($can_modify == true) {
523
					$template->set_var('DISABLED', '');
524
				} else {
525
					$template->set_var('DISABLED', ' disabled="disabled" class="disabled"');
526
				}
527
				$template->parse('page_list2', 'page_list_block2', true);
528
		}
529
		parent_list($page['page_id']);
530
	}
531
}
532
$template->set_block('main_block', 'page_list_block2', 'page_list2');
533
if($admin->get_permission('pages_add_l0') == true) {
534
	$template->set_var(array(
535
						'ID' => '0',
536
						'TITLE' => $TEXT['NONE'],
537
						'SELECTED' => ' selected="selected"',
538
						'DISABLED' => ''
539
					)
540
				);
541
	$template->parse('page_list2', 'page_list_block2', true);
542
}
543
parent_list(0);
544

    
545
// Explode module permissions
546
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
547
// Modules list
548
$template->set_block('main_block', 'module_list_block', 'module_list');
549
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
550
if($result->numRows() > 0) {
551
	while ($module = $result->fetchRow()) {
552
		// Check if user is allowed to use this module
553
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
554
			$template->set_var('VALUE', $module['directory']);
555
			$template->set_var('NAME', $module['name']);
556
			if($module['directory'] == 'wysiwyg') {
557
				$template->set_var('SELECTED', ' selected="selected"');
558
			} else {
559
				$template->set_var('SELECTED', '');
560
			}
561
			$template->parse('module_list', 'module_list_block', true);
562
		}
563
	}
564
}
565

    
566
// Insert urls
567
$template->set_var(array(
568
								'THEME_URL' => THEME_URL,
569
								'WB_URL' => WB_URL,
570
								'ADMIN_URL' => ADMIN_URL,
571
								)
572
						);
573

    
574
// Insert language headings
575
$template->set_var(array(
576
								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
577
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
578
								)
579
						);
580
// Insert language text and messages
581
$template->set_var(array(
582
								'TEXT_TITLE' => $TEXT['TITLE'],
583
								'TEXT_TYPE' => $TEXT['TYPE'],
584
								'TEXT_PARENT' => $TEXT['PARENT'],
585
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
586
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
587
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
588
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
589
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
590
								'TEXT_NONE' => $TEXT['NONE'],
591
								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
592
								'TEXT_ADD' => $TEXT['ADD'],
593
								'TEXT_RESET' => $TEXT['RESET'],
594
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
595
								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
596
								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
597
								'INTRO_LINK' => $MESSAGE['PAGES_INTRO_LINK'],
598
								)
599
						);
600

    
601
// Insert permissions values
602
if($admin->get_permission('pages_add') != true) {
603
	$template->set_var('DISPLAY_ADD', 'hide');
604
} elseif($admin->get_permission('pages_add_l0') != true && $editable_pages == 0) {
605
	$template->set_var('DISPLAY_ADD', 'hide');
606
}
607
if($admin->get_permission('pages_intro') != true || INTRO_PAGE != 'enabled') {
608
	$template->set_var('DISPLAY_INTRO', 'hide');
609
}
610

    
611

    
612
// Parse template object
613
$template->parse('main', 'main_block', false);
614
$template->pparse('output', 'page');
615

    
616
// include the required file for Javascript admin
617
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
618
{
619
	include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
620
}
621

    
622
// Print admin
623
$admin->print_footer();
(6-6/22)