322 $this->error_404(); |
322 $this->error_404(); |
323 $output->footer(); |
323 $output->footer(); |
324 } |
324 } |
325 } |
325 } |
326 } |
326 } |
|
327 |
|
328 /** |
|
329 * Get a redirect, if there is one. |
|
330 * @return mixed Array: Page ID and namespace, associative; bool: false (no redirect) |
|
331 */ |
|
332 |
|
333 public function get_redirect() |
|
334 { |
|
335 $text = $this->fetch_text(); |
|
336 if ( preg_match('/^#redirect \[\[([^\]]+?)\]\]/i', $text, $match ) ) |
|
337 { |
|
338 list($page_id, $namespace) = RenderMan::strToPageID($match[1]); |
|
339 return array( |
|
340 'page_id' => $page_id, |
|
341 'namespace' => $namespace |
|
342 ); |
|
343 } |
|
344 return false; |
|
345 } |
327 |
346 |
328 /** |
347 /** |
329 * The "real" send-the-page function. The reason for this is so other namespaces can re-use the code |
348 * The "real" send-the-page function. The reason for this is so other namespaces can re-use the code |
330 * to fetch the page from the DB while being able to install their own wrappers. |
349 * to fetch the page from the DB while being able to install their own wrappers. |
331 */ |
350 */ |
340 |
359 |
341 profiler_log("Namespace [$this->namespace, $this->page_id]: pulled text from DB"); |
360 profiler_log("Namespace [$this->namespace, $this->page_id]: pulled text from DB"); |
342 |
361 |
343 $text = preg_replace('/([\s]*)__NOBREADCRUMBS__([\s]*)/', '', $text); |
362 $text = preg_replace('/([\s]*)__NOBREADCRUMBS__([\s]*)/', '', $text); |
344 $text = preg_replace('/([\s]*)__NOTOC__([\s]*)/', '', $text); |
363 $text = preg_replace('/([\s]*)__NOTOC__([\s]*)/', '', $text); |
345 |
364 $text = preg_replace('/^#redirect \[\[.+?\]\]\s*/i', '', $text); |
346 $redir_enabled = false; |
|
347 if ( preg_match('/^#redirect \[\[([^\]]+?)\]\]/i', $text, $match ) ) |
|
348 { |
|
349 $redir_enabled = true; |
|
350 |
|
351 $oldtarget = RenderMan::strToPageID($match[1]); |
|
352 $oldtarget[0] = sanitize_page_id($oldtarget[0]); |
|
353 |
|
354 $url = makeUrlNS($oldtarget[1], $oldtarget[0], false, true); |
|
355 $page_data = $paths->get_cdata($oldtarget[0], $oldtarget[1]); |
|
356 $title = ( isset($page_data['name']) ) ? $page_data['name'] : $paths->nslist[$oldtarget[1]] . htmlspecialchars( str_replace('_', ' ', dirtify_page_id( $oldtarget[0] ) ) ); |
|
357 if ( !isset($page_data['name']) ) |
|
358 { |
|
359 $cls = 'class="wikilink-nonexistent"'; |
|
360 } |
|
361 else |
|
362 { |
|
363 $cls = ''; |
|
364 } |
|
365 $a = '<a ' . $cls . ' href="' . $url . '">' . $title . '</a>'; |
|
366 $redir_html = '<br /><div class="mdg-infobox"> |
|
367 <table border="0" width="100%" cellspacing="0" cellpadding="0"> |
|
368 <tr> |
|
369 <td valign="top"> |
|
370 <img alt="Cute wet-floor icon" src="'.scriptPath.'/images/redirector.png" /> |
|
371 </td> |
|
372 <td valign="top" style="padding-left: 10px;"> |
|
373 ' . $lang->get('page_msg_this_is_a_redirector', array( 'redirect_target' => $a )) . ' |
|
374 </td> |
|
375 </tr> |
|
376 </table> |
|
377 </div> |
|
378 <br /> |
|
379 <hr style="margin-left: 1em; width: 200px;" />'; |
|
380 $text = str_replace($match[0], '', $text); |
|
381 $text = trim($text); |
|
382 } |
|
383 |
365 |
384 if ( $send_headers ) |
366 if ( $send_headers ) |
385 { |
367 { |
386 $output->set_title($this->title); |
368 $output->set_title($this->title); |
387 $output->header(); |
369 $output->header(); |