Project

General

Profile

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