Revision 8
Added by stefan about 20 years ago
| sections.php | ||
|---|---|---|
| 1 | 1 |
<?php |
| 2 | 2 |
|
| 3 |
// $Id: sections.php,v 1.10 2005/04/09 01:00:53 rdjurovich Exp $ |
|
| 4 |
|
|
| 5 | 3 |
/* |
| 6 | 4 |
|
| 7 | 5 |
Website Baker Project <http://www.websitebaker.org/> |
| ... | ... | |
| 45 | 43 |
// Check if we are supposed to add or delete a section |
| 46 | 44 |
if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) {
|
| 47 | 45 |
// Get more information about this section |
| 48 |
$section_id = $_GET['section_id']; |
|
| 49 |
$query_section = $database->query("SELECT module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id'");
|
|
| 50 |
if($query_section->numRows() == 0) {
|
|
| 51 |
$admin->print_error('Section not found');
|
|
| 52 |
} |
|
| 53 |
$section = $query_section->fetchRow(); |
|
| 54 |
// Include the modules delete file if it exists |
|
| 55 |
if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
|
|
| 56 |
require(WB_PATH.'/modules/'.$section['module'].'/delete.php'); |
|
| 46 |
$section_id = $_GET['section_id']; |
|
| 47 |
$query_section = $database->query("SELECT module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id'");
|
|
| 48 |
if($query_section->numRows() == 0) {
|
|
| 49 |
$admin->print_error('Section not found');
|
|
| 57 | 50 |
} |
| 51 |
$section = $query_section->fetchRow(); |
|
| 52 |
// Include the modules delete file if it exists |
|
| 53 |
if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
|
|
| 54 |
require(WB_PATH.'/modules/'.$section['module'].'/delete.php'); |
|
| 55 |
} |
|
| 58 | 56 |
$database->query("DELETE FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' LIMIT 1");
|
| 59 | 57 |
if($database->is_error()) {
|
| 60 | 58 |
$admin->print_error($database->get_error()); |
| ... | ... | |
| 110 | 108 |
|
| 111 | 109 |
// Set module permissions |
| 112 | 110 |
$module_permissions = $_SESSION['MODULE_PERMISSIONS']; |
| 113 |
|
|
| 114 |
// Unset block var |
|
| 115 |
unset($block); |
|
| 116 |
// Include template info file (if it exists) |
|
| 117 |
if($results_array['template'] != '') {
|
|
| 118 |
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php'; |
|
| 119 |
} else {
|
|
| 120 |
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php'; |
|
| 121 |
} |
|
| 122 |
if(file_exists($template_location)) {
|
|
| 123 |
require($template_location); |
|
| 124 |
} |
|
| 125 |
// Check if $menu is set |
|
| 126 |
if(!isset($block[1]) OR $block[1] == '') {
|
|
| 127 |
// Make our own menu list |
|
| 128 |
$block[1] = $TEXT['MAIN']; |
|
| 129 |
} |
|
| 130 |
-?> |
|
| 131 |
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%" height="50" style="margin-bottom: 10px;"> |
|
| 132 |
<tr style="background-color: #F0F0F0;"> |
|
| 133 |
<td valign="middle" align="left"> |
|
| 134 |
<h2><?php echo $HEADING['MANAGE_SECTIONS']; ?></h2> |
|
| 135 |
</td> |
|
| 136 |
<td align="right"> |
|
| 137 |
<?php echo $TEXT['CURRENT_PAGE']; ?>: |
|
| 138 |
<b><?php echo stripslashes($results_array['page_title']); ?></b> |
|
| 139 |
- |
|
| 140 |
<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>"><?php echo $HEADING['MODIFY_PAGE']; ?></a> |
|
| 141 |
- |
|
| 142 |
<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page_id; ?>"><?php echo $TEXT['CHANGE_SETTINGS']; ?></a> |
|
| 143 |
</td> |
|
| 144 |
</tr> |
|
| 145 |
</table> |
|
| 146 |
|
|
| 147 |
<?php |
|
| 111 |
|
|
| 112 |
// Unset block var |
|
| 113 |
unset($block); |
|
| 114 |
// Include template info file (if it exists) |
|
| 115 |
if($results_array['template'] != '') {
|
|
| 116 |
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php'; |
|
| 117 |
} else {
|
|
| 118 |
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php'; |
|
| 119 |
} |
|
| 120 |
if(file_exists($template_location)) {
|
|
| 121 |
require($template_location); |
|
| 122 |
} |
|
| 123 |
// Check if $menu is set |
|
| 124 |
if(!isset($block[1]) OR $block[1] == '') {
|
|
| 125 |
// Make our own menu list |
|
| 126 |
$block[1] = $TEXT['MAIN']; |
|
| 127 |
} |
|
| 128 |
|
|
| 129 |
?> |
|
| 130 |
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%" height="50" style="margin-bottom: 10px;"> |
|
| 131 |
<tr style="background-color: #F0F0F0;"> |
|
| 132 |
<td valign="middle" align="left"> |
|
| 133 |
<h2><?php echo $HEADING['MANAGE_SECTIONS']; ?></h2> |
|
| 134 |
</td> |
|
| 135 |
<td align="right"> |
|
| 136 |
<?php echo $TEXT['CURRENT_PAGE']; ?>: |
|
| 137 |
<b><?php echo stripslashes($results_array['page_title']); ?></b> |
|
| 138 |
- |
|
| 139 |
<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>"><?php echo $HEADING['MODIFY_PAGE']; ?></a> |
|
| 140 |
- |
|
| 141 |
<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page_id; ?>"><?php echo $TEXT['CHANGE_SETTINGS']; ?></a> |
|
| 142 |
</td> |
|
| 143 |
</tr> |
|
| 144 |
</table> |
|
| 145 |
|
|
| 146 |
<?php |
|
| 148 | 147 |
$query_sections = $database->query("SELECT section_id,module,position,block FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
|
| 149 |
if($query_sections->numRows() > 0) {
|
|
| 150 |
?> |
|
| 151 |
<form name="section_properties" action="<?php echo ADMIN_URL; ?>/pages/sections_save.php?page_id=<?php echo $page_id; ?>" method="post"> |
|
| 152 |
|
|
| 153 |
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%"> |
|
| 154 |
<tr> |
|
| 155 |
<td><?php echo $TEXT['TYPE']; ?>:</td> |
|
| 156 |
<?php if(SECTION_BLOCKS) { ?>
|
|
| 157 |
<td style="display: {DISPLAY_BLOCK}"><?php echo $TEXT['BLOCK']; ?>:</td>
|
|
| 158 |
<?php } ?> |
|
| 159 |
<td colspan="3" width="60"><?php echo $TEXT['ACTIONS']; ?>:</td> |
|
| 160 |
</tr> |
|
| 148 |
if($query_sections->numRows() > 0) {
|
|
| 149 |
?>
|
|
| 150 |
<form name="section_properties" action="<?php echo ADMIN_URL; ?>/pages/sections_save.php?page_id=<?php echo $page_id; ?>" method="post">
|
|
| 151 |
|
|
| 152 |
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%">
|
|
| 153 |
<tr>
|
|
| 154 |
<td><?php echo $TEXT['TYPE']; ?>:</td>
|
|
| 155 |
<?php if(SECTION_BLOCKS) { ?>
|
|
| 156 |
<td style="display: {DISPLAY_BLOCK}"><?php echo $TEXT['BLOCK']; ?>:</td>
|
|
| 157 |
<?php } ?>
|
|
| 158 |
<td colspan="3" width="60"><?php echo $TEXT['ACTIONS']; ?>:</td>
|
|
| 159 |
</tr>
|
|
| 161 | 160 |
<?php |
| 162 | 161 |
$num_sections = $query_sections->numRows(); |
| 163 | 162 |
while($section = $query_sections->fetchRow()) {
|
| 164 |
// Get the modules real name |
|
| 163 |
// Get the modules real name
|
|
| 165 | 164 |
$module_path = WB_PATH.'/modules/'.$section['module'].'/info.php'; |
| 166 | 165 |
if(file_exists($module_path)) {
|
| 167 | 166 |
require($module_path); |
| 168 | 167 |
if(!isset($module_type)) { $module_type = 'unknown'; }
|
| 169 |
if(!is_numeric(array_search($section['module'], $module_permissions)) AND $module_type == 'page') {
|
|
| 170 |
?> |
|
| 171 |
<tr> |
|
| 172 |
<td style="width: 250px;"><a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>#<?php echo $section['section_id']; ?>"><?php echo $module_name; ?></a></td> |
|
| 173 |
<?php if(SECTION_BLOCKS) { ?>
|
|
| 174 |
<td> |
|
| 175 |
<select name="block<?php echo $section['section_id']; ?>" style="width: 150px;"> |
|
| 176 |
<?php |
|
| 177 |
foreach($block AS $number => $name) {
|
|
| 178 |
?> |
|
| 179 |
<option value="<?php echo $number; ?>"<?php if($number == $section['block']) { echo ' selected'; } ?>><?php echo $name; ?></option>
|
|
| 180 |
<?php |
|
| 181 |
} |
|
| 182 |
?> |
|
| 183 |
</select> |
|
| 184 |
</td> |
|
| 185 |
<?php } ?> |
|
| 186 |
<td width="20"> |
|
| 187 |
<?php if($section['position'] != 1) { ?>
|
|
| 188 |
<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>"> |
|
| 189 |
<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" alt="^" border="0" /> |
|
| 190 |
</a> |
|
| 191 |
<?php } ?> |
|
| 192 |
</td> |
|
| 193 |
<td width="20"> |
|
| 194 |
<?php if($section['position'] != $num_sections) { ?>
|
|
| 195 |
<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>"> |
|
| 196 |
<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" alt="v" border="0" /> |
|
| 197 |
</a> |
|
| 198 |
<?php } ?> |
|
| 199 |
</td> |
|
| 200 |
<td width="20"> |
|
| 201 |
<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>');">
|
|
| 202 |
<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="Del" border="0" /> |
|
| 203 |
</a> |
|
| 204 |
</td> |
|
| 205 |
</tr> |
|
| 206 |
<?php |
|
| 168 |
if(!is_numeric(array_search($section['module'], $module_permissions)) AND $module_type == 'page') {
|
|
| 169 |
?>
|
|
| 170 |
<tr>
|
|
| 171 |
<td style="width: 250px;"><a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>#<?php echo $section['section_id']; ?>"><?php echo $module_name; ?></a></td>
|
|
| 172 |
<?php if(SECTION_BLOCKS) { ?>
|
|
| 173 |
<td>
|
|
| 174 |
<select name="block<?php echo $section['section_id']; ?>" style="width: 150px;">
|
|
| 175 |
<?php
|
|
| 176 |
foreach($block AS $number => $name) {
|
|
| 177 |
?>
|
|
| 178 |
<option value="<?php echo $number; ?>"<?php if($number == $section['block']) { echo ' selected'; } ?>><?php echo $name; ?></option>
|
|
| 179 |
<?php
|
|
| 180 |
}
|
|
| 181 |
?>
|
|
| 182 |
</select>
|
|
| 183 |
</td>
|
|
| 184 |
<?php } ?>
|
|
| 185 |
<td width="20">
|
|
| 186 |
<?php if($section['position'] != 1) { ?>
|
|
| 187 |
<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>">
|
|
| 188 |
<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" alt="^" border="0" />
|
|
| 189 |
</a>
|
|
| 190 |
<?php } ?>
|
|
| 191 |
</td>
|
|
| 192 |
<td width="20">
|
|
| 193 |
<?php if($section['position'] != $num_sections) { ?>
|
|
| 194 |
<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>">
|
|
| 195 |
<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" alt="v" border="0" />
|
|
| 196 |
</a>
|
|
| 197 |
<?php } ?>
|
|
| 198 |
</td>
|
|
| 199 |
<td width="20">
|
|
| 200 |
<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>');">
|
|
| 201 |
<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="Del" border="0" />
|
|
| 202 |
</a>
|
|
| 203 |
</td>
|
|
| 204 |
</tr>
|
|
| 205 |
<?php
|
|
| 207 | 206 |
} |
| 208 | 207 |
if(isset($module_type)) { unset($module_type); } // Unset module type
|
| 209 | 208 |
} |
| 210 |
} |
|
| 211 |
?> |
|
| 212 |
<tr> |
|
| 213 |
<td> </td> |
|
| 214 |
<?php if(SECTION_BLOCKS) { ?>
|
|
| 215 |
<td><input type="submit" name="save" value="<?php echo $TEXT['SAVE']; ?>" style="width: 150px;" /></td> |
|
| 216 |
<?php } ?> |
|
| 217 |
<td colspan="3" width="60"> </td> |
|
| 218 |
</tr> |
|
| 219 |
</table> |
|
| 220 |
|
|
| 221 |
</form> |
|
| 222 |
|
|
| 209 |
}
|
|
| 210 |
?>
|
|
| 211 |
<tr>
|
|
| 212 |
<td> </td>
|
|
| 213 |
<?php if(SECTION_BLOCKS) { ?>
|
|
| 214 |
<td><input type="submit" name="save" value="<?php echo $TEXT['SAVE']; ?>" style="width: 150px;" /></td>
|
|
| 215 |
<?php } ?>
|
|
| 216 |
<td colspan="3" width="60"> </td>
|
|
| 217 |
</tr>
|
|
| 218 |
</table>
|
|
| 219 |
|
|
| 220 |
</form>
|
|
| 221 |
|
|
| 223 | 222 |
<?php |
| 224 |
} |
|
| 225 |
|
|
| 226 |
// Work-out if we should show the "Add Section" form |
|
| 223 |
}
|
|
| 224 |
|
|
| 225 |
// Work-out if we should show the "Add Section" form
|
|
| 227 | 226 |
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
|
| 228 |
if($query_sections->numRows() == 0) {
|
|
| 229 |
?> |
|
| 230 |
<h2><?php echo $TEXT['ADD_SECTION']; ?></h2> |
|
| 231 |
|
|
| 232 |
<form name="add" action="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>" method="post"> |
|
| 233 |
|
|
| 234 |
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%"> |
|
| 235 |
<tr> |
|
| 236 |
<td> |
|
| 237 |
<select name="module" style="width: 100%;"> |
|
| 238 |
<?php |
|
| 227 |
if($query_sections->numRows() == 0) {
|
|
| 228 |
?>
|
|
| 229 |
<h2><?php echo $TEXT['ADD_SECTION']; ?></h2>
|
|
| 230 |
|
|
| 231 |
<form name="add" action="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>" method="post">
|
|
| 232 |
|
|
| 233 |
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%">
|
|
| 234 |
<tr>
|
|
| 235 |
<td>
|
|
| 236 |
<select name="module" style="width: 100%;">
|
|
| 237 |
<?php
|
|
| 239 | 238 |
// Insert module list |
| 240 | 239 |
if($handle = opendir(WB_PATH.'/modules/')) {
|
| 241 | 240 |
while (false !== ($file = readdir($handle))) {
|
| 242 |
if($file != '.' AND $file != '..' AND $file != 'CVS' AND $file != 'menu_link' AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) {
|
|
| 243 |
// Include the modules info file |
|
| 241 |
if($file != '.' AND $file != '..' AND $file != '.svn' AND $file != 'menu_link' AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) {
|
|
| 242 |
// Include the modules info file
|
|
| 244 | 243 |
require(WB_PATH.'/modules/'.$file.'/info.php'); |
| 245 |
// Check if user is allowed to use this module |
|
| 244 |
// Check if user is allowed to use this module
|
|
| 246 | 245 |
if(!isset($module_type)) { $module_type = 'unknown'; }
|
| 247 | 246 |
if(!is_numeric(array_search($file, $module_permissions)) AND $module_type == 'page') {
|
| 248 |
?> |
|
| 249 |
<option value="<?php echo $file; ?>"<?php if($file == 'wysiwyg') { echo 'selected'; } ?>><?php echo $module_name; ?></option>
|
|
| 250 |
<?php |
|
| 247 |
?>
|
|
| 248 |
<option value="<?php echo $file; ?>"<?php if($file == 'wysiwyg') { echo 'selected'; } ?>><?php echo $module_name; ?></option>
|
|
| 249 |
<?php
|
|
| 251 | 250 |
} |
| 252 |
if(isset($module_type)) { unset($module_type); } // Unset module type
-
|
|
| 251 |
if(isset($module_type)) { unset($module_type); } // Unset module type
|
|
| 252 |
|
|
| 253 | 253 |
} |
| 254 | 254 |
} |
| 255 |
} |
|
| 256 |
?> |
|
| 257 |
</select> |
|
| 258 |
</td> |
|
| 259 |
<td width="100"> |
|
| 260 |
<input type="submit" name="submit" value="<?php echo $TEXT['ADD']; ?>" style="width: 100px" /> |
|
| 261 |
</td> |
|
| 262 |
</tr> |
|
| 263 |
</table> |
|
| 264 |
|
|
| 265 |
</form> |
|
| 266 |
<?php |
|
| 267 |
} |
|
| 255 |
}
|
|
| 256 |
?>
|
|
| 257 |
</select>
|
|
| 258 |
</td>
|
|
| 259 |
<td width="100">
|
|
| 260 |
<input type="submit" name="submit" value="<?php echo $TEXT['ADD']; ?>" style="width: 100px" />
|
|
| 261 |
</td>
|
|
| 262 |
</tr>
|
|
| 263 |
</table>
|
|
| 264 |
|
|
| 265 |
</form>
|
|
| 266 |
<?php
|
|
| 267 |
}
|
|
| 268 | 268 |
|
| 269 | 269 |
// Print admin footer |
| 270 | 270 |
$admin->print_footer(); |
| 271 | 271 |
|
| 272 |
?> |
|
| 272 |
?> |
|
Also available in: Unified diff
All occurrences of "CVS" in the code are replace by ".svn"