File rollbacks should be all up to date now.
authorDan
Wed, 15 Apr 2009 16:20:33 -0400
changeset 912 95d0d8596c87
parent 911 facff435cdaa
child 913 3ec535acd11e
File rollbacks should be all up to date now.
includes/clientside/static/enano-lib-basic.js
includes/log.php
includes/namespaces/file.php
includes/pageprocess.php
language/english/tools.json
plugins/SpecialUserFuncs.php
--- a/includes/clientside/static/enano-lib-basic.js	Wed Apr 15 14:23:48 2009 -0400
+++ b/includes/clientside/static/enano-lib-basic.js	Wed Apr 15 16:20:33 2009 -0400
@@ -565,6 +565,7 @@
   ajaxDelVote: 'ajax.js',
   ajaxProtect: 'ajax.js',
   ajaxClearLogs: 'ajax.js',
+  ajaxRollback: 'ajax.js',
   ajaxResetDelVotes: 'ajax.js',
   ajaxDeletePage: 'ajax.js',
   ajaxSetPassword: 'ajax.js',
--- a/includes/log.php	Wed Apr 15 14:23:48 2009 -0400
+++ b/includes/log.php	Wed Apr 15 16:20:33 2009 -0400
@@ -164,7 +164,7 @@
    * @return array
    */
   
-  public function get_data($offset, $page_size)
+  public function get_data($offset = 0, $page_size = 0)
   {
     global $db, $session, $paths, $session, $plugins; // Common objects
     $sql = $this->build_sql($offset, $page_size);
@@ -270,11 +270,13 @@
   /**
    * Formats a result row into pretty HTML.
    * @param array dataset from LogDisplay::get_data()
+   * @param bool If true (default), shows action buttons.
+   * @param bool If true (default), shows page title; good for integrated displays
    * @static
    * @return string
    */
   
-  public static function render_row($row)
+  public static function render_row($row, $show_buttons = true, $show_pagetitle = true)
   {
     global $db, $session, $paths, $session, $plugins; // Common objects
     global $lang;
@@ -285,52 +287,64 @@
     $pagekey = sanitize_page_id($pagekey);
     
     // diff button
-    if ( $row['action'] == 'edit' && !empty($row['parent_revid']) )
+    if ( $show_buttons )
     {
+      if ( $row['action'] == 'edit' && !empty($row['parent_revid']) )
+      {
+        $html .= '(';
+        if ( isPage($pagekey) )
+        {
+          $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], "do=diff&diff1={$row['parent_revid']}&diff2={$row['log_id']}", true) . '">';
+        }
+        $html .= $lang->get('pagetools_rc_btn_diff');
+        if ( isPage($pagekey) )
+        {
+          $html .= '</a>';
+        }
+        if ( $row['parent_revid'] > 0 && isPage($pagekey) )
+        {
+          $html .= ', <a href="' . makeUrlNS($row['namespace'], $row['page_id'], false, true) . '#do:edit;rev:' . $row['parent_revid'] . '">' . $lang->get('pagetools_rc_btn_undo') . '</a>';
+        }
+        $html .= ') ';
+      }
+      else if ( $row['action'] != 'edit' && ( isPage($pagekey) || $row['action'] == 'delete' ) )
+      {
+        $html .= '(';
+        $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], "do=rollback&id={$row['log_id']}", true). '">' . $lang->get('pagetools_rc_btn_undo') . '</a>';
+        $html .= ') ';
+      }
+      
+      // hist button
       $html .= '(';
       if ( isPage($pagekey) )
       {
-        $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], "do=diff&diff1={$row['parent_revid']}&diff2={$row['log_id']}", true) . '">';
+        $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], "do=history", true) . '">';
       }
-      $html .= $lang->get('pagetools_rc_btn_diff');
+      $html .= $lang->get('pagetools_rc_btn_hist');
       if ( isPage($pagekey) )
       {
         $html .= '</a>';
       }
-      if ( $row['parent_revid'] > 0 && isPage($pagekey) )
-      {
-        $html .= ', <a href="' . makeUrlNS($row['namespace'], $row['page_id'], false, true) . '#do:edit;rev:' . $row['parent_revid'] . '">' . $lang->get('pagetools_rc_btn_undo') . '</a>';
-      }
-      $html .= ') ';
+      $html .= ') . . ';
     }
     
-    // hist button
-    $html .= '(';
-    if ( isPage($pagekey) )
+    if ( $show_pagetitle )
     {
-      $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], "do=history", true) . '">';
-    }
-    $html .= $lang->get('pagetools_rc_btn_hist');
-    if ( isPage($pagekey) )
-    {
-      $html .= '</a>';
+      // new page?
+      if ( $row['action'] == 'edit' && empty($row['parent_revid']) )
+      {
+        $html .= '<b>N</b> ';
+      }
+      // minor edit?
+      if ( $row['action'] == 'edit' && $row['minor_edit'] )
+      {
+        $html .= '<b>m</b> ';
+      }
+      
+      // link to the page
+      $cls = ( isPage($pagekey) ) ? '' : ' class="wikilink-nonexistent"';
+      $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id']) . '"' . $cls . '>' . htmlspecialchars(get_page_title_ns($row['page_id'], $row['namespace'])) . '</a>; ';
     }
-    $html .= ') . . ';
-    
-    // new page?
-    if ( $row['action'] == 'edit' && empty($row['parent_revid']) )
-    {
-      $html .= '<b>N</b> ';
-    }
-    // minor edit?
-    if ( $row['action'] == 'edit' && $row['minor_edit'] )
-    {
-      $html .= '<b>m</b> ';
-    }
-    
-    // link to the page
-    $cls = ( isPage($pagekey) ) ? '' : ' class="wikilink-nonexistent"';
-    $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id']) . '"' . $cls . '>' . htmlspecialchars(get_page_title_ns($row['page_id'], $row['namespace'])) . '</a>; ';
     
     // date
     $today = time() - ( time() % 86400 );
@@ -395,15 +409,19 @@
         case 'unprot':
         case 'semiprot':
         case 'delete':
+        case 'reupload':
           $stringmap = array(
             'prot' => 'log_action_protect_full',
             'unprot' => 'log_action_protect_none',
             'semiprot' => 'log_action_protect_semi',
-            'delete' => 'log_action_delete'
+            'delete' => 'log_action_delete',
+            'reupload' => 'log_action_reupload'
           );
         
         if ( $row['edit_summary'] === '__REVERSION__' )
-           $reason = '<span style="color: #808080;">' . $lang->get('log_msg_reversion') . '</span>';
+          $reason = '<span style="color: #808080;">' . $lang->get('log_msg_reversion') . '</span>';
+        else if ( $row['action'] == 'reupload' && $row['edit_summary'] === '__ROLLBACK__' )
+          $reason = '<span style="color: #808080;">' . $lang->get('log_msg_file_restored') . '</span>';
         else
           $reason = ( !empty($row['edit_summary']) ) ? htmlspecialchars($row['edit_summary']) : '<span style="color: #808080;">' . $lang->get('log_msg_no_reason_provided') . '</span>';
         
--- a/includes/namespaces/file.php	Wed Apr 15 14:23:48 2009 -0400
+++ b/includes/namespaces/file.php	Wed Apr 15 16:20:33 2009 -0400
@@ -38,6 +38,8 @@
     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 = '';
@@ -128,9 +130,15 @@
       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 .= '<h3>' . $lang->get('onpage_filebox_heading_history') . '</h3><p>';
       $last_rollback_id = false;
-      while ( $r = $db->fetchrow() )
+      while ( $r = $db->fetchrow($q) )
       {
         $html .= '(<a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.'/'.$r['time_id'].htmlspecialchars(urlSeparator).'download').'">' . $lang->get('onpage_filebox_btn_this_version') . '</a>) ';
         if ( $session->get_permissions('history_rollback') && $last_rollback_id )
@@ -138,10 +146,8 @@
         else if ( $session->get_permissions('history_rollback') && !$last_rollback_id )
           $html .= ' (' . $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']);
         
-        $html .= $datestring.': '.$r['mimetype'].', ';
+        $html .= $r['mimetype'].', ';
         
         $fs = $r['size'];
         $fs = (int)$fs;
@@ -163,6 +169,8 @@
         }
         
         $html .= $size;
+        if ( isset($data[++$i]) )
+          $html .= ': ' . LogDisplay::render_row($data[$i], false, false);
         
         $html .= '<br />';
       }
--- a/includes/pageprocess.php	Wed Apr 15 14:23:48 2009 -0400
+++ b/includes/pageprocess.php	Wed Apr 15 16:20:33 2009 -0400
@@ -637,7 +637,7 @@
     {
       case 'rename':
         // Page was renamed, let the rename method handle this
-        return array_merge($this->rename($log_entry['edit_summary']), array('dateline' => $dateline, 'action' => $log_entry['action']));
+        return array_merge($this->rename_page($log_entry['edit_summary']), array('dateline' => $dateline, 'action' => $log_entry['action']));
         break;
       case 'prot':
       case 'unprot':
--- a/language/english/tools.json	Wed Apr 15 14:23:48 2009 -0400
+++ b/language/english/tools.json	Wed Apr 15 16:20:33 2009 -0400
@@ -157,6 +157,7 @@
       action_protect_none: 'Unprotected page (%reason%)',
       action_protect_semi: 'Semiprotected page (%reason%)',
       action_protect_full: 'Protected page (%reason%)',
+      action_reupload: 'Uploaded new revision: %reason%',
       action_protect: 'Protect and unprotect',
       action_edit: 'Edit',
       
@@ -167,6 +168,7 @@
       
       msg_no_reason_provided: 'No reason provided',
       msg_reversion: 'Reversion of previous action',
+      msg_file_restored: 'Restored previous version',
       msg_no_results: 'No results',
       msg_no_filters: 'All site logs',
       
--- a/plugins/SpecialUserFuncs.php	Wed Apr 15 14:23:48 2009 -0400
+++ b/plugins/SpecialUserFuncs.php	Wed Apr 15 16:20:33 2009 -0400
@@ -1882,7 +1882,7 @@
    * @return string
    */
   
-  function format_date($time)
+  public static function format_date($time)
   {
     global $lang;
     // Our formattting string to pass to enano_date()