Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.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 use MediaWiki\MediaWikiServices;
25
26 /**
27 * A special page looking for articles with no article linking to them,
28 * thus being lonely.
29 *
30 * @ingroup SpecialPage
31 */
32 class LonelyPagesPage extends PageQueryPage {
33 function __construct( $name = 'Lonelypages' ) {
34 parent::__construct( $name );
35 }
36
37 function getPageHeader() {
38 return $this->msg( 'lonelypagestext' )->parseAsBlock();
39 }
40
41 function sortDescending() {
42 return false;
43 }
44
45 function isExpensive() {
46 return true;
47 }
48
49 function isSyndicated() {
50 return false;
51 }
52
53 function getQueryInfo() {
54 $tables = [ 'page', 'pagelinks', 'templatelinks' ];
55 $conds = [
56 'pl_namespace IS NULL',
57 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
58 getContentNamespaces(),
59 'page_is_redirect' => 0,
60 'tl_namespace IS NULL'
61 ];
62 $joinConds = [
63 'pagelinks' => [
64 'LEFT JOIN', [
65 'pl_namespace = page_namespace',
66 'pl_title = page_title'
67 ]
68 ],
69 'templatelinks' => [
70 'LEFT JOIN', [
71 'tl_namespace = page_namespace',
72 'tl_title = page_title'
73 ]
74 ]
75 ];
76
77 // Allow extensions to modify the query
78 Hooks::run( 'LonelyPagesQuery', [ &$tables, &$conds, &$joinConds ] );
79
80 return [
81 'tables' => $tables,
82 'fields' => [
83 'namespace' => 'page_namespace',
84 'title' => 'page_title',
85 'value' => 'page_title'
86 ],
87 'conds' => $conds,
88 'join_conds' => $joinConds
89 ];
90 }
91
92 function getOrderFields() {
93 // For some crazy reason ordering by a constant
94 // causes a filesort in MySQL 5
95 if ( count( MediaWikiServices::getInstance()->getNamespaceInfo()->
96 getContentNamespaces() ) > 1
97 ) {
98 return [ 'page_namespace', 'page_title' ];
99 } else {
100 return [ 'page_title' ];
101 }
102 }
103
104 protected function getGroupName() {
105 return 'maintenance';
106 }
107 }