Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher and higher
12
 * @version         $Id: modify.php 1758 2012-09-16 08:46:13Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/modify.php $
14
 * @lastmodified    $Date: 2012-09-16 10:46:13 +0200 (Sun, 16 Sep 2012) $
15
 *
16
 */
17
/*
18
*/
19
// Create new admin object
20
require('../../config.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22

    
23
$admin = new admin('Pages', 'pages_modify');
24
/*
25
// 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
	$page_id = (int)$_GET['page_id'];
31
}
32
*/
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

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

    
48
// Get perms
49
if(!$admin->get_page_permission($page_id,'admin')) {
50
	$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
51
}
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
        ? $modified_ts = date(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE)
65
        : 'Unknown';
66
// $ftan_module = $GLOBALS['ftan_module'];
67
// Setup template object, parse vars to it, then parse it
68
// Create new template object
69
$template = new Template(dirname($admin->correct_theme_source('pages_modify.htt')),'keep');
70
// $template->debug = true;
71
$template->set_file('page', 'pages_modify.htt');
72
$template->set_block('page', 'main_block', 'main');
73
$template->set_var('FTAN', $admin->getFTAN() );
74

    
75
$template->set_var(array(
76
			'PAGE_ID' => $results_array['page_id'],
77
			// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
78
			'PAGE_IDKEY' => $results_array['page_id'],
79
			'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
//			'LAST_MODIFIED' => $MESSAGE['PAGES_LAST_MODIFIED'],
91
			'TEXT_LAST_MODIFIED' => $TEXT['LAST_UPDATED_BY'],
92
			'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS']
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
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
$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
*/
168
// 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
	while($section = $query_sections->fetchRow())
209
    {
210
		$section_id = $section['section_id'];
211
		$module = $section['module'];
212
		//Have permission?
213
		if(!is_numeric(array_search($module, $module_permissions)))
214
        {
215
			// Include the modules editing script if it exists
216
			if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php'))
217
            {
218
				print /* '<a name="'.$section_id.'"></a>'. */"\n";
219
				// output block name if blocks are enabled
220
				if (SECTION_BLOCKS) {
221
					if (isset($block[$section['block']]) && trim(strip_tags(($block[$section['block']]))) != '')
222
                    {
223
						$block_name = htmlentities(strip_tags($block[$section['block']]));
224
					} else {
225
						if ($section['block'] == 1)
226
                        {
227
							$block_name = $TEXT['MAIN'];
228
						} else {
229
							$block_name = '#' . (int) $section['block'];
230
						}
231
					}
232

    
233
                    $sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? 'id="'.SEC_ANCHOR.$section['section_id'].'"' : 'section_'.$section_id);
234
					print '<div class="section-info" '.$sec_anchor.' ><b>' . $TEXT['BLOCK'] . ': </b>' . $block_name;
235
					print '<b>  Modul: </b>' . $section['module']." ";
236
					print '<b>  ID: </b>' . $section_id."</div>\n";
237

    
238
				}
239
				require(WB_PATH.'/modules/'.$module.'/modify.php');
240
			}
241
		}
242
	}
243
}
244

    
245
// Print admin footer
246
$admin->print_footer();
(9-9/22)