http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88394
Revision: 88394
Author: jeroendedauw
Date: 2011-05-18 21:47:30 +0000 (Wed, 18 May 2011)
Log Message:
-----------
work on semantic watchlist user preferences
Modified Paths:
--------------
trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
2011-05-18 20:33:47 UTC (rev 88393)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
2011-05-18 21:47:30 UTC (rev 88394)
@@ -75,7 +75,75 @@
return true;
}
+
+ /**
+ * Adds the preferences of Semantic Watchlist to the list of available
ones.
+ *
+ * @since 0.1
+ *
+ * @param User $user
+ * @param array $preferences
+ *
+ * @return true
+ */
+ public static function onGetPreferences( User $user, array
&$preferences ) {
+ $groups = SWLGroups::getAll();
+
+ $preferences['swlemail'] = array(
+ 'type' => 'toggle',
+ 'label-message' => 'swl-prefs-emailnofity',
+ 'section' => 'swl/swlnotification',
+ );
+
+ foreach ( $groups as /* SWLGroup */ $group ) {
+ if ( count( $group->getProperties() ) == 0 ) {
+ continue;
+ }
+
+ switch ( true ) {
+ case count( $group->getCategories() ) > 0 :
+ $type = 'swl-prefs-category';
+ $name = $group->getCategories();
+ $name = $name[0];
+ break;
+ case count( $group->getNamespaces() ) > 0 :
+ $type = 'swl-prefs-namespace';
+ $name = $group->getNamespaces();
+ $name = $name[0] == 0 ? wfMsg( 'main' )
: MWNamespace::getCanonicalName( $name[0] );
+ break;
+ case count( $group->getConcepts() ) > 0 :
+ $type = 'swl-prefs-concept';
+ $name = $group->getConcepts();
+ $name = $item[0];
+ break;
+ }
+
+ $type = wfMsg( $type );
+
+ $properties = $group->getProperties();
+
+ foreach ( $properties as &$property ) {
+ $property = "''$property''";
+ }
+
+ $preferences['swlwatchgroup-' . $group->getId()] =
array(
+ 'type' => 'toggle',
+ 'label' => wfMsgExt(
+ 'swl-prefs-label',
+ 'parseinline',
+ $group->getName(),
+ count( $group->getProperties() ),
+ $GLOBALS['wgLang']->listToText(
$properties ),
+ $type,
+ $name
+ ),
+ 'section' => 'swl/swlgroup',
+ );
+ }
+ return true;
+ }
+
/**
* Schema update to set up the needed database tables.
*
Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
2011-05-18 20:33:47 UTC (rev 88393)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
2011-05-18 21:47:30 UTC (rev 88394)
@@ -44,6 +44,16 @@
'swl-email-propschanged' => 'Properties have changed at $1',
'swl-email-propschanged-long' => "One or more properties you watch at
'''$1''' have been changed by user '''$2''' at $4. You can view these and other
changes on [$3 your semantic watchlist].",
'swl-email-changes' => 'Property changes on [$2 $1]:',
+
+ // Preferences
+ 'prefs-swl' => 'Semantic watchlist',
+ 'prefs-swlgroup' => 'Groups to watch',
+ 'prefs-swlnotification' => 'Notification options',
+ 'swl-prefs-label' => "'''$1''': {{PLURAL:$2|property|properties}} $3
from $4 ''$5''.",
+ 'swl-prefs-category' => 'category',
+ 'swl-prefs-namespace' => 'namespace',
+ 'swl-prefs-concept' => 'concept',
+ 'swl-prefs-emailnofity' => 'E-mail me on changes to properties I am
watching'
);
/** German (Deutsch)
Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.php 2011-05-18
20:33:47 UTC (rev 88393)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.php 2011-05-18
21:47:30 UTC (rev 88394)
@@ -81,6 +81,8 @@
$wgHooks['SMWStore::dataChanged'][] = 'SWLHooks::onDataChanged';
+$wgHooks['GetPreferences'][] = 'SWLHooks::onGetPreferences';
+
$moduleTemplate = array(
'localBasePath' => dirname( __FILE__ ),
'remoteBasePath' => $egSWLScriptPath
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs