r88394 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88393‎ | r88394 | r88395 >
Date:21:47, 18 May 2011
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
work on semantic watchlist user preferences
Modified paths:
  • /trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php (modified) (history)
  • /trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php (modified) (history)
  • /trunk/extensions/SemanticWatchlist/SemanticWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
@@ -44,6 +44,16 @@
4545 'swl-email-propschanged' => 'Properties have changed at $1',
4646 '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].",
4747 'swl-email-changes' => 'Property changes on [$2 $1]:',
 48+
 49+ // Preferences
 50+ 'prefs-swl' => 'Semantic watchlist',
 51+ 'prefs-swlgroup' => 'Groups to watch',
 52+ 'prefs-swlnotification' => 'Notification options',
 53+ 'swl-prefs-label' => "'''$1''': {{PLURAL:$2|property|properties}} $3 from $4 ''$5''.",
 54+ 'swl-prefs-category' => 'category',
 55+ 'swl-prefs-namespace' => 'namespace',
 56+ 'swl-prefs-concept' => 'concept',
 57+ 'swl-prefs-emailnofity' => 'E-mail me on changes to properties I am watching'
4858 );
4959
5060 /** German (Deutsch)
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
@@ -81,6 +81,8 @@
8282
8383 $wgHooks['SMWStore::dataChanged'][] = 'SWLHooks::onDataChanged';
8484
 85+$wgHooks['GetPreferences'][] = 'SWLHooks::onGetPreferences';
 86+
8587 $moduleTemplate = array(
8688 'localBasePath' => dirname( __FILE__ ),
8789 'remoteBasePath' => $egSWLScriptPath
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
@@ -75,7 +75,75 @@
7676
7777 return true;
7878 }
 79+
 80+ /**
 81+ * Adds the preferences of Semantic Watchlist to the list of available ones.
 82+ *
 83+ * @since 0.1
 84+ *
 85+ * @param User $user
 86+ * @param array $preferences
 87+ *
 88+ * @return true
 89+ */
 90+ public static function onGetPreferences( User $user, array &$preferences ) {
 91+ $groups = SWLGroups::getAll();
 92+
 93+ $preferences['swlemail'] = array(
 94+ 'type' => 'toggle',
 95+ 'label-message' => 'swl-prefs-emailnofity',
 96+ 'section' => 'swl/swlnotification',
 97+ );
 98+
 99+ foreach ( $groups as /* SWLGroup */ $group ) {
 100+ if ( count( $group->getProperties() ) == 0 ) {
 101+ continue;
 102+ }
 103+
 104+ switch ( true ) {
 105+ case count( $group->getCategories() ) > 0 :
 106+ $type = 'swl-prefs-category';
 107+ $name = $group->getCategories();
 108+ $name = $name[0];
 109+ break;
 110+ case count( $group->getNamespaces() ) > 0 :
 111+ $type = 'swl-prefs-namespace';
 112+ $name = $group->getNamespaces();
 113+ $name = $name[0] == 0 ? wfMsg( 'main' ) : MWNamespace::getCanonicalName( $name[0] );
 114+ break;
 115+ case count( $group->getConcepts() ) > 0 :
 116+ $type = 'swl-prefs-concept';
 117+ $name = $group->getConcepts();
 118+ $name = $item[0];
 119+ break;
 120+ }
 121+
 122+ $type = wfMsg( $type );
 123+
 124+ $properties = $group->getProperties();
 125+
 126+ foreach ( $properties as &$property ) {
 127+ $property = "''$property''";
 128+ }
 129+
 130+ $preferences['swlwatchgroup-' . $group->getId()] = array(
 131+ 'type' => 'toggle',
 132+ 'label' => wfMsgExt(
 133+ 'swl-prefs-label',
 134+ 'parseinline',
 135+ $group->getName(),
 136+ count( $group->getProperties() ),
 137+ $GLOBALS['wgLang']->listToText( $properties ),
 138+ $type,
 139+ $name
 140+ ),
 141+ 'section' => 'swl/swlgroup',
 142+ );
 143+ }
79144
 145+ return true;
 146+ }
 147+
80148 /**
81149 * Schema update to set up the needed database tables.
82150 *

Follow-up revisions

RevisionCommit summaryAuthorDate
r88404follow up to r88394jeroendedauw13:08, 19 May 2011

Comments

#Comment by Siebrand (talk | contribs)   23:10, 18 May 2011

If any of the variables in 'swl-prefs-label' can only be category, namespace or concept, it is preferred that you duplicate these and use one less variable.

Status & tagging log