Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php |
— | — | @@ -44,6 +44,16 @@ |
45 | 45 | 'swl-email-propschanged' => 'Properties have changed at $1', |
46 | 46 | '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].", |
47 | 47 | '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' |
48 | 58 | ); |
49 | 59 | |
50 | 60 | /** German (Deutsch) |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php |
— | — | @@ -81,6 +81,8 @@ |
82 | 82 | |
83 | 83 | $wgHooks['SMWStore::dataChanged'][] = 'SWLHooks::onDataChanged'; |
84 | 84 | |
| 85 | +$wgHooks['GetPreferences'][] = 'SWLHooks::onGetPreferences'; |
| 86 | + |
85 | 87 | $moduleTemplate = array( |
86 | 88 | 'localBasePath' => dirname( __FILE__ ), |
87 | 89 | 'remoteBasePath' => $egSWLScriptPath |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php |
— | — | @@ -75,7 +75,75 @@ |
76 | 76 | |
77 | 77 | return true; |
78 | 78 | } |
| 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 | + } |
79 | 144 | |
| 145 | + return true; |
| 146 | + } |
| 147 | + |
80 | 148 | /** |
81 | 149 | * Schema update to set up the needed database tables. |
82 | 150 | * |