Project

General

Profile

« Previous | Next » 

Revision 579

Added by thorn almost 17 years ago

upgrade-script.php: fixed mysql_error() handling. added code to update menu_links (partly finished)

View differences:

upgrade-script.php
67 67
		return true;
68 68
	} else {
69 69
		$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('$key', '$value', '')");
70
		echo mysql_error()?'<br />':'';
70
		echo mysql_error()?mysql_error().'<br />':'';
71 71
		$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = '$key' LIMIT 1");
72 72
		if($query->numRows() > 0) {
73 73
			echo "$key: $OK.<br />";
......
107 107
		$string .= "<tr><td colspan=\"2\" style=\"text-align: justify; padding-bottom: 10px;\">[EXCERPT]</td></tr>";
108 108
		$string = addslashes($string);
109 109
		$database->query("UPDATE ".TABLE_PREFIX."search SET name='results_loop',value='".$string."',extra='' WHERE name = 'results_loop' LIMIT 1");
110
		echo mysql_error().'<br />';
110
		echo mysql_error()?mysql_error().'<br />':'';
111 111
		$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'results_loop' LIMIT 1");
112 112
		if($query->numRows() > 0) {
113 113
			$fetch_results_loop = $query->fetchRow();
......
134 134
		$string = preg_replace("/<input type=\"text\" name=\"string\" value=\"\[SEARCH_STRING\]\" style=\"width: 100%;\" \/>/", "<input type=\"hidden\" name=\"search_path\" value=\"[SEARCH_PATH]\" /><input type=\"text\" name=\"string\" value=\"[SEARCH_STRING]\" style=\"width: 100%;\" />", $string);
135 135
		$string = addslashes($string);
136 136
		$database->query("UPDATE ".TABLE_PREFIX."search SET name='header',value='".$string."',extra='' WHERE name = 'header' LIMIT 1");
137
		echo mysql_error().'<br />';
137
		echo mysql_error()?mysql_error().'<br />':'';
138 138
		$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'header' LIMIT 1");
139 139
		if($query->numRows() > 0) {
140 140
			$fetch_header = $query->fetchRow();
......
175 175
$query = $database->query("DESCRIBE $table 'publ_start'");
176 176
if($query->numRows() == 0) { // add field
177 177
	$query = $database->query("ALTER TABLE $table ADD publ_start INT NOT NULL DEFAULT '0'");
178
	echo mysql_error()?mysql_error().'<br />':'';
178 179
	$query = $database->query("DESCRIBE $table 'publ_start'");
180
	echo mysql_error()?mysql_error().'<br />':'';
179 181
	if($query->numRows() > 0) {
180 182
		echo "'publ_start' added. $OK.<br />";
181 183
	} else {
......
187 189
$query = $database->query("DESCRIBE $table 'publ_end'");
188 190
if($query->numRows() == 0) { // add field
189 191
	$query = $database->query("ALTER TABLE $table ADD publ_end INT NOT NULL DEFAULT '0'");
192
	echo mysql_error()?mysql_error().'<br />':'';
190 193
	$query = $database->query("DESCRIBE $table 'publ_end'");
191 194
	if($query->numRows() > 0) {
192 195
		echo "'publ_end' added. $OK.<br />";
......
256 259
	}
257 260
}
258 261
// try to convert old menu_links to new ones
262
$table_p = TABLE_PREFIX.'pages';
263
$table_s = TABLE_PREFIX.'sections';
264
$table_mm = TABLE_PREFIX ."mod_menu_link";
259 265
foreach($pages as $p) {
260 266
	$page = $p['page_details'];
261 267
	$file_content = $p['file_content'];
262 268
	$filename = $p['filename'];
263 269
	$link = $p['page_details']['link'];
264
//var_dump($page);var_dump($file_content);var_dump($filename);var_dump($link);
270
	$page_trail = $p['page_details']['page_trail'];
271
	$page_id = $p['page_details']['page_id'];
272
	//var_dump($page);var_dump($file_content);var_dump($filename);var_dump($link);var_dump($page_trail);
265 273

  
266
// This part is still missing
274
	// - aus wb_pages.page_trail aktuelle Position bestimmen
275
	// - daraus link bestimmen und in wb_pages eintragen
276
	// - Datei in pages wenn nötig verschieben
277
	//ok - Über $link die page_id der Zielseite feststellen (--> $target_page_id), und nach mod_menu_link speichern, anchor leer.
278
	if($query_pid = $database->query("SELECT p.page_id, s.section_id FROM $table_p AS p, $table_s AS s WHERE p.page_id = s.page_id AND p.link = '$link' AND p.page_id != '$page_id'")) {
279
		$res = $query_pid->fetchRow();
280
		$target_page_id = $res['page_id'];
281
		$section_id = $res['section_id'];
282
		$database->query("INSERT INTO $table_mm (page_id, section_id, target_page_id, anchor) VALUES ('$page_id', '$section_id', '$target_page_id', '0')");
283
		echo mysql_error()?mysql_error().'<br />':'';
284
	}
285
//var_dump("-------------------");
286
	// This part is still missing
267 287

  
268 288

  
269 289
}

Also available in: Unified diff