includes/log.php
author Dan
Fri, 18 Dec 2009 21:21:59 -0500
changeset 1183 15957df91ea4
parent 1175 1e2c9819ede3
child 1212 db2edac4e5a7
permissions -rw-r--r--
OK screw that, put the crypto backend check in functions.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
     1
<?php
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
     2
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
     3
/*
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
1081
745200a9cc2a Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents: 980
diff changeset
     5
 * Copyright (C) 2006-2009 Dan Fuhry
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
     6
 * log.php - Logs table parsing and displaying
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
     7
 *
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
     8
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
     9
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    10
 *
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    13
 */
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    14
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    15
/**
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    16
 * Front-end for showing page revisions and actions in the logs table.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    17
 * @package Enano
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    18
 * @subpackage Frontend
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    19
 * @author Dan Fuhry <dan@enanocms.org>
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    20
 * @license GNU General Public License
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    21
 */
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    22
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    23
class LogDisplay
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    24
{
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    25
  /**
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    26
   * Criteria for the search.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    27
   * Structure:
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    28
   <code>
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    29
   array(
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    30
       array( 'user', 'Dan' ),
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    31
       array( 'within', 86400 ),
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    32
       array( 'page', 'Main_Page' )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    33
     )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    34
   </code>
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    35
   * @var array
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    36
   */
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    37
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    38
  var $criteria = array();
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    39
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    40
  /**
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    41
   * Adds a criterion for the log display.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    42
   * @param string Criterion type - user, page, or within
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    43
   * @param string Value - username, page ID, or (int) within # seconds or (string) number + suffix (suffix: d = day, w = week, m = month, y = year) ex: "1w"
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    44
   */
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    45
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    46
  public function add_criterion($criterion, $value)
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    47
  {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    48
    switch ( $criterion )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    49
    {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    50
      case 'user':
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    51
      case 'page':
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
    52
      case 'action':
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    53
        $this->criteria[] = array($criterion, $value);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    54
        break;
980
d13fad911955 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
Dan
parents: 947
diff changeset
    55
      case 'minor':
d13fad911955 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
Dan
parents: 947
diff changeset
    56
        $this->criteria[] = array($criterion, intval($value));
d13fad911955 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
Dan
parents: 947
diff changeset
    57
        break;
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    58
      case 'within':
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    59
        if ( is_int($value) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    60
        {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    61
          $this->criteria[] = array($criterion, $value);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    62
        }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    63
        else if ( is_string($value) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    64
        {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    65
          $lastchar = substr($value, -1);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    66
          $amt = intval($value);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    67
          switch($lastchar)
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    68
          {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    69
            case 'd':
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    70
              $amt = $amt * 86400;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    71
              break;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    72
            case 'w':
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    73
              $amt = $amt * 604800;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    74
              break;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    75
            case 'm':
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    76
              $amt = $amt * 2592000;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    77
              break;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    78
            case 'y':
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    79
              $amt = $amt * 31536000;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    80
              break;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    81
          }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    82
          $this->criteria[] = array($criterion, $amt);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    83
        }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    84
        else
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    85
        {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    86
          throw new Exception('Invalid value type for within');
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    87
        }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    88
        break;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    89
      default:
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    90
        throw new Exception('Unknown criterion type');
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    91
        break;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    92
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    93
  }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    94
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    95
  /**
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    96
   * Build the necessary SQL query.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    97
   * @param int Optional: offset, defaults to 0
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    98
   * @param int Optional: page size, defaults to 0; 0 = don't limit
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    99
   */
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   100
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   101
  public function build_sql($offset = 0, $page_size = 0, $just_page_count = false)
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   102
  {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   103
    global $db, $session, $paths, $template, $plugins; // Common objects
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   104
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   105
    $where_extra = '';
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   106
    $where_bits = array(
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   107
        'user' => array(),
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   108
        'page' => array(),
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   109
        'action' => array()
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   110
      );
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   111
    foreach ( $this->criteria as $criterion )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   112
    {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   113
      list($type, $value) = $criterion;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   114
      switch($type)
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   115
      {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   116
        case 'user':
909
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   117
          $where_bits['user'][] = "author = '" . $db->escape(str_replace('_', ' ', $value)) . "'";
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   118
          break;
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   119
        case 'action':
909
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   120
          if ( $value === 'protect' )
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   121
          {
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   122
            $where_bits['action'][] = "action = 'prot'";
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   123
            $where_bits['action'][] = "action = 'unprot'";
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   124
            $where_bits['action'][] = "action = 'semiprot'";
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   125
          }
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   126
          else
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   127
          {
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   128
            $where_bits['action'][] = "action = '" . $db->escape($value) . "'";
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   129
          }
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   130
          break;
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   131
        case 'page':
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   132
          list($page_id, $namespace) = RenderMan::strToPageId($value);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   133
          $where_bits['page'][] = "page_id = '" . $db->escape($page_id) . "' AND namespace = '" . $db->escape($namespace) . "'";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   134
          break;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   135
        case 'within':
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   136
          $threshold = time() - $value;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   137
          $where_extra .= "\n    AND time_id > $threshold";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   138
          break;
980
d13fad911955 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
Dan
parents: 947
diff changeset
   139
        case 'minor':
d13fad911955 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
Dan
parents: 947
diff changeset
   140
          if ( $value == 1 )
d13fad911955 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
Dan
parents: 947
diff changeset
   141
            $where_extra .= "\n    AND ( minor_edit = 1 OR action != 'edit' )";
d13fad911955 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
Dan
parents: 947
diff changeset
   142
          else
d13fad911955 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
Dan
parents: 947
diff changeset
   143
            $where_extra .= "\n    AND minor_edit != 1";
d13fad911955 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
Dan
parents: 947
diff changeset
   144
          break;
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   145
      }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   146
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   147
    if ( !empty($where_bits['user']) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   148
    {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   149
      $where_extra .= "\n    AND ( " . implode(" OR ", $where_bits['user']) . " )";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   150
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   151
    if ( !empty($where_bits['page']) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   152
    {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   153
      $where_extra .= "\n    AND ( (" . implode(") OR (", $where_bits['page']) . ") )";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   154
    }
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   155
    if ( !empty($where_bits['action']) )
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   156
    {
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   157
      $where_extra .= "\n    AND ( (" . implode(") OR (", $where_bits['action']) . ") )";
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   158
    }
918
1064e7e57eeb Fixed logs not working under postgresql
Dan
parents: 913
diff changeset
   159
    if ( ENANO_DBLAYER == 'PGSQL' )
1064e7e57eeb Fixed logs not working under postgresql
Dan
parents: 913
diff changeset
   160
      $limit = ( $page_size > 0 ) ? "\n  LIMIT $page_size OFFSET $offset" : '';
1064e7e57eeb Fixed logs not working under postgresql
Dan
parents: 913
diff changeset
   161
    else
1064e7e57eeb Fixed logs not working under postgresql
Dan
parents: 913
diff changeset
   162
      $limit = ( $page_size > 0 ) ? "\n  LIMIT $offset, $page_size" : '';
1175
1e2c9819ede3 Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents: 1152
diff changeset
   163
    $columns = ( $just_page_count ) ? 'COUNT(*)' : 'log_id, action, page_id, namespace, CHAR_LENGTH(page_text) AS revision_size, author, author_uid, u.username, time_id, edit_summary, minor_edit';
918
1064e7e57eeb Fixed logs not working under postgresql
Dan
parents: 913
diff changeset
   164
    $sql = 'SELECT ' . $columns . ' FROM ' . table_prefix . "logs AS l\n"
1175
1e2c9819ede3 Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents: 1152
diff changeset
   165
         . "  LEFT JOIN " . table_prefix . "users AS u\n"
1e2c9819ede3 Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents: 1152
diff changeset
   166
         . "    ON ( u.user_id = l.author_uid OR u.user_id IS NULL )\n"
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   167
         . "  WHERE log_type = 'page' AND is_draft != 1$where_extra\n"
1152
e3fb74e3e74e PostgreSQL: Fixed another bug, this time in the log fetch code
Dan
parents: 1081
diff changeset
   168
         . "  GROUP BY log_id, action, page_id, namespace, page_text, author, time_id, edit_summary, minor_edit\n"
947
f222643fb578 Whoops. LogDisplay sorted by log_id, not time_id.
Dan
parents: 918
diff changeset
   169
         . "  ORDER BY time_id DESC $limit;";
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   170
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   171
    return $sql;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   172
  }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   173
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   174
  /**
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   175
   * Get data!
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   176
   * @param int Offset, defaults to 0
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   177
   * @param int Page size, if 0 (default) returns entire table (danger Will Robinson!)
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   178
   * @return array
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   179
   */
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   180
  
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   181
  public function get_data($offset = 0, $page_size = 0)
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   182
  {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   183
    global $db, $session, $paths, $session, $plugins; // Common objects
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   184
    $sql = $this->build_sql($offset, $page_size);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   185
    if ( !$db->sql_query($sql) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   186
      $db->_die();
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   187
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   188
    $return = array();
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   189
    $deplist = array();
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   190
    $idlist = array();
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   191
    while ( $row = $db->fetchrow() )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   192
    {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   193
      $return[ $row['log_id'] ] = $row;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   194
      if ( $row['action'] === 'edit' )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   195
      {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   196
        // This is a page revision; its parent needs to be found
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   197
        $pagekey = serialize(array($row['page_id'], $row['namespace']));
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   198
        $deplist[$pagekey] = "( page_id = '" . $db->escape($row['page_id']) . "' AND namespace = '" . $db->escape($row['namespace']) . "' AND log_id < {$row['log_id']} )";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   199
        // if we already have a revision from this page in the dataset, we've found its parent
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   200
        if ( isset($idlist[$pagekey]) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   201
        {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   202
          $child =& $return[ $idlist[$pagekey] ];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   203
          $child['parent_size'] = $row['revision_size'];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   204
          $child['parent_revid'] = $row['log_id'];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   205
          $child['parent_time'] = $row['time_id'];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   206
          unset($child);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   207
        }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   208
        $idlist[$pagekey] = $row['log_id'];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   209
      }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   210
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   211
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   212
    // Second query fetches all parent revision data
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   213
    // (maybe we have no edits?? check deplist)
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   214
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   215
    if ( !empty($deplist) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   216
    {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   217
      // FIXME: inefficient. damn GROUP BY for not obeying ORDER BY, it means we can't group and instead have to select
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   218
      // all previous revisions of page X and discard all but the first one we find.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   219
      $where_extra = implode("\n    OR ", $deplist);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   220
      $sql = 'SELECT log_id, page_id, namespace, CHAR_LENGTH(page_text) AS revision_size, time_id FROM ' . table_prefix . "logs\n"
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   221
           . "  WHERE log_type = 'page' AND action = 'edit'\n  AND ( $where_extra )\n"
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   222
           // . "  GROUP BY page_id, namespace\n"
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   223
           . "  ORDER BY log_id DESC;";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   224
      if ( !$db->sql_query($sql) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   225
        $db->_die();
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   226
      
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   227
      while ( $row = $db->fetchrow() )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   228
      {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   229
        $pagekey = serialize(array($row['page_id'], $row['namespace']));
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   230
        if ( isset($idlist[$pagekey]) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   231
        {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   232
          $child =& $return[ $idlist[$pagekey] ];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   233
          $child['parent_size'] = $row['revision_size'];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   234
          $child['parent_revid'] = $row['log_id'];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   235
          $child['parent_time'] = $row['time_id'];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   236
          unset($child, $idlist[$pagekey]);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   237
        }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   238
      }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   239
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   240
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   241
    // final iteration goes through all edits and if there's not info on the parent, sets to 0. It also calculates size change.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   242
    foreach ( $return as &$row )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   243
    {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   244
      if ( $row['action'] === 'edit' && !isset($row['parent_revid']) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   245
      {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   246
        $row['parent_revid'] = 0;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   247
        $row['parent_size'] = 0;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   248
      }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   249
      if ( $row['action'] === 'edit' )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   250
      {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   251
        $row['size_delta'] = $row['revision_size'] - $row['parent_size'];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   252
      }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   253
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   254
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   255
    return array_values($return);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   256
  }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   257
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   258
  /**
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   259
   * Get the number of rows that will be in the result set.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   260
   * @return int
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   261
   */
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   262
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   263
  public function get_row_count()
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   264
  {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   265
    global $db, $session, $paths, $session, $plugins; // Common objects
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   266
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   267
    if ( !$db->sql_query( $this->build_sql(0, 0, true) ) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   268
      $db->_die();
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   269
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   270
    list($count) = $db->fetchrow_num();
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   271
    return $count;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   272
  }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   273
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   274
  /**
909
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   275
   * Returns the list of criteria
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   276
   * @return array
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   277
   */
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   278
  
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   279
  public function get_criteria()
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   280
  {
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   281
    return $this->criteria;
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   282
  }
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   283
  
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   284
  /**
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   285
   * Formats a result row into pretty HTML.
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   286
   * @param array dataset from LogDisplay::get_data()
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   287
   * @param bool If true (default), shows action buttons.
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   288
   * @param bool If true (default), shows page title; good for integrated displays
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   289
   * @static
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   290
   * @return string
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   291
   */
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   292
  
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   293
  public static function render_row($row, $show_buttons = true, $show_pagetitle = true)
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   294
  {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   295
    global $db, $session, $paths, $session, $plugins; // Common objects
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   296
    global $lang;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   297
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   298
    $html = '';
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   299
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   300
    $pagekey = ( isset($paths->nslist[$row['namespace']]) ) ? $paths->nslist[$row['namespace']] . $row['page_id'] : $row['namespace'] . ':' . $row['page_id'];
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   301
    $pagekey = sanitize_page_id($pagekey);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   302
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   303
    // diff button
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   304
    if ( $show_buttons )
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   305
    {
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   306
      if ( $row['action'] == 'edit' && !empty($row['parent_revid']) )
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   307
      {
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   308
        $html .= '(';
980
d13fad911955 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
Dan
parents: 947
diff changeset
   309
        $ispage = isPage($pagekey);
d13fad911955 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
Dan
parents: 947
diff changeset
   310
        
d13fad911955 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
Dan
parents: 947
diff changeset
   311
        if ( $ispage )
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   312
          $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], "do=diff&diff1={$row['parent_revid']}&diff2={$row['log_id']}", true) . '">';
980
d13fad911955 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
Dan
parents: 947
diff changeset
   313
        
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   314
        $html .= $lang->get('pagetools_rc_btn_diff');
980
d13fad911955 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
Dan
parents: 947
diff changeset
   315
        
d13fad911955 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
Dan
parents: 947
diff changeset
   316
        if ( $ispage )
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   317
          $html .= '</a>';
980
d13fad911955 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
Dan
parents: 947
diff changeset
   318
        
d13fad911955 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
Dan
parents: 947
diff changeset
   319
        if ( $ispage )
d13fad911955 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
Dan
parents: 947
diff changeset
   320
          $html .= ', <a href="' . makeUrlNS($row['namespace'], $row['page_id'], "oldid={$row['log_id']}", true) . '">';
d13fad911955 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
Dan
parents: 947
diff changeset
   321
        
d13fad911955 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
Dan
parents: 947
diff changeset
   322
        $html .= $lang->get('pagetools_rc_btn_view');
d13fad911955 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
Dan
parents: 947
diff changeset
   323
        
d13fad911955 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
Dan
parents: 947
diff changeset
   324
        if ( $ispage )
d13fad911955 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
Dan
parents: 947
diff changeset
   325
          $html .= '</a>';
d13fad911955 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
Dan
parents: 947
diff changeset
   326
        
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   327
        if ( $row['parent_revid'] > 0 && isPage($pagekey) )
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   328
        {
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   329
          $html .= ', <a href="' . makeUrlNS($row['namespace'], $row['page_id'], false, true) . '#do:edit;rev:' . $row['parent_revid'] . '">' . $lang->get('pagetools_rc_btn_undo') . '</a>';
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   330
        }
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   331
        $html .= ') ';
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   332
      }
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   333
      else if ( $row['action'] != 'edit' && ( isPage($pagekey) || $row['action'] == 'delete' ) )
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   334
      {
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   335
        $html .= '(';
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   336
        $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], "do=rollback&id={$row['log_id']}", true). '">' . $lang->get('pagetools_rc_btn_undo') . '</a>';
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   337
        $html .= ') ';
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   338
      }
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   339
      
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   340
      // hist button
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   341
      $html .= '(';
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   342
      if ( isPage($pagekey) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   343
      {
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   344
        $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], "do=history", true) . '">';
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   345
      }
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   346
      $html .= $lang->get('pagetools_rc_btn_hist');
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   347
      if ( isPage($pagekey) )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   348
      {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   349
        $html .= '</a>';
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   350
      }
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   351
      $html .= ') . . ';
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   352
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   353
    
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   354
    if ( $show_pagetitle )
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   355
    {
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   356
      // new page?
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   357
      if ( $row['action'] == 'edit' && empty($row['parent_revid']) )
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   358
      {
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   359
        $html .= '<b>N</b> ';
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   360
      }
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   361
      // minor edit?
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   362
      if ( $row['action'] == 'edit' && $row['minor_edit'] )
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   363
      {
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   364
        $html .= '<b>m</b> ';
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   365
      }
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   366
      
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   367
      // link to the page
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   368
      $cls = ( isPage($pagekey) ) ? '' : ' class="wikilink-nonexistent"';
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   369
      $html .= '<a href="' . makeUrlNS($row['namespace'], $row['page_id']) . '"' . $cls . '>' . htmlspecialchars(get_page_title_ns($row['page_id'], $row['namespace'])) . '</a>; ';
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   370
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   371
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   372
    // date
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   373
    $today = time() - ( time() % 86400 );
909
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   374
    $date = MemberlistFormatter::format_date($row['time_id']) . ' ';
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   375
    $date .= date('h:i:s', $row['time_id']);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   376
    $html .= "$date . . ";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   377
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   378
    // size counter
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   379
    if ( $row['action'] == 'edit' )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   380
    {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   381
      $css = self::get_css($row['size_delta']);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   382
      $size_change = number_format($row['size_delta']);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   383
      if ( substr($size_change, 0, 1) != '-' )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   384
        $size_change = "+$size_change";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   385
      
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   386
      $html .= "<span style=\"$css\">({$size_change})</span>";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   387
      $html .= ' . . ';
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   388
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   389
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   390
    // link to userpage
1175
1e2c9819ede3 Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents: 1152
diff changeset
   391
    $real_username = $row['author_uid'] > 1 && !empty($row['username']) ? $row['username'] : $row['author'];
1e2c9819ede3 Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents: 1152
diff changeset
   392
    $cls = ( isPage($paths->nslist['User'] . $real_username) ) ? '' : ' class="wikilink-nonexistent"';
1e2c9819ede3 Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents: 1152
diff changeset
   393
    $rank_info = $session->get_user_rank($row['author_uid']);
1e2c9819ede3 Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents: 1152
diff changeset
   394
    $html .= '<a style="' . $rank_info['rank_style'] . '" href="' . makeUrlNS('User', sanitize_page_id($real_username), false, true) . '"' . $cls . '>' . htmlspecialchars($real_username) . '</a> ';
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   395
    $html .= '(';
1175
1e2c9819ede3 Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents: 1152
diff changeset
   396
    $html .= '<a href="' . makeUrlNS('Special', 'PrivateMessages/Compose/To/' . sanitize_page_id($real_username), false, true) . '">';
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   397
    $html .= $lang->get('pagetools_rc_btn_pm');
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   398
    $html .= '</a>, ';
1175
1e2c9819ede3 Logs: Fully integrated an author_uid column. Logs are now linked by user ID instead of just username, so they survive username changes better. Database is changed. Fixes issue 6.
Dan
parents: 1152
diff changeset
   399
    $html .= '<a href="' . makeUrlNS('User', sanitize_page_id($real_username), false, true) . '#do:comments">';
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   400
    $html .= $lang->get('pagetools_rc_btn_usertalk');
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   401
    $html .= '</a>';
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   402
    $html .= ') . . ';
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   403
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   404
    // Edit summary
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   405
    
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   406
    if ( $row['action'] == 'edit' )
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   407
    {
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   408
      $html .= '<i>(';
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   409
      if ( empty($row['edit_summary']) )
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   410
      {
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   411
        $html .= '<span style="color: #808080;">' . $lang->get('history_summary_none_given') . '</span>';
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   412
      }
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   413
      else
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   414
      {
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   415
        $html .= RenderMan::parse_internal_links(htmlspecialchars($row['edit_summary']));
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   416
      }
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   417
      $html .= ')</i>';
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   418
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   419
    else
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   420
    {
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   421
      switch($row['action'])
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   422
      {
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   423
        default:
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   424
          $html .= $row['action'];
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   425
          break;
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   426
        case 'rename':
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   427
          $html .= $lang->get('log_action_rename', array('old_name' => htmlspecialchars($row['edit_summary'])));
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   428
          break;
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   429
        case 'create':
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   430
          $html .= $lang->get('log_action_create');
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   431
          break;
913
3ec535acd11e Deletion vote reset is now logged and able to be rolled back
Dan
parents: 912
diff changeset
   432
        case 'votereset':
3ec535acd11e Deletion vote reset is now logged and able to be rolled back
Dan
parents: 912
diff changeset
   433
          $html .= $lang->get('log_action_votereset', array('num_votes' => $row['edit_summary'], 'plural' => ( intval($row['edit_summary']) == 1 ? '' : $lang->get('meta_plural'))));
3ec535acd11e Deletion vote reset is now logged and able to be rolled back
Dan
parents: 912
diff changeset
   434
          break;
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   435
        case 'prot':
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   436
        case 'unprot':
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   437
        case 'semiprot':
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   438
        case 'delete':
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   439
        case 'reupload':
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   440
          $stringmap = array(
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   441
            'prot' => 'log_action_protect_full',
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   442
            'unprot' => 'log_action_protect_none',
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   443
            'semiprot' => 'log_action_protect_semi',
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   444
            'delete' => 'log_action_delete',
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   445
            'reupload' => 'log_action_reupload'
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   446
          );
909
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   447
        
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   448
        if ( $row['edit_summary'] === '__REVERSION__' )
912
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   449
          $reason = '<span style="color: #808080;">' . $lang->get('log_msg_reversion') . '</span>';
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   450
        else if ( $row['action'] == 'reupload' && $row['edit_summary'] === '__ROLLBACK__' )
95d0d8596c87 File rollbacks should be all up to date now.
Dan
parents: 909
diff changeset
   451
          $reason = '<span style="color: #808080;">' . $lang->get('log_msg_file_restored') . '</span>';
909
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   452
        else
94c1ff984286 Finished core of log display interface including filter management. There is still a bit of a to-do list, especially regarding rollbacks and reuploads.
Dan
parents: 905
diff changeset
   453
          $reason = ( !empty($row['edit_summary']) ) ? htmlspecialchars($row['edit_summary']) : '<span style="color: #808080;">' . $lang->get('log_msg_no_reason_provided') . '</span>';
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   454
        
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   455
        $html .= $lang->get($stringmap[$row['action']], array('reason' => $reason));
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
   456
      }
901
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   457
    }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   458
    
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   459
    return $html;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   460
  }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   461
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   462
  /**
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   463
   * Return CSS blurb for size delta
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   464
   * @return string
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   465
   * @static
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   466
   * @access private
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   467
   */
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   468
  
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   469
  private static function get_css($change_size)
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   470
  {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   471
    // Hardly changed at all? Return a gray
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   472
    if ( $change_size <= 5 && $change_size >= -5 )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   473
      return 'color: #808080;';
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   474
    // determine saturation based on size of change (1-500 bytes)
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   475
    $change_abs = abs($change_size);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   476
    $index = 0x70 * ( $change_abs / 500 );
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   477
    if ( $index > 0x70 )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   478
      $index = 0x70;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   479
    $index = $index + 0x40;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   480
    $index = dechex($index);
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   481
    if ( strlen($index) < 2 )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   482
      $index = "0$index";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   483
    $css = ( $change_size > 0 ) ? "color: #00{$index}00;" : "color: #{$index}0000;";
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   484
    if ( $change_abs > 500 )
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   485
      $css .= ' font-weight: bold;';
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   486
    return $css;
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   487
  }
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   488
}
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   489
 
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
   490
?>