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-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 1333 2010-04-22 03:13:59Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/modify.php $
15
 * @lastmodified    $Date: 2010-04-22 05:13:59 +0200 (Thu, 22 Apr 2010) $
16
 *
17
*/
18

    
19
// Get page id
20
if(!isset($_GET['page_id']) || !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

    
31
$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
$sectionId = isset($_GET['wysiwyg']) ? htmlspecialchars($admin->get_get('wysiwyg')) : NULL;
39

    
40
// 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
$modified_ts = ($results_array['modified_when'] != 0)
49
        ? $modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE)
50
        : 'Unknown';
51

    
52
// 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

    
57
$template->set_var(array(
58
			'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
	$template->set_var('CLASS_DISPLAY_MODIFIED', 'hide');
79

    
80
} else {
81
	$template->set_var('CLASS_DISPLAY_MODIFIED', '');
82
    $template->parse('show_modify', 'show_modify_block', true);
83
}
84

    
85
// Work-out if we should show the "manage sections" link
86
$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
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
95

    
96
} elseif(MANAGE_SECTIONS == 'enabled')
97
{
98

    
99
	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
100
    $template->parse('show_section', 'show_section_block', true);
101

    
102
} else {
103
	$template->set_block('show_section', '');
104
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
105

    
106
}
107

    
108
// Insert language TEXT
109
$template->set_var(array(
110
				'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
111
				'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
112
				'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
113
				));
114

    
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
		if (file_exists(WB_PATH . '/templates/' . $page_template . '/info.php'))
129
		{
130
			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
// workout for edit only one section for faster pageloading
138
// Constant later set in wb_settings, in meantime defined in framework/initialize.php
139
$sql = 'SELECT `section_id`, `module`, `block` FROM `'.TABLE_PREFIX.'sections` ';
140

    
141
$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
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
				print /* '<a name="'.$section_id.'"></a>'. */"\n";
159
				// 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
					print '<div id="wb'.$section['section_id'].'"><b>' . $TEXT['BLOCK'] . ': </b>' . $block_name;
173
					print '<b>  Modul: </b>' . $section['module']." ";
174
					print '<b>  ID: </b>' . $section_id."</div>\n";
175
				}
176
				require(WB_PATH.'/modules/'.$module.'/modify.php');
177
			}
178
		}
179
	}
180
}
181

    
182
// Print admin footer
183
$admin->print_footer();
184

    
185
?>
(8-8/21)