3 * Class definition for a wanted query page.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
24 use Wikimedia\Rdbms\ResultWrapper
;
27 * Class definition for a wanted query page like
28 * WantedPages, WantedTemplates, etc
29 * @ingroup SpecialPage
31 abstract class WantedQueryPage
extends QueryPage
{
32 function isExpensive() {
36 function isSyndicated() {
41 * Cache page existence for performance
42 * @param IDatabase $db
43 * @param ResultWrapper $res
45 function preprocessResults( $db, $res ) {
46 $this->executeLBFromResultWrapper( $res );
50 * Should formatResult() always check page existence, even if
51 * the results are fresh? This is a (hopefully temporary)
52 * kluge for Special:WantedFiles, which may contain false
53 * positives for files that exist e.g. in a shared repo (bug
57 function forceExistenceCheck() {
62 * Format an individual result
64 * @param Skin $skin Skin to use for UI elements
65 * @param object $result Result row
68 public function formatResult( $skin, $result ) {
69 $linkRenderer = $this->getLinkRenderer();
70 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
71 if ( $title instanceof Title
) {
72 if ( $this->isCached() ||
$this->forceExistenceCheck() ) {
73 $pageLink = $this->existenceCheck( $title )
74 ?
'<del>' . $linkRenderer->makeLink( $title ) . '</del>'
75 : $linkRenderer->makeLink( $title );
77 $pageLink = $linkRenderer->makeLink(
85 return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
87 return $this->msg( 'wantedpages-badtitle', $result->title
)->escaped();
92 * Does the Title currently exists
94 * This method allows a subclass to override this check
95 * (For example, wantedfiles, would want to check if the file exists
96 * not just that a page in the file namespace exists).
98 * This will only control if the link is crossed out. Whether or not the link
99 * is blue vs red is controlled by if the title exists.
101 * @note This will only be run if the page is cached (ie $wgMiserMode = true)
102 * unless forceExistenceCheck() is true.
106 protected function existenceCheck( Title
$title ) {
107 return $title->isKnown();
111 * Make a "what links here" link for a given title
113 * @param Title $title Title to make the link for
114 * @param object $result Result row
117 private function makeWlhLink( $title, $result ) {
118 $wlh = SpecialPage
::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
119 $label = $this->msg( 'nlinks' )->numParams( $result->value
)->escaped();
120 return Linker
::link( $wlh, $label );
124 * Order by title, overwrites QueryPage::getOrderFields
128 function getOrderFields() {
129 return [ 'value DESC', 'namespace', 'title' ];
133 * Do not order descending for all order fields. We will use DESC only on one field, see
134 * getOrderFields above. This overwrites sortDescending from QueryPage::getOrderFields().
135 * Do NOT change this to true unless you remove the phrase DESC in getOrderFiels above.
136 * If you do a database error will be thrown due to double adding DESC to query!
140 function sortDescending() {