Revision 566
Added by thorn almost 17 years ago
upgrade-script.php | ||
---|---|---|
198 | 198 |
} |
199 | 199 |
|
200 | 200 |
|
201 |
$database = new database(DB_URL); |
|
201 |
/********************************************************** |
|
202 |
* - core-module menu_link |
|
203 |
*/ |
|
204 |
// create table |
|
205 |
$table = TABLE_PREFIX ."mod_menu_link"; |
|
206 |
$database->query("DROP TABLE IF EXISTS `$table`"); |
|
207 |
$database->query(" |
|
208 |
CREATE TABLE `$table` ( |
|
209 |
`section_id` INT(11) NOT NULL DEFAULT '0', |
|
210 |
`page_id` INT(11) NOT NULL DEFAULT '0', |
|
211 |
`target_page_id` INT(11) NOT NULL DEFAULT '0', |
|
212 |
`anchor` VARCHAR(255) NOT NULL DEFAULT '' , |
|
213 |
PRIMARY KEY (`section_id`) |
|
214 |
) |
|
215 |
"); |
|
216 |
// fetch all menu_link-pages in $pages |
|
217 |
$pages = array(); |
|
218 |
$table_p = TABLE_PREFIX.'pages'; |
|
219 |
$table_s = TABLE_PREFIX.'sections'; |
|
220 |
$query_page = $database->query("SELECT p.* FROM $table_p AS p, $table_s AS s WHERE p.page_id=s.page_id AND s.module = 'menu_link'"); |
|
221 |
if($query_page->numRows() > 0) { |
|
222 |
while($page = $query_page->fetchRow()) { |
|
223 |
$pages[$page['page_id']]['page_details'] = $page; |
|
224 |
} |
|
225 |
} |
|
226 |
// get all related files with content from pages/ in $pages, too |
|
227 |
function list_files_dirs($dir, $depth=true, $files=array(), $dirs=array()) { |
|
228 |
$dh=opendir($dir); |
|
229 |
while(($file = readdir($dh)) !== false) { |
|
230 |
if($file == '.' || $file == '..') { |
|
231 |
continue; |
|
232 |
} |
|
233 |
if(is_dir($dir.'/'.$file)) { |
|
234 |
if($depth) { |
|
235 |
$dirs[] = $dir.'/'.$file; |
|
236 |
list($files, $dirs) = list_files_dirs($dir.'/'.$file, $depth, $files, $dirs); |
|
237 |
} |
|
238 |
} else { |
|
239 |
$files[] = $dir.'/'.$file; |
|
240 |
} |
|
241 |
} |
|
242 |
closedir($dh); |
|
243 |
natcasesort($files); |
|
244 |
natcasesort($dirs); |
|
245 |
return(array($files, $dirs)); |
|
246 |
} |
|
247 |
list($files, $dirs) = list_files_dirs(WB_PATH.PAGES_DIRECTORY); |
|
248 |
foreach($files as $file) { |
|
249 |
if(($content = implode('', file($file))) !== FALSE) { |
|
250 |
if(preg_match('/\$page_id = (\d+)/', $content, $matches)) { |
|
251 |
if(array_key_exists($matches[1], $pages)) { |
|
252 |
$pages[$matches[1]]['file_content'] = $content; |
|
253 |
$pages[$matches[1]]['filename'] = $file; |
|
254 |
} |
|
255 |
} |
|
256 |
} |
|
257 |
} |
|
258 |
// try to convert old menu_links to new ones |
|
259 |
foreach($pages as $p) { |
|
260 |
$page = $p['page_details']; |
|
261 |
$file_content = $p['file_content']; |
|
262 |
$filename = $p['filename']; |
|
263 |
$link = $p['page_details']['link']; |
|
264 |
//var_dump($page);var_dump($file_content);var_dump($filename);var_dump($link); |
|
202 | 265 |
|
266 |
// This part is still missing |
|
267 |
|
|
268 |
|
|
269 |
} |
|
270 |
|
|
271 |
|
|
203 | 272 |
//****************************************************************************** |
204 | 273 |
//Start of upgrade script for the form modul |
205 | 274 |
//****************************************************************************** |
Also available in: Unified diff
upgrade-script: added code to convert old menu_links to new ones (partly)