diff -r d52dfa1f08da -r 323c4cd1aa37 includes/functions.php --- a/includes/functions.php Mon May 04 23:07:00 2009 -0400 +++ b/includes/functions.php Tue May 05 00:10:26 2009 -0400 @@ -380,16 +380,7 @@ global $db, $session, $paths, $template, $plugins; // Common objects $idata = RenderMan::strToPageID($page_id); - $page_id_key = $paths->nslist[ $idata[1] ] . $idata[0]; - $page_id_key = sanitize_page_id($page_id_key); - $page_data = @$paths->pages[$page_id_key]; - $title = ( isset($page_data['name']) ) ? - ( ( $page_data['namespace'] == 'Article' || !$show_ns ) ? - '' : - $paths->nslist[ $idata[1] ] ) - . $page_data['name'] : - ( $show_ns ? $paths->nslist[$idata[1]] : '' ) . str_replace('_', ' ', dirtify_page_id( $idata[0] ) ); - return $title; + return get_page_title_ns($idata[0], $idata[1]); } /** @@ -402,19 +393,9 @@ function get_page_title_ns($page_id, $namespace) { global $db, $session, $paths, $template, $plugins; // Common objects - - $ns_prefix = ( isset($paths->nslist[ $namespace ]) ) ? $paths->nslist[ $namespace ] : $namespace . substr($paths->nslist['Special'], -1); - $page_id_key = $ns_prefix . $page_id; - if ( isPage($page_id_key) ) - { - $page_data = $paths->pages[$page_id_key]; - } - else - { - $page_data = array(); - } - $title = ( isset($page_data['name']) ) ? $page_data['name'] : $ns_prefix . str_replace('_', ' ', dirtify_page_id( $page_id ) ); - return $title; + + $ns = namespace_factory($page_id, $namespace); + return $ns->title; } /** @@ -578,32 +559,24 @@ * @return bool True if the page exists, false otherwise */ -function isPage($p) { +function isPage($p) +{ global $db, $session, $paths, $template, $plugins; // Common objects - - // Try the easy way first ;-) - if ( isset( $paths->pages[ $p ] ) ) - { - return true; - } - - // Special case for Special, Template, and Admin pages that can't have slashes in their URIs - $ns_test = RenderMan::strToPageID( $p ); - - if($ns_test[1] != 'Special' && $ns_test[1] != 'Template' && $ns_test[1] != 'Admin') - { - return false; - } - - $particles = explode('/', $p); - if ( isset ( $paths->pages[ $particles[ 0 ] ] ) ) - { - return true; - } - else - { - return false; - } + static $ispage_cache = array(); + if ( isset($ispage_cache[$p]) ) + return $ispage_cache[$p]; + + list($page_id, $namespace) = RenderMan::strToPageID($p); + $cdata = $paths->get_cdata($page_id, $namespace); + if ( !isset($cdata['page_exists']) ) + { + $class = ( class_exists($_ = "Namespace_$namespace") ) ? $_ : "Namespace_Default"; + $page = new $class($page_id, $namespace); + return $page->exists(); + } + + $ispage_cache[$p] = $cdata['page_exists']; + return $cdata['page_exists']; } /** @@ -615,6 +588,13 @@ function namespace_factory($page_id, $namespace, $revision_id = 0) { + global $db, $session, $paths, $template, $plugins; // Common objects + + static $objcache = array(); + $pathskey = $paths->get_pathskey($page_id, $namespace) . ":$revision_id"; + if ( isset($objcache[$pathskey]) ) + return $objcache[$pathskey]; + if ( !class_exists("Namespace_$namespace") ) { if ( file_exists(ENANO_ROOT . "/includes/namespaces/" . strtolower($namespace) . ".php") ) @@ -626,11 +606,13 @@ { $class = "Namespace_$namespace"; $ns = new $class($page_id, $namespace, $revision_id); + $objcache[$pathskey] = $ns; return $ns; } else { $ns = new Namespace_Default($page_id, $namespace, $revision_id); + $objcache[$pathskey] = $ns; return $ns; } } @@ -915,22 +897,7 @@ function display_page_headers() { - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - if($session->get_permissions('vote_reset') && $paths->cpage['delvotes'] > 0) - { - $delvote_ips = unserialize($paths->cpage['delvote_ips']); - $hr = htmlspecialchars(implode(', ', $delvote_ips['u'])); - - $string_id = ( $paths->cpage['delvotes'] == 1 ) ? 'delvote_lbl_votes_one' : 'delvote_lbl_votes_plural'; - $string = $lang->get($string_id, array('num_users' => $paths->cpage['delvotes'])); - - echo '