Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -202,6 +202,7 @@ |
203 | 203 | 'UserArrayFromResult' => 'includes/UserArray.php', |
204 | 204 | 'UserMailer' => 'includes/UserMailer.php', |
205 | 205 | 'UserRightsProxy' => 'includes/UserRightsProxy.php', |
| 206 | + 'WantedQueryPage' => 'includes/QueryPage.php', |
206 | 207 | 'WatchedItem' => 'includes/WatchedItem.php', |
207 | 208 | 'WatchlistEditor' => 'includes/WatchlistEditor.php', |
208 | 209 | 'WebRequest' => 'includes/WebRequest.php', |
Index: trunk/phase3/includes/specials/SpecialWantedtemplates.php |
— | — | @@ -15,20 +15,12 @@ |
16 | 16 | * @copyright Copyright © 2008, Danny B. |
17 | 17 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
18 | 18 | */ |
19 | | -class WantedTemplatesPage extends QueryPage { |
| 19 | +class WantedTemplatesPage extends WantedQueryPage { |
20 | 20 | |
21 | 21 | function getName() { |
22 | 22 | return 'Wantedtemplates'; |
23 | 23 | } |
24 | 24 | |
25 | | - function isExpensive() { |
26 | | - return true; |
27 | | - } |
28 | | - |
29 | | - function isSyndicated() { |
30 | | - return false; |
31 | | - } |
32 | | - |
33 | 25 | function getSQL() { |
34 | 26 | $dbr = wfGetDB( DB_SLAVE ); |
35 | 27 | list( $templatelinks, $page ) = $dbr->tableNamesN( 'templatelinks', 'page' ); |
— | — | @@ -45,55 +37,6 @@ |
46 | 38 | GROUP BY tl_namespace, tl_title |
47 | 39 | "; |
48 | 40 | } |
49 | | - |
50 | | - function sortDescending() { return true; } |
51 | | - |
52 | | - /** |
53 | | - * Fetch user page links and cache their existence |
54 | | - */ |
55 | | - function preprocessResults( $db, $res ) { |
56 | | - $batch = new LinkBatch; |
57 | | - while ( $row = $db->fetchObject( $res ) ) |
58 | | - $batch->add( $row->namespace, $row->title ); |
59 | | - $batch->execute(); |
60 | | - |
61 | | - // Back to start for display |
62 | | - if ( $db->numRows( $res ) > 0 ) |
63 | | - // If there are no rows we get an error seeking. |
64 | | - $db->dataSeek( $res, 0 ); |
65 | | - } |
66 | | - |
67 | | - function formatResult( $skin, $result ) { |
68 | | - global $wgLang, $wgContLang; |
69 | | - |
70 | | - $nt = Title::makeTitle( $result->namespace, $result->title ); |
71 | | - $text = $wgContLang->convert( $nt->getText() ); |
72 | | - |
73 | | - $plink = $this->isCached() ? |
74 | | - $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) : |
75 | | - $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) ); |
76 | | - |
77 | | - return wfSpecialList( |
78 | | - $plink, |
79 | | - $this->makeWlhLink( $nt, $skin, $result ) |
80 | | - ); |
81 | | - } |
82 | | - |
83 | | - /** |
84 | | - * Make a "what links here" link for a given title |
85 | | - * |
86 | | - * @param Title $title Title to make the link for |
87 | | - * @param Skin $skin Skin to use |
88 | | - * @param object $result Result row |
89 | | - * @return string |
90 | | - */ |
91 | | - private function makeWlhLink( $title, $skin, $result ) { |
92 | | - global $wgLang; |
93 | | - $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' ); |
94 | | - $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), |
95 | | - $wgLang->formatNum( $result->value ) ); |
96 | | - return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) ); |
97 | | - } |
98 | 41 | } |
99 | 42 | |
100 | 43 | /** |
Index: trunk/phase3/includes/specials/SpecialWantedfiles.php |
— | — | @@ -13,20 +13,12 @@ |
14 | 14 | * @copyright Copyright © 2008, Soxred93 |
15 | 15 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
16 | 16 | */ |
17 | | -class WantedFilesPage extends QueryPage { |
| 17 | +class WantedFilesPage extends WantedQueryPage { |
18 | 18 | |
19 | 19 | function getName() { |
20 | 20 | return 'Wantedfiles'; |
21 | 21 | } |
22 | 22 | |
23 | | - function isExpensive() { |
24 | | - return true; |
25 | | - } |
26 | | - |
27 | | - function isSyndicated() { |
28 | | - return false; |
29 | | - } |
30 | | - |
31 | 23 | function getSQL() { |
32 | 24 | $dbr = wfGetDB( DB_SLAVE ); |
33 | 25 | list( $imagelinks, $page ) = $dbr->tableNamesN( 'imagelinks', 'page' ); |
— | — | @@ -44,55 +36,6 @@ |
45 | 37 | GROUP BY il_to |
46 | 38 | "; |
47 | 39 | } |
48 | | - |
49 | | - function sortDescending() { return true; } |
50 | | - |
51 | | - /** |
52 | | - * Fetch user page links and cache their existence |
53 | | - */ |
54 | | - function preprocessResults( $db, $res ) { |
55 | | - $batch = new LinkBatch; |
56 | | - while ( $row = $db->fetchObject( $res ) ) |
57 | | - $batch->add( $row->namespace, $row->title ); |
58 | | - $batch->execute(); |
59 | | - |
60 | | - // Back to start for display |
61 | | - if ( $db->numRows( $res ) > 0 ) |
62 | | - // If there are no rows we get an error seeking. |
63 | | - $db->dataSeek( $res, 0 ); |
64 | | - } |
65 | | - |
66 | | - function formatResult( $skin, $result ) { |
67 | | - global $wgLang, $wgContLang; |
68 | | - |
69 | | - $nt = Title::makeTitle( $result->namespace, $result->title ); |
70 | | - $text = $wgContLang->convert( $nt->getText() ); |
71 | | - |
72 | | - $plink = $this->isCached() ? |
73 | | - $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) : |
74 | | - $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) ); |
75 | | - |
76 | | - return wfSpecialList( |
77 | | - $plink, |
78 | | - $this->makeWlhLink( $nt, $skin, $result ) |
79 | | - ); |
80 | | - } |
81 | | - |
82 | | - /** |
83 | | - * Make a "what links here" link for a given title |
84 | | - * |
85 | | - * @param Title $title Title to make the link for |
86 | | - * @param Skin $skin Skin to use |
87 | | - * @param object $result Result row |
88 | | - * @return string |
89 | | - */ |
90 | | - private function makeWlhLink( $title, $skin, $result ) { |
91 | | - global $wgLang; |
92 | | - $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' ); |
93 | | - $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), |
94 | | - $wgLang->formatNum( $result->value ) ); |
95 | | - return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) ); |
96 | | - } |
97 | 40 | } |
98 | 41 | |
99 | 42 | /** |
Index: trunk/phase3/includes/specials/SpecialWantedcategories.php |
— | — | @@ -13,20 +13,12 @@ |
14 | 14 | * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason |
15 | 15 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
16 | 16 | */ |
17 | | -class WantedCategoriesPage extends QueryPage { |
| 17 | +class WantedCategoriesPage extends WantedQueryPage { |
18 | 18 | |
19 | 19 | function getName() { |
20 | 20 | return 'Wantedcategories'; |
21 | 21 | } |
22 | 22 | |
23 | | - function isExpensive() { |
24 | | - return true; |
25 | | - } |
26 | | - |
27 | | - function isSyndicated() { |
28 | | - return false; |
29 | | - } |
30 | | - |
31 | 23 | function getSQL() { |
32 | 24 | $dbr = wfGetDB( DB_SLAVE ); |
33 | 25 | list( $categorylinks, $page ) = $dbr->tableNamesN( 'categorylinks', 'page' ); |
— | — | @@ -45,23 +37,6 @@ |
46 | 38 | "; |
47 | 39 | } |
48 | 40 | |
49 | | - function sortDescending() { return true; } |
50 | | - |
51 | | - /** |
52 | | - * Fetch user page links and cache their existence |
53 | | - */ |
54 | | - function preprocessResults( $db, $res ) { |
55 | | - $batch = new LinkBatch; |
56 | | - while ( $row = $db->fetchObject( $res ) ) |
57 | | - $batch->add( $row->namespace, $row->title ); |
58 | | - $batch->execute(); |
59 | | - |
60 | | - // Back to start for display |
61 | | - if ( $db->numRows( $res ) > 0 ) |
62 | | - // If there are no rows we get an error seeking. |
63 | | - $db->dataSeek( $res, 0 ); |
64 | | - } |
65 | | - |
66 | 41 | function formatResult( $skin, $result ) { |
67 | 42 | global $wgLang, $wgContLang; |
68 | 43 | |
Index: trunk/phase3/includes/specials/SpecialWantedpages.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * implements Special:Wantedpages |
10 | 10 | * @ingroup SpecialPage |
11 | 11 | */ |
12 | | -class WantedPagesPage extends QueryPage { |
| 12 | +class WantedPagesPage extends WantedQueryPage { |
13 | 13 | var $nlinks; |
14 | 14 | |
15 | 15 | function WantedPagesPage( $inc = false, $nlinks = true ) { |
— | — | @@ -20,11 +20,6 @@ |
21 | 21 | return 'Wantedpages'; |
22 | 22 | } |
23 | 23 | |
24 | | - function isExpensive() { |
25 | | - return true; |
26 | | - } |
27 | | - function isSyndicated() { return false; } |
28 | | - |
29 | 24 | function getSQL() { |
30 | 25 | global $wgWantedPagesThreshold; |
31 | 26 | $count = $wgWantedPagesThreshold - 1; |
— | — | @@ -49,66 +44,6 @@ |
50 | 45 | wfRunHooks( 'WantedPages::getSQL', array( &$this, &$sql ) ); |
51 | 46 | return $sql; |
52 | 47 | } |
53 | | - |
54 | | - /** |
55 | | - * Cache page existence for performance |
56 | | - */ |
57 | | - function preprocessResults( $db, $res ) { |
58 | | - $batch = new LinkBatch; |
59 | | - while ( $row = $db->fetchObject( $res ) ) |
60 | | - $batch->add( $row->namespace, $row->title ); |
61 | | - $batch->execute(); |
62 | | - |
63 | | - // Back to start for display |
64 | | - if ( $db->numRows( $res ) > 0 ) |
65 | | - // If there are no rows we get an error seeking. |
66 | | - $db->dataSeek( $res, 0 ); |
67 | | - } |
68 | | - |
69 | | - /** |
70 | | - * Format an individual result |
71 | | - * |
72 | | - * @param $skin Skin to use for UI elements |
73 | | - * @param $result Result row |
74 | | - * @return string |
75 | | - */ |
76 | | - public function formatResult( $skin, $result ) { |
77 | | - $title = Title::makeTitleSafe( $result->namespace, $result->title ); |
78 | | - if( $title instanceof Title ) { |
79 | | - if( $this->isCached() ) { |
80 | | - $pageLink = $title->exists() |
81 | | - ? '<s>' . $skin->makeLinkObj( $title ) . '</s>' |
82 | | - : $skin->makeBrokenLinkObj( $title ); |
83 | | - } else { |
84 | | - $pageLink = $skin->makeBrokenLinkObj( $title ); |
85 | | - } |
86 | | - return wfSpecialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) ); |
87 | | - } else { |
88 | | - $tsafe = htmlspecialchars( $result->title ); |
89 | | - return wfMsg( 'wantedpages-badtitle', $tsafe ); |
90 | | - } |
91 | | - } |
92 | | - |
93 | | - /** |
94 | | - * Make a "what links here" link for a specified result if required |
95 | | - * |
96 | | - * @param $title Title to make the link for |
97 | | - * @param $skin Skin to use |
98 | | - * @param $result Result row |
99 | | - * @return string |
100 | | - */ |
101 | | - private function makeWlhLink( $title, $skin, $result ) { |
102 | | - global $wgLang; |
103 | | - if( $this->nlinks ) { |
104 | | - $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' ); |
105 | | - $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), |
106 | | - $wgLang->formatNum( $result->value ) ); |
107 | | - return $skin->makeKnownLinkObj( $wlh, $label, 'target=' . $title->getPrefixedUrl() ); |
108 | | - } else { |
109 | | - return null; |
110 | | - } |
111 | | - } |
112 | | - |
113 | 48 | } |
114 | 49 | |
115 | 50 | /** |
Index: trunk/phase3/includes/QueryPage.php |
— | — | @@ -535,3 +535,73 @@ |
536 | 536 | return $title->getFullURL(); |
537 | 537 | } |
538 | 538 | } |
| 539 | + |
| 540 | +/** |
| 541 | + * Class definition for a wanted query page like |
| 542 | + * WantedPages, WantedTemplates, etc |
| 543 | + */ |
| 544 | +abstract class WantedQueryPage extends QueryPage { |
| 545 | + |
| 546 | + function isExpensive() { |
| 547 | + return true; |
| 548 | + } |
| 549 | + |
| 550 | + function isSyndicated() { |
| 551 | + return false; |
| 552 | + } |
| 553 | + |
| 554 | + /** |
| 555 | + * Cache page existence for performance |
| 556 | + */ |
| 557 | + function preprocessResults( $db, $res ) { |
| 558 | + $batch = new LinkBatch; |
| 559 | + while ( $row = $db->fetchObject( $res ) ) |
| 560 | + $batch->add( $row->namespace, $row->title ); |
| 561 | + $batch->execute(); |
| 562 | + |
| 563 | + // Back to start for display |
| 564 | + if ( $db->numRows( $res ) > 0 ) |
| 565 | + // If there are no rows we get an error seeking. |
| 566 | + $db->dataSeek( $res, 0 ); |
| 567 | + } |
| 568 | + |
| 569 | + /** |
| 570 | + * Format an individual result |
| 571 | + * |
| 572 | + * @param $skin Skin to use for UI elements |
| 573 | + * @param $result Result row |
| 574 | + * @return string |
| 575 | + */ |
| 576 | + public function formatResult( $skin, $result ) { |
| 577 | + $title = Title::makeTitleSafe( $result->namespace, $result->title ); |
| 578 | + if( $title instanceof Title ) { |
| 579 | + if( $this->isCached() ) { |
| 580 | + $pageLink = $title->exists() |
| 581 | + ? '<s>' . $skin->makeLinkObj( $title ) . '</s>' |
| 582 | + : $skin->makeBrokenLinkObj( $title ); |
| 583 | + } else { |
| 584 | + $pageLink = $skin->makeBrokenLinkObj( $title ); |
| 585 | + } |
| 586 | + return wfSpecialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) ); |
| 587 | + } else { |
| 588 | + $tsafe = htmlspecialchars( $result->title ); |
| 589 | + return wfMsg( 'wantedpages-badtitle', $tsafe ); |
| 590 | + } |
| 591 | + } |
| 592 | + |
| 593 | + /** |
| 594 | + * Make a "what links here" link for a given title |
| 595 | + * |
| 596 | + * @param Title $title Title to make the link for |
| 597 | + * @param Skin $skin Skin to use |
| 598 | + * @param object $result Result row |
| 599 | + * @return string |
| 600 | + */ |
| 601 | + private function makeWlhLink( $title, $skin, $result ) { |
| 602 | + global $wgLang; |
| 603 | + $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' ); |
| 604 | + $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), |
| 605 | + $wgLang->formatNum( $result->value ) ); |
| 606 | + return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) ); |
| 607 | + } |
| 608 | +} |