@@ 32-120 (lines=89) @@ | ||
29 | * |
|
30 | * @ingroup SpecialPage |
|
31 | */ |
|
32 | class MostcategoriesPage extends QueryPage { |
|
33 | function __construct( $name = 'Mostcategories' ) { |
|
34 | parent::__construct( $name ); |
|
35 | } |
|
36 | ||
37 | public function isExpensive() { |
|
38 | return true; |
|
39 | } |
|
40 | ||
41 | function isSyndicated() { |
|
42 | return false; |
|
43 | } |
|
44 | ||
45 | public function getQueryInfo() { |
|
46 | return [ |
|
47 | 'tables' => [ 'categorylinks', 'page' ], |
|
48 | 'fields' => [ |
|
49 | 'namespace' => 'page_namespace', |
|
50 | 'title' => 'page_title', |
|
51 | 'value' => 'COUNT(*)' |
|
52 | ], |
|
53 | 'conds' => [ 'page_namespace' => MWNamespace::getContentNamespaces() ], |
|
54 | 'options' => [ |
|
55 | 'HAVING' => 'COUNT(*) > 1', |
|
56 | 'GROUP BY' => [ 'page_namespace', 'page_title' ] |
|
57 | ], |
|
58 | 'join_conds' => [ |
|
59 | 'page' => [ |
|
60 | 'LEFT JOIN', |
|
61 | 'page_id = cl_from' |
|
62 | ] |
|
63 | ] |
|
64 | ]; |
|
65 | } |
|
66 | ||
67 | /** |
|
68 | * @param IDatabase $db |
|
69 | * @param ResultWrapper $res |
|
70 | */ |
|
71 | function preprocessResults( $db, $res ) { |
|
72 | # There's no point doing a batch check if we aren't caching results; |
|
73 | # the page must exist for it to have been pulled out of the table |
|
74 | if ( !$this->isCached() || !$res->numRows() ) { |
|
75 | return; |
|
76 | } |
|
77 | ||
78 | $batch = new LinkBatch(); |
|
79 | foreach ( $res as $row ) { |
|
80 | $batch->add( $row->namespace, $row->title ); |
|
81 | } |
|
82 | $batch->execute(); |
|
83 | ||
84 | $res->seek( 0 ); |
|
85 | } |
|
86 | ||
87 | /** |
|
88 | * @param Skin $skin |
|
89 | * @param object $result Result row |
|
90 | * @return string |
|
91 | */ |
|
92 | function formatResult( $skin, $result ) { |
|
93 | $title = Title::makeTitleSafe( $result->namespace, $result->title ); |
|
94 | if ( !$title ) { |
|
95 | return Html::element( |
|
96 | 'span', |
|
97 | [ 'class' => 'mw-invalidtitle' ], |
|
98 | Linker::getInvalidTitleDescription( |
|
99 | $this->getContext(), |
|
100 | $result->namespace, |
|
101 | $result->title |
|
102 | ) |
|
103 | ); |
|
104 | } |
|
105 | ||
106 | if ( $this->isCached() ) { |
|
107 | $link = Linker::link( $title ); |
|
108 | } else { |
|
109 | $link = Linker::linkKnown( $title ); |
|
110 | } |
|
111 | ||
112 | $count = $this->msg( 'ncategories' )->numParams( $result->value )->escaped(); |
|
113 | ||
114 | return $this->getLanguage()->specialList( $link, $count ); |
|
115 | } |
|
116 | ||
117 | protected function getGroupName() { |
|
118 | return 'highuse'; |
|
119 | } |
|
120 | } |
|
121 |
@@ 32-127 (lines=96) @@ | ||
29 | * |
|
30 | * @ingroup SpecialPage |
|
31 | */ |
|
32 | class MostinterwikisPage extends QueryPage { |
|
33 | function __construct( $name = 'Mostinterwikis' ) { |
|
34 | parent::__construct( $name ); |
|
35 | } |
|
36 | ||
37 | public function isExpensive() { |
|
38 | return true; |
|
39 | } |
|
40 | ||
41 | function isSyndicated() { |
|
42 | return false; |
|
43 | } |
|
44 | ||
45 | public function getQueryInfo() { |
|
46 | return [ |
|
47 | 'tables' => [ |
|
48 | 'langlinks', |
|
49 | 'page' |
|
50 | ], 'fields' => [ |
|
51 | 'namespace' => 'page_namespace', |
|
52 | 'title' => 'page_title', |
|
53 | 'value' => 'COUNT(*)' |
|
54 | ], 'conds' => [ |
|
55 | 'page_namespace' => MWNamespace::getContentNamespaces() |
|
56 | ], 'options' => [ |
|
57 | 'HAVING' => 'COUNT(*) > 1', |
|
58 | 'GROUP BY' => [ |
|
59 | 'page_namespace', |
|
60 | 'page_title' |
|
61 | ] |
|
62 | ], 'join_conds' => [ |
|
63 | 'page' => [ |
|
64 | 'LEFT JOIN', |
|
65 | 'page_id = ll_from' |
|
66 | ] |
|
67 | ] |
|
68 | ]; |
|
69 | } |
|
70 | ||
71 | /** |
|
72 | * Pre-fill the link cache |
|
73 | * |
|
74 | * @param IDatabase $db |
|
75 | * @param ResultWrapper $res |
|
76 | */ |
|
77 | function preprocessResults( $db, $res ) { |
|
78 | # There's no point doing a batch check if we aren't caching results; |
|
79 | # the page must exist for it to have been pulled out of the table |
|
80 | if ( !$this->isCached() || !$res->numRows() ) { |
|
81 | return; |
|
82 | } |
|
83 | ||
84 | $batch = new LinkBatch; |
|
85 | foreach ( $res as $row ) { |
|
86 | $batch->add( $row->namespace, $row->title ); |
|
87 | } |
|
88 | $batch->execute(); |
|
89 | ||
90 | // Back to start for display |
|
91 | $res->seek( 0 ); |
|
92 | } |
|
93 | ||
94 | /** |
|
95 | * @param Skin $skin |
|
96 | * @param object $result |
|
97 | * @return string |
|
98 | */ |
|
99 | function formatResult( $skin, $result ) { |
|
100 | $title = Title::makeTitleSafe( $result->namespace, $result->title ); |
|
101 | if ( !$title ) { |
|
102 | return Html::element( |
|
103 | 'span', |
|
104 | [ 'class' => 'mw-invalidtitle' ], |
|
105 | Linker::getInvalidTitleDescription( |
|
106 | $this->getContext(), |
|
107 | $result->namespace, |
|
108 | $result->title |
|
109 | ) |
|
110 | ); |
|
111 | } |
|
112 | ||
113 | if ( $this->isCached() ) { |
|
114 | $link = Linker::link( $title ); |
|
115 | } else { |
|
116 | $link = Linker::linkKnown( $title ); |
|
117 | } |
|
118 | ||
119 | $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped(); |
|
120 | ||
121 | return $this->getLanguage()->specialList( $link, $count ); |
|
122 | } |
|
123 | ||
124 | protected function getGroupName() { |
|
125 | return 'highuse'; |
|
126 | } |
|
127 | } |
|
128 |