diff -r ceeecb160aec -r b572ce1114f1 includes/namespaces/default.php --- a/includes/namespaces/default.php Sun May 10 14:47:14 2009 -0400 +++ b/includes/namespaces/default.php Sun May 10 15:52:53 2009 -0400 @@ -324,6 +324,25 @@ } } } + + /** + * Get a redirect, if there is one. + * @return mixed Array: Page ID and namespace, associative; bool: false (no redirect) + */ + + public function get_redirect() + { + $text = $this->fetch_text(); + if ( preg_match('/^#redirect \[\[([^\]]+?)\]\]/i', $text, $match ) ) + { + list($page_id, $namespace) = RenderMan::strToPageID($match[1]); + return array( + 'page_id' => $page_id, + 'namespace' => $namespace + ); + } + return false; + } /** * The "real" send-the-page function. The reason for this is so other namespaces can re-use the code @@ -342,44 +361,7 @@ $text = preg_replace('/([\s]*)__NOBREADCRUMBS__([\s]*)/', '', $text); $text = preg_replace('/([\s]*)__NOTOC__([\s]*)/', '', $text); - - $redir_enabled = false; - if ( preg_match('/^#redirect \[\[([^\]]+?)\]\]/i', $text, $match ) ) - { - $redir_enabled = true; - - $oldtarget = RenderMan::strToPageID($match[1]); - $oldtarget[0] = sanitize_page_id($oldtarget[0]); - - $url = makeUrlNS($oldtarget[1], $oldtarget[0], false, true); - $page_data = $paths->get_cdata($oldtarget[0], $oldtarget[1]); - $title = ( isset($page_data['name']) ) ? $page_data['name'] : $paths->nslist[$oldtarget[1]] . htmlspecialchars( str_replace('_', ' ', dirtify_page_id( $oldtarget[0] ) ) ); - if ( !isset($page_data['name']) ) - { - $cls = 'class="wikilink-nonexistent"'; - } - else - { - $cls = ''; - } - $a = '' . $title . ''; - $redir_html = '
- - - - - -
- Cute wet-floor icon - - ' . $lang->get('page_msg_this_is_a_redirector', array( 'redirect_target' => $a )) . ' -
-
-
-
'; - $text = str_replace($match[0], '', $text); - $text = trim($text); - } + $text = preg_replace('/^#redirect \[\[.+?\]\]\s*/i', '', $text); if ( $send_headers ) { @@ -433,11 +415,6 @@ $page_format = $this->cdata['page_format']; } - if ( $redir_enabled ) - { - echo $redir_html; - } - $code = $plugins->setHook('pageprocess_render_head'); foreach ( $code as $cmd ) {