From 7891439f884ec4bf5c67bef12b3fe3475f6b2833 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 10 Feb 2007 13:28:10 +0000 Subject: - Patch #113377: legacy module has reached end of life ... --- modules/legacy/legacy.module | 216 ------------------------------------------- 1 file changed, 216 deletions(-) delete mode 100644 modules/legacy/legacy.module (limited to 'modules') diff --git a/modules/legacy/legacy.module b/modules/legacy/legacy.module deleted file mode 100644 index 8f5a7b271..000000000 --- a/modules/legacy/legacy.module +++ /dev/null @@ -1,216 +0,0 @@ -'. t('The legacy module provides legacy handlers for upgrades from older installations. These handlers help automatically redirect references to pages from old installations and prevent page not found errors for your site.') .'

'; - $output .= '

'. t('The legacy module handles legacy style taxonomy page, taxonomy feed, and blog feed paths. It also handles URL upgrades from Drupal 4.1. It rewrites old-style URLs to new-style URLs (clean URLs). ') .'

'; - $output .= t('

Example Mappings:

- -'); - $output .= '

'. t('For more information please read the configuration and customization handbook Legacy page.', array('@legacy' => 'http://drupal.org/handbook/modules/legacy/')) .'

'; - return $output; - } -} - -/** - * Implementation of hook_menu(). - * - * Registers menu paths used in earlier Drupal versions. - */ -function legacy_menu() { - // Map "taxonomy/page/or/52,97" to "taxonomy/term/52+97". - $items['taxonomy/page'] = array( - 'title' => t('Taxonomy'), - 'page callback' => 'legacy_taxonomy_page', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - // Map "taxonomy/feed/or/52,97" to "taxonomy/term/52+97/0/feed". - $items['taxonomy/feed'] = array( - 'title' => t('Taxonomy'), - 'page callback' => 'legacy_taxonomy_feed', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - // Map "blog/feed/52" to "blog/52/feed". - $items['blog/feed'] = array( - 'title' => t('Blog'), - 'page callback' => 'legacy_blog_feed', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - // Map "node/view/52" to "node/52". - $items['node/view'] = array( - 'title' => t('View'), - 'page callback' => '_legacy_goto', - 'page arguments' => array('node', 2), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - // Map "book/view/52" to "node/52". - $items['book/view'] = array( - 'title' => t('View'), - 'page callback' => '_legacy_goto', - 'page arguments' => array('node', 2), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - // Map "user/view/52" to "user/52". - $items['user/view'] = array( - 'title' => t('View'), - 'page callback' => 'drupal_goto', - 'page arguments' => array('user', 2), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - return $items; -} - -function _legacy_goto($type, $arg) { - drupal_goto("$type/$arg", NULL, NULL); -} - -/** - * Menu callback; redirects users to new taxonomy page paths. - */ -function legacy_taxonomy_page($operation = 'or', $str_tids = '') { - if ($operation == 'or') { - $str_tids = str_replace(',', '+', $str_tids); - } - drupal_goto('taxonomy/term/'. $str_tids); -} - -/** - * Menu callback; redirects users to new taxonomy feed paths. - */ -function legacy_taxonomy_feed($operation = 'or', $str_tids = '') { - if ($operation == 'or') { - $str_tids = str_replace(',', '+', $str_tids); - } - drupal_goto('taxonomy/term/'. $str_tids .'/0/feed'); -} - -/** - * Menu callback; redirects users to new blog feed paths. - */ -function legacy_blog_feed($str_uid = '') { - // if URL is of form blog/feed/52 redirect - // if URL is of form blog/feed we have to call blog_feed_last(). - if (is_numeric($str_uid)) { - drupal_goto('blog/'. $str_uid .'/feed'); - } - else { - module_invoke('blog', 'feed_last'); - } -} - -/** - * Implementation of hook_filter(). Handles URL upgrades from Drupal 4.1. - */ -function legacy_filter($op, $delta = 0, $format = -1, $text = '') { - switch ($op) { - case 'list': - return array(t('Legacy filter')); - - case 'description': - return t('Replaces URLs from Drupal 4.1 (and lower) with updated equivalents.'); - - case 'process': - return _legacy_filter_old_urls($text); - - case 'settings': - return; - - default: - return $text; - } -} - -/** - * Rewrite legacy URLs. - * - * This is a *temporary* filter to rewrite old-style URLs to new-style - * URLs (clean URLs). Currently, URLs are being rewritten dynamically - * (ie. "on output"), however when these rewrite rules have been tested - * enough, we will use them to permanently rewrite the links in node - * and comment bodies. - */ -function _legacy_filter_old_urls($text) { - if (!variable_get('rewrite_old_urls', 0)) { - return $text; - } - - global $base_url; - - $end = substr($base_url, 12); - - if (variable_get('clean_url', '0') == '0') { - // Relative URLs: - - // rewrite 'node.php?id=[&cid=]' style URLs: - $text = eregi_replace("\"(node)\.php\?id=([[:digit:]]+)(&cid=)?([[:digit:]]*)", "\"?q=\\1/view/\\2/\\4", $text); - - // rewrite 'module.php?mod={&=}' style URLs: - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "\"?q=\\2/\\4/\\6" , $text); - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "\"?q=\\2/\\4", $text); - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))", "\"?q=\\2", $text); - - // Absolute URLs: - - // rewrite 'node.php?id=[&cid=]' style URLs: - $text = eregi_replace("$end/(node)\.php\?id=([[:digit:]]+)(&cid=)?([[:digit:]]*)", "$end/?q=\\1/view/\\2/\\4", $text); - - // rewrite 'module.php?mod={&=}' style URLs: - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/?q=\\2/\\4/\\6" , $text); - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/?q=\\2/\\4", $text); - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))", "\"$end/?q=\\2", $text); - } - else { - // Relative URLs: - - // Rewrite 'node.php?id=[&cid=]' style URLs: - $text = eregi_replace("\"(node)\.php\?id=([[:digit:]]+)(&cid=)?([[:digit:]]*)", "\"\\1/view/\\2/\\4", $text); - - // Rewrite 'module.php?mod={&=}' style URLs: - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "\"\\2/\\4/\\6", $text); - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "\"\\2/\\4", $text); - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))", "\"\\2", $text); - - // Absolute URLs: - - // Rewrite 'node.php?id=[&cid=]' style URLs: - $text = eregi_replace("$end/(node)\.php\?id=([[:digit:]]+)(&cid=)?([[:digit:]]*)", "$end/\\1/view/\\2/\\4", $text); - - // Rewrite 'module.php?mod={&=}' style URLs: - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/\\2/\\4/\\6", $text); - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/\\2/\\4", $text); - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/\\2", $text); - } - - return $text; -} - - -- cgit v1.2.3