--- a/includes/pageutils.php Tue Jan 29 17:29:08 2008 -0500
+++ b/includes/pageutils.php Tue Jan 29 23:15:44 2008 -0500
@@ -89,7 +89,7 @@
}
/**
- * Basically a frontend to RenderMan::getPage(), with the ability to send valid data for nonexistent pages
+ * DEPRECATED. Previously returned the full rendered contents of a page.
* @param $page the full page id (Namespace:Pagename)
* @param $send_headers true if the theme headers should be sent (still dependent on current page settings), false otherwise
* @return string
@@ -98,226 +98,6 @@
public static function getpage($page, $send_headers = false, $hist_id = false)
{
die('PageUtils->getpage is deprecated.');
- global $db, $session, $paths, $template, $plugins; // Common objects
- ob_start();
- $pid = RenderMan::strToPageID($page);
- //die('<pre>'.print_r($pid, true).'</pre>');
- if(isset($paths->pages[$page]['password']) && strlen($paths->pages[$page]['password']) == 40)
- {
- password_prompt($page);
- }
- if(isset($paths->pages[$page]))
- {
- doStats($pid[0], $pid[1]);
- }
- if($paths->custom_page || $pid[1] == 'Special')
- {
- // If we don't have access to the page, get out and quick!
- if(!$session->get_permissions('read') && $pid[0] != 'Login' && $pid[0] != 'Register')
- {
- $template->tpl_strings['PAGE_NAME'] = 'Access denied';
-
- if ( $send_headers )
- {
- $template->header();
- }
-
- echo '<div class="error-box"><b>Access to this page is denied.</b><br />This may be because you are not logged in or you have not met certain criteria for viewing this page.</div>';
-
- if ( $send_headers )
- {
- $template->footer();
- }
-
- $r = ob_get_contents();
- ob_end_clean();
- return $r;
- }
-
- $fname = 'page_' . $pid[1] . '_' . $paths->pages[$page]['urlname_nons'];
- @call_user_func($fname);
-
- }
- else if ( $pid[1] == 'Admin' )
- {
- // If we don't have access to the page, get out and quick!
- if(!$session->get_permissions('read'))
- {
- $template->tpl_strings['PAGE_NAME'] = 'Access denied';
- if ( $send_headers )
- {
- $template->header();
- }
- echo '<div class="error-box"><b>Access to this page is denied.</b><br />This may be because you are not logged in or you have not met certain criteria for viewing this page.</div>';
- if ( $send_headers )
- {
- $template->footer();
- }
- $r = ob_get_contents();
- ob_end_clean();
- return $r;
- }
-
- $fname = 'page_' . $pid[1] . '_' . $pid[0];
- if ( !function_exists($fname) )
- {
- $title = 'Page backend not found';
- $message = "The administration page you are looking for was properly registered using the page API, but the backend function
- (<tt>$fname</tt>) was not found. If this is a plugin page, then this is almost certainly a bug with the plugin.";
- if ( $send_headers )
- {
- die_friendly($title, "<p>$message</p>");
- }
- else
- {
- echo "<h2>$title</h2>\n<p>$message</p>";
- }
- }
- @call_user_func($fname);
- }
- else if ( !isset( $paths->pages[$page] ) )
- {
- ob_start();
- $code = $plugins->setHook('page_not_found');
- foreach ( $code as $cmd )
- {
- eval($cmd);
- }
- $text = ob_get_contents();
- if ( $text != '' )
- {
- ob_end_clean();
- return $text;
- }
- $template->header();
- if($m = $paths->sysmsg('Page_not_found'))
- {
- eval('?>'.RenderMan::render($m));
- }
- else
- {
- header('HTTP/1.1 404 Not Found');
- echo '<h3>There is no page with this title yet.</h3>
- <p>You have requested a page that doesn\'t exist yet.';
- if($session->get_permissions('create_page')) echo ' You can <a href="'.makeUrl($paths->page, 'do=edit', true).'" onclick="ajaxEditor(); return false;">create this page</a>, or return to the <a href="'.makeUrl(getConfig('main_page')).'">homepage</a>.';
- else echo ' Return to the <a href="'.makeUrl(getConfig('main_page')).'">homepage</a>.</p>';
- if ( $session->get_permissions('history_rollback') )
- {
- $e = $db->sql_query('SELECT * FROM ' . table_prefix.'logs WHERE action=\'delete\' AND page_id=\'' . $paths->page_id . '\' AND namespace=\'' . $pid[1] . '\' ORDER BY time_id DESC;');
- if ( !$e )
- {
- $db->_die('The deletion log could not be selected.');
- }
- if ($db->numrows() > 0 )
- {
- $r = $db->fetchrow();
- echo '<p>This page also appears to have some log entries in the database - it seems that it was deleted on ' . enano_date('d M Y h:i a', intval($r['time_id'])) . '. You can probably <a href="'.makeUrl($paths->page, 'do=rollback&id=' . $r['time_id']) . '" onclick="ajaxRollback(\'' . $r['time_id'] . '\'); return false;">roll back</a> the deletion.</p>';
- }
- $db->free_result();
- }
- echo '<p>
- HTTP Error: 404 Not Found
- </p>';
- }
- $template->footer();
- }
- else
- {
-
- // If we don't have access to the page, get out and quick!
- if(!$session->get_permissions('read'))
- {
- $template->tpl_strings['PAGE_NAME'] = 'Access denied';
- if($send_headers) $template->header();
- echo '<div class="error-box"><b>Access to this page is denied.</b><br />This may be because you are not logged in or you have not met certain criteria for viewing this page.</div>';
- if($send_headers) $template->footer();
- $r = ob_get_contents();
- ob_end_clean();
- return $r;
- }
-
- ob_start();
- $code = $plugins->setHook('page_custom_handler');
- foreach ( $code as $cmd )
- {
- eval($cmd);
- }
- $text = ob_get_contents();
- if ( $text != '' )
- {
- ob_end_clean();
- return $text;
- }
-
- if ( $hist_id )
- {
- $e = $db->sql_query('SELECT page_text,date_string,char_tag FROM ' . table_prefix.'logs WHERE page_id=\'' . $paths->pages[$page]['urlname_nons'] . '\' AND namespace=\'' . $pid[1] . '\' AND log_type=\'page\' AND action=\'edit\' AND time_id=' . $db->escape($hist_id) . '');
- if($db->numrows() < 1)
- {
- $db->_die('There were no rows in the text table that matched the page text query.');
- }
- $r = $db->fetchrow();
- $db->free_result();
- $message = '<div class="info-box" style="margin-left: 0; margin-top: 5px;"><b>Notice:</b><br />The page you are viewing was archived on ' . enano_date('d M Y h:i a', intval($r['time_id'])) . '.<br /><a href="'.makeUrl($page).'" onclick="ajaxReset(); return false;">View current version</a> | <a href="'.makeUrl($page, 'do=rollback&id=' . $hist_id) . '" onclick="ajaxRollback(\'' . $hist_id . '\')">Restore this version</a></div><br />'.RenderMan::render($r['page_text']);
-
- if( !$paths->pages[$page]['special'] )
- {
- if($send_headers)
- {
- $template->header();
- }
- display_page_headers();
- }
-
- eval('?>' . $message);
-
- if( !$paths->pages[$page]['special'] )
- {
- display_page_footers();
- if($send_headers)
- {
- $template->footer();
- }
- }
-
- } else {
- if(!$paths->pages[$page]['special'])
- {
- $message = RenderMan::getPage($paths->pages[$page]['urlname_nons'], $pid[1]);
- }
- else
- {
- $message = RenderMan::getPage($paths->pages[$page]['urlname_nons'], $pid[1], 0, false, false, false, false);
- }
- // This line is used to debug wikiformatted code
- // die('<pre>'.htmlspecialchars($message).'</pre>');
-
- if( !$paths->pages[$page]['special'] )
- {
- if($send_headers)
- {
- $template->header();
- }
- display_page_headers();
- }
-
- // This is it, this is what all of Enano has been working up to...
-
- eval('?>' . $message);
-
- if( !$paths->pages[$page]['special'] )
- {
- display_page_footers();
- if($send_headers)
- {
- $template->footer();
- }
- }
- }
- }
- $ret = ob_get_contents();
- ob_end_clean();
- return $ret;
}
/**