]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialLonelypages.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialLonelypages.php
1 <?php
2 /**
3  * Implements Special:Lonelypaages
4  *
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.
9  *
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.
14  *
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
19  *
20  * @file
21  * @ingroup SpecialPage
22  */
23
24 /**
25  * A special page looking for articles with no article linking to them,
26  * thus being lonely.
27  *
28  * @ingroup SpecialPage
29  */
30 class LonelyPagesPage extends PageQueryPage {
31         function __construct( $name = 'Lonelypages' ) {
32                 parent::__construct( $name );
33         }
34
35         function getPageHeader() {
36                 return $this->msg( 'lonelypagestext' )->parseAsBlock();
37         }
38
39         function sortDescending() {
40                 return false;
41         }
42
43         function isExpensive() {
44                 return true;
45         }
46
47         function isSyndicated() {
48                 return false;
49         }
50
51         function getQueryInfo() {
52                 $tables = [ 'page', 'pagelinks', 'templatelinks' ];
53                 $conds = [
54                         'pl_namespace IS NULL',
55                         'page_namespace' => MWNamespace::getContentNamespaces(),
56                         'page_is_redirect' => 0,
57                         'tl_namespace IS NULL'
58                 ];
59                 $joinConds = [
60                         'pagelinks' => [
61                                 'LEFT JOIN', [
62                                         'pl_namespace = page_namespace',
63                                         'pl_title = page_title'
64                                 ]
65                         ],
66                         'templatelinks' => [
67                                 'LEFT JOIN', [
68                                         'tl_namespace = page_namespace',
69                                         'tl_title = page_title'
70                                 ]
71                         ]
72                 ];
73
74                 // Allow extensions to modify the query
75                 Hooks::run( 'LonelyPagesQuery', [ &$tables, &$conds, &$joinConds ] );
76
77                 return [
78                         'tables' => $tables,
79                         'fields' => [
80                                 'namespace' => 'page_namespace',
81                                 'title' => 'page_title',
82                                 'value' => 'page_title'
83                         ],
84                         'conds' => $conds,
85                         'join_conds' => $joinConds
86                 ];
87         }
88
89         function getOrderFields() {
90                 // For some crazy reason ordering by a constant
91                 // causes a filesort in MySQL 5
92                 if ( count( MWNamespace::getContentNamespaces() ) > 1 ) {
93                         return [ 'page_namespace', 'page_title' ];
94                 } else {
95                         return [ 'page_title' ];
96                 }
97         }
98
99         protected function getGroupName() {
100                 return 'maintenance';
101         }
102 }