* New WantedQueryPage class for all of these Wanted*s, moved some identical methods to it
* Removed sortDescending() because it was already defined as returning true @ QueryPage, no need to duplicate
'UserArrayFromResult' => 'includes/UserArray.php',
'UserMailer' => 'includes/UserMailer.php',
'UserRightsProxy' => 'includes/UserRightsProxy.php',
+ 'WantedQueryPage' => 'includes/QueryPage.php',
'WatchedItem' => 'includes/WatchedItem.php',
'WatchlistEditor' => 'includes/WatchlistEditor.php',
'WebRequest' => 'includes/WebRequest.php',
return $title->getFullURL();
}
}
+
+/**
+ * Class definition for a wanted query page like
+ * WantedPages, WantedTemplates, etc
+ */
+abstract class WantedQueryPage extends QueryPage {
+
+ function isExpensive() {
+ return true;
+ }
+
+ function isSyndicated() {
+ return false;
+ }
+
+ /**
+ * Cache page existence for performance
+ */
+ function preprocessResults( $db, $res ) {
+ $batch = new LinkBatch;
+ while ( $row = $db->fetchObject( $res ) )
+ $batch->add( $row->namespace, $row->title );
+ $batch->execute();
+
+ // Back to start for display
+ if ( $db->numRows( $res ) > 0 )
+ // If there are no rows we get an error seeking.
+ $db->dataSeek( $res, 0 );
+ }
+
+ /**
+ * Format an individual result
+ *
+ * @param $skin Skin to use for UI elements
+ * @param $result Result row
+ * @return string
+ */
+ public function formatResult( $skin, $result ) {
+ $title = Title::makeTitleSafe( $result->namespace, $result->title );
+ if( $title instanceof Title ) {
+ if( $this->isCached() ) {
+ $pageLink = $title->exists()
+ ? '<s>' . $skin->makeLinkObj( $title ) . '</s>'
+ : $skin->makeBrokenLinkObj( $title );
+ } else {
+ $pageLink = $skin->makeBrokenLinkObj( $title );
+ }
+ return wfSpecialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) );
+ } else {
+ $tsafe = htmlspecialchars( $result->title );
+ return wfMsg( 'wantedpages-badtitle', $tsafe );
+ }
+ }
+
+ /**
+ * Make a "what links here" link for a given title
+ *
+ * @param Title $title Title to make the link for
+ * @param Skin $skin Skin to use
+ * @param object $result Result row
+ * @return string
+ */
+ private function makeWlhLink( $title, $skin, $result ) {
+ global $wgLang;
+ $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
+ $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
+ $wgLang->formatNum( $result->value ) );
+ return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
+ }
+}
* @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
*/
-class WantedCategoriesPage extends QueryPage {
+class WantedCategoriesPage extends WantedQueryPage {
function getName() {
return 'Wantedcategories';
}
- function isExpensive() {
- return true;
- }
-
- function isSyndicated() {
- return false;
- }
-
function getSQL() {
$dbr = wfGetDB( DB_SLAVE );
list( $categorylinks, $page ) = $dbr->tableNamesN( 'categorylinks', 'page' );
";
}
- function sortDescending() { return true; }
-
- /**
- * Fetch user page links and cache their existence
- */
- function preprocessResults( $db, $res ) {
- $batch = new LinkBatch;
- while ( $row = $db->fetchObject( $res ) )
- $batch->add( $row->namespace, $row->title );
- $batch->execute();
-
- // Back to start for display
- if ( $db->numRows( $res ) > 0 )
- // If there are no rows we get an error seeking.
- $db->dataSeek( $res, 0 );
- }
-
function formatResult( $skin, $result ) {
global $wgLang, $wgContLang;
* @copyright Copyright © 2008, Soxred93
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
*/
-class WantedFilesPage extends QueryPage {
+class WantedFilesPage extends WantedQueryPage {
function getName() {
return 'Wantedfiles';
}
- function isExpensive() {
- return true;
- }
-
- function isSyndicated() {
- return false;
- }
-
function getSQL() {
$dbr = wfGetDB( DB_SLAVE );
list( $imagelinks, $page ) = $dbr->tableNamesN( 'imagelinks', 'page' );
GROUP BY il_to
";
}
-
- function sortDescending() { return true; }
-
- /**
- * Fetch user page links and cache their existence
- */
- function preprocessResults( $db, $res ) {
- $batch = new LinkBatch;
- while ( $row = $db->fetchObject( $res ) )
- $batch->add( $row->namespace, $row->title );
- $batch->execute();
-
- // Back to start for display
- if ( $db->numRows( $res ) > 0 )
- // If there are no rows we get an error seeking.
- $db->dataSeek( $res, 0 );
- }
-
- function formatResult( $skin, $result ) {
- global $wgLang, $wgContLang;
-
- $nt = Title::makeTitle( $result->namespace, $result->title );
- $text = $wgContLang->convert( $nt->getText() );
-
- $plink = $this->isCached() ?
- $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) :
- $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
-
- return wfSpecialList(
- $plink,
- $this->makeWlhLink( $nt, $skin, $result )
- );
- }
-
- /**
- * Make a "what links here" link for a given title
- *
- * @param Title $title Title to make the link for
- * @param Skin $skin Skin to use
- * @param object $result Result row
- * @return string
- */
- private function makeWlhLink( $title, $skin, $result ) {
- global $wgLang;
- $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
- $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
- $wgLang->formatNum( $result->value ) );
- return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
- }
}
/**
* implements Special:Wantedpages
* @ingroup SpecialPage
*/
-class WantedPagesPage extends QueryPage {
+class WantedPagesPage extends WantedQueryPage {
var $nlinks;
function WantedPagesPage( $inc = false, $nlinks = true ) {
return 'Wantedpages';
}
- function isExpensive() {
- return true;
- }
- function isSyndicated() { return false; }
-
function getSQL() {
global $wgWantedPagesThreshold;
$count = $wgWantedPagesThreshold - 1;
wfRunHooks( 'WantedPages::getSQL', array( &$this, &$sql ) );
return $sql;
}
-
- /**
- * Cache page existence for performance
- */
- function preprocessResults( $db, $res ) {
- $batch = new LinkBatch;
- while ( $row = $db->fetchObject( $res ) )
- $batch->add( $row->namespace, $row->title );
- $batch->execute();
-
- // Back to start for display
- if ( $db->numRows( $res ) > 0 )
- // If there are no rows we get an error seeking.
- $db->dataSeek( $res, 0 );
- }
-
- /**
- * Format an individual result
- *
- * @param $skin Skin to use for UI elements
- * @param $result Result row
- * @return string
- */
- public function formatResult( $skin, $result ) {
- $title = Title::makeTitleSafe( $result->namespace, $result->title );
- if( $title instanceof Title ) {
- if( $this->isCached() ) {
- $pageLink = $title->exists()
- ? '<s>' . $skin->makeLinkObj( $title ) . '</s>'
- : $skin->makeBrokenLinkObj( $title );
- } else {
- $pageLink = $skin->makeBrokenLinkObj( $title );
- }
- return wfSpecialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) );
- } else {
- $tsafe = htmlspecialchars( $result->title );
- return wfMsg( 'wantedpages-badtitle', $tsafe );
- }
- }
-
- /**
- * Make a "what links here" link for a specified result if required
- *
- * @param $title Title to make the link for
- * @param $skin Skin to use
- * @param $result Result row
- * @return string
- */
- private function makeWlhLink( $title, $skin, $result ) {
- global $wgLang;
- if( $this->nlinks ) {
- $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
- $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
- $wgLang->formatNum( $result->value ) );
- return $skin->makeKnownLinkObj( $wlh, $label, 'target=' . $title->getPrefixedUrl() );
- } else {
- return null;
- }
- }
-
}
/**
* @copyright Copyright © 2008, Danny B.
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
*/
-class WantedTemplatesPage extends QueryPage {
+class WantedTemplatesPage extends WantedQueryPage {
function getName() {
return 'Wantedtemplates';
}
- function isExpensive() {
- return true;
- }
-
- function isSyndicated() {
- return false;
- }
-
function getSQL() {
$dbr = wfGetDB( DB_SLAVE );
list( $templatelinks, $page ) = $dbr->tableNamesN( 'templatelinks', 'page' );
GROUP BY tl_namespace, tl_title
";
}
-
- function sortDescending() { return true; }
-
- /**
- * Fetch user page links and cache their existence
- */
- function preprocessResults( $db, $res ) {
- $batch = new LinkBatch;
- while ( $row = $db->fetchObject( $res ) )
- $batch->add( $row->namespace, $row->title );
- $batch->execute();
-
- // Back to start for display
- if ( $db->numRows( $res ) > 0 )
- // If there are no rows we get an error seeking.
- $db->dataSeek( $res, 0 );
- }
-
- function formatResult( $skin, $result ) {
- global $wgLang, $wgContLang;
-
- $nt = Title::makeTitle( $result->namespace, $result->title );
- $text = $wgContLang->convert( $nt->getText() );
-
- $plink = $this->isCached() ?
- $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) :
- $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
-
- return wfSpecialList(
- $plink,
- $this->makeWlhLink( $nt, $skin, $result )
- );
- }
-
- /**
- * Make a "what links here" link for a given title
- *
- * @param Title $title Title to make the link for
- * @param Skin $skin Skin to use
- * @param object $result Result row
- * @return string
- */
- private function makeWlhLink( $title, $skin, $result ) {
- global $wgLang;
- $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
- $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
- $wgLang->formatNum( $result->value ) );
- return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
- }
}
/**