Project

General

Profile

« Previous | Next » 

Revision 452

Added by Matthias about 17 years ago

again copied all changes for WB 2.6.6 from trunk to branches

View differences:

settings2.php
41 41

  
42 42
// Get values
43 43
$page_title = $admin->add_slashes($admin->get_post_escaped('page_title'));
44
$page_title = my_htmlspecialchars($page_title);
44 45
$menu_title = $admin->add_slashes($admin->get_post_escaped('menu_title'));
46
$menu_title = my_htmlspecialchars($menu_title);
45 47
$description = $admin->add_slashes($admin->get_post('description'));
46 48
$keywords = $admin->add_slashes($admin->get_post('keywords'));
47 49
$parent = $admin->get_post('parent');
......
55 57
$menu = $admin->get_post('menu');
56 58

  
57 59
// Validate data
58
if($page_title == '') {
60
if($page_title == '' || substr($page_title,0,1)=='.') {
59 61
	$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']);
60 62
}
61
if($menu_title == '') {
63
if($menu_title == '' || substr($menu_title,0,1)=='.') {
62 64
	$admin->print_error($MESSAGE['PAGES']['BLANK_MENU_TITLE']);
63 65
}
64 66

  
......
114 116
// Work-out what the link should be
115 117
if($parent == '0') {
116 118
	$link = '/'.page_filename($menu_title);
117
	$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($menu_title).'.php';
119
	$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($menu_title).PAGE_EXTENSION; 
118 120
} else {
119 121
	$parent_section = '';
120 122
	$parent_titles = array_reverse(get_parent_titles($parent));
......
123 125
	}
124 126
	if($parent_section == '/') { $parent_section = ''; }
125 127
	$link = '/'.$parent_section.page_filename($menu_title);
126
	$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($menu_title).'.php';
128
	$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($menu_title).PAGE_EXTENSION;  
127 129
}
128 130

  
129 131
// Check if a page with same page filename exists
......
142 144
$page_trail = get_page_trail($page_id);
143 145

  
144 146
// Make sure link is not overwritten if page uses the menu link module
145
if(strstr($old_link, '://') != '') {
147
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
148
if($query_sections->numRows() > 0) {
146 149
	$link = $old_link;
147
}
150
} 
148 151

  
149 152
// Update page settings in the pages table
150 153
$query = "UPDATE ".TABLE_PREFIX."pages SET parent = '$parent', page_title = '$page_title', menu_title = '$menu_title', menu = '$menu', level = '$level', page_trail = '$page_trail', root_parent = '$root_parent', link = '$link', template = '$template', target = '$target', description = '$description', keywords = '$keywords', position = '$position', visibility = '$visibility', searching = '$searching', language = '$language', admin_groups = '$admin_groups', viewing_groups = '$viewing_groups' WHERE page_id = '$page_id'";
......
164 167
	// First check if we need to create a new file
165 168
	if($old_link != $link) {
166 169
		// Delete old file
167
		unlink(WB_PATH.PAGES_DIRECTORY.$old_link.'.php');
170
		unlink(WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION);
168 171
		// Create access file
169 172
		create_access_file($filename,$page_id,$level);
170 173
		// Move a directory for this page
......
187 190
					// Update level and link
188 191
					$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$new_sub_link', level = '$new_sub_level' WHERE page_id = '".$sub['page_id']."' LIMIT 1");
189 192
					// Re-write the access file for this page
190
					$old_subpage_file = WB_PATH.PAGES_DIRECTORY.$new_sub_link.'.php';
193
					$old_subpage_file = WB_PATH.PAGES_DIRECTORY.$new_sub_link.PAGE_EXTENSION;
191 194
					if(file_exists($old_subpage_file)) {
192 195
						unlink($old_subpage_file);
193 196
					}
194
					create_access_file(WB_PATH.PAGES_DIRECTORY.$new_sub_link.'.php', $sub['page_id'], $new_sub_level);
197
					create_access_file(WB_PATH.PAGES_DIRECTORY.$new_sub_link.PAGE_EXTENSION, $sub['page_id'], $new_sub_level);
195 198
				}
196 199
			}
197 200
		}
......
199 202
}
200 203

  
201 204
// Function to fix page trail of subs
202
function fix_page_trail($parent) {
205
function fix_page_trail($parent,$root_parent) {
203 206
	// Get objects and vars from outside this function
204 207
	global $admin, $template, $database, $TEXT, $MESSAGE;
205 208
	// Get page list from database
......
210 213
	if($get_pages->numRows() > 0)	{
211 214
		while($page = $get_pages->fetchRow()) {
212 215
			// Fix page trail
213
			$database->query("UPDATE ".TABLE_PREFIX."pages SET page_trail = '".get_page_trail($page['page_id'])."' WHERE page_id = '".$page['page_id']."'");
216
			$database->query("UPDATE ".TABLE_PREFIX."pages SET ".($root_parent != 0 ?"root_parent = '$root_parent', ":"")." page_trail = '".get_page_trail($page['page_id'])."' WHERE page_id = '".$page['page_id']."'");
214 217
			// Run this query on subs
215
			fix_page_trail($page['page_id']);
218
			fix_page_trail($page['page_id'],$root_parent);
216 219
		}
217 220
	}
218 221
}
219 222
// Fix sub-pages page trail
220
fix_page_trail($page_id);
223
fix_page_trail($page_id,$root_parent);
221 224

  
222 225
/* END page "access file" code */
223 226

  

Also available in: Unified diff