Revision 1358
Added by Luisehahne almost 15 years ago
| modify.php | ||
|---|---|---|
| 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 |
|
| 13 |
* @version $Id$ |
|
| 14 |
* @filesource $HeadURL$ |
|
| 15 |
* @lastmodified $Date$ |
|
| 16 |
* |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
// Get page id |
|
| 20 |
if(!isset($_GET['page_id']) || !is_numeric($_GET['page_id'])) {
|
|
| 21 |
header("Location: index.php");
|
|
| 22 |
exit(0); |
|
| 23 |
} else {
|
|
| 24 |
$page_id = $_GET['page_id']; |
|
| 25 |
} |
|
| 26 |
|
|
| 27 |
if (!$admin->checkFTAN('get'))
|
|
| 28 |
{
|
|
| 29 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
| 30 |
exit(); |
|
| 31 |
} |
|
| 32 |
|
|
| 33 |
// Create new admin object |
|
| 34 |
require('../../config.php');
|
|
| 35 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
| 36 |
|
|
| 37 |
$admin = new admin('Pages', 'pages_modify');
|
|
| 38 |
|
|
| 39 |
// Get perms |
|
| 40 |
if(!$admin->get_page_permission($page_id,'admin')) {
|
|
| 41 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
$sectionId = isset($_GET['wysiwyg']) ? htmlspecialchars($admin->get_get('wysiwyg')) : NULL;
|
|
| 45 |
|
|
| 46 |
// Get page details |
|
| 47 |
$results_array=$admin->get_page_details($page_id); |
|
| 48 |
|
|
| 49 |
// Get display name of person who last modified the page |
|
| 50 |
$user=$admin->get_user_details($results_array['modified_by']); |
|
| 51 |
|
|
| 52 |
// Convert the unix ts for modified_when to human a readable form |
|
| 53 |
|
|
| 54 |
$modified_ts = ($results_array['modified_when'] != 0) |
|
| 55 |
? $modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE) |
|
| 56 |
: 'Unknown'; |
|
| 57 |
|
|
| 58 |
// Include page info script |
|
| 59 |
$template = new Template(THEME_PATH.'/templates'); |
|
| 60 |
$template->set_file('page', 'pages_modify.htt');
|
|
| 61 |
$template->set_block('page', 'main_block', 'main');
|
|
| 62 |
$template->set_var('FTAN2', $admin->getFTAN(2));
|
|
| 63 |
|
|
| 64 |
$template->set_var(array( |
|
| 65 |
'PAGE_ID' => $results_array['page_id'], |
|
| 66 |
'PAGE_TITLE' => ($results_array['page_title']), |
|
| 67 |
'MENU_TITLE' => ($results_array['menu_title']), |
|
| 68 |
'ADMIN_URL' => ADMIN_URL, |
|
| 69 |
'WB_URL' => WB_URL, |
|
| 70 |
'WB_PATH' => WB_PATH, |
|
| 71 |
'THEME_URL' => THEME_URL |
|
| 72 |
)); |
|
| 73 |
|
|
| 74 |
$template->set_var(array( |
|
| 75 |
'MODIFIED_BY' => $user['display_name'], |
|
| 76 |
'MODIFIED_BY_USERNAME' => $user['username'], |
|
| 77 |
'MODIFIED_WHEN' => $modified_ts, |
|
| 78 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'], |
|
| 79 |
)); |
|
| 80 |
|
|
| 81 |
$template->set_block('main_block', 'show_modify_block', 'show_modify');
|
|
| 82 |
if($modified_ts == 'Unknown') |
|
| 83 |
{
|
|
| 84 |
$template->set_block('show_modify', '');
|
|
| 85 |
$template->set_var('CLASS_DISPLAY_MODIFIED', 'hide');
|
|
| 86 |
|
|
| 87 |
} else {
|
|
| 88 |
$template->set_var('CLASS_DISPLAY_MODIFIED', '');
|
|
| 89 |
$template->parse('show_modify', 'show_modify_block', true);
|
|
| 90 |
} |
|
| 91 |
|
|
| 92 |
// Work-out if we should show the "manage sections" link |
|
| 93 |
$sql = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.(int)$page_id.' '; |
|
| 94 |
$sql .= 'AND `module` = "menu_link"'; |
|
| 95 |
$query_sections = $database->query($sql); |
|
| 96 |
|
|
| 97 |
$template->set_block('main_block', 'show_section_block', 'show_section');
|
|
| 98 |
if($query_sections->numRows() > 0) |
|
| 99 |
{
|
|
| 100 |
$template->set_block('show_section', '');
|
|
| 101 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
|
|
| 102 |
|
|
| 103 |
} elseif(MANAGE_SECTIONS == 'enabled') |
|
| 104 |
{
|
|
| 105 |
|
|
| 106 |
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
|
|
| 107 |
$template->parse('show_section', 'show_section_block', true);
|
|
| 108 |
|
|
| 109 |
} else {
|
|
| 110 |
$template->set_block('show_section', '');
|
|
| 111 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
|
|
| 112 |
|
|
| 113 |
} |
|
| 114 |
|
|
| 115 |
// Insert language TEXT |
|
| 116 |
$template->set_var(array( |
|
| 117 |
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'], |
|
| 118 |
'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'], |
|
| 119 |
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'] |
|
| 120 |
)); |
|
| 121 |
|
|
| 122 |
// Parse and print header template |
|
| 123 |
$template->parse('main', 'main_block', false);
|
|
| 124 |
$template->pparse('output', 'page');
|
|
| 125 |
|
|
| 126 |
// get template used for the displayed page (for displaying block details) |
|
| 127 |
if (SECTION_BLOCKS) |
|
| 128 |
{
|
|
| 129 |
$sql = "SELECT `template` from `" . TABLE_PREFIX . "pages` WHERE `page_id` = '$page_id' "; |
|
| 130 |
$result = $database->query($sql); |
|
| 131 |
if ($result && $result->numRows() == 1) {
|
|
| 132 |
$row = $result->fetchRow(); |
|
| 133 |
$page_template = ($row['template'] == '') ? DEFAULT_TEMPLATE : $row['template']; |
|
| 134 |
// include template info file if exists |
|
| 135 |
if (file_exists(WB_PATH . '/templates/' . $page_template . '/info.php')) |
|
| 136 |
{
|
|
| 137 |
include_once(WB_PATH . '/templates/' . $page_template . '/info.php'); |
|
| 138 |
} |
|
| 139 |
} |
|
| 140 |
} |
|
| 141 |
|
|
| 142 |
// Get sections for this page |
|
| 143 |
$module_permissions = $_SESSION['MODULE_PERMISSIONS']; |
|
| 144 |
// workout for edit only one section for faster pageloading |
|
| 145 |
// Constant later set in wb_settings, in meantime defined in framework/initialize.php |
|
| 146 |
$sql = 'SELECT `section_id`, `module`, `block` FROM `'.TABLE_PREFIX.'sections` '; |
|
| 147 |
|
|
| 148 |
$sql .= (defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION && is_numeric($sectionId))
|
|
| 149 |
? 'WHERE `section_id` = '.$sectionId |
|
| 150 |
: 'WHERE `page_id` = '.intval($page_id); |
|
| 151 |
$sql .= ' ORDER BY position ASC'; |
|
| 152 |
$query_sections = $database->query($sql); |
|
| 153 |
if($query_sections->numRows() > 0) |
|
| 154 |
{
|
|
| 155 |
while($section = $query_sections->fetchRow()) |
|
| 156 |
{
|
|
| 157 |
$section_id = $section['section_id']; |
|
| 158 |
$module = $section['module']; |
|
| 159 |
//Have permission? |
|
| 160 |
if(!is_numeric(array_search($module, $module_permissions))) |
|
| 161 |
{
|
|
| 162 |
// Include the modules editing script if it exists |
|
| 163 |
if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php')) |
|
| 164 |
{
|
|
| 165 |
print /* '<a name="'.$section_id.'"></a>'. */"\n"; |
|
| 166 |
// output block name if blocks are enabled |
|
| 167 |
if (SECTION_BLOCKS) {
|
|
| 168 |
if (isset($block[$section['block']]) && trim(strip_tags(($block[$section['block']]))) != '') |
|
| 169 |
{
|
|
| 170 |
$block_name = htmlentities(strip_tags($block[$section['block']])); |
|
| 171 |
} else {
|
|
| 172 |
if ($section['block'] == 1) |
|
| 173 |
{
|
|
| 174 |
$block_name = $TEXT['MAIN']; |
|
| 175 |
} else {
|
|
| 176 |
$block_name = '#' . (int) $section['block']; |
|
| 177 |
} |
|
| 178 |
} |
|
| 179 |
print '<div id="wb'.$section['section_id'].'"><b>' . $TEXT['BLOCK'] . ': </b>' . $block_name; |
|
| 180 |
print '<b> Modul: </b>' . $section['module']." "; |
|
| 181 |
print '<b> ID: </b>' . $section_id."</div>\n"; |
|
| 182 |
} |
|
| 183 |
require(WB_PATH.'/modules/'.$module.'/modify.php'); |
|
| 184 |
} |
|
| 185 |
} |
|
| 186 |
} |
|
| 187 |
} |
|
| 188 |
|
|
| 189 |
// Print admin footer |
|
| 190 |
$admin->print_footer(); |
|
| 191 |
|
|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category admin |
|
| 5 |
* @package pages |
|
| 6 |
* @author WebsiteBaker Project |
|
| 7 |
* @copyright 2004-2009, Ryan Djurovich |
|
| 8 |
* @copyright 2009-2010, 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 4.3.4 and higher |
|
| 13 |
* @version $Id$ |
|
| 14 |
* @filesource $HeadURL$ |
|
| 15 |
* @lastmodified $Date$ |
|
| 16 |
* |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
// Get page id |
|
| 20 |
if(!isset($_GET['page_id']) || !is_numeric($_GET['page_id'])) {
|
|
| 21 |
header("Location: index.php");
|
|
| 22 |
exit(0); |
|
| 23 |
} else {
|
|
| 24 |
$page_id = $_GET['page_id']; |
|
| 25 |
} |
|
| 26 |
|
|
| 27 |
// Create new admin object |
|
| 28 |
require('../../config.php');
|
|
| 29 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
| 30 |
|
|
| 31 |
$admin = new admin('Pages', 'pages_modify');
|
|
| 32 |
|
|
| 33 |
// Get perms |
|
| 34 |
if(!$admin->get_page_permission($page_id,'admin')) {
|
|
| 35 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
$sectionId = isset($_GET['wysiwyg']) ? htmlspecialchars($admin->get_get('wysiwyg')) : NULL;
|
|
| 39 |
|
|
| 40 |
// Get page details |
|
| 41 |
$results_array=$admin->get_page_details($page_id); |
|
| 42 |
|
|
| 43 |
// Get display name of person who last modified the page |
|
| 44 |
$user=$admin->get_user_details($results_array['modified_by']); |
|
| 45 |
|
|
| 46 |
// Convert the unix ts for modified_when to human a readable form |
|
| 47 |
|
|
| 48 |
$modified_ts = ($results_array['modified_when'] != 0) |
|
| 49 |
? $modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE) |
|
| 50 |
: 'Unknown'; |
|
| 51 |
|
|
| 52 |
// Include page info script |
|
| 53 |
$template = new Template(THEME_PATH.'/templates'); |
|
| 54 |
$template->set_file('page', 'pages_modify.htt');
|
|
| 55 |
$template->set_block('page', 'main_block', 'main');
|
|
| 56 |
$template->set_var('FTAN', $admin->getFTAN());
|
|
| 57 |
|
|
| 58 |
$template->set_var(array( |
|
| 59 |
'PAGE_ID' => $results_array['page_id'], |
|
| 60 |
'PAGE_TITLE' => ($results_array['page_title']), |
|
| 61 |
'MENU_TITLE' => ($results_array['menu_title']), |
|
| 62 |
'FTAN' => 'FTAN', |
|
| 63 |
'ADMIN_URL' => ADMIN_URL, |
|
| 64 |
'WB_URL' => WB_URL, |
|
| 65 |
'WB_PATH' => WB_PATH, |
|
| 66 |
'THEME_URL' => THEME_URL |
|
| 67 |
)); |
|
| 68 |
|
|
| 69 |
$template->set_var(array( |
|
| 70 |
'MODIFIED_BY' => $user['display_name'], |
|
| 71 |
'MODIFIED_BY_USERNAME' => $user['username'], |
|
| 72 |
'MODIFIED_WHEN' => $modified_ts, |
|
| 73 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'], |
|
| 74 |
)); |
|
| 75 |
|
|
| 76 |
$template->set_block('main_block', 'show_modify_block', 'show_modify');
|
|
| 77 |
if($modified_ts == 'Unknown') |
|
| 78 |
{
|
|
| 79 |
$template->set_block('show_modify', '');
|
|
| 80 |
$template->set_var('CLASS_DISPLAY_MODIFIED', 'hide');
|
|
| 81 |
|
|
| 82 |
} else {
|
|
| 83 |
$template->set_var('CLASS_DISPLAY_MODIFIED', '');
|
|
| 84 |
$template->parse('show_modify', 'show_modify_block', true);
|
|
| 85 |
} |
|
| 86 |
|
|
| 87 |
// Work-out if we should show the "manage sections" link |
|
| 88 |
$sql = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.(int)$page_id.' '; |
|
| 89 |
$sql .= 'AND `module` = "menu_link"'; |
|
| 90 |
$query_sections = $database->query($sql); |
|
| 91 |
|
|
| 92 |
$template->set_block('main_block', 'show_section_block', 'show_section');
|
|
| 93 |
if($query_sections->numRows() > 0) |
|
| 94 |
{
|
|
| 95 |
$template->set_block('show_section', '');
|
|
| 96 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
|
|
| 97 |
|
|
| 98 |
} elseif(MANAGE_SECTIONS == 'enabled') |
|
| 99 |
{
|
|
| 100 |
|
|
| 101 |
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
|
|
| 102 |
$template->parse('show_section', 'show_section_block', true);
|
|
| 103 |
|
|
| 104 |
} else {
|
|
| 105 |
$template->set_block('show_section', '');
|
|
| 106 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
|
|
| 107 |
|
|
| 108 |
} |
|
| 109 |
|
|
| 110 |
// Insert language TEXT |
|
| 111 |
$template->set_var(array( |
|
| 112 |
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'], |
|
| 113 |
'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'], |
|
| 114 |
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'] |
|
| 115 |
)); |
|
| 116 |
|
|
| 117 |
// Parse and print header template |
|
| 118 |
$template->parse('main', 'main_block', false);
|
|
| 119 |
$template->pparse('output', 'page');
|
|
| 120 |
|
|
| 121 |
// get template used for the displayed page (for displaying block details) |
|
| 122 |
if (SECTION_BLOCKS) |
|
| 123 |
{
|
|
| 124 |
$sql = "SELECT `template` from `" . TABLE_PREFIX . "pages` WHERE `page_id` = '$page_id' "; |
|
| 125 |
$result = $database->query($sql); |
|
| 126 |
if ($result && $result->numRows() == 1) {
|
|
| 127 |
$row = $result->fetchRow(); |
|
| 128 |
$page_template = ($row['template'] == '') ? DEFAULT_TEMPLATE : $row['template']; |
|
| 129 |
// include template info file if exists |
|
| 130 |
if (file_exists(WB_PATH . '/templates/' . $page_template . '/info.php')) |
|
| 131 |
{
|
|
| 132 |
include_once(WB_PATH . '/templates/' . $page_template . '/info.php'); |
|
| 133 |
} |
|
| 134 |
} |
|
| 135 |
} |
|
| 136 |
|
|
| 137 |
// Get sections for this page |
|
| 138 |
$module_permissions = $_SESSION['MODULE_PERMISSIONS']; |
|
| 139 |
// workout for edit only one section for faster pageloading |
|
| 140 |
// Constant later set in wb_settings, in meantime defined in framework/initialize.php |
|
| 141 |
$sql = 'SELECT `section_id`, `module`, `block` FROM `'.TABLE_PREFIX.'sections` '; |
|
| 142 |
|
|
| 143 |
$sql .= (defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION && is_numeric($sectionId))
|
|
| 144 |
? 'WHERE `section_id` = '.$sectionId |
|
| 145 |
: 'WHERE `page_id` = '.intval($page_id); |
|
| 146 |
$sql .= ' ORDER BY position ASC'; |
|
| 147 |
$query_sections = $database->query($sql); |
|
| 148 |
if($query_sections->numRows() > 0) |
|
| 149 |
{
|
|
| 150 |
while($section = $query_sections->fetchRow()) |
|
| 151 |
{
|
|
| 152 |
$section_id = $section['section_id']; |
|
| 153 |
$module = $section['module']; |
|
| 154 |
//Have permission? |
|
| 155 |
if(!is_numeric(array_search($module, $module_permissions))) |
|
| 156 |
{
|
|
| 157 |
// Include the modules editing script if it exists |
|
| 158 |
if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php')) |
|
| 159 |
{
|
|
| 160 |
print /* '<a name="'.$section_id.'"></a>'. */"\n"; |
|
| 161 |
// output block name if blocks are enabled |
|
| 162 |
if (SECTION_BLOCKS) {
|
|
| 163 |
if (isset($block[$section['block']]) && trim(strip_tags(($block[$section['block']]))) != '') |
|
| 164 |
{
|
|
| 165 |
$block_name = htmlentities(strip_tags($block[$section['block']])); |
|
| 166 |
} else {
|
|
| 167 |
if ($section['block'] == 1) |
|
| 168 |
{
|
|
| 169 |
$block_name = $TEXT['MAIN']; |
|
| 170 |
} else {
|
|
| 171 |
$block_name = '#' . (int) $section['block']; |
|
| 172 |
} |
|
| 173 |
} |
|
| 174 |
print '<div id="wb_'.$section['section_id'].'"><b>' . $TEXT['BLOCK'] . ': </b>' . $block_name; |
|
| 175 |
print '<b> Modul: </b>' . $section['module']." "; |
|
| 176 |
print '<b> ID: </b>' . $section_id."</div>\n"; |
|
| 177 |
} |
|
| 178 |
require(WB_PATH.'/modules/'.$module.'/modify.php'); |
|
| 179 |
} |
|
| 180 |
} |
|
| 181 |
} |
|
| 182 |
} |
|
| 183 |
|
|
| 184 |
// Print admin footer |
|
| 185 |
$admin->print_footer(); |
|
| 186 |
|
|
| 192 | 187 |
?> |
Also available in: Unified diff
validation fixes in pages backend theme