diff -r de56132c008d -r bdac73ed481e includes/namespaces/file.php --- a/includes/namespaces/file.php Sun Mar 28 21:49:26 2010 -0400 +++ b/includes/namespaces/file.php Sun Mar 28 23:10:46 2010 -0400 @@ -13,255 +13,255 @@ class Namespace_File extends Namespace_Default { - function send() - { - global $output; - - $output->add_before_footer($this->show_info()); - $output->add_before_footer($this->display_categories()); - - if ( $this->exists ) - { - $this->send_from_db(); - } - else - { - $output->header(); - $this->error_404(); - $output->footer(); - } - } - - function show_info() - { - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - - require_once(ENANO_ROOT . '/includes/log.php'); - - $local_page_id = $this->page_id; - $local_namespace = $this->namespace; - $html = ''; - - // Prevent unnecessary work - if ( $local_namespace != 'File' ) - return null; - - $selfn = $db->escape($this->page_id); - $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('The file type could not be fetched.'); - } - - if ( $db->numrows() < 1 ) - { - $html .= '
' . $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') . ')';
- }
-
- $html .= $lang->get('onpage_filebox_lbl_size', array('size' => $size));
-
- $html .= '
' . $lang->get('onpage_filebox_lbl_uploaded') . ' ' . $datestring . '
- - - -
'; - } - $html .= '- - ' . $lang->get('onpage_filebox_btn_download') . ' - '; - // allow reupload if: - // * we are allowed to upload new versions, and - // - the file is unprotected, or - // - we have permission to override protection - - if ( !$this->perms ) - $this->perms = $session->fetch_page_acl($this->page_id, $this->namespace); - - if ( $this->perms->get_permissions('upload_new_version') && ( !$this->page_protected || $this->perms->get_permissions('even_when_protected') ) ) - { - // upload new version link - $html .= ' | - ' . $lang->get('onpage_filebox_btn_upload_new') . ' - '; - } - // close off paragraph - $html .= '
'; - // only show this if there's more than one revision - 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(); - - $log = new LogDisplay(); - $log->add_criterion('page', $paths->nslist['File'] . $this->page_id); - $log->add_criterion('action', 'reupload'); - $data = $log->get_data(); - $i = -1; - - $html .= '';
- $last_rollback_id = false;
- $download_flag = $is_image ? false : 'download';
- while ( $r = $db->fetchrow($q) )
- {
- $html .= '(' . $lang->get('onpage_filebox_btn_this_version') . ') ';
- if ( $session->get_permissions('history_rollback') && $last_rollback_id )
- $html .= ' (' . $lang->get('onpage_filebox_btn_revert') . ') ';
- else if ( $session->get_permissions('history_rollback') && !$last_rollback_id )
- $html .= ' (' . $lang->get('onpage_filebox_btn_current') . ') ';
- $last_rollback_id = $r['log_id'];
-
- $html .= $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');
- }
-
- $html .= $size;
- if ( isset($data[++$i]) )
- $html .= ': ' . LogDisplay::render_row($data[$i], false, false);
-
- $html .= '
';
- }
- $html .= '
' . $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') . ')';
+ }
+
+ $html .= $lang->get('onpage_filebox_lbl_size', array('size' => $size));
+
+ $html .= '
' . $lang->get('onpage_filebox_lbl_uploaded') . ' ' . $datestring . '
+ + + +
'; + } + $html .= '+ + ' . $lang->get('onpage_filebox_btn_download') . ' + '; + // allow reupload if: + // * we are allowed to upload new versions, and + // - the file is unprotected, or + // - we have permission to override protection + + if ( !$this->perms ) + $this->perms = $session->fetch_page_acl($this->page_id, $this->namespace); + + if ( $this->perms->get_permissions('upload_new_version') && ( !$this->page_protected || $this->perms->get_permissions('even_when_protected') ) ) + { + // upload new version link + $html .= ' | + ' . $lang->get('onpage_filebox_btn_upload_new') . ' + '; + } + // close off paragraph + $html .= '
'; + // only show this if there's more than one revision + 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(); + + $log = new LogDisplay(); + $log->add_criterion('page', $paths->nslist['File'] . $this->page_id); + $log->add_criterion('action', 'reupload'); + $data = $log->get_data(); + $i = -1; + + $html .= '';
+ $last_rollback_id = false;
+ $download_flag = $is_image ? false : 'download';
+ while ( $r = $db->fetchrow($q) )
+ {
+ $html .= '(' . $lang->get('onpage_filebox_btn_this_version') . ') ';
+ if ( $session->get_permissions('history_rollback') && $last_rollback_id )
+ $html .= ' (' . $lang->get('onpage_filebox_btn_revert') . ') ';
+ else if ( $session->get_permissions('history_rollback') && !$last_rollback_id )
+ $html .= ' (' . $lang->get('onpage_filebox_btn_current') . ') ';
+ $last_rollback_id = $r['log_id'];
+
+ $html .= $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');
+ }
+
+ $html .= $size;
+ if ( isset($data[++$i]) )
+ $html .= ': ' . LogDisplay::render_row($data[$i], false, false);
+
+ $html .= '
';
+ }
+ $html .= '
' . $lang->get('onpage_filebox_heading') . '
-' . $lang->get('onpage_filebox_msg_not_found', array('upload_link' => makeUrlNS('Special', 'UploadFile/'.$local_page_id))) . '
-