| Index: trunk/phase3/RELEASE-NOTES |
| — | — | @@ -328,6 +328,10 @@ |
| 329 | 329 | * (bug 6061) Improper escaping in some html forms |
| 330 | 330 | * (bug 6065) Remove underscore when using NAMESPACE and TALKSPACE magics. |
| 331 | 331 | * (bug 6074) Correct squid purging of offsite upload URLs |
| | 332 | +* To simplify the lives of extension developers, the logging type arrays |
| | 333 | + can now be appended to directly by an extension setup function. It is |
| | 334 | + no longer necessary to write four separate functions just to add a |
| | 335 | + custom log type. |
| 332 | 336 | |
| 333 | 337 | |
| 334 | 338 | == Compatibility == |
| Index: trunk/phase3/includes/DefaultSettings.php |
| — | — | @@ -1712,6 +1712,70 @@ |
| 1713 | 1713 | $wgHooks = array(); |
| 1714 | 1714 | |
| 1715 | 1715 | /** |
| | 1716 | + * The logging system has two levels: an event type, which describes the |
| | 1717 | + * general category and can be viewed as a named subset of all logs; and |
| | 1718 | + * an action, which is a specific kind of event that can exist in that |
| | 1719 | + * log type. |
| | 1720 | + */ |
| | 1721 | +$wgLogTypes = array( '', 'block', 'protect', 'rights', 'delete', 'upload', 'move' ); |
| | 1722 | + |
| | 1723 | +/** |
| | 1724 | + * Lists the message key string for each log type. The localized messages |
| | 1725 | + * will be listed in the user interface. |
| | 1726 | + * |
| | 1727 | + * Extensions with custom log types may add to this array. |
| | 1728 | + */ |
| | 1729 | +$wgLogNames = array( |
| | 1730 | + '' => 'log', |
| | 1731 | + 'block' => 'blocklogpage', |
| | 1732 | + 'protect' => 'protectlogpage', |
| | 1733 | + 'rights' => 'rightslog', |
| | 1734 | + 'delete' => 'dellogpage', |
| | 1735 | + 'upload' => 'uploadlogpage', |
| | 1736 | + 'move' => 'movelogpage' ); |
| | 1737 | + |
| | 1738 | +/** |
| | 1739 | + * Lists the message key string for descriptive text to be shown at the |
| | 1740 | + * top of each log type. |
| | 1741 | + * |
| | 1742 | + * Extensions with custom log types may add to this array. |
| | 1743 | + */ |
| | 1744 | +$wgLogHeaders = array( |
| | 1745 | + '' => 'alllogstext', |
| | 1746 | + 'block' => 'blocklogtext', |
| | 1747 | + 'protect' => 'protectlogtext', |
| | 1748 | + 'rights' => 'rightslogtext', |
| | 1749 | + 'delete' => 'dellogpagetext', |
| | 1750 | + 'upload' => 'uploadlogpagetext', |
| | 1751 | + 'move' => 'movelogpagetext' ); |
| | 1752 | + |
| | 1753 | +/** |
| | 1754 | + * Lists the message key string for formatting individual events of each |
| | 1755 | + * type and action when listed in the logs. |
| | 1756 | + * |
| | 1757 | + * Extensions with custom log types may add to this array. |
| | 1758 | + */ |
| | 1759 | +$wgLogActions = array( |
| | 1760 | + 'block/block' => 'blocklogentry', |
| | 1761 | + 'block/unblock' => 'unblocklogentry', |
| | 1762 | + 'protect/protect' => 'protectedarticle', |
| | 1763 | + 'protect/unprotect' => 'unprotectedarticle', |
| | 1764 | + |
| | 1765 | + // TODO: This whole section should be moved to extensions/Makesysop/SpecialMakesysop.php |
| | 1766 | + 'rights/rights' => 'rightslogentry', |
| | 1767 | + 'rights/addgroup' => 'addgrouplogentry', |
| | 1768 | + 'rights/rngroup' => 'renamegrouplogentry', |
| | 1769 | + 'rights/chgroup' => 'changegrouplogentry', |
| | 1770 | + |
| | 1771 | + 'delete/delete' => 'deletedarticle', |
| | 1772 | + 'delete/restore' => 'undeletedarticle', |
| | 1773 | + 'delete/revision' => 'revdelete-logentry', |
| | 1774 | + 'upload/upload' => 'uploadedimage', |
| | 1775 | + 'upload/revert' => 'uploadedimage', |
| | 1776 | + 'move/move' => '1movedto2', |
| | 1777 | + 'move/move_redir' => '1movedto2_redir' ); |
| | 1778 | + |
| | 1779 | +/** |
| 1716 | 1780 | * Experimental preview feature to fetch rendered text |
| 1717 | 1781 | * over an XMLHttpRequest from JavaScript instead of |
| 1718 | 1782 | * forcing a submit and reload of the whole page. |
| Index: trunk/phase3/includes/LogPage.php |
| — | — | @@ -94,9 +94,8 @@ |
| 95 | 95 | * @static |
| 96 | 96 | */ |
| 97 | 97 | function validTypes() { |
| 98 | | - static $types = array( '', 'block', 'protect', 'rights', 'delete', 'upload', 'move' ); |
| 99 | | - wfRunHooks( 'LogPageValidTypes', array( &$types ) ); |
| 100 | | - return $types; |
| | 98 | + global $wgLogTypes; |
| | 99 | + return $wgLogTypes; |
| 101 | 100 | } |
| 102 | 101 | |
| 103 | 102 | /** |
| — | — | @@ -110,19 +109,10 @@ |
| 111 | 110 | * @static |
| 112 | 111 | */ |
| 113 | 112 | function logName( $type ) { |
| 114 | | - static $typeText = array( |
| 115 | | - '' => 'log', |
| 116 | | - 'block' => 'blocklogpage', |
| 117 | | - 'protect' => 'protectlogpage', |
| 118 | | - 'rights' => 'rightslog', |
| 119 | | - 'delete' => 'dellogpage', |
| 120 | | - 'upload' => 'uploadlogpage', |
| 121 | | - 'move' => 'movelogpage' |
| 122 | | - ); |
| 123 | | - wfRunHooks( 'LogPageLogName', array( &$typeText ) ); |
| | 113 | + global $wgLogNames; |
| 124 | 114 | |
| 125 | | - if( isset( $typeText[$type] ) ) { |
| 126 | | - return str_replace( '_', ' ', wfMsg( $typeText[$type] ) ); |
| | 115 | + if( isset( $wgLogNames[$type] ) ) { |
| | 116 | + return str_replace( '_', ' ', wfMsg( $wgLogNames[$type] ) ); |
| 127 | 117 | } else { |
| 128 | 118 | // Bogus log types? Perhaps an extension was removed. |
| 129 | 119 | return $type; |
| — | — | @@ -130,54 +120,24 @@ |
| 131 | 121 | } |
| 132 | 122 | |
| 133 | 123 | /** |
| | 124 | + * @fixme: handle missing log types |
| 134 | 125 | * @static |
| 135 | 126 | */ |
| 136 | 127 | function logHeader( $type ) { |
| 137 | | - static $headerText = array( |
| 138 | | - '' => 'alllogstext', |
| 139 | | - 'block' => 'blocklogtext', |
| 140 | | - 'protect' => 'protectlogtext', |
| 141 | | - 'rights' => 'rightslogtext', |
| 142 | | - 'delete' => 'dellogpagetext', |
| 143 | | - 'upload' => 'uploadlogpagetext', |
| 144 | | - 'move' => 'movelogpagetext' |
| 145 | | - ); |
| 146 | | - wfRunHooks( 'LogPageLogHeader', array( &$headerText ) ); |
| 147 | | - |
| 148 | | - return wfMsg( $headerText[$type] ); |
| | 128 | + global $wgLogHeaders; |
| | 129 | + return wfMsg( $wgLogHeaders[$type] ); |
| 149 | 130 | } |
| 150 | 131 | |
| 151 | 132 | /** |
| 152 | 133 | * @static |
| 153 | 134 | */ |
| 154 | 135 | function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false, $translate=false ) { |
| 155 | | - global $wgLang, $wgContLang; |
| 156 | | - static $actions = array( |
| 157 | | - 'block/block' => 'blocklogentry', |
| 158 | | - 'block/unblock' => 'unblocklogentry', |
| 159 | | - 'protect/protect' => 'protectedarticle', |
| 160 | | - 'protect/unprotect' => 'unprotectedarticle', |
| | 136 | + global $wgLang, $wgContLang, $wgLogActions; |
| 161 | 137 | |
| 162 | | - // TODO: This whole section should be moved to extensions/Makesysop/SpecialMakesysop.php |
| 163 | | - 'rights/rights' => 'rightslogentry', |
| 164 | | - 'rights/addgroup' => 'addgrouplogentry', |
| 165 | | - 'rights/rngroup' => 'renamegrouplogentry', |
| 166 | | - 'rights/chgroup' => 'changegrouplogentry', |
| 167 | | - |
| 168 | | - 'delete/delete' => 'deletedarticle', |
| 169 | | - 'delete/restore' => 'undeletedarticle', |
| 170 | | - 'delete/revision' => 'revdelete-logentry', |
| 171 | | - 'upload/upload' => 'uploadedimage', |
| 172 | | - 'upload/revert' => 'uploadedimage', |
| 173 | | - 'move/move' => '1movedto2', |
| 174 | | - 'move/move_redir' => '1movedto2_redir' |
| 175 | | - ); |
| 176 | | - wfRunHooks( 'LogPageActionText', array( &$actions ) ); |
| 177 | | - |
| 178 | 138 | $key = "$type/$action"; |
| 179 | | - if( isset( $actions[$key] ) ) { |
| | 139 | + if( isset( $wgLogActions[$key] ) ) { |
| 180 | 140 | if( is_null( $title ) ) { |
| 181 | | - $rv=wfMsg( $actions[$key] ); |
| | 141 | + $rv=wfMsg( $wgLogActions[$key] ); |
| 182 | 142 | } else { |
| 183 | 143 | if( $skin ) { |
| 184 | 144 | |
| — | — | @@ -209,16 +169,16 @@ |
| 210 | 170 | } |
| 211 | 171 | if( count( $params ) == 0 ) { |
| 212 | 172 | if ( $skin ) { |
| 213 | | - $rv = wfMsg( $actions[$key], $titleLink ); |
| | 173 | + $rv = wfMsg( $wgLogActions[$key], $titleLink ); |
| 214 | 174 | } else { |
| 215 | | - $rv = wfMsgForContent( $actions[$key], $titleLink ); |
| | 175 | + $rv = wfMsgForContent( $wgLogActions[$key], $titleLink ); |
| 216 | 176 | } |
| 217 | 177 | } else { |
| 218 | 178 | array_unshift( $params, $titleLink ); |
| 219 | 179 | if ( $translate && $key == 'block/block' ) { |
| 220 | 180 | $params[1] = $wgLang->translateBlockExpiry($params[1]); |
| 221 | 181 | } |
| 222 | | - $rv = wfMsgReal( $actions[$key], $params, true, !$skin ); |
| | 182 | + $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ); |
| 223 | 183 | } |
| 224 | 184 | } |
| 225 | 185 | } else { |
| Index: trunk/phase3/includes/Setup.php |
| — | — | @@ -320,6 +320,13 @@ |
| 321 | 321 | call_user_func( $func ); |
| 322 | 322 | } |
| 323 | 323 | |
| | 324 | +// For compatibility |
| | 325 | +wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) ); |
| | 326 | +wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) ); |
| | 327 | +wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) ); |
| | 328 | +wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) ); |
| | 329 | + |
| | 330 | + |
| 324 | 331 | wfDebug( "\n" ); |
| 325 | 332 | $wgFullyInitialised = true; |
| 326 | 333 | wfProfileOut( $fname.'-extensions' ); |
| Index: trunk/phase3/docs/hooks.txt |
| — | — | @@ -346,15 +346,18 @@ |
| 347 | 347 | $url: string value as output (out parameter, can modify) |
| 348 | 348 | $query: query options passed to Title::getFullURL() |
| 349 | 349 | |
| 350 | | -'LogPageValidTypes': action being logged. |
| 351 | | -$type: array of strings |
| | 350 | +'LogPageValidTypes': action being logged. DEPRECATED: Use $wgLogTypes |
| | 351 | +&$type: array of strings |
| 352 | 352 | |
| 353 | | -'LogPageLogName': name of the logging page(s). |
| 354 | | -$typeText: array of strings |
| | 353 | +'LogPageLogName': name of the logging page(s). DEPRECATED: Use $wgLogNames |
| | 354 | +&$typeText: array of strings |
| 355 | 355 | |
| 356 | | -'LogPageLogHeader': strings used by wfMsg as a header. |
| 357 | | -$headerText: array of strings |
| | 356 | +'LogPageLogHeader': strings used by wfMsg as a header. DEPRECATED: Use $wgLogHeaders |
| | 357 | +&$headerText: array of strings |
| 358 | 358 | |
| | 359 | +'LogPageActionText': strings used by wfMsg as a header. DEPRECATED: Use $wgLogActions |
| | 360 | +&$actionText: array of strings |
| | 361 | + |
| 359 | 362 | 'MarkPatrolled': before an edit is marked patrolled |
| 360 | 363 | $rcid: ID of the revision to be marked patrolled |
| 361 | 364 | $user: the user (object) marking the revision as patrolled |