Index: trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | * @param string $arg |
62 | 62 | */ |
63 | 63 | public function execute( $subPage ) { |
64 | | - global $wgOut, $wgUser, $wgRequest, $wgLang; |
| 64 | + global $wgOut, $wgUser; |
65 | 65 | |
66 | 66 | $this->setHeaders(); |
67 | 67 | $this->outputHeader(); |
— | — | @@ -73,6 +73,35 @@ |
74 | 74 | |
75 | 75 | $this->registerUserView( $wgUser ); |
76 | 76 | |
| 77 | + $wgOut->addHTML( '<p>' ); |
| 78 | + |
| 79 | + if ( $wgUser->isAllowed( 'semanticwatchgroups' ) ) { |
| 80 | + $wgOut->addHTML( wfMsgExt( 'swl-watchlist-can-mod-groups', 'parseinline', 'Special:WatchlistConditions' ) . ' ' ); |
| 81 | + } |
| 82 | + |
| 83 | + if ( $this->userHasWatchlistGroups( $wgUser ) ) { |
| 84 | + $wgOut->addHTML( wfMsgExt( 'swl-watchlist-can-mod-prefs', 'parseinline', 'Special:Preferences#prefsection-swl' ) ); |
| 85 | + $wgOut->addHTML( '</p>' ); |
| 86 | + |
| 87 | + $this->getAndDisplaySets( $subPage ); |
| 88 | + } |
| 89 | + else { |
| 90 | + $wgOut->addHTML( wfMsgExt( 'swl-watchlist-no-groups', 'parseinline', 'Special:Preferences#prefsection-swl' ) ); |
| 91 | + $wgOut->addHTML( '</p>' ); |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * Obtains the change sets and displays them by calling displayWatchlist. |
| 97 | + * Also takes care of pagination and displaying appropriate message when there are no results. |
| 98 | + * |
| 99 | + * @since 0.1 |
| 100 | + * |
| 101 | + * @param string $subPage |
| 102 | + */ |
| 103 | + protected function getAndDisplaySets( $subPage ) { |
| 104 | + global $wgRequest, $wgOut, $wgLang; |
| 105 | + |
77 | 106 | $limit = $wgRequest->getInt( 'limit', 20 ); |
78 | 107 | $offset = $wgRequest->getInt( 'offset', 0 ); |
79 | 108 | $continue = $wgRequest->getVal( 'continue' ); |
— | — | @@ -91,16 +120,23 @@ |
92 | 121 | $newContinue = $changeSetData['query-continue']['semanticwatchlist']['swcontinue']; |
93 | 122 | } |
94 | 123 | |
95 | | - $wgOut->addHTML( '<p>' . wfMsgExt( |
96 | | - 'swl-watchlist-position', |
97 | | - array( 'parseinline' ), |
98 | | - $wgLang->formatNum( count( $sets ) ), |
99 | | - $wgLang->formatNum( $offset + 1 ) |
100 | | - ) . '</p>' ); |
| 124 | + if ( $offset != 0 || count( $sets ) > 0 ) { |
| 125 | + $wgOut->addHTML( '<p>' . wfMsgExt( |
| 126 | + 'swl-watchlist-position', |
| 127 | + array( 'parseinline' ), |
| 128 | + $wgLang->formatNum( count( $sets ) ), |
| 129 | + $wgLang->formatNum( $offset + 1 ) |
| 130 | + ) . '</p>' ); |
| 131 | + |
| 132 | + $wgOut->addHTML( $this->getPagingControlHTML( $limit, $continue, $subPage, $newContinue, $offset ) ); |
| 133 | + } |
101 | 134 | |
102 | | - $wgOut->addHTML( $this->getPagingControlHTML( $limit, $continue, $subPage, $newContinue, $offset ) ); |
103 | | - |
104 | | - $this->displayWatchlist( $sets ); |
| 135 | + if ( count( $sets ) > 0 ) { |
| 136 | + $this->displayWatchlist( $sets ); |
| 137 | + } |
| 138 | + else { |
| 139 | + $wgOut->addWikiMsg( 'swl-watchlist-no-items' ); |
| 140 | + } |
105 | 141 | } |
106 | 142 | |
107 | 143 | /** |
— | — | @@ -380,4 +416,29 @@ |
381 | 417 | return $html; |
382 | 418 | } |
383 | 419 | |
| 420 | + /** |
| 421 | + * Rteurns if the specified user has any watchlist groups in his notification list. |
| 422 | + * |
| 423 | + * @since 0.1 |
| 424 | + * |
| 425 | + * @param User $user |
| 426 | + * |
| 427 | + * @return boolean |
| 428 | + */ |
| 429 | + protected function userHasWatchlistGroups( User $user ) { |
| 430 | + if ( !$user->isLoggedIn() ) { |
| 431 | + return false; |
| 432 | + } |
| 433 | + |
| 434 | + $dbr = wfGetDB( DB_SLAVE ); |
| 435 | + |
| 436 | + $group = $dbr->selectRow( |
| 437 | + 'swl_users_per_group', |
| 438 | + array( 'upg_group_id' ), |
| 439 | + array( 'upg_user_id' => $user->getId() ) |
| 440 | + ); |
| 441 | + |
| 442 | + return $group !== false; |
| 443 | + } |
| 444 | + |
384 | 445 | } |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php |
— | — | @@ -53,7 +53,11 @@ |
54 | 54 | 'swl-watchlist-pagincontrol' => 'View ($1) ($2)', |
55 | 55 | 'swl-watchlist-firstn' => 'first $1', |
56 | 56 | 'swl-watchlist-firstn-title' => 'First $1 {{PLURAL:$1|result|results}}', |
57 | | - |
| 57 | + 'swl-watchlist-no-items' => 'You have no items on your watchlist.', |
| 58 | + 'swl-watchlist-can-mod-groups' => 'You can [[$1|modify the watchlist groups]].', |
| 59 | + 'swl-watchlist-can-mod-prefs' => 'You can [[$1|modify your watchlist preferences]].', |
| 60 | + 'swl-watchlist-no-groups' => 'You are not yet watching any watchlist groups. [[$1|Modify your watchlist preferences]].', |
| 61 | + |
58 | 62 | // Email |
59 | 63 | 'swl-email-propschanged' => 'Properties have changed at $1', |
60 | 64 | 'swl-email-propschanged-long' => "One or more properties you watch at '''$1''' have been changed by user '''$2''' at $4 on $5. You can view these and other changes on [$3 your semantic watchlist].", |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php |
— | — | @@ -290,8 +290,12 @@ |
291 | 291 | * Called after the personal URLs have been set up, before they are shown. |
292 | 292 | * https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Manual:Hooks/PersonalUrls |
293 | 293 | * |
| 294 | + * @since 0.1 |
| 295 | + * |
294 | 296 | * @param array $personal_urls |
295 | 297 | * @param Title $title |
| 298 | + * |
| 299 | + * @return true |
296 | 300 | */ |
297 | 301 | public static function onPersonalUrls( array &$personal_urls, Title &$title ) { |
298 | 302 | if ( $GLOBALS['egSWLEnableTopLink'] ) { |