Index: trunk/extensions/Favorites/FavParser.php |
— | — | @@ -2,58 +2,66 @@ |
3 | 3 | |
4 | 4 | class FavParser { |
5 | 5 | |
6 | | -function wfSpecialFavoritelist() { |
| 6 | + function wfSpecialFavoritelist($argv, $parser) { |
| 7 | + |
| 8 | + global $wgUser, $wgOut, $wgLang, $wgRequest; |
| 9 | + global $wgRCShowFavoritingUsers, $wgEnotifFavoritelist, $wgShowUpdatedMarker; |
| 10 | + $output = ''; |
7 | 11 | |
8 | | - global $wgUser, $wgOut, $wgLang, $wgRequest; |
9 | | - global $wgRCShowFavoritingUsers, $wgEnotifFavoritelist, $wgShowUpdatedMarker; |
10 | | - $output = ''; |
11 | | - |
12 | | - $skin = $wgUser->getSkin(); |
13 | | - $specialTitle = SpecialPage::getTitleFor( 'Favoritelist' ); |
14 | | - //$wgOut->setRobotPolicy( 'noindex,nofollow' ); |
15 | | - |
16 | | - # Anons don't get a favoritelist |
17 | | - if( $wgUser->isAnon() ) { |
18 | | - //$wgOut->setPageTitle( wfMsg( 'favoritenologin' ) ); |
19 | | - $llink = $skin->linkKnown( |
20 | | - SpecialPage::getTitleFor( 'Userlogin' ), |
21 | | - wfMsg( 'loginreqlink' ), |
22 | | - array(), |
23 | | - array( 'returnto' => $specialTitle->getPrefixedText() ) |
24 | | - ); |
25 | | - $output = wfMsgHtml( 'favoritelistanontext', $llink ) ; |
| 12 | + $skin = $wgUser->getSkin(); |
| 13 | + $specialTitle = SpecialPage::getTitleFor( 'Favoritelist' ); |
| 14 | + //$wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 15 | + |
| 16 | + # Anons don't get a favoritelist |
| 17 | + if( $wgUser->isAnon() ) { |
| 18 | + //$wgOut->setPageTitle( wfMsg( 'favoritenologin' ) ); |
| 19 | + $llink = $skin->linkKnown( |
| 20 | + SpecialPage::getTitleFor( 'Userlogin' ), |
| 21 | + wfMsg( 'loginreqlink' ), |
| 22 | + array(), |
| 23 | + array( 'returnto' => $specialTitle->getPrefixedText() ) |
| 24 | + ); |
| 25 | + $output = wfMsgHtml( 'favoritelistanontext', $llink ) ; |
| 26 | + |
| 27 | + |
| 28 | + return $output ; |
| 29 | + |
| 30 | + } |
| 31 | + |
| 32 | + $output = $this->viewFavList($wgUser, $output, $wgRequest); |
| 33 | + if ( array_key_exists('editlink', $argv) && $argv['editlink']) { |
| 34 | + # Add an edit link if you want it: |
| 35 | + $output .= "<div id='contentSub'><br>" . |
| 36 | + $skin->link( |
| 37 | + SpecialPage::getTitleFor( 'Favoritelist', 'edit' ), |
| 38 | + wfMsgHtml( "favoritelisttools-edit" ), |
| 39 | + array(), |
| 40 | + array(), |
| 41 | + array( 'known', 'noclasses' ) |
| 42 | + ) . "</div>"; |
| 43 | + } |
| 44 | + |
26 | 45 | return $output ; |
27 | | - |
28 | 46 | } |
29 | 47 | |
30 | | - |
31 | | - |
32 | 48 | |
33 | | - $output = $this->viewFavList($wgUser, $output, $wgRequest); |
34 | | - return $output ; |
35 | | -} |
36 | | - |
37 | | - |
38 | 49 | private function viewFavList ($user, $output, $request) { |
39 | | - global $wgUser, $wgOut, $wgLang, $wgRequest; |
40 | | - $uid = $wgUser->getId(); |
41 | | - $output = $this->showNormalForm( $output, $user ); |
42 | | - |
43 | | - $dbr = wfGetDB( DB_SLAVE, 'favoritelist' ); |
| 50 | + global $wgUser, $wgOut, $wgLang, $wgRequest; |
| 51 | + $uid = $wgUser->getId(); |
| 52 | + $output = $this->showNormalForm( $output, $user ); |
44 | 53 | |
45 | | - |
46 | | - $favoritelistCount = $dbr->selectField( 'favoritelist', 'COUNT(*)', |
47 | | - array( 'fl_user' => $uid ), __METHOD__ ); |
48 | | - // Adjust for page X, talk:page X, which are both stored separately, |
49 | | - // but treated together |
50 | | - $nitems = floor($favoritelistCount); |
51 | | - |
52 | | - if( $nitems == 0 ) { |
53 | | - $output = wfmsg('nofavoritelist'); |
| 54 | + $dbr = wfGetDB( DB_SLAVE, 'favoritelist' ); |
54 | 55 | |
| 56 | + $favoritelistCount = $dbr->selectField( 'favoritelist', 'COUNT(*)', |
| 57 | + array( 'fl_user' => $uid ), __METHOD__ ); |
| 58 | + $nitems = floor($favoritelistCount); |
| 59 | + |
| 60 | + if( $nitems == 0 ) { |
| 61 | + $output = wfmsg('nofavoritelist'); |
| 62 | + |
| 63 | + } |
| 64 | + return $output; |
55 | 65 | } |
56 | | - return $output; |
57 | | -} |
58 | 66 | |
59 | 67 | |
60 | 68 | /** |
— | — | @@ -193,9 +201,10 @@ |
194 | 202 | * @param $user User |
195 | 203 | */ |
196 | 204 | private function showNormalForm( $output, $user ) { |
197 | | - global $wgUser; |
| 205 | + global $wgUser, $wgOut; |
| 206 | + $skin = $wgUser->getSkin(); |
198 | 207 | if( ( $count = $this->showItemCount( $output, $user ) ) > 0 ) { |
199 | | - $form = $this->buildRemoveList( $user, $wgUser->getSkin() ); |
| 208 | + $form = $this->buildRemoveList( $user, $skin ); |
200 | 209 | $output .= $form ; |
201 | 210 | return $output; |
202 | 211 | } |
— | — | @@ -209,15 +218,14 @@ |
210 | 219 | */ |
211 | 220 | private function buildRemoveList( $user, $skin ) { |
212 | 221 | $list = ""; |
| 222 | + $list .= "<ul>\n"; |
213 | 223 | foreach( $this->getFavoritelistInfo( $user ) as $namespace => $pages ) { |
214 | | - |
215 | | - $list .= "<ul>\n"; |
216 | 224 | foreach( $pages as $dbkey => $redirect ) { |
217 | 225 | $title = Title::makeTitleSafe( $namespace, $dbkey ); |
218 | 226 | $list .= $this->buildRemoveLine( $title, $redirect, $skin ); |
219 | 227 | } |
220 | | - $list .= "</ul>\n"; |
221 | 228 | } |
| 229 | + $list .= "</ul>\n"; |
222 | 230 | return $list; |
223 | 231 | } |
224 | 232 | |
Index: trunk/extensions/Favorites/SpecialFavoritelist.php |
— | — | @@ -449,12 +449,16 @@ |
450 | 450 | */ |
451 | 451 | private function buildRemoveLine( $title, $redirect, $skin ) { |
452 | 452 | global $wgLang; |
453 | | - |
| 453 | + # In case the user adds something unusual to their list using the raw editor |
| 454 | + # We moved the Tools array completely into the "if( $title->exists() )" section. |
| 455 | + $showlinks=false; |
454 | 456 | $link = $skin->link( $title ); |
455 | 457 | if( $redirect ) |
456 | 458 | $link = '<span class="favoritelistredir">' . $link . '</span>'; |
457 | | - $tools[] = $skin->link( $title->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) ); |
| 459 | + |
458 | 460 | if( $title->exists() ) { |
| 461 | + $showlinks = true; |
| 462 | + $tools[] = $skin->link( $title->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) ); |
459 | 463 | $tools[] = $skin->link( |
460 | 464 | $title, |
461 | 465 | wfMsgHtml( 'history_short' ), |
— | — | @@ -472,10 +476,15 @@ |
473 | 477 | array( 'known', 'noclasses' ) |
474 | 478 | ); |
475 | 479 | } |
476 | | - return "<li>" |
477 | | - //. Xml::check( 'titles[]', false, array( 'value' => $title->getPrefixedText() ) ) |
| 480 | + |
| 481 | + if ($showlinks) { |
| 482 | + return "<li>" |
478 | 483 | . $link . " (" . $wgLang->pipeList( $tools ) . ")" . "</li>\n"; |
| 484 | + } else { |
| 485 | + return "<li>" |
| 486 | + . $link . "</li>\n"; |
479 | 487 | } |
| 488 | + } |
480 | 489 | |
481 | 490 | /** |
482 | 491 | * Show a form for editing the favoritelist in "raw" mode |
Index: trunk/extensions/Favorites/favorites.i18n.php |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | 'favoritelistall2' => 'all', |
62 | 62 | |
63 | 63 | # Favoritelist editor |
64 | | -'favoritelistedit-numitems' => 'Your favorites contain {{PLURAL:$1|1 title|$1 titles}}, excluding talk pages.', |
| 64 | +'favoritelistedit-numitems' => 'Your favorites contain {{PLURAL:$1|1 title|$1 titles}}.', |
65 | 65 | 'favoritelistedit-noitems' => 'Your favorites contain no titles.', |
66 | 66 | 'favoritelistedit-normal-title' => 'Edit favorites', |
67 | 67 | 'favoritelistedit-normal-legend' => 'Remove titles from favorites', |
— | — | @@ -120,7 +120,7 @@ |
121 | 121 | 'tooltip-ca-unfavorite' => 'Entferne diese Seite von deiner Favoritenliste', |
122 | 122 | 'tooltip-favorite' => 'Füge diese Seite zu deiner Favoritenliste hinzu', |
123 | 123 | 'favoritelistall2' => 'alle', |
124 | | - 'favoritelistedit-numitems' => 'Deine Favoritenliste enthält {{PLURAL:$1|einen Eintrag |$1 Einträge}}. Die Diskussionsseiten wurden dabei nicht mitgezählt.', |
| 124 | + 'favoritelistedit-numitems' => 'Deine Favoritenliste enthält {{PLURAL:$1|einen Eintrag |$1 Einträge}}.', |
125 | 125 | 'favoritelistedit-noitems' => 'Deine Favoritenliste enthält keine Einträge.', |
126 | 126 | 'favoritelistedit-normal-title' => 'Favoritenliste bearbeiten', |
127 | 127 | 'favoritelistedit-normal-legend' => 'Einträge aus der Favoritenliste entfernen', |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | 'tooltip-ca-favorite' => 'Fügen Sie diese Seite zu Ihrer Favoritenliste hinzu', |
160 | 160 | 'tooltip-ca-unfavorite' => 'Entfernen Sie diese Seite von Ihrer Favoritenliste', |
161 | 161 | 'tooltip-favorite' => 'Fügen Sie diese Seite zu Ihrer Favoritenliste hinzu', |
162 | | - 'favoritelistedit-numitems' => 'Ihre Favoritenliste enthält {{PLURAL:$1|einen Eintrag|$1 Einträge}}. Die Diskussionsseiten wurden dabei nicht mitgezählt.', |
| 162 | + 'favoritelistedit-numitems' => 'Ihre Favoritenliste enthält {{PLURAL:$1|einen Eintrag|$1 Einträge}}.', |
163 | 163 | 'favoritelistedit-noitems' => 'Ihre Favoritenliste enthält keine Einträge.', |
164 | 164 | 'favoritelistedit-normal-explain' => 'Dies sind die Einträge Ihrer Favoritenliste. |
165 | 165 | Um Einträge zu entfernen, markieren Sie die Kästchen neben den Einträgen und klicken Sie am Ende der Seite auf „{{int:Favoritelistedit-normal-submit}}“. |
— | — | @@ -233,7 +233,7 @@ |
234 | 234 | 'tooltip-ca-unfavorite' => 'Отстрани ја страницава од бендисаните', |
235 | 235 | 'tooltip-favorite' => 'Додај ја страницава во бендисаните', |
236 | 236 | 'favoritelistall2' => 'сите', |
237 | | - 'favoritelistedit-numitems' => 'Во бендисаните има {{PLURAL:$1|1 наслов|$1 наслови}}, без страниците за разговор.', |
| 237 | + 'favoritelistedit-numitems' => 'Во бендисаните има {{PLURAL:$1|1 наслов|$1 наслови}}.', |
238 | 238 | 'favoritelistedit-noitems' => 'Немате наслови во бендисаните.', |
239 | 239 | 'favoritelistedit-normal-title' => 'Уреди бендисани', |
240 | 240 | 'favoritelistedit-normal-legend' => 'Отстрани наслови од бендисаните', |
— | — | @@ -320,7 +320,7 @@ |
321 | 321 | 'tooltip-ca-unfavorite' => 'Remover esta página das páginas preferidas', |
322 | 322 | 'tooltip-favorite' => 'Adicionar esta página às suas preferidas', |
323 | 323 | 'favoritelistall2' => 'todas', |
324 | | - 'favoritelistedit-numitems' => 'A sua lista de páginas preferidas contém {{PLURAL:$1|uma página|$1 páginas}}, excluindo páginas de discussão.', |
| 324 | + 'favoritelistedit-numitems' => 'A sua lista de páginas preferidas contém {{PLURAL:$1|uma página|$1 páginas}}.', |
325 | 325 | 'favoritelistedit-noitems' => 'A sua lista de página preferidas está vazia.', |
326 | 326 | 'favoritelistedit-normal-title' => 'Editar a lista de preferidas', |
327 | 327 | 'favoritelistedit-normal-legend' => 'Remover páginas das preferidas', |
Index: trunk/extensions/Favorites/FavoritedItem.php |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | */ |
91 | 91 | public static function duplicateEntries( $ot, $nt ) { |
92 | 92 | FavoritedItem::doDuplicateEntries( $ot->getSubjectPage(), $nt->getSubjectPage() ); |
93 | | - FavoritedItem::doDuplicateEntries( $ot->getTalkPage(), $nt->getTalkPage() ); |
| 93 | + //FavoritedItem::doDuplicateEntries( $ot->getTalkPage(), $nt->getTalkPage() ); |
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
Index: trunk/extensions/Favorites/FavoritelistEditor.php |
— | — | @@ -150,7 +150,7 @@ |
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | | - * Count the number of titles on a user's favoritelist, excluding talk pages |
| 154 | + * Count the number of titles on a user's favoritelist |
155 | 155 | * |
156 | 156 | * @param $user User |
157 | 157 | * @return int |
— | — | @@ -159,11 +159,11 @@ |
160 | 160 | $dbr = wfGetDB( DB_MASTER ); |
161 | 161 | $res = $dbr->select( 'favoritelist', 'COUNT(*) AS count', array( 'fl_user' => $user->getId() ), __METHOD__ ); |
162 | 162 | $row = $dbr->fetchObject( $res ); |
163 | | - return ceil( $row->count / 2 ); // Paranoia |
| 163 | + return ceil( $row->count); |
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
167 | | - * Prepare a list of titles on a user's favoritelist (excluding talk pages) |
| 167 | + * Prepare a list of titles on a user's favoritelist |
168 | 168 | * and return an array of (prefixed) strings |
169 | 169 | * |
170 | 170 | * @param $user User |
— | — | @@ -192,7 +192,7 @@ |
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | | - * Get a list of titles on a user's favoritelist, excluding talk pages, |
| 196 | + * Get a list of titles on a user's favoritelist, |
197 | 197 | * and return as a two-dimensional array with namespace, title and |
198 | 198 | * redirect status |
199 | 199 | * |
— | — | @@ -220,7 +220,7 @@ |
221 | 221 | $cache->addBadLinkObj( $title ); |
222 | 222 | } |
223 | 223 | // Ignore non-talk |
224 | | - if( !$title->isTalkPage() ) |
| 224 | + //if( !$title->isTalkPage() ) |
225 | 225 | $titles[$row->fl_namespace][$row->fl_title] = $row->page_is_redirect; |
226 | 226 | } |
227 | 227 | } |
— | — | @@ -274,12 +274,6 @@ |
275 | 275 | if( $title instanceof Title ) { |
276 | 276 | $rows[] = array( |
277 | 277 | 'fl_user' => $user->getId(), |
278 | | - 'fl_namespace' => ( $title->getNamespace() & ~1 ), |
279 | | - 'fl_title' => $title->getDBkey(), |
280 | | - 'fl_notificationtimestamp' => null, |
281 | | - ); |
282 | | - $rows[] = array( |
283 | | - 'fl_user' => $user->getId(), |
284 | 278 | 'fl_namespace' => ( $title->getNamespace() | 1 ), |
285 | 279 | 'fl_title' => $title->getDBkey(), |
286 | 280 | 'fl_notificationtimestamp' => null, |
— | — | @@ -308,15 +302,6 @@ |
309 | 303 | 'favoritelist', |
310 | 304 | array( |
311 | 305 | 'fl_user' => $user->getId(), |
312 | | - 'fl_namespace' => ( $title->getNamespace() & ~1 ), |
313 | | - 'fl_title' => $title->getDBkey(), |
314 | | - ), |
315 | | - __METHOD__ |
316 | | - ); |
317 | | - $dbw->delete( |
318 | | - 'favoritelist', |
319 | | - array( |
320 | | - 'fl_user' => $user->getId(), |
321 | 306 | 'fl_namespace' => ( $title->getNamespace() | 1 ), |
322 | 307 | 'fl_title' => $title->getDBkey(), |
323 | 308 | ), |
— | — | @@ -370,12 +355,12 @@ |
371 | 356 | $list .= $skin->makeHeadLine( 2, ">", $anchor, $heading, "" ); |
372 | 357 | $toc .= $skin->tocLine( $anchor, $heading, $tocLength, 1 ) . $skin->tocLineEnd(); |
373 | 358 | |
374 | | - $list .= "<ul>\n"; |
| 359 | + $list .= "\n"; |
375 | 360 | foreach( $pages as $dbkey => $redirect ) { |
376 | 361 | $title = Title::makeTitleSafe( $namespace, $dbkey ); |
377 | 362 | $list .= $this->buildRemoveLine( $title, $redirect, $skin ); |
378 | 363 | } |
379 | | - $list .= "</ul>\n"; |
| 364 | + $list .= "\n"; |
380 | 365 | } |
381 | 366 | // ISSUE: omit the TOC if the total number of titles is low? |
382 | 367 | if( $tocLength > 1 ) { |
— | — | @@ -407,12 +392,15 @@ |
408 | 393 | */ |
409 | 394 | private function buildRemoveLine( $title, $redirect, $skin ) { |
410 | 395 | global $wgLang; |
411 | | - |
| 396 | + # In case the user adds something unusual to their list using the raw editor |
| 397 | + # We moved the Tools array completely into the "if( $title->exists() )" section. |
| 398 | + $showlinks=false; |
412 | 399 | $link = $skin->link( $title ); |
413 | 400 | if( $redirect ) |
414 | 401 | $link = '<span class="favoritelistredir">' . $link . '</span>'; |
415 | | - $tools[] = $skin->link( $title->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) ); |
416 | 402 | if( $title->exists() ) { |
| 403 | + $showlinks = true; |
| 404 | + $tools[] = $skin->link( $title->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) ); |
417 | 405 | $tools[] = $skin->link( |
418 | 406 | $title, |
419 | 407 | wfMsgHtml( 'history_short' ), |
— | — | @@ -430,10 +418,18 @@ |
431 | 419 | array( 'known', 'noclasses' ) |
432 | 420 | ); |
433 | 421 | } |
434 | | - return "<li>" |
435 | | - . Xml::check( 'titles[]', false, array( 'value' => $title->getPrefixedText() ) ) |
436 | | - . $link . " (" . $wgLang->pipeList( $tools ) . ")" . "</li>\n"; |
| 422 | + |
| 423 | + if ($showlinks) { |
| 424 | + return |
| 425 | + Xml::check( 'titles[]', false, array( 'value' => $title->getPrefixedText() ) ) |
| 426 | + . $link . " (" . $wgLang->pipeList( $tools ) . ")" . "\n<br>"; |
| 427 | + } else { |
| 428 | + return |
| 429 | + Xml::check( 'titles[]', false, array( 'value' => $title->getPrefixedText() ) ) |
| 430 | + . $link . "\n<br>"; |
437 | 431 | } |
| 432 | + |
| 433 | + } |
438 | 434 | |
439 | 435 | /** |
440 | 436 | * Show a form for editing the favoritelist in "raw" mode |
Index: trunk/extensions/Favorites/Favorites.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | 'name' => 'Favorites', |
24 | 24 | 'author' => 'Jeremy Lemley', |
25 | 25 | 'descriptionmsg' => 'favorites-desc', |
26 | | - 'version' => '0.1.0', |
| 26 | + 'version' => '0.1.4', |
27 | 27 | 'url' => "http://www.mediawiki.org/wiki/Extension:Favorites", |
28 | 28 | ); |
29 | 29 | |
— | — | @@ -124,10 +124,10 @@ |
125 | 125 | # The parser function itself |
126 | 126 | # The input parameters are wikitext with templates expanded |
127 | 127 | # The output should be wikitext too |
128 | | - $output = "Parser Output goes here."; |
| 128 | + //$output = "Parser Output goes here."; |
129 | 129 | |
130 | 130 | $favParse = new FavParser(); |
131 | | - $output = $favParse->wfSpecialFavoritelist(); |
| 131 | + $output = $favParse->wfSpecialFavoritelist($argv, $parser); |
132 | 132 | $parser->disableCache(); |
133 | 133 | return $output; |
134 | 134 | |