Project

General

Profile

1 4 ryan
<?php
2
3 36 stefan
// $Id$
4 4 ryan
5
/*
6
7
 Website Baker Project <http://www.websitebaker.org/>
8 519 Ruebenwurz
 Copyright (C) 2004-2008, Ryan Djurovich
9 4 ryan
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
30
?>
31
<script type="text/javascript" language="javascript">
32
function toggle_viewers() {
33
	if(document.add.visibility.value == 'private') {
34
		document.getElementById('private_viewers').style.display = 'block';
35
		document.getElementById('registered_viewers').style.display = 'none';
36
	} else if(document.add.visibility.value == 'registered') {
37
		document.getElementById('private_viewers').style.display = 'none';
38
		document.getElementById('registered_viewers').style.display = 'block';
39
	} else {
40
		document.getElementById('private_viewers').style.display = 'none';
41
		document.getElementById('registered_viewers').style.display = 'none';
42
	}
43
}
44
function toggle_visibility(id){
45
	if(document.getElementById(id).style.display == "block") {
46
		document.getElementById(id).style.display = "none";
47
	} else {
48
		document.getElementById(id).style.display = "block";
49
	}
50
}
51
var plus = new Image;
52
plus.src = "<?php echo ADMIN_URL; ?>/images/plus_16.png";
53
var minus = new Image;
54
minus.src = "<?php echo ADMIN_URL; ?>/images/minus_16.png";
55
function toggle_plus_minus(id) {
56
	var img_src = document.images['plus_minus_' + id].src;
57
	if(img_src == plus.src) {
58
		document.images['plus_minus_' + id].src = minus.src;
59
	} else {
60
		document.images['plus_minus_' + id].src = plus.src;
61
	}
62
}
63
</script>
64
65
<style type="text/css">
66
.pages_list img {
67
	display: block;
68
}
69
ul, li {
70
	list-style: none;
71
	margin: 0;
72
	padding: 0;
73
}
74
.page_list {
75
	display: none;
76
}
77
</style>
78
79
<noscript>
80
	<style type="text/css">
81
	.page_list {
82
		display: block;
83
	}
84
	</style>
85
</noscript>
86
<?php
87
88
function make_list($parent, $editable_pages) {
89
	// Get objects and vars from outside this function
90
	global $admin, $template, $database, $TEXT, $MESSAGE;
91
	?>
92
	<ul id="p<?php echo $parent; ?>" <?php if($parent != 0) { echo 'class="page_list"'; } ?>>
93
	<?php
94
	// Get page list from database
95
	$database = new database();
96
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility = 'deleted' ORDER BY position ASC";
97
	$get_pages = $database->query($query);
98
99
	// Insert values into main page list
100
	if($get_pages->numRows() > 0)	{
101
		while($page = $get_pages->fetchRow()) {
102
			// Get user perms
103
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
104
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
105 546 doc
			$in_old_group = FALSE;
106
			foreach($admin->get_groups_id() as $cur_gid){
107
			    if (in_array($cur_gid, $old_admin_groups)) {
108
				$in_old_group = TRUE;
109
			    }
110
			}
111
			if((!$in_old_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
112 4 ryan
				if($page['visibility'] == 'deleted') {
113
					$can_modify = true;
114
					$editable_pages = $editable_pages+1;
115
				} else {
116
					$can_modify = false;
117
				}
118
			} else {
119
				$can_modify = false;
120
			}
121
122
			// Work out if we should show a plus or not
123
			$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
124
			if($get_page_subs->numRows() > 0) {
125
				$display_plus = true;
126
			} else {
127
				$display_plus = false;
128
			}
129
130
			// Work out how many pages there are for this parent
131
			$num_pages = $get_pages->numRows();
132
			?>
133
134
			<li id="p<?php echo $page['parent']; ?>" style="padding: 2px 0px 2px 0px;">
135
			<table width="720" cellpadding="1" cellspacing="0" border="0" style="background-color: #F0F0F0;">
136
			<tr>
137
				<td width="20" style="padding-left: <?php echo $page['level']*20; ?>px;">
138
					<?php
139
					if($display_plus == true) {
140
					?>
141
					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
142
						<img src="<?php echo ADMIN_URL; ?>/images/plus_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id']; ?>');" name="plus_minus_<?php echo $page['page_id']; ?>" border="0" alt="+" />
143
					</a>
144
					<?php
145
					}
146
					?>
147
				</td>
148
				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true AND $page['visibility'] != 'heading') { ?>
149
				<td>
150 442 Ruebenwurz
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>"><?php echo ($page['page_title']); ?></a>
151 4 ryan
				</td>
152
				<?php } else { ?>
153
				<td>
154
					<?php
155
					if($page['visibility'] != 'heading') {
156 442 Ruebenwurz
						echo ($page['page_title']);
157 4 ryan
					} else {
158 442 Ruebenwurz
						echo '<b>'.($page['page_title']).'</b>';
159 4 ryan
					}
160
					?>
161
				</td>
162
				<?php } ?>
163
				<td align="left" width="232">
164 442 Ruebenwurz
					<font color="#999999"><?php echo $page['menu_title']; ?></font>
165 4 ryan
				</td>
166
				<td align="right" valign="middle" width="30" style="padding-right: 20px;">
167
				<?php if($page['visibility'] == 'public') { ?>
168
					<img src="<?php echo ADMIN_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" border="0" />
169
				<?php } elseif($page['visibility'] == 'private') { ?>
170
					<img src="<?php echo ADMIN_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" border="0" />
171
				<?php } elseif($page['visibility'] == 'registered') { ?>
172
					<img src="<?php echo ADMIN_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" border="0" />
173
				<?php } elseif($page['visibility'] == 'none') { ?>
174
					<img src="<?php echo ADMIN_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" border="0" />
175
				<?php } elseif($page['visibility'] == 'deleted') { ?>
176
					<img src="<?php echo ADMIN_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" border="0" />
177
				<?php } ?>
178
				</td>
179
				<td width="20">
180
					<?php if($page['visibility'] != 'deleted') { ?>
181
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
182
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
183
							<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
184
						</a>
185
						<?php } ?>
186
					<?php } else { ?>
187
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
188
							<img src="<?php echo ADMIN_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
189
						</a>
190
					<?php } ?>
191
				</td>
192
				<td width="20">
193
				<?php if($page['position'] != 1) { ?>
194
					<?php if($page['visibility'] != 'deleted') { ?>
195
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
196
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
197
							<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" border="0" alt="^" />
198
						</a>
199
						<?php } ?>
200
					<?php } ?>
201
				<?php } ?>
202
				</td>
203
				<td width="20">
204
				<?php if($page['position'] != $num_pages) { ?>
205
					<?php if($page['visibility'] != 'deleted') { ?>
206
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
207
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
208
							<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" border="0" alt="v" />
209
						</a>
210
						<?php } ?>
211
					<?php } ?>
212
				<?php } ?>
213
				</td>
214
				<td width="20">
215
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
216
					<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']; ?>">
217
						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
218
					</a>
219
					<?php } ?>
220
				</td>
221
			</tr>
222
			</table>
223
			</li>
224
225
			<?php
226
			// Get subs
227
			make_list($page['page_id'], $editable_pages);
228
		}
229
230
	}
231
	?>
232
	</ul>
233
	<?php
234
	return $editable_pages;
235
}
236
237
// Generate pages list
238
if($admin->get_permission('pages_view') == true) {
239
	?>
240
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
241
	<tr>
242
		<td>
243
			<h2><?php echo $HEADING['DELETED_PAGES']; ?></h2>
244
		</td>
245
		<td align="right">
246
				<a href="<?php echo ADMIN_URL; ?>/pages/empty_trash.php">
247
				<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
248
				<?php echo $TEXT['EMPTY_TRASH']; ?></a>
249
		</td>
250
	</tr>
251
	</table>
252
	<div class="pages_list">
253
	<table cellpadding="1" cellspacing="0" width="720" border="0">
254
	<tr>
255
		<td width="20">
256
			&nbsp;
257
		</td>
258
		<td>
259
			<?php echo $TEXT['PAGE_TITLE']; ?>:
260
		</td>
261
		<td width="198" align="left">
262
			<?php echo $TEXT['MENU_TITLE']; ?>:
263
		</td>
264
		<td width="80" align="center">
265
			<?php echo $TEXT['VISIBILITY']; ?>:
266
		</td>
267
		<td width="90" align="center">
268
			<?php echo $TEXT['ACTIONS']; ?>:
269
		</td>
270
	</tr>
271
	</table>
272
	<?php
273
	$editable_pages = make_list(0, 0);
274
	?>
275
	</div>
276
	<div class="empty_list">
277
		<?php echo $TEXT['NONE_FOUND']; ?>
278
	</div>
279
	<?php
280
} else {
281
	$editable_pages = 0;
282
}
283
284
// Figure out if the no pages found message should be shown or not
285
if($editable_pages == 0) {
286
	?>
287
	<style type="text/css">
288
	.pages_list {
289
		display: none;
290
	}
291
	</style>
292
	<?php
293
} else {
294
	?>
295
	<style type="text/css">
296
	.empty_list {
297
		display: none;
298
	}
299
	</style>
300
	<?php
301
}
302
303
?>
304
<br />< <a href="<?php echo ADMIN_URL; ?>/pages/index.php"><?php echo $MESSAGE['PAGES']['RETURN_TO_PAGES']; ?></a>
305
<?php
306
307
// Print admin
308
$admin->print_footer();
309
310
?>