http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90759
Revision: 90759
Author: bawolff
Date: 2011-06-25 07:21:29 +0000 (Sat, 25 Jun 2011)
Log Message:
-----------
Let $wgCategoryCollation take a class name as a value so that extensions
can define new Collation classes.
(I plan to commit such an extension shortly)
Wasn't sure if it would be better to make an array mapping collation names =>
class names
instead. However, that seemed to be unneededly complicated so I went with
letting that variable take class names.
Modified Paths:
--------------
trunk/phase3/RELEASE-NOTES-1.19
trunk/phase3/includes/Collation.php
trunk/phase3/includes/DefaultSettings.php
Modified: trunk/phase3/RELEASE-NOTES-1.19
===================================================================
--- trunk/phase3/RELEASE-NOTES-1.19 2011-06-25 06:24:09 UTC (rev 90758)
+++ trunk/phase3/RELEASE-NOTES-1.19 2011-06-25 07:21:29 UTC (rev 90759)
@@ -27,6 +27,8 @@
was removed in about 1.5.
* LogPageValidTypes, LogPageLogName, LogPageLogHeader and LogPageActionText
hooks have been removed.
+* $wgCategoryCollation can now use a class name as its value, in order for
+ extensions to be able to define new collations
=== New features in 1.19 ===
* BREAKING CHANGE: action=watch / action=unwatch now requires a token.
Modified: trunk/phase3/includes/Collation.php
===================================================================
--- trunk/phase3/includes/Collation.php 2011-06-25 06:24:09 UTC (rev 90758)
+++ trunk/phase3/includes/Collation.php 2011-06-25 07:21:29 UTC (rev 90759)
@@ -26,7 +26,18 @@
case 'uca-default':
return new IcuCollation( 'root' );
default:
- throw new MWException( __METHOD__.": unknown
collation type \"$collationName\"" );
+ # Provide a mechanism for extensions to hook in.
+ if ( class_exists( $collationName ) ) {
+ $collationObject = new $collationName;
+ if ( $collationObject instanceof
Collation ) {
+ return $collationObject;
+ } else {
+ throw new MWException(
__METHOD__.": collation type \"$collationName\""
+ . " is not a subclass
of Collation." );
+ }
+ } else {
+ throw new MWException( __METHOD__.":
unknown collation type \"$collationName\"" );
+ }
}
}
Modified: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php 2011-06-25 06:24:09 UTC (rev
90758)
+++ trunk/phase3/includes/DefaultSettings.php 2011-06-25 07:21:29 UTC (rev
90759)
@@ -4731,6 +4731,9 @@
*
* After you change this, you must run maintenance/updateCollation.php to fix
* the sort keys in the database.
+ *
+ * Extensions can define there own collations by subclassing Collation
+ * and using the class name as the value of this variable.
*/
$wgCategoryCollation = 'uppercase';
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs