Project

General

Profile

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