plugins/SpecialLog.php
changeset 901 99ea0b0ac4be
child 905 1e40b33f2e3e
equal deleted inserted replaced
900:c5409416b61b 901:99ea0b0ac4be
       
     1 <?php
       
     2 /**!info**
       
     3 {
       
     4   "Plugin Name"  : "plugin_speciallog_title",
       
     5   "Plugin URI"   : "http://enanocms.org/",
       
     6   "Description"  : "plugin_speciallog_desc",
       
     7   "Author"       : "Dan Fuhry",
       
     8   "Version"      : "1.1.6",
       
     9   "Author URI"   : "http://enanocms.org/"
       
    10 }
       
    11 **!*/
       
    12 
       
    13 /*
       
    14  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
       
    15  * Version 1.1.6 (Caoineag beta 1)
       
    16  * Copyright (C) 2006-2008 Dan Fuhry
       
    17  *
       
    18  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
       
    19  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
       
    20  *
       
    21  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
       
    22  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
       
    23  */
       
    24 
       
    25 function SpecialLog_paths_init()
       
    26 {
       
    27   global $paths;
       
    28   $paths->add_page(Array(
       
    29     'name'=>'specialpage_log',
       
    30     'urlname'=>'Log',
       
    31     'namespace'=>'Special',
       
    32     'special'=>0,'visible'=>1,'comments_on'=>0,'protected'=>1,'delvotes'=>0,'delvote_ips'=>'',
       
    33     ));
       
    34 }
       
    35 
       
    36 function page_Special_Log()
       
    37 {
       
    38   global $db, $session, $paths, $template, $plugins; // Common objects
       
    39   global $lang;
       
    40   global $output;
       
    41   
       
    42   require_once(ENANO_ROOT . '/includes/log.php');
       
    43   $log = new LogDisplay();
       
    44   $page = 1;
       
    45   $pagesize = 50;
       
    46   
       
    47   if ( $params = explode('/', $paths->getAllParams()) )
       
    48   {
       
    49     foreach ( $params as $param )
       
    50     {
       
    51       if ( preg_match('/^(user|page|within|resultpage|size)=(.+?)$/', $param, $match) )
       
    52       {
       
    53         $name =& $match[1];
       
    54         $value =& $match[2];
       
    55         switch($name)
       
    56         {
       
    57           case 'resultpage':
       
    58             $page = intval($value);
       
    59             break;
       
    60           case 'size':
       
    61             $pagesize = intval($value);
       
    62             break;
       
    63           default:
       
    64             $log->add_criterion($name, $value);
       
    65             break;
       
    66         }
       
    67       }
       
    68     }
       
    69   }
       
    70 
       
    71   $page--;
       
    72   $rowcount = $log->get_row_count();  
       
    73   $result_url = makeUrlNS('Special', 'Log/' . rtrim(preg_replace('|/?resultpage=(.+?)/?|', '/', $paths->getAllParams()), '/') . '/resultpage=%s', false, true);
       
    74   $paginator = generate_paginator($page, ceil($rowcount / $pagesize), $result_url);
       
    75   
       
    76   $dataset = $log->get_data($page * $pagesize, $pagesize);
       
    77   
       
    78   $output->header();
       
    79   echo $paginator;
       
    80   foreach ( $dataset as $row )
       
    81   {
       
    82     echo LogDisplay::render_row($row) . '<br />';
       
    83   }
       
    84   $output->footer();
       
    85 }