示例#1
0
 $query_subs = $database->query(sprintf("SELECT `page_id`, `parent`, `link`, `level` FROM `%spages` WHERE `page_trail` LIKE '%s,%%' ORDER BY LEVEL ASC", CAT_TABLE_PREFIX, $options['page_trail']));
 if (is_object($query_subs) && $query_subs->numRows() > 0) {
     while ($sub = $query_subs->fetchRow(MYSQL_ASSOC)) {
         // Double-check to see if it contains old link
         if (substr($sub['link'], 0, $old_link_len) == $old_link) {
             // Get new link
             $replace_this = $old_link;
             $old_sub_link_len = strlen($sub['link']);
             $new_sub_link = $options['link'] . '/' . substr($sub['link'], $old_link_len + 1, $old_sub_link_len);
             // Work out level
             $new_sub_level = count(explode('/', $new_sub_link)) - 2;
             $root_parent = $options['root_parent'] == '0' ? $page_id : $options['root_parent'];
             // Update link and level
             $database->query(sprintf("UPDATE `%spages` SET link='%s', level='%s', root_parent='%s' WHERE page_id='%s' LIMIT 1", CAT_TABLE_PREFIX, $new_sub_link, $new_sub_level, $root_parent, $sub['page_id']));
             // we use reset() to reload the page tree
             CAT_Helper_Page::reset();
             // update trail
             $database->query(sprintf("UPDATE `%spages` SET page_trail='%s' WHERE page_id='%s' LIMIT 1", CAT_TABLE_PREFIX, CAT_Helper_Page::getPageTrail($sub['page_id']), $sub['page_id']));
             // Re-write the access file for this page
             $old_subpage_file = CAT_PATH . PAGES_DIRECTORY . $new_sub_link . PAGE_EXTENSION;
             // remove old file
             if (file_exists($old_subpage_file)) {
                 unlink($old_subpage_file);
             }
             // create new
             CAT_Helper_Page::createAccessFile($new_sub_link, $sub['page_id']);
         }
     }
 }
 // check if source directory is empty now
 $source_dir = pathinfo(CAT_PATH . PAGES_DIRECTORY . $old_link, PATHINFO_DIRNAME);