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