plugins/SpecialLog.php
author Dan
Mon, 13 Apr 2009 14:43:28 -0400
changeset 906 c949e82b8f49
parent 905 1e40b33f2e3e
child 909 94c1ff984286
permissions -rw-r--r--
New page protection UI. Both miniPrompt and failsafe HTML.
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
/**!info**
99ea0b0ac4be Work 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
  "Plugin Name"  : "plugin_speciallog_title",
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
     5
  "Plugin URI"   : "http://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
     6
  "Description"  : "plugin_speciallog_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
     7
  "Author"       : "Dan Fuhry",
99ea0b0ac4be Work 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
  "Version"      : "1.1.6",
99ea0b0ac4be Work 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
  "Author URI"   : "http://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
    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
**!*/
99ea0b0ac4be Work 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
99ea0b0ac4be Work 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
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
99ea0b0ac4be Work 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
 * Version 1.1.6 (Caoineag beta 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
    16
 * Copyright (C) 2006-2008 Dan Fuhry
99ea0b0ac4be Work 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
 *
99ea0b0ac4be Work 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
 * 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
    19
 * 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
    20
 *
99ea0b0ac4be Work 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
 * 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
    22
 * 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
    23
 */
99ea0b0ac4be Work 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
function SpecialLog_paths_init()
99ea0b0ac4be Work 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
{
99ea0b0ac4be Work 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
  global $paths;
99ea0b0ac4be Work 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
  $paths->add_page(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
    29
    'name'=>'specialpage_log',
99ea0b0ac4be Work 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
    'urlname'=>'Log',
99ea0b0ac4be Work 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
    'namespace'=>'Special',
99ea0b0ac4be Work 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
    'special'=>0,'visible'=>1,'comments_on'=>0,'protected'=>1,'delvotes'=>0,'delvote_ips'=>'',
99ea0b0ac4be Work 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
}
99ea0b0ac4be Work 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
99ea0b0ac4be Work 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
function page_Special_Log()
99ea0b0ac4be Work 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
  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
    39
  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
    40
  global $output;
99ea0b0ac4be Work 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
  
99ea0b0ac4be Work 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
  require_once(ENANO_ROOT . '/includes/log.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
    43
  $log = new 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
    44
  $page = 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
    45
  $pagesize = 50;
99ea0b0ac4be Work 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
  
99ea0b0ac4be Work 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
  if ( $params = explode('/', $paths->getAllParams()) )
99ea0b0ac4be Work 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
  {
99ea0b0ac4be Work 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
    foreach ( $params as $param )
99ea0b0ac4be Work 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
    {
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
    51
      if ( preg_match('/^([a-z]+)=(.+?)$/', $param, $match) )
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
    52
      {
99ea0b0ac4be Work 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
        $name =& $match[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
    54
        $value =& $match[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
    55
        switch($name)
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    56
        {
99ea0b0ac4be Work started on Special:Log and associated tools/interfaces. This is far from complete, but the basic functionality is in there.
Dan
parents:
diff changeset
    57
          case 'resultpage':
99ea0b0ac4be Work 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
            $page = 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
    59
            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
    60
          case '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
    61
            $pagesize = 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
    62
            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
    63
          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
    64
            $log->add_criterion($name, $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
    65
            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
    66
        }
99ea0b0ac4be Work 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
      }
99ea0b0ac4be Work 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
  }
99ea0b0ac4be Work 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
99ea0b0ac4be Work 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
  $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
    72
  $rowcount = $log->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
    73
  $result_url = makeUrlNS('Special', 'Log/' . rtrim(preg_replace('|/?resultpage=(.+?)/?|', '/', $paths->getAllParams()), '/') . '/resultpage=%s', false, 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
    74
  $paginator = generate_paginator($page, ceil($rowcount / $pagesize), $result_url);
99ea0b0ac4be Work 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
  
99ea0b0ac4be Work 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
  $dataset = $log->get_data($page * $pagesize, $pagesize);
99ea0b0ac4be Work 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
  
99ea0b0ac4be Work 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
  $output->header();
99ea0b0ac4be Work 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
  echo $paginator;
99ea0b0ac4be Work 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
  foreach ( $dataset 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
    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
    echo LogDisplay::render_row($row) . '<br />';
99ea0b0ac4be Work 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
  $output->footer();
905
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
    85
}
1e40b33f2e3e Log displayer should support some actions besides edit now
Dan
parents: 901
diff changeset
    86