diff -r 4629ad98ee88 -r 9cdfe82c56cd includes/functions.php --- a/includes/functions.php Sat Jan 03 17:54:26 2009 -0500 +++ b/includes/functions.php Sat Jan 03 18:11:18 2009 -0500 @@ -277,7 +277,7 @@ { $logged_in = true; } - return $logged_in ? getConfig('main_page_alt', getConfig('main_page')) : getConfig('main_page'); + return $logged_in && getConfig('main_page_alt_enable', '0') == '1' ? getConfig('main_page_alt', getConfig('main_page')) : getConfig('main_page'); } /** @@ -523,10 +523,10 @@ function csrf_request_confirm() { global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; + global $lang, $output; // If the token was overridden with the correct one, the user confirmed the action using this form. Continue exec. - if ( isset($_POST['cstok']) || isset($_GET ['cstok']) ) + if ( isset($_POST['cstok']) || isset($_GET['cstok']) ) { // using the if() check makes sure that the token isn't in a cookie, since $_REQUEST includes $_COOKIE. $token_check =& $_REQUEST['cstok']; @@ -537,8 +537,8 @@ } } - $template->tpl_strings['PAGE_NAME'] = htmlspecialchars($lang->get('user_csrf_confirm_title')); - $template->header(); + $output->set_title($lang->get('user_csrf_confirm_title')); + $output->header(); // initial info echo '
' . $lang->get('user_csrf_confirm_body') . '
'; @@ -564,9 +564,9 @@ // insert the right CSRF token echo ''; echo ''; - echo ''; + echo ''; - $template->footer(); + $output->footer(); exit; } @@ -638,6 +638,35 @@ } /** + * Returns the appropriate Namespace_* object for a page. + * @param string Page ID + * @param string Namespace + * @param int Revision ID + */ + +function namespace_factory($page_id, $namespace, $revision_id = 0) +{ + if ( !class_exists("Namespace_$namespace") ) + { + if ( file_exists(ENANO_ROOT . "/includes/namespaces/" . strtolower($namespace) . ".php") ) + { + require(ENANO_ROOT . "/includes/namespaces/" . strtolower($namespace) . ".php"); + } + } + if ( class_exists("Namespace_$namespace") ) + { + $class = "Namespace_$namespace"; + $ns = new $class($page_id, $namespace, $revision_id); + return $ns; + } + else + { + $ns = new Namespace_Default($page_id, $namespace, $revision_id); + return $ns; + } +} + +/** * These are some old functions that were used with the Midget codebase. They are deprecated and should not be used any more. */ @@ -683,22 +712,10 @@ } function arrayItemBottom($arr, $keyname) { - $keylist = array_keys($arr); - $keyflop = array_flip($keylist); - $idx = $keyflop[$keyname]; - $sz = sizeof($arr); $sz--; - while( $orig != $arr[$keylist[$sz]] ) { - // echo 'Keyname: '.$keylist[$idx] . ''; - print_r($arr); - echo '
'; - } - } - else - { - echo ' | ' . $lang->get('onpage_cat_msg_no_subcategories') . ' | '; - } - echo '
"; // " to workaround stupid jEdit bug - - $link = makeUrlNS($row['namespace'], sanitize_page_id($row['urlname'])); - echo 'nslist[$row['namespace']] . sanitize_page_id($row['urlname']); - if ( !isPage( $key ) ) - { - echo ' class="wikilink-nonexistent"'; - } - echo '>'; - $title = get_page_title_ns($row['urlname'], $row['namespace']); - echo htmlspecialchars($title); - echo ''; - - echo " | "; - } - if ( !$switched ) - { - if ( $counter > 0 ) - { - // Fill-in - while ( $ticker < 2 ) - { - $ticker++; - echo ''; - } - } - else - { - echo ' | ' . $lang->get('onpage_cat_msg_no_subcategories') . ' | '; - } - echo '
'; - } - } - else - { - echo ' | ' . $lang->get('onpage_cat_msg_no_pages') . ' | '; - } - echo '
' . $lang->get('onpage_filebox_msg_not_found', array('upload_link' => makeUrlNS('Special', 'UploadFile/'.$local_page_id))) . '
-' . $lang->get('onpage_filebox_lbl_type') . ' '.$r['mimetype'].'
';
-
- $size = $r['size'] . ' ' . $lang->get('etc_unit_bytes');
- if ( $r['size'] >= 1048576 )
- {
- $size .= ' (' . ( round($r['size'] / 1048576, 1) ) . ' ' . $lang->get('etc_unit_megabytes_short') . ')';
- }
- else if ( $r['size'] >= 1024 )
- {
- $size .= ' (' . ( round($r['size'] / 1024, 1) ) . ' ' . $lang->get('etc_unit_kilobytes_short') . ')';
- }
-
- echo $lang->get('onpage_filebox_lbl_size', array('size' => $size));
-
- echo '
' . $lang->get('onpage_filebox_lbl_uploaded') . ' ' . $datestring . '
- - - -
'; - } - echo '- - ' . $lang->get('onpage_filebox_btn_download') . ' - '; - if(!$paths->page_protected && ( $paths->wiki_mode || $session->get_permissions('upload_new_version') )) - { - echo ' | - ' . $lang->get('onpage_filebox_btn_upload_new') . ' - '; - } - echo '
'; - if ( $db->numrows() > 1 ) - { - // requery, sql_result_seek() doesn't work on postgres - $db->free_result(); - $q = $db->sql_query('SELECT f.mimetype,f.time_id,f.size,l.log_id FROM ' . table_prefix . "files AS f\n" - . " LEFT JOIN " . table_prefix . "logs AS l\n" - . " ON ( l.time_id = f.time_id AND ( l.action = 'reupload' OR l.action IS NULL ) )\n" - . " WHERE f.page_id = '$selfn'\n" - . " ORDER BY f.time_id DESC;"); - if ( !$q ) - $db->_die(); - - echo '';
- $last_rollback_id = false;
- while ( $r = $db->fetchrow() )
- {
- echo '(' . $lang->get('onpage_filebox_btn_this_version') . ') ';
- if ( $session->get_permissions('history_rollback') && $last_rollback_id )
- echo ' (' . $lang->get('onpage_filebox_btn_revert') . ') ';
- else if ( $session->get_permissions('history_rollback') && !$last_rollback_id )
- echo ' (' . $lang->get('onpage_filebox_btn_current') . ') ';
- $last_rollback_id = $r['log_id'];
- $mimetype = $r['mimetype'];
- $datestring = enano_date('F d, Y h:i a', (int)$r['time_id']);
-
- echo $datestring.': '.$r['mimetype'].', ';
-
- $fs = $r['size'];
- $fs = (int)$fs;
-
- if($fs >= 1048576)
- {
- $fs = round($fs / 1048576, 1);
- $size = $fs . ' ' . $lang->get('etc_unit_megabytes_short');
- }
- else
- if ( $fs >= 1024 )
- {
- $fs = round($fs / 1024, 1);
- $size = $fs . ' ' . $lang->get('etc_unit_kilobytes_short');
- }
- else
- {
- $size = $fs . ' ' . $lang->get('etc_unit_bytes');
- }
-
- echo $size;
-
- echo '
';
- }
- echo '