Project

General

Profile

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 1545 2011-12-15 19:12:56Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/modify.php $
15
 * @lastmodified    $Date: 2011-12-15 20:12:56 +0100 (Thu, 15 Dec 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 = (int)$_GET['page_id'];
32
}
33
*/
34
// Get page id
35
	$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
36
	$page_id = intval(isset(${$requestMethod}['page_id'])) ? ${$requestMethod}['page_id'] : 0;
37
	if(	($page_id == 0)) {
38
		header("Location: index.php");
39
		exit(0);
40
	}
41

    
42
/*
43
if( (!($page_id = $admin->checkIDKEY('page_id', $page_id, $_SERVER['REQUEST_METHOD']))) )
44
{
45
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
46
}
47
*/
48

    
49
// Get perms
50
if(!$admin->get_page_permission($page_id,'admin')) {
51
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
52
}
53

    
54
$sectionId = isset($_GET['wysiwyg']) ? htmlspecialchars($admin->get_get('wysiwyg')) : NULL;
55

    
56
// Get page details
57
$results_array=$admin->get_page_details($page_id);
58

    
59
// Get display name of person who last modified the page
60
$user=$admin->get_user_details($results_array['modified_by']);
61

    
62
// Convert the unix ts for modified_when to human a readable form
63

    
64
$modified_ts = ($results_array['modified_when'] != 0)
65
        ? $modified_ts = date(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE)
66
        : 'Unknown';
67
// $ftan_module = $GLOBALS['ftan_module'];
68
// Setup template object, parse vars to it, then parse it
69
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('pages_modify.htt'));
70
// Create new template object
71
$template = new Template($ThemePath);
72
// $template->debug = true;
73
$template->set_file('page', 'pages_modify.htt');
74
$template->set_block('page', 'main_block', 'main');
75
$template->set_var('FTAN', $admin->getFTAN() );
76

    
77
$template->set_var(array(
78
			'PAGE_ID' => $results_array['page_id'],
79
			// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
80
			'PAGE_IDKEY' => $results_array['page_id'],
81
			'PAGE_TITLE' => ($results_array['page_title']),
82
			'MENU_TITLE' => ($results_array['menu_title']),
83
			'ADMIN_URL' => ADMIN_URL,
84
			'WB_URL' => WB_URL,
85
			'THEME_URL' => THEME_URL
86
			));
87

    
88
$template->set_var(array(
89
			'MODIFIED_BY' => $user['display_name'],
90
			'MODIFIED_BY_USERNAME' => $user['username'],
91
			'MODIFIED_WHEN' => $modified_ts,
92
			'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
93
			));
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
$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

    
111
$template->set_block('main_block', 'show_section_block', 'show_section');
112
if($query_sections->numRows() > 0)
113
{
114
	$template->set_block('show_section', '');
115
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
116

    
117
} elseif(MANAGE_SECTIONS == 'enabled')
118
{
119

    
120
	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
121
    $template->parse('show_section', 'show_section_block', true);
122

    
123
} else {
124
	$template->set_block('show_section', '');
125
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
126

    
127
}
128

    
129
// Insert language TEXT
130
$template->set_var(array(
131
				'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
132
				'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
133
				'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
134
				));
135

    
136
// Parse and print header template
137
$template->parse('main', 'main_block', false);
138
$template->pparse('output', 'page');
139

    
140
// get template used for the displayed page (for displaying block details)
141
if (SECTION_BLOCKS)
142
{
143
	$sql = "SELECT `template` from `" . TABLE_PREFIX . "pages` WHERE `page_id` = '$page_id' ";
144
	$result = $database->query($sql);
145
	if ($result && $result->numRows() == 1) {
146
		$row = $result->fetchRow();
147
		$page_template = ($row['template'] == '') ? DEFAULT_TEMPLATE : $row['template'];
148
		// include template info file if exists
149
		if (file_exists(WB_PATH . '/templates/' . $page_template . '/info.php'))
150
		{
151
			include_once(WB_PATH . '/templates/' . $page_template . '/info.php');
152
		}
153
	}
154
}
155

    
156
// Get sections for this page
157
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
158
// workout for edit only one section for faster pageloading
159
// Constant later set in wb_settings, in meantime defined in framework/initialize.php
160
$sql = 'SELECT `section_id`, `module`, `block` FROM `'.TABLE_PREFIX.'sections` ';
161

    
162
$sql .= (defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION && is_numeric($sectionId))
163
		? 'WHERE `section_id` = '.$sectionId
164
		: 'WHERE `page_id` = '.intval($page_id);
165
$sql .= ' ORDER BY position ASC';
166
$query_sections = $database->query($sql);
167
if($query_sections->numRows() > 0)
168
{
169
	while($section = $query_sections->fetchRow())
170
    {
171
		$section_id = $section['section_id'];
172
		$module = $section['module'];
173
		//Have permission?
174
		if(!is_numeric(array_search($module, $module_permissions)))
175
        {
176
			// Include the modules editing script if it exists
177
			if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php'))
178
            {
179
				print /* '<a name="'.$section_id.'"></a>'. */"\n";
180
				// output block name if blocks are enabled
181
				if (SECTION_BLOCKS) {
182
					if (isset($block[$section['block']]) && trim(strip_tags(($block[$section['block']]))) != '')
183
                    {
184
						$block_name = htmlentities(strip_tags($block[$section['block']]));
185
					} else {
186
						if ($section['block'] == 1)
187
                        {
188
							$block_name = $TEXT['MAIN'];
189
						} else {
190
							$block_name = '#' . (int) $section['block'];
191
						}
192
					}
193

    
194
                    $sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? 'id="'.SEC_ANCHOR.$section['section_id'].'"' : '');
195
					print '<div class="section-info" '.$sec_anchor.' ><b>' . $TEXT['BLOCK'] . ': </b>' . $block_name;
196
					print '<b>  Modul: </b>' . $section['module']." ";
197
					print '<b>  ID: </b>' . $section_id."</div>\n";
198

    
199
				}
200
				require(WB_PATH.'/modules/'.$module.'/modify.php');
201
			}
202
		}
203
	}
204
}
205

    
206
// Print admin footer
207
$admin->print_footer();
(9-9/22)