To simplify the lives of extension developers, the logging type arrays can now be...
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 25 May 2006 07:37:20 +0000 (07:37 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 25 May 2006 07:37:20 +0000 (07:37 +0000)
The old hooks for this are retained for backwards compatibility, but are deprecated.

RELEASE-NOTES
docs/hooks.txt
includes/DefaultSettings.php
includes/LogPage.php
includes/Setup.php

index 3c54474..ec88ea0 100644 (file)
@@ -328,6 +328,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 6061) Improper escaping in some html forms
 * (bug 6065) Remove underscore when using NAMESPACE and TALKSPACE magics.
 * (bug 6074) Correct squid purging of offsite upload URLs
+* To simplify the lives of extension developers, the logging type arrays
+  can now be appended to directly by an extension setup function. It is
+  no longer necessary to write four separate functions just to add a
+  custom log type.
 
 
 == Compatibility ==
index 48b8e17..b2ee82a 100644 (file)
@@ -346,14 +346,17 @@ $title: Title object of page
 $url: string value as output (out parameter, can modify)
 $query: query options passed to Title::getFullURL()
 
-'LogPageValidTypes': action being logged.
-$type: array of strings
+'LogPageValidTypes': action being logged. DEPRECATED: Use $wgLogTypes
+&$type: array of strings
 
-'LogPageLogName': name of the logging page(s).
-$typeText: array of strings
+'LogPageLogName': name of the logging page(s). DEPRECATED: Use $wgLogNames
+&$typeText: array of strings
 
-'LogPageLogHeader': strings used by wfMsg as a header.
-$headerText: array of strings
+'LogPageLogHeader': strings used by wfMsg as a header. DEPRECATED: Use $wgLogHeaders
+&$headerText: array of strings
+
+'LogPageActionText': strings used by wfMsg as a header. DEPRECATED: Use $wgLogActions
+&$actionText: array of strings
 
 'MarkPatrolled': before an edit is marked patrolled
 $rcid: ID of the revision to be marked patrolled
index 16db781..7037288 100644 (file)
@@ -1711,6 +1711,70 @@ $wgAuth = null;
  */
 $wgHooks = array();
 
+/**
+ * The logging system has two levels: an event type, which describes the
+ * general category and can be viewed as a named subset of all logs; and
+ * an action, which is a specific kind of event that can exist in that
+ * log type.
+ */
+$wgLogTypes = array( '', 'block', 'protect', 'rights', 'delete', 'upload', 'move' );
+
+/**
+ * Lists the message key string for each log type. The localized messages
+ * will be listed in the user interface.
+ *
+ * Extensions with custom log types may add to this array.
+ */
+$wgLogNames = array(
+       ''        => 'log',
+       'block'   => 'blocklogpage',
+       'protect' => 'protectlogpage',
+       'rights'  => 'rightslog',
+       'delete'  => 'dellogpage',
+       'upload'  => 'uploadlogpage',
+       'move'    => 'movelogpage' );
+
+/**
+ * Lists the message key string for descriptive text to be shown at the
+ * top of each log type.
+ *
+ * Extensions with custom log types may add to this array.
+ */
+$wgLogHeaders = array(
+       ''        => 'alllogstext',
+       'block'   => 'blocklogtext',
+       'protect' => 'protectlogtext',
+       'rights'  => 'rightslogtext',
+       'delete'  => 'dellogpagetext',
+       'upload'  => 'uploadlogpagetext',
+       'move'    => 'movelogpagetext' );
+
+/**
+ * Lists the message key string for formatting individual events of each
+ * type and action when listed in the logs.
+ *
+ * Extensions with custom log types may add to this array.
+ */
+$wgLogActions = array(
+       'block/block'       => 'blocklogentry',
+       'block/unblock'     => 'unblocklogentry',
+       'protect/protect'   => 'protectedarticle',
+       'protect/unprotect' => 'unprotectedarticle',
+
+       // TODO: This whole section should be moved to extensions/Makesysop/SpecialMakesysop.php
+       'rights/rights'     => 'rightslogentry',
+       'rights/addgroup'   => 'addgrouplogentry',
+       'rights/rngroup'    => 'renamegrouplogentry',
+       'rights/chgroup'    => 'changegrouplogentry',
+
+       'delete/delete'     => 'deletedarticle',
+       'delete/restore'    => 'undeletedarticle',
+       'delete/revision'   => 'revdelete-logentry',
+       'upload/upload'     => 'uploadedimage',
+       'upload/revert'     => 'uploadedimage',
+       'move/move'         => '1movedto2',
+       'move/move_redir'   => '1movedto2_redir' );
+
 /**
  * Experimental preview feature to fetch rendered text
  * over an XMLHttpRequest from JavaScript instead of
index 5741e0c..c3b2367 100644 (file)
@@ -94,9 +94,8 @@ class LogPage {
         * @static
         */
        function validTypes() {
-               static $types = array( '', 'block', 'protect', 'rights', 'delete', 'upload', 'move' );
-               wfRunHooks( 'LogPageValidTypes', array( &$types ) );
-               return $types;
+               global $wgLogTypes;
+               return $wgLogTypes;
        }
 
        /**
@@ -110,19 +109,10 @@ class LogPage {
         * @static
         */
        function logName( $type ) {
-               static $typeText = array(
-                       ''        => 'log',
-                       'block'   => 'blocklogpage',
-                       'protect' => 'protectlogpage',
-                       'rights'  => 'rightslog',
-                       'delete'  => 'dellogpage',
-                       'upload'  => 'uploadlogpage',
-                       'move'    => 'movelogpage'
-               );
-               wfRunHooks( 'LogPageLogName', array( &$typeText ) );
+               global $wgLogNames;
 
-               if( isset( $typeText[$type] ) ) {
-                       return str_replace( '_', ' ', wfMsg( $typeText[$type] ) );
+               if( isset( $wgLogNames[$type] ) ) {
+                       return str_replace( '_', ' ', wfMsg( $wgLogNames[$type] ) );
                } else {
                        // Bogus log types? Perhaps an extension was removed.
                        return $type;
@@ -130,54 +120,24 @@ class LogPage {
        }
 
        /**
+        * @fixme: handle missing log types
         * @static
         */
        function logHeader( $type ) {
-               static $headerText = array(
-                       ''        => 'alllogstext',
-                       'block'   => 'blocklogtext',
-                       'protect' => 'protectlogtext',
-                       'rights'  => 'rightslogtext',
-                       'delete'  => 'dellogpagetext',
-                       'upload'  => 'uploadlogpagetext',
-                       'move'    => 'movelogpagetext'
-               );
-               wfRunHooks( 'LogPageLogHeader', array( &$headerText ) );
-
-               return wfMsg( $headerText[$type] );
+               global $wgLogHeaders;
+               return wfMsg( $wgLogHeaders[$type] );
        }
 
        /**
         * @static
         */
        function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false, $translate=false ) {
-               global $wgLang, $wgContLang;
-               static $actions = array(
-                       'block/block'       => 'blocklogentry',
-                       'block/unblock'     => 'unblocklogentry',
-                       'protect/protect'   => 'protectedarticle',
-                       'protect/unprotect' => 'unprotectedarticle',
-
-                       // TODO: This whole section should be moved to extensions/Makesysop/SpecialMakesysop.php
-                       'rights/rights'     => 'rightslogentry',
-                       'rights/addgroup'   => 'addgrouplogentry',
-                       'rights/rngroup'    => 'renamegrouplogentry',
-                       'rights/chgroup'    => 'changegrouplogentry',
-
-                       'delete/delete'     => 'deletedarticle',
-                       'delete/restore'    => 'undeletedarticle',
-                       'delete/revision'   => 'revdelete-logentry',
-                       'upload/upload'     => 'uploadedimage',
-                       'upload/revert'     => 'uploadedimage',
-                       'move/move'         => '1movedto2',
-                       'move/move_redir'   => '1movedto2_redir'
-               );
-               wfRunHooks( 'LogPageActionText', array( &$actions ) );
+               global $wgLang, $wgContLang, $wgLogActions;
 
                $key = "$type/$action";
-               if( isset( $actions[$key] ) ) {
+               if( isset( $wgLogActions[$key] ) ) {
                        if( is_null( $title ) ) {
-                               $rv=wfMsg( $actions[$key] );
+                               $rv=wfMsg( $wgLogActions[$key] );
                        } else {
                                if( $skin ) {
 
@@ -209,16 +169,16 @@ class LogPage {
                                }
                                if( count( $params ) == 0 ) {
                                        if ( $skin ) {
-                                               $rv = wfMsg( $actions[$key], $titleLink );
+                                               $rv = wfMsg( $wgLogActions[$key], $titleLink );
                                        } else {
-                                               $rv = wfMsgForContent( $actions[$key], $titleLink );
+                                               $rv = wfMsgForContent( $wgLogActions[$key], $titleLink );
                                        }
                                } else {
                                        array_unshift( $params, $titleLink );
                                        if ( $translate && $key == 'block/block' ) {
                                                $params[1] = $wgLang->translateBlockExpiry($params[1]);
                                        }
-                                       $rv = wfMsgReal( $actions[$key], $params, true, !$skin );
+                                       $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin );
                                }
                        }
                } else {
index 59aff89..4c4328d 100644 (file)
@@ -320,6 +320,13 @@ foreach ( $wgExtensionFunctions as $func ) {
        call_user_func( $func );
 }
 
+// For compatibility
+wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
+wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
+wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
+wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
+
+
 wfDebug( "\n" );
 $wgFullyInitialised = true;
 wfProfileOut( $fname.'-extensions' );