diff -r 402adf8ea719 -r 72818d2bf336 includes/functions.php --- a/includes/functions.php Mon Jul 28 13:05:41 2008 -0600 +++ b/includes/functions.php Mon Jul 28 13:06:36 2008 -0600 @@ -76,41 +76,44 @@ * @return string */ -function makeUrl($t, $query = false, $escape = false) +if ( !function_exists('makeUrl') ) { - global $db, $session, $paths, $template, $plugins; // Common objects - $flags = ''; - $sep = urlSeparator; - $t = sanitize_page_id($t); - if ( isset($_GET['printable'] ) ) - { - $flags .= $sep . 'printable=yes'; - $sep = '&'; - } - if ( isset($_GET['theme'] ) ) - { - $flags .= $sep . 'theme='.$session->theme; - $sep = '&'; - } - if ( isset($_GET['style'] ) ) + function makeUrl($t, $query = false, $escape = false) { - $flags .= $sep . 'style='.$session->style; - $sep = '&'; - } - if ( isset($_GET['lang']) && preg_match('/^[a-z0-9_]+$/', @$_GET['lang']) ) - { - $flags .= $sep . 'lang=' . urlencode($_GET['lang']); - $sep = '&'; + global $db, $session, $paths, $template, $plugins; // Common objects + $flags = ''; + $sep = urlSeparator; + $t = sanitize_page_id($t); + if ( isset($_GET['printable'] ) ) + { + $flags .= $sep . 'printable=yes'; + $sep = '&'; + } + if ( isset($_GET['theme'] ) ) + { + $flags .= $sep . 'theme='.$session->theme; + $sep = '&'; + } + if ( isset($_GET['style'] ) ) + { + $flags .= $sep . 'style='.$session->style; + $sep = '&'; + } + if ( isset($_GET['lang']) && preg_match('/^[a-z0-9_]+$/', @$_GET['lang']) ) + { + $flags .= $sep . 'lang=' . urlencode($_GET['lang']); + $sep = '&'; + } + + $url = $session->append_sid(contentPath.$t.$flags); + if($query) + { + $sep = strstr($url, '?') ? '&' : '?'; + $url = $url . $sep . $query; + } + + return ($escape) ? htmlspecialchars($url) : $url; } - - $url = $session->append_sid(contentPath.$t.$flags); - if($query) - { - $sep = strstr($url, '?') ? '&' : '?'; - $url = $url . $sep . $query; - } - - return ($escape) ? htmlspecialchars($url) : $url; } /** @@ -122,71 +125,74 @@ * @return string */ -function makeUrlNS($n, $t, $query = false, $escape = false) +if ( !function_exists('makeUrlNS') ) { - global $db, $session, $paths, $template, $plugins; // Common objects - $flags = ''; - - if(defined('ENANO_BASE_CLASSES_INITIALIZED')) - { - $sep = urlSeparator; - } - else - { - $sep = (strstr($_SERVER['REQUEST_URI'], '?')) ? '&' : '?'; - } - if ( isset( $_GET['printable'] ) ) { - $flags .= $sep . 'printable'; - $sep = '&'; - } - if ( isset( $_GET['theme'] ) ) - { - $flags .= $sep . 'theme='.$session->theme; - $sep = '&'; - } - if ( isset( $_GET['style'] ) ) + function makeUrlNS($n, $t, $query = false, $escape = false) { - $flags .= $sep . 'style='.$session->style; - $sep = '&'; - } - if ( isset($_GET['lang']) && preg_match('/^[a-z0-9_]+$/', @$_GET['lang']) ) - { - $flags .= $sep . 'lang=' . urlencode($_GET['lang']); - $sep = '&'; - } + global $db, $session, $paths, $template, $plugins; // Common objects + $flags = ''; - $ns_prefix = "$n:"; - - if(defined('ENANO_BASE_CLASSES_INITIALIZED')) - { - $ns_prefix = ( isset($paths->nslist[$n]) ) ? $paths->nslist[$n] : $n . substr($paths->nslist['Special'], -1); - $url = contentPath . $ns_prefix . $t . $flags; - } - else - { - // If the path manager hasn't been initted yet, take an educated guess at what the URI should be - $url = contentPath . $n . ':' . $t . $flags; - } - - if($query) - { - if(strstr($url, '?')) + if(defined('ENANO_BASE_CLASSES_INITIALIZED')) { - $sep = '&'; + $sep = urlSeparator; } else { - $sep = '?'; + $sep = (strstr($_SERVER['REQUEST_URI'], '?')) ? '&' : '?'; + } + if ( isset( $_GET['printable'] ) ) { + $flags .= $sep . 'printable'; + $sep = '&'; + } + if ( isset( $_GET['theme'] ) ) + { + $flags .= $sep . 'theme='.$session->theme; + $sep = '&'; + } + if ( isset( $_GET['style'] ) ) + { + $flags .= $sep . 'style='.$session->style; + $sep = '&'; + } + if ( isset($_GET['lang']) && preg_match('/^[a-z0-9_]+$/', @$_GET['lang']) ) + { + $flags .= $sep . 'lang=' . urlencode($_GET['lang']); + $sep = '&'; } - $url = $url . $sep . $query . $flags; + + $ns_prefix = "$n:"; + + if(defined('ENANO_BASE_CLASSES_INITIALIZED')) + { + $ns_prefix = ( isset($paths->nslist[$n]) ) ? $paths->nslist[$n] : $n . substr($paths->nslist['Special'], -1); + $url = contentPath . $ns_prefix . $t . $flags; + } + else + { + // If the path manager hasn't been initted yet, take an educated guess at what the URI should be + $url = contentPath . $n . ':' . $t . $flags; + } + + if($query) + { + if(strstr($url, '?')) + { + $sep = '&'; + } + else + { + $sep = '?'; + } + $url = $url . $sep . $query . $flags; + } + + if(defined('ENANO_BASE_CLASSES_INITIALIZED')) + { + $url = $session->append_sid($url); + } + + return ($escape) ? htmlspecialchars($url) : $url; } - - if(defined('ENANO_BASE_CLASSES_INITIALIZED')) - { - $url = $session->append_sid($url); - } - - return ($escape) ? htmlspecialchars($url) : $url; } /** @@ -949,19 +955,28 @@ * Prints out the file information box seen on File: pages. Doesn't take or return anything, but assumes that the page information is already set in $paths, and expects $paths->namespace to be File. */ -function show_file_info() +function show_file_info($page = false) { global $db, $session, $paths, $template, $plugins; // Common objects global $lang; + $local_page_id = $paths->page_id; + $local_namespace = $paths->namespace; + + if ( is_object($page) ) + { + $local_page = $page->page_id; + $local_namespace = $page->namespace; + } + // Prevent unnecessary work - if ( $paths->namespace != 'File' ) + if ( $local_namespace != 'File' ) return null; - $selfn = $paths->page_id; + $selfn = $local_page_id; if ( substr($paths->cpage['name'], 0, strlen($paths->nslist['File'])) == $paths->nslist['File']) { - $selfn = substr($paths->page_id, strlen($paths->nslist['File']), strlen($paths->page_id)); + $selfn = substr($local_page_id, strlen($paths->nslist['File']), strlen($local_page_id)); } $selfn = $db->escape($selfn); $q = $db->sql_query('SELECT f.mimetype,f.time_id,f.size,l.log_id FROM ' . table_prefix . "files AS f\n" @@ -978,7 +993,7 @@ { echo '
' . $lang->get('onpage_filebox_heading') . '
-' . $lang->get('onpage_filebox_msg_not_found', array('upload_link' => makeUrlNS('Special', 'UploadFile/'.$paths->page_id))) . '
+' . $lang->get('onpage_filebox_msg_not_found', array('upload_link' => makeUrlNS('Special', 'UploadFile/'.$local_page_id))) . '