| 1 |
1358
|
Luisehahne
|
<?php
|
| 2 |
|
|
/**
|
| 3 |
|
|
*
|
| 4 |
|
|
* @category admin
|
| 5 |
|
|
* @package pages
|
| 6 |
1707
|
Luisehahne
|
* @author Ryan Djurovich, WebsiteBaker Project
|
| 7 |
1914
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
| 8 |
|
|
* @link http://www.websitebaker.org/
|
| 9 |
1358
|
Luisehahne
|
* @license http://www.gnu.org/licenses/gpl.html
|
| 10 |
1914
|
Luisehahne
|
* @platform WebsiteBaker 2.8.4
|
| 11 |
1373
|
Luisehahne
|
* @requirements PHP 5.2.2 and higher and higher
|
| 12 |
1358
|
Luisehahne
|
* @version $Id$
|
| 13 |
1914
|
Luisehahne
|
* @filesource $HeadURL$
|
| 14 |
1358
|
Luisehahne
|
* @lastmodified $Date$
|
| 15 |
|
|
*
|
| 16 |
1707
|
Luisehahne
|
*/
|
| 17 |
1402
|
Luisehahne
|
/*
|
| 18 |
|
|
*/
|
| 19 |
|
|
// Create new admin object
|
| 20 |
|
|
require('../../config.php');
|
| 21 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
| 22 |
1358
|
Luisehahne
|
|
| 23 |
1402
|
Luisehahne
|
$admin = new admin('Pages', 'pages_modify');
|
| 24 |
1545
|
Luisehahne
|
/*
|
| 25 |
1358
|
Luisehahne
|
// Get page id
|
| 26 |
|
|
if(!isset($_GET['page_id']) || !is_numeric($_GET['page_id'])) {
|
| 27 |
|
|
header("Location: index.php");
|
| 28 |
|
|
exit(0);
|
| 29 |
|
|
} else {
|
| 30 |
1457
|
Luisehahne
|
$page_id = (int)$_GET['page_id'];
|
| 31 |
1358
|
Luisehahne
|
}
|
| 32 |
1545
|
Luisehahne
|
*/
|
| 33 |
|
|
// Get page id
|
| 34 |
|
|
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
| 35 |
|
|
$page_id = intval(isset(${$requestMethod}['page_id'])) ? ${$requestMethod}['page_id'] : 0;
|
| 36 |
|
|
if( ($page_id == 0)) {
|
| 37 |
|
|
header("Location: index.php");
|
| 38 |
|
|
exit(0);
|
| 39 |
|
|
}
|
| 40 |
1358
|
Luisehahne
|
|
| 41 |
1402
|
Luisehahne
|
/*
|
| 42 |
1457
|
Luisehahne
|
if( (!($page_id = $admin->checkIDKEY('page_id', $page_id, $_SERVER['REQUEST_METHOD']))) )
|
| 43 |
1402
|
Luisehahne
|
{
|
| 44 |
|
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
| 45 |
|
|
}
|
| 46 |
|
|
*/
|
| 47 |
1358
|
Luisehahne
|
|
| 48 |
|
|
// Get perms
|
| 49 |
|
|
if(!$admin->get_page_permission($page_id,'admin')) {
|
| 50 |
1707
|
Luisehahne
|
$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
|
| 51 |
1358
|
Luisehahne
|
}
|
| 52 |
|
|
|
| 53 |
|
|
$sectionId = isset($_GET['wysiwyg']) ? htmlspecialchars($admin->get_get('wysiwyg')) : NULL;
|
| 54 |
|
|
|
| 55 |
|
|
// Get page details
|
| 56 |
|
|
$results_array=$admin->get_page_details($page_id);
|
| 57 |
|
|
|
| 58 |
|
|
// Get display name of person who last modified the page
|
| 59 |
|
|
$user=$admin->get_user_details($results_array['modified_by']);
|
| 60 |
|
|
|
| 61 |
|
|
// Convert the unix ts for modified_when to human a readable form
|
| 62 |
|
|
|
| 63 |
|
|
$modified_ts = ($results_array['modified_when'] != 0)
|
| 64 |
1457
|
Luisehahne
|
? $modified_ts = date(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE)
|
| 65 |
1358
|
Luisehahne
|
: 'Unknown';
|
| 66 |
1457
|
Luisehahne
|
// $ftan_module = $GLOBALS['ftan_module'];
|
| 67 |
1529
|
Luisehahne
|
// Setup template object, parse vars to it, then parse it
|
| 68 |
|
|
// Create new template object
|
| 69 |
1707
|
Luisehahne
|
$template = new Template(dirname($admin->correct_theme_source('pages_modify.htt')),'keep');
|
| 70 |
1529
|
Luisehahne
|
// $template->debug = true;
|
| 71 |
1358
|
Luisehahne
|
$template->set_file('page', 'pages_modify.htt');
|
| 72 |
|
|
$template->set_block('page', 'main_block', 'main');
|
| 73 |
1457
|
Luisehahne
|
$template->set_var('FTAN', $admin->getFTAN() );
|
| 74 |
1358
|
Luisehahne
|
|
| 75 |
|
|
$template->set_var(array(
|
| 76 |
|
|
'PAGE_ID' => $results_array['page_id'],
|
| 77 |
1402
|
Luisehahne
|
// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
|
| 78 |
|
|
'PAGE_IDKEY' => $results_array['page_id'],
|
| 79 |
1358
|
Luisehahne
|
'PAGE_TITLE' => ($results_array['page_title']),
|
| 80 |
|
|
'MENU_TITLE' => ($results_array['menu_title']),
|
| 81 |
|
|
'ADMIN_URL' => ADMIN_URL,
|
| 82 |
|
|
'WB_URL' => WB_URL,
|
| 83 |
|
|
'THEME_URL' => THEME_URL
|
| 84 |
|
|
));
|
| 85 |
|
|
|
| 86 |
|
|
$template->set_var(array(
|
| 87 |
|
|
'MODIFIED_BY' => $user['display_name'],
|
| 88 |
|
|
'MODIFIED_BY_USERNAME' => $user['username'],
|
| 89 |
|
|
'MODIFIED_WHEN' => $modified_ts,
|
| 90 |
1707
|
Luisehahne
|
// 'LAST_MODIFIED' => $MESSAGE['PAGES_LAST_MODIFIED'],
|
| 91 |
|
|
'TEXT_LAST_MODIFIED' => $TEXT['LAST_UPDATED_BY'],
|
| 92 |
|
|
'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS']
|
| 93 |
1358
|
Luisehahne
|
));
|
| 94 |
|
|
|
| 95 |
|
|
$template->set_block('main_block', 'show_modify_block', 'show_modify');
|
| 96 |
|
|
if($modified_ts == 'Unknown')
|
| 97 |
|
|
{
|
| 98 |
|
|
$template->set_block('show_modify', '');
|
| 99 |
|
|
$template->set_var('CLASS_DISPLAY_MODIFIED', 'hide');
|
| 100 |
|
|
|
| 101 |
|
|
} else {
|
| 102 |
|
|
$template->set_var('CLASS_DISPLAY_MODIFIED', '');
|
| 103 |
|
|
$template->parse('show_modify', 'show_modify_block', true);
|
| 104 |
|
|
}
|
| 105 |
|
|
|
| 106 |
|
|
// Work-out if we should show the "manage sections" link
|
| 107 |
1707
|
Luisehahne
|
//$sql = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.(int)$page_id.' ';
|
| 108 |
|
|
//$sql .= 'AND `module` = "menu_link"';
|
| 109 |
|
|
//$query_sections = $database->query($sql);
|
| 110 |
1358
|
Luisehahne
|
|
| 111 |
1707
|
Luisehahne
|
if( $admin->get_permission('pages_settings') )
|
| 112 |
|
|
{
|
| 113 |
|
|
$template->set_var(array(
|
| 114 |
|
|
'SETTINGS_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'].'">',
|
| 115 |
|
|
'SETTINGS_LINK_AFTER' => '</a>',
|
| 116 |
|
|
'DISPLAY_MANAGE_SETTINGS' => 'link',
|
| 117 |
|
|
));
|
| 118 |
|
|
} else {
|
| 119 |
|
|
$template->set_var(array(
|
| 120 |
|
|
'SETTINGS_LINK_BEFORE' => '<span class="bold grey">',
|
| 121 |
|
|
'SETTINGS_LINK_AFTER' => '</span>',
|
| 122 |
|
|
'DISPLAY_MANAGE_SECTIONS' => 'link',
|
| 123 |
|
|
));
|
| 124 |
|
|
}
|
| 125 |
|
|
|
| 126 |
|
|
/*-- workout if we should show the "manage sections" link ------------------------------*/
|
| 127 |
|
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` '
|
| 128 |
|
|
. 'WHERE `page_id`='.$page_id.' AND `module`=\'menu_link\'';
|
| 129 |
|
|
$bIsMenuLink = (intval($database->get_one($sql)) != 0);
|
| 130 |
|
|
// $oTpl->set_block('main_block', 'show_manage_sections_block', 'show_manage_sections');
|
| 131 |
|
|
// if(!$bIsMenuLink && (MANAGE_SECTIONS == true) && $admin->get_permission('pages_add') )
|
| 132 |
|
|
if((MANAGE_SECTIONS == true) && $admin->get_permission('pages_add') )
|
| 133 |
|
|
{
|
| 134 |
|
|
// $oTpl->parse('show_manage_sections', 'show_manage_sections_block', true);
|
| 135 |
|
|
$template->set_var(array(
|
| 136 |
|
|
'SECTIONS_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/sections.php?page_id='.$results_array['page_id'].'">',
|
| 137 |
|
|
'SECTIONS_LINK_AFTER' => '</a>',
|
| 138 |
|
|
'DISPLAY_MANAGE_SECTIONS' => 'link',
|
| 139 |
|
|
));
|
| 140 |
|
|
}else {
|
| 141 |
|
|
// $oTpl->set_block('show_manage_sections', '');
|
| 142 |
|
|
$template->set_var(array(
|
| 143 |
|
|
'SECTIONS_LINK_BEFORE' => '<span class="bold grey">',
|
| 144 |
|
|
'SECTIONS_LINK_AFTER' => '</span>',
|
| 145 |
|
|
'DISPLAY_MANAGE_SECTIONS' => 'link',
|
| 146 |
|
|
));
|
| 147 |
|
|
}
|
| 148 |
|
|
|
| 149 |
|
|
/*
|
| 150 |
1358
|
Luisehahne
|
$template->set_block('main_block', 'show_section_block', 'show_section');
|
| 151 |
|
|
if($query_sections->numRows() > 0)
|
| 152 |
|
|
{
|
| 153 |
|
|
$template->set_block('show_section', '');
|
| 154 |
|
|
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
|
| 155 |
|
|
|
| 156 |
|
|
} elseif(MANAGE_SECTIONS == 'enabled')
|
| 157 |
|
|
{
|
| 158 |
|
|
|
| 159 |
|
|
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
|
| 160 |
|
|
$template->parse('show_section', 'show_section_block', true);
|
| 161 |
|
|
|
| 162 |
|
|
} else {
|
| 163 |
|
|
$template->set_block('show_section', '');
|
| 164 |
|
|
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
|
| 165 |
|
|
|
| 166 |
|
|
}
|
| 167 |
1707
|
Luisehahne
|
*/
|
| 168 |
1358
|
Luisehahne
|
// Insert language TEXT
|
| 169 |
|
|
$template->set_var(array(
|
| 170 |
|
|
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
|
| 171 |
|
|
'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
|
| 172 |
|
|
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
|
| 173 |
|
|
));
|
| 174 |
|
|
|
| 175 |
|
|
// Parse and print header template
|
| 176 |
|
|
$template->parse('main', 'main_block', false);
|
| 177 |
|
|
$template->pparse('output', 'page');
|
| 178 |
|
|
|
| 179 |
|
|
// get template used for the displayed page (for displaying block details)
|
| 180 |
|
|
if (SECTION_BLOCKS)
|
| 181 |
|
|
{
|
| 182 |
|
|
$sql = "SELECT `template` from `" . TABLE_PREFIX . "pages` WHERE `page_id` = '$page_id' ";
|
| 183 |
|
|
$result = $database->query($sql);
|
| 184 |
|
|
if ($result && $result->numRows() == 1) {
|
| 185 |
|
|
$row = $result->fetchRow();
|
| 186 |
|
|
$page_template = ($row['template'] == '') ? DEFAULT_TEMPLATE : $row['template'];
|
| 187 |
|
|
// include template info file if exists
|
| 188 |
|
|
if (file_exists(WB_PATH . '/templates/' . $page_template . '/info.php'))
|
| 189 |
|
|
{
|
| 190 |
|
|
include_once(WB_PATH . '/templates/' . $page_template . '/info.php');
|
| 191 |
|
|
}
|
| 192 |
|
|
}
|
| 193 |
|
|
}
|
| 194 |
|
|
|
| 195 |
|
|
// Get sections for this page
|
| 196 |
|
|
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
| 197 |
|
|
// workout for edit only one section for faster pageloading
|
| 198 |
|
|
// Constant later set in wb_settings, in meantime defined in framework/initialize.php
|
| 199 |
|
|
$sql = 'SELECT `section_id`, `module`, `block` FROM `'.TABLE_PREFIX.'sections` ';
|
| 200 |
|
|
|
| 201 |
|
|
$sql .= (defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION && is_numeric($sectionId))
|
| 202 |
|
|
? 'WHERE `section_id` = '.$sectionId
|
| 203 |
|
|
: 'WHERE `page_id` = '.intval($page_id);
|
| 204 |
|
|
$sql .= ' ORDER BY position ASC';
|
| 205 |
|
|
$query_sections = $database->query($sql);
|
| 206 |
|
|
if($query_sections->numRows() > 0)
|
| 207 |
|
|
{
|
| 208 |
1914
|
Luisehahne
|
while($section = $query_sections->fetchRow(MYSQL_ASSOC))
|
| 209 |
1358
|
Luisehahne
|
{
|
| 210 |
|
|
$section_id = $section['section_id'];
|
| 211 |
|
|
$module = $section['module'];
|
| 212 |
|
|
//Have permission?
|
| 213 |
1889
|
Luisehahne
|
if(!is_numeric(array_search($module, $module_permissions))) {
|
| 214 |
1358
|
Luisehahne
|
// Include the modules editing script if it exists
|
| 215 |
1889
|
Luisehahne
|
if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php')) {
|
| 216 |
1358
|
Luisehahne
|
print /* '<a name="'.$section_id.'"></a>'. */"\n";
|
| 217 |
|
|
// output block name if blocks are enabled
|
| 218 |
1889
|
Luisehahne
|
// if (SECTION_BLOCKS) {
|
| 219 |
|
|
if (isset($block[$section['block']]) && trim(strip_tags(($block[$section['block']]))) != '') {
|
| 220 |
1358
|
Luisehahne
|
$block_name = htmlentities(strip_tags($block[$section['block']]));
|
| 221 |
|
|
} else {
|
| 222 |
1889
|
Luisehahne
|
if ($section['block'] == 1) {
|
| 223 |
1358
|
Luisehahne
|
$block_name = $TEXT['MAIN'];
|
| 224 |
|
|
} else {
|
| 225 |
|
|
$block_name = '#' . (int) $section['block'];
|
| 226 |
|
|
}
|
| 227 |
|
|
}
|
| 228 |
1914
|
Luisehahne
|
$sSectionIdPrefix = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? SEC_ANCHOR : 'Sec');
|
| 229 |
|
|
print '<div class="section-info" id="'.$sSectionIdPrefix.$section['section_id'].'" ><b>' . $TEXT['BLOCK'] . ': </b>' . $block_name;
|
| 230 |
1358
|
Luisehahne
|
print '<b> Modul: </b>' . $section['module']." ";
|
| 231 |
|
|
print '<b> ID: </b>' . $section_id."</div>\n";
|
| 232 |
1889
|
Luisehahne
|
// }
|
| 233 |
1358
|
Luisehahne
|
require(WB_PATH.'/modules/'.$module.'/modify.php');
|
| 234 |
|
|
}
|
| 235 |
|
|
}
|
| 236 |
|
|
}
|
| 237 |
|
|
}
|
| 238 |
|
|
|
| 239 |
|
|
// Print admin footer
|
| 240 |
|
|
$admin->print_footer();
|