diff -r e9708657875a -r 9dc4fded30e6 includes/pageprocess.php --- a/includes/pageprocess.php Tue Jul 10 12:31:12 2007 -0400 +++ b/includes/pageprocess.php Wed Jul 11 13:00:19 2007 -0400 @@ -32,6 +32,20 @@ var $namespace; /** + * The title of the page sent to the template parser + * @var string + */ + + var $title = ''; + + /** + * The information about the page(s) we were redirected from + * @var array + */ + + var $redirect_stack = array(); + + /** * The revision ID (history entry) to send. If set to 0 (the default) then the most recent revision will be sent. * @var int */ @@ -231,7 +245,6 @@ if ( empty($ob) ) { - die('ob is empty'); $this->err_page_not_existent(); } else @@ -257,7 +270,30 @@ } else { - $this->render( (!$strict_no_headers) ); + $redirect = ( isset($_GET['redirect']) ) ? $_GET['redirect'] : 'YES YOU IDIOT'; + if ( preg_match('/^#redirect \[\[([^\]]+)\]\]/i', $text, $match) && $redirect != 'no' ) + { + // Redirect page! + $page_to = sanitize_page_id($match[1]); + $page_id_data = RenderMan::strToPageID($page_to); + if ( count($this->redirect_stack) >= 3 ) + { + $this->render( (!$strict_no_headers), '
' ); + } + else + { + $result = $this->_handle_redirect($page_id_data[0], $page_id_data[1]); + if ( $result !== true ) + { + // There was some error during the redirect process - usually an infinite redirect + $this->render( (!$strict_no_headers), ' ' ); + } + } + } + else + { + $this->render( (!$strict_no_headers) ); + } } } } @@ -320,6 +356,8 @@ } + $this->title = get_page_title_ns($this->page_id, $this->namespace); + } /** @@ -327,13 +365,79 @@ * @access private */ - function render($incl_inner_headers = true) + function render($incl_inner_headers = true, $_errormsg = false) { + global $db, $session, $paths, $template, $plugins; // Common objects + $text = $this->fetch_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_id_key = $paths->nslist[ $oldtarget[1] ] . $oldtarget[0]; + $page_data = $paths->pages[$page_id_key]; + $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 = '+ + | +
+ This page is a redirector. + This means that this page will not show its own content by default. Instead it will display the contents of the page it redirects to. + To create a redirect page, make the first characters in the page content #redirect [[Page_ID]]. For more information, see the + Enano Wiki formatting guide. + This page redirects to ' . $a . '. + |
+