Fixed some bugs with history viewing and log display (wrong row counts, failing to provide result resource, etc.); added "view" button to edits in log display; fixed underscores in auto generated titles
authorDan
Fri, 15 May 2009 14:03:54 -0400
changeset 980 d13fad911955
parent 979 aafb9f6806c9
child 981 888502d761b4
Fixed some bugs with history viewing and log display (wrong row counts, failing to provide result resource, etc.); added "view" button to edits in log display; fixed underscores in auto generated titles
includes/log.php
includes/namespaces/default.php
includes/pageutils.php
language/english/tools.json
plugins/SpecialLog.php
--- a/includes/log.php	Fri May 15 13:31:12 2009 -0400
+++ b/includes/log.php	Fri May 15 14:03:54 2009 -0400
@@ -53,6 +53,9 @@
       case 'action':
         $this->criteria[] = array($criterion, $value);
         break;
+      case 'minor':
+        $this->criteria[] = array($criterion, intval($value));
+        break;
       case 'within':
         if ( is_int($value) )
         {
@@ -134,6 +137,12 @@
           $threshold = time() - $value;
           $where_extra .= "\n    AND time_id > $threshold";
           break;
+        case 'minor':
+          if ( $value == 1 )
+            $where_extra .= "\n    AND ( minor_edit = 1 OR action != 'edit' )";
+          else
+            $where_extra .= "\n    AND minor_edit != 1";
+          break;
       }
     }
     if ( !empty($where_bits['user']) )
@@ -155,7 +164,7 @@
     $columns = ( $just_page_count ) ? 'COUNT(*)' : 'log_id, action, page_id, namespace, CHAR_LENGTH(page_text) AS revision_size, author, time_id, edit_summary, minor_edit';
     $sql = 'SELECT ' . $columns . ' FROM ' . table_prefix . "logs AS l\n"
          . "  WHERE log_type = 'page' AND is_draft != 1$where_extra\n"
-         . "  GROUP BY log_id, action, page_id, namespace, page_text, author, time_id, edit_summary, minor_edit"
+         . ( $just_page_count ? '' : "  GROUP BY log_id, action, page_id, namespace, page_text, author, time_id, edit_summary, minor_edit\n" )
          . "  ORDER BY time_id DESC $limit;";
     
     return $sql;
@@ -296,15 +305,24 @@
       if ( $row['action'] == 'edit' && !empty($row['parent_revid']) )
       {
         $html .= '(';
-        if ( isPage($pagekey) )
-        {
+        $ispage = isPage($pagekey);
+        
+        if ( $ispage )
           $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) )
-        {
+        
+        if ( $ispage )
           $html .= '</a>';
-        }
+        
+        if ( $ispage )
+          $html .= ', <a href="' . makeUrlNS($row['namespace'], $row['page_id'], "oldid={$row['log_id']}", true) . '">';
+        
+        $html .= $lang->get('pagetools_rc_btn_view');
+        
+        if ( $ispage )
+          $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>';
--- a/includes/namespaces/default.php	Fri May 15 13:31:12 2009 -0400
+++ b/includes/namespaces/default.php	Fri May 15 14:03:54 2009 -0400
@@ -143,6 +143,7 @@
     $this->exists = false;
     $ns_char = substr($paths->nslist['Special'], -1);
     $page_name = $this->namespace == 'Article' ? dirtify_page_id($this->page_id) : "{$this->namespace}{$ns_char}" . dirtify_page_id($this->page_id);
+    $page_name = str_replace('_', ' ', $page_name);
     $this->title = $page_name;
     
     $this->cdata = array(
--- a/includes/pageutils.php	Fri May 15 13:31:12 2009 -0400
+++ b/includes/pageutils.php	Fri May 15 14:03:54 2009 -0400
@@ -271,7 +271,9 @@
     $prot = ( ( $cdata['protected'] == 2 && $session->user_logged_in && $session->reg_time + 60*60*24*4 < time() ) || $cdata['protected'] == 1) ? true : false;
     
     $q = 'SELECT log_id,time_id,date_string,page_id,namespace,author,edit_summary,minor_edit FROM ' . table_prefix.'logs WHERE log_type=\'page\' AND action=\'edit\' AND page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\' AND is_draft != 1 ORDER BY time_id DESC;';
-    if(!$db->sql_query($q)) $db->_die('The history data for the page "' . $paths->cpage['name'] . '" could not be selected.');
+    if ( !($q = $db->sql_query($q)) )
+      $db->_die('The history data for the page "' . $paths->cpage['name'] . '" could not be selected.');
+    
     echo $lang->get('history_page_subtitle') . '
           <h3>' . $lang->get('history_heading_edits') . '</h3>';
     $numrows = $db->numrows();
@@ -300,7 +302,7 @@
       $cls = 'row2';
       $ticker = 0;
       
-      while ( $r = $db->fetchrow() )
+      while ( $r = $db->fetchrow($q) )
       {
         
         $ticker++;
--- a/language/english/tools.json	Fri May 15 13:31:12 2009 -0400
+++ b/language/english/tools.json	Fri May 15 14:03:54 2009 -0400
@@ -147,6 +147,7 @@
       rc_btn_diff: 'diff',
       rc_btn_hist: 'hist',
       rc_btn_undo: 'undo',
+      rc_btn_view: 'view',
       rc_btn_pm: 'PM',
       rc_btn_usertalk: 'comment',
     },
--- a/plugins/SpecialLog.php	Fri May 15 13:31:12 2009 -0400
+++ b/plugins/SpecialLog.php	Fri May 15 14:03:54 2009 -0400
@@ -148,8 +148,10 @@
   }
   
   $page--;
-  $rowcount = $log->get_row_count();  
-  $result_url = makeUrlNS('Special', 'Log/' . rtrim(preg_replace('|/?resultpage=([0-9]+)/?|', '/', $paths->getAllParams()), '/') . '/resultpage=%s', false, true);
+  $rowcount = $log->get_row_count();
+  $paramsbit = rtrim(preg_replace('|/?resultpage=([0-9]+)/?|', '/', $paths->getAllParams()), '/');
+  $paramsbit = ( !empty($paramsbit) ) ? "/$paramsbit" : '';
+  $result_url = makeUrlNS('Special', 'Log' . $paramsbit . '/resultpage=%s', false, true);
   $paginator = generate_paginator($page, ceil($rowcount / $pagesize), $result_url);
   
   $dataset = $log->get_data($page * $pagesize, $pagesize);