Tell regexp parser to use extra analysis on external link regexp;
[lhc/web/wiklou.git] / includes / LogPage.php
index 5260356..68b73b2 100644 (file)
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 # http://www.gnu.org/copyleft/gpl.html
 
-# Class to simplify the use of log pages.
-# The logs are now kept in a table which is easier to manage and trim
-# than ever-growing wiki pages.
+/**
+ * Contain log classes
+ *
+ * @package MediaWiki
+ */
 
+/**
+ * Class to simplify the use of log pages.
+ * The logs are now kept in a table which is easier to manage and trim
+ * than ever-growing wiki pages.
+ *
+ * @package MediaWiki
+ */
 class LogPage {
        /* private */ var $type, $action, $comment;
        var $updateRecentChanges = true;
@@ -42,7 +51,7 @@ class LogPage {
                $uid = $wgUser->getID();
 
                $this->timestamp = $now = wfTimestampNow();
-               $dbw->insertArray( 'logging',
+               $dbw->insert( 'logging',
                        array(
                                'log_type' => $this->type,
                                'log_action' => $this->action,
@@ -66,7 +75,70 @@ class LogPage {
                return true;
        }
 
-       /* static */ function actionText( $type, $action, $titleLink ) {
+       /**
+        * @static
+        */
+       function validTypes() {
+               static $types = array( '', 'block', 'protect', 'rights', 'delete', 'upload' );
+               return $types;
+       }
+       
+       /**
+        * @static
+        */
+       function validActions( $type ) {
+               static $actions = array(
+                       '' => NULL,
+                       'block' => array( 'block', 'unblock' ),
+                       'protect' => array( 'protect', 'unprotect' ),
+                       'rights' => array( 'rights' ),
+                       'delete' => array( 'delete', 'restore' ),
+                       'upload' => array( 'upload' )
+               );
+               return $actions[$type];
+       }
+       
+       /**
+        * @static
+        */
+       function isLogType( $type ) {
+               return in_array( $type, LogPage::validTypes() );
+       }
+       
+       /**
+        * @static
+        */
+       function logName( $type ) {
+               static $typeText = array(
+                       ''        => 'log',
+                       'block'   => 'blocklogpage',
+                       'protect' => 'protectlogpage',
+                       'rights'  => 'bureaucratlog',
+                       'delete'  => 'dellogpage',
+                       'upload'  => 'uploadlogpage',
+               );
+               return str_replace( '_', ' ', wfMsg( $typeText[$type] ) );
+       }
+       
+       /**
+        * @static
+        */
+       function logHeader( $type ) {
+               static $headerText = array(
+                       ''        => 'alllogstext',
+                       'block'   => 'blocklogtext',
+                       'protect' => 'protectlogtext',
+                       'rights'  => '',
+                       'delete'  => 'dellogpagetext',
+                       'upload'  => 'uploadlogpagetext'
+               );
+               return wfMsg( $headerText[$type] );
+       }
+       
+       /**
+        * @static
+        */
+       function actionText( $type, $action, $titleLink = NULL ) {
                static $actions = array(
                        'block/block' => 'blocklogentry',
                        'block/unblock' => 'blocklogentry',
@@ -80,13 +152,23 @@ class LogPage {
                );
                $key = "$type/$action";
                if( isset( $actions[$key] ) ) {
-                       return wfMsg( $actions[$key], $titleLink );
+                       if( is_null( $titleLink ) ) {
+                               return wfMsg( $actions[$key] );
+                       } else {
+                               return wfMsg( $actions[$key], $titleLink );
+                       }
                } else {
                        wfDebug( "LogPage::actionText - unknown action $key\n" );
                        return "$action $titleLink";
                }
        }
-       
+
+       /**
+        * Add a log entry
+        * @param string $action one of 'block', 'protect', 'rights', 'delete', 'upload'
+        * @param &$target
+        * @param string $comment Description associated
+        */
        function addEntry( $action, &$target, $comment ) {
                global $wgLang, $wgUser;