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