As requested in MediaZilla bug 6, this patch allows for wanted pages to be filtered by keyword.
Could someone please review and/or commit this.
Thanks, Andrew
Index: includes/SpecialWantedpages.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/includes/SpecialWantedpages.php,v retrieving revision 1.17 diff -b -u -d -r1.17 SpecialWantedpages.php --- includes/SpecialWantedpages.php 13 Nov 2004 20:40:28 -0000 1.17 +++ includes/SpecialWantedpages.php 15 Jan 2005 04:20:52 -0000 @@ -16,16 +16,38 @@ * @subpackage SpecialPage */ class WantedPagesPage extends QueryPage { + var $mUseQuery, $mSearchQuery; + + function WantedPagesPage() + { + global $wgRequest; + $this->mSearchQuery = trim($wgRequest->getVal('query', '')); + $this->mUseQuery = ($this->mSearchQuery != "") && + !$wgRequest->getBool('ignoreSearch'); + }
function getName() { return 'Wantedpages'; }
function isExpensive() { - return true; + /* If we can't cache it, consider it inexpensive... */ + return !$this->mUseQuery; } function isSyndicated() { return false; }
+ function getPageHeader() { + $safeText = htmlspecialchars($this->mSearchQuery); + return "<form method="post">" . wfMsg('search') . ": + <input type="text" name="query" value="$safeText" /> + <input type="submit" value="" . + wfMsg('allpagessubmit') . "" /> + <input type="submit" name="ignoreSearch" value="" . + wfMsg('allpages') . "" /> + </form></p> +"; + } + function getSQL() { $dbr =& wfGetDB( DB_SLAVE ); $brokenlinks = $dbr->tableName( 'brokenlinks' ); @@ -33,12 +55,23 @@ # We cheat and return the full-text from bl_to in the title. # In the future, a pre-parsed name will be available. $agrvalue=$dbr->aggregateValue('COUNT(DISTINCT bl_from)'); - return - "SELECT 'Wantedpages' as type, + $restriction = ""; + if ($this->mUseQuery) + { + $escapedSearch = strtolower($this->mSearchQuery); + $escapedSearch = str_replace(" ", "_", $escapedSearch); + $escapedSearch = str_replace("\", "\\", $escapedSearch); + $escapedSearch = str_replace('%', "\%", $escapedSearch); + $escapedSearch = str_replace('_', "\_", $escapedSearch); + $escapedSearch = $dbr->addQuotes("%$escapedSearch%"); + $restriction .= "WHERE lower(bl_to) LIKE $escapedSearch"; + } + return "SELECT 'Wantedpages' as type, 0 as namespace, bl_to as title, COUNT(DISTINCT bl_from) as value FROM $brokenlinks + $restriction GROUP BY bl_to HAVING $agrvalue > 1 ORDER BY $agrvalue ". @@ -63,6 +96,7 @@
return "{$plink} ({$nlink})"; } + }
/**