diff --git a/sites/all/modules/unl/unl_migration.php b/sites/all/modules/unl/unl_migration.php index b2bbc16eaa31f130d3c972b6d4a17dcfd4148f16..6a87ea202c0d539c366cb60586d12a5805b36016 100644 --- a/sites/all/modules/unl/unl_migration.php +++ b/sites/all/modules/unl/unl_migration.php @@ -78,6 +78,7 @@ class Unl_Migration_Tool private $_content = array(); private $_createdContent = array(); private $_lastModifications = array(); + private $_redirects = array(); private $_hrefTransform = array(); private $_hrefTransformFiles = array(); private $_menu = array(); @@ -150,6 +151,9 @@ class Unl_Migration_Tool unset($transforms['']); } foreach ($transforms as $oldPath => &$newPath) { + if (array_key_exists($newPath, $this->_redirects)) { + $newPath = $this->_redirects[$newPath]; + } if (array_key_exists($newPath, $this->_hrefTransformFiles)) { $newPath = $this->_hrefTransformFiles[$newPath]; } @@ -262,6 +266,17 @@ class Unl_Migration_Tool private function _createMenu() { + // Start off by removing the "Home" menu link if it exists. + $menu_links = menu_load_links('main-menu'); + foreach ($menu_links as $menu_link) { + if ($menu_link['plid'] == 0 && + $menu_link['link_title'] == 'Home' && + $menu_link['link_path'] == '<front>') { + menu_link_delete($menu_link['mlid']); + } + } + + // Now recursively create each menu. $primaryWeights = 1; foreach ($this->_menu as $primaryMenu) { $item = array( @@ -639,6 +654,13 @@ class Unl_Migration_Tool $location = $headers['Location']; $path = substr($location, strlen($this->_baseUrl)); $this->_addSitePath($path); + + if (substr($location, 0, strlen($this->_baseUrl)) == $this->_baseUrl) { + $this->_redirects[substr($url, strlen($this->_baseUrl))] = substr($location, strlen($this->_baseUrl)); + } else { + $this->_redirects[substr($url, strlen($this->_baseUrl))] = $location; + } + $this->_log('Found a redirect from ' . $url . ' to ' . $location . '. Some links may need to be updated.'); return FALSE; } else if ($meta['http_code'] != 200) {