Index: trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php |
— | — | @@ -75,6 +75,15 @@ |
76 | 76 | $wgOut->addModules( 'ext.swl.watchlistconditions' ); |
77 | 77 | } |
78 | 78 | |
| 79 | + /** |
| 80 | + * |
| 81 | + * |
| 82 | + * @since 0.1 |
| 83 | + * |
| 84 | + * @param SWLGroup $group |
| 85 | + * |
| 86 | + * @return string |
| 87 | + */ |
79 | 88 | protected function getGroupHtml( SWLGroup $group ) { |
80 | 89 | return Html::rawElement( |
81 | 90 | 'fieldset', |
Index: trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlist.css |
— | — | @@ -1 +1,13 @@ |
2 | | -@CHARSET "UTF-8"; |
\ No newline at end of file |
| 2 | +@CHARSET "UTF-8"; |
| 3 | + |
| 4 | +div .swl-prop-div { |
| 5 | + padding-left: 15px; |
| 6 | +} |
| 7 | + |
| 8 | +.swl-watchlist-insertions { |
| 9 | + display: inline; |
| 10 | +} |
| 11 | + |
| 12 | +.swl-watchlist-deletions { |
| 13 | + display: inline; |
| 14 | +} |
\ No newline at end of file |
Index: trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | * |
52 | 52 | * @param string $arg |
53 | 53 | */ |
54 | | - public function execute( $arg ) { |
| 54 | + public function execute( $subPage ) { |
55 | 55 | global $wgOut, $wgUser, $wgRequest, $wgLang; |
56 | 56 | |
57 | 57 | $this->setHeaders(); |
— | — | @@ -74,31 +74,97 @@ |
75 | 75 | $sets[] = SWLChangeSet::newFromArray( $set ); |
76 | 76 | } |
77 | 77 | |
78 | | - $hasContinue = array_key_exists( 'query-continue', $changeSetData ); |
| 78 | + $newContinue = false; |
79 | 79 | |
80 | | - if ( $hasContinue ) { |
| 80 | + if ( array_key_exists( 'query-continue', $changeSetData ) ) { |
81 | 81 | $newContinue = $changeSetData['query-continue']['semanticwatchlist']['swcontinue']; |
82 | 82 | } |
83 | 83 | |
84 | 84 | $wgOut->addHTML( '<p>' . wfMsgExt( |
85 | | - 'swl-wacthlist-position', |
| 85 | + 'swl-watchlist-position', |
86 | 86 | array( 'parseinline' ), |
87 | 87 | $wgLang->formatNum( count( $sets ) ), |
88 | 88 | $wgLang->formatNum( $offset + 1 ) |
89 | 89 | ) . '</p>' ); |
90 | 90 | |
91 | | - $wgOut->addHTML( wfViewPrevNext( |
92 | | - $offset, |
93 | | - $limit, |
94 | | - $this->getTitle( $arg ), |
95 | | - $hasContinue ? 'continue=' . $newContinue : '', |
96 | | - !$hasContinue |
97 | | - ) ); |
| 91 | + $wgOut->addHTML( $this->getPagingControlHTML( $limit, $continue, $subPage, $newContinue, $offset ) ); |
98 | 92 | |
99 | 93 | $this->displayWatchlist( $sets ); |
100 | 94 | } |
101 | 95 | |
102 | 96 | /** |
| 97 | + * @since 0.1 |
| 98 | + * |
| 99 | + * @return string |
| 100 | + */ |
| 101 | + protected function getPagingControlHTML( $limit, $currentContinue, $subPage, $newContinue, $offset ) { |
| 102 | + global $wgLang; |
| 103 | + |
| 104 | + $nextMsg = wfMsgExt( 'nextn', array( 'parsemag', 'escape' ), $limit ); |
| 105 | + $firstMsg = wfMsgExt( 'swl-watchlist-firstn', array( 'parsemag', 'escape' ), $limit ); |
| 106 | + |
| 107 | + if ( $newContinue === false ) { |
| 108 | + $nextLink = $nextMsg; |
| 109 | + } |
| 110 | + else { |
| 111 | + $nextLink = Html::element( |
| 112 | + 'a', |
| 113 | + array( |
| 114 | + 'href' => $this->getTitle( $subPage )->getLocalURL( wfArrayToCGI( array( |
| 115 | + 'limit' => $limit, |
| 116 | + 'continue' => $newContinue, |
| 117 | + 'offset' => $offset + $limit |
| 118 | + ) ) ), |
| 119 | + 'title' => wfMsgExt( 'nextn-title', array( 'parsemag', 'escape' ), $limit ), |
| 120 | + 'class' => 'mw-nextlink' |
| 121 | + ), |
| 122 | + $nextMsg |
| 123 | + ); |
| 124 | + } |
| 125 | + |
| 126 | + $limitLinks = array(); |
| 127 | + $limitLinkArgs = array(); |
| 128 | + |
| 129 | + if ( $currentContinue == '' ) { |
| 130 | + $firstLink = $firstMsg; |
| 131 | + } |
| 132 | + else { |
| 133 | + $limitLinkArgs['continue'] = $currentContinue; |
| 134 | + |
| 135 | + $firstLink = Html::element( |
| 136 | + 'a', |
| 137 | + array( |
| 138 | + 'href' => $this->getTitle( $subPage )->getLocalURL( wfArrayToCGI( array( 'limit' => $limit ) ) ), |
| 139 | + 'title' => wfMsgExt( 'swl-watchlist-firstn-title', array( 'parsemag', 'escape' ), $limit ) |
| 140 | + ), |
| 141 | + $firstMsg |
| 142 | + ); |
| 143 | + } |
| 144 | + |
| 145 | + foreach ( array( 20, 50, 100, 250, 500 ) as $limitValue ) { |
| 146 | + $limitLinkArgs['limit'] = $limitValue; |
| 147 | + if ( $offset != 0 ) { |
| 148 | + $limitLinkArgs['offset'] = $offset; |
| 149 | + } |
| 150 | + |
| 151 | + $limitLinks[] = Html::element( |
| 152 | + 'a', |
| 153 | + array( |
| 154 | + 'href' => $this->getTitle( $subPage )->getLocalURL( wfArrayToCGI( $limitLinkArgs ) ), |
| 155 | + 'title' => wfMsgExt( 'shown-title', array( 'parsemag', 'escape' ), $limitValue ) |
| 156 | + ), |
| 157 | + $wgLang->formatNum( $limitValue ) |
| 158 | + ); |
| 159 | + } |
| 160 | + |
| 161 | + return Html::rawElement( |
| 162 | + 'p', |
| 163 | + array(), |
| 164 | + wfMsgHtml( 'swl-watchlist-pagincontrol', $wgLang->pipeList( array( $firstLink, $nextLink ) ), $wgLang->pipeList( $limitLinks ) ) |
| 165 | + ); |
| 166 | + } |
| 167 | + |
| 168 | + /** |
103 | 169 | * Displays the watchlist. |
104 | 170 | * |
105 | 171 | * @since 0.1 |
— | — | @@ -123,7 +189,7 @@ |
124 | 190 | krsort( $changeSetsHTML ); |
125 | 191 | |
126 | 192 | foreach ( $changeSetsHTML as $dayKey => $daySets ) { |
127 | | - $wgOut->addHTML( HTML::element( |
| 193 | + $wgOut->addHTML( Html::element( |
128 | 194 | 'h4', |
129 | 195 | array(), |
130 | 196 | $wgLang->date( str_pad( $dayKey, 14, '0' ) ) |
— | — | @@ -139,6 +205,8 @@ |
140 | 206 | } |
141 | 207 | |
142 | 208 | SMWOutputs::commitToOutputPage( $wgOut ); |
| 209 | + |
| 210 | + $wgOut->addModules( 'ext.swl.watchlist' ); |
143 | 211 | } |
144 | 212 | |
145 | 213 | /** |
— | — | @@ -185,34 +253,34 @@ |
186 | 254 | $html .= |
187 | 255 | '<p>' . |
188 | 256 | $wgLang->time( $changeSet->getTime(), true ) . ' ' . |
189 | | - HTML::element( |
| 257 | + Html::element( |
190 | 258 | 'a', |
191 | 259 | array( 'href' => $changeSet->getTitle()->getLocalURL() ), |
192 | 260 | $changeSet->getTitle()->getText() |
193 | 261 | ) . ' (' . |
194 | | - HTML::element( |
| 262 | + Html::element( |
195 | 263 | 'a', |
196 | 264 | array( 'href' => $changeSet->getTitle()->getLocalURL( 'action=history' ) ), |
197 | 265 | wfMsg( 'hist' ) |
198 | 266 | ) . ') . . ' . |
199 | | - HTML::element( |
| 267 | + Html::element( |
200 | 268 | 'a', |
201 | 269 | array( 'href' => $changeSet->getUser()->getUserPage()->getLocalURL() ), |
202 | 270 | $changeSet->getUser()->getName() |
203 | 271 | ) . ' (' . |
204 | | - HTML::element( |
| 272 | + Html::element( |
205 | 273 | 'a', |
206 | 274 | array( 'href' => $changeSet->getUser()->getTalkPage()->getLocalURL() ), |
207 | 275 | wfMsg( 'talkpagelinktext' ) |
208 | 276 | ) . ' | ' . |
209 | 277 | ( $changeSet->getUser()->isAnon() ? '' : |
210 | | - HTML::element( |
| 278 | + Html::element( |
211 | 279 | 'a', |
212 | 280 | array( 'href' => SpecialPage::getTitleFor( 'Contributions', $changeSet->getUser()->getName() )->getLocalURL() ), |
213 | 281 | wfMsg( 'contribslink' ) |
214 | 282 | ) . ' | ' |
215 | 283 | ) . |
216 | | - HTML::element( |
| 284 | + Html::element( |
217 | 285 | 'a', |
218 | 286 | array( 'href' => SpecialPage::getTitleFor( 'Block', $changeSet->getUser()->getName() )->getLocalURL() ), |
219 | 287 | wfMsg( 'blocklink' ) |
— | — | @@ -242,16 +310,37 @@ |
243 | 311 | * @return string |
244 | 312 | */ |
245 | 313 | protected function getPropertyHTML( SMWDIProperty $property, array $changes ) { |
246 | | - $html = ''; |
| 314 | + $insertions = array(); |
| 315 | + $deletions = array(); |
247 | 316 | |
| 317 | + // Convert the changes into a list of insertions and a list of deletions. |
248 | 318 | foreach ( $changes as /* SMWPropertyChange */ $change ) { |
249 | | - $old = $change->getOldValue(); |
250 | | - $old = is_null( $old ) ? wfMsg( 'swl-novalue' ) : SMWDataValueFactory::newDataItemValue( $old, $property )->getLongHTMLText(); |
251 | | - $new = $change->getNewValue(); |
252 | | - $new = is_null( $new ) ? wfMsg( 'swl-novalue' ) : SMWDataValueFactory::newDataItemValue( $new, $property )->getLongHTMLText(); |
253 | | - $html .= '* ' . $old . ' -> ' . $new; |
| 319 | + if ( !is_null( $change->getOldValue() ) ) { |
| 320 | + $deletions[] = SMWDataValueFactory::newDataItemValue( $change->getOldValue(), $property )->getLongHTMLText(); |
| 321 | + } |
| 322 | + if ( !is_null( $change->getNewValue() ) ) { |
| 323 | + $insertions[] = SMWDataValueFactory::newDataItemValue( $change->getNewValue(), $property )->getLongHTMLText(); |
| 324 | + } |
254 | 325 | } |
255 | 326 | |
| 327 | + $lines = array(); |
| 328 | + |
| 329 | + if ( count( $insertions ) > 0 ) { |
| 330 | + $lines[] = Html::element( 'div', array( 'class' => 'swl-watchlist-insertions' ), wfMsg( 'swl-watchlist-insertions' ) ) . ' ' . implode( ', ', $insertions ); |
| 331 | + } |
| 332 | + |
| 333 | + if ( count( $deletions ) > 0 ) { |
| 334 | + $lines[] = Html::element( 'div', array( 'class' => 'swl-watchlist-deletions' ), wfMsg( 'swl-watchlist-deletions' ) ) . ' ' . implode( ', ', $deletions ); |
| 335 | + } |
| 336 | + |
| 337 | + $html = Html::element( 'b', array(), $property->getLabel() ); |
| 338 | + |
| 339 | + $html .= Html::rawElement( |
| 340 | + 'div', |
| 341 | + array( 'class' => 'swl-prop-div' ), |
| 342 | + implode( '<br />', $lines ) |
| 343 | + ); |
| 344 | + |
256 | 345 | return $html; |
257 | 346 | } |
258 | 347 | |
Index: trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php |
— | — | @@ -1,5 +1,17 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +/** |
| 5 | + * Wrapper around SMWChangeSet that holds extra info such as user and time, |
| 6 | + * and has methods for (un)serialization and database interaction. |
| 7 | + * |
| 8 | + * @since 0.1 |
| 9 | + * |
| 10 | + * @file SWL_ChangeSet.php |
| 11 | + * @ingroup SemanticWatchlist |
| 12 | + * |
| 13 | + * @licence GNU GPL v3 or later |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
4 | 16 | class SWLChangeSet { |
5 | 17 | |
6 | 18 | /** |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php |
— | — | @@ -33,7 +33,12 @@ |
34 | 34 | 'swl-group-page-selection' => 'Pages in ', |
35 | 35 | |
36 | 36 | // Special:SemanticWatchlist |
37 | | - 'swl-wacthlist-position' => "Showing '''$1''' of the last changes starting with '''#$2'''.", |
| 37 | + 'swl-watchlist-position' => "Showing '''$1''' of the last changes starting with '''#$2'''.", |
| 38 | + 'swl-watchlist-insertions' => 'Added:', |
| 39 | + 'swl-watchlist-deletions' => 'Deleted:', |
| 40 | + 'swl-watchlist-pagincontrol' => 'View ($1) ($2)', |
| 41 | + 'swl-watchlist-firstn' => 'First $1', |
| 42 | + 'swl-watchlist-firstn-title' => 'First $1 {{PLURAL:$1|result|results}}', |
38 | 43 | ); |
39 | 44 | |
40 | 45 | /** German (Deutsch) |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php |
— | — | @@ -88,6 +88,15 @@ |
89 | 89 | 'remoteBasePath' => $egSWLScriptPath |
90 | 90 | ); |
91 | 91 | |
| 92 | +$wgResourceModules['ext.swl.watchlist'] = $moduleTemplate + array( |
| 93 | + 'styles' => array( 'specials/ext.swl.watchlist.css' ), |
| 94 | + 'scripts' => array( |
| 95 | + ), |
| 96 | + 'dependencies' => array(), |
| 97 | + 'messages' => array( |
| 98 | + ) |
| 99 | +); |
| 100 | + |
92 | 101 | $wgResourceModules['ext.swl.watchlistconditions'] = $moduleTemplate + array( |
93 | 102 | 'styles' => array( 'specials/ext.swl.watchlistconditions.css' ), |
94 | 103 | 'scripts' => array( |