Merge "Add ss_active_users in SiteStats::isSane"
[mediawiki.git] / includes / specials / SpecialPagesWithProp.php
blob72a34763631275d44a2c084271de1255869decc3
1 <?php
2 /**
3 * Implements Special:PagesWithProp
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
20 * @since 1.21
21 * @file
22 * @ingroup SpecialPage
23 * @author Brad Jorsch
26 /**
27 * Special:PagesWithProp to search the page_props table
28 * @ingroup SpecialPage
29 * @since 1.21
31 class SpecialPagesWithProp extends QueryPage {
32 private $propName = null;
34 function __construct( $name = 'PagesWithProp' ) {
35 parent::__construct( $name );
38 function isCacheable() {
39 return false;
42 function execute( $par ) {
43 $this->setHeaders();
44 $this->outputHeader();
46 $request = $this->getRequest();
47 $propname = $request->getVal( 'propname', $par );
49 $dbr = wfGetDB( DB_SLAVE );
50 $res = $dbr->select(
51 'page_props',
52 'pp_propname',
53 '',
54 __METHOD__,
55 array( 'DISTINCT', 'ORDER BY' => 'pp_propname' )
57 foreach ( $res as $row ) {
58 $propnames[$row->pp_propname] = $row->pp_propname;
61 $form = new HTMLForm( array(
62 'propname' => array(
63 'type' => 'selectorother',
64 'name' => 'propname',
65 'options' => $propnames,
66 'default' => $propname,
67 'label-message' => 'pageswithprop-prop',
68 'required' => true,
70 ), $this->getContext() );
71 $form->setMethod( 'get' );
72 $form->setSubmitCallback( array( $this, 'onSubmit' ) );
73 $form->setWrapperLegendMsg( 'pageswithprop-legend' );
74 $form->addHeaderText( $this->msg( 'pageswithprop-text' )->parseAsBlock() );
75 $form->setSubmitTextMsg( 'pageswithprop-submit' );
77 $form->prepareForm();
78 $form->displayForm( false );
79 if ( $propname !== '' && $propname !== null ) {
80 $form->trySubmit();
84 public function onSubmit( $data, $form ) {
85 $this->propName = $data['propname'];
86 parent::execute( $data['propname'] );
89 /**
90 * Disable RSS/Atom feeds
91 * @return bool
93 function isSyndicated() {
94 return false;
97 function getQueryInfo() {
98 return array(
99 'tables' => array( 'page_props', 'page' ),
100 'fields' => array(
101 'page_id' => 'pp_page',
102 'page_namespace',
103 'page_title',
104 'page_len',
105 'page_is_redirect',
106 'page_latest',
107 'pp_value',
109 'conds' => array(
110 'page_id = pp_page',
111 'pp_propname' => $this->propName,
113 'options' => array()
117 function getOrderFields() {
118 return array( 'page_id' );
122 * @param Skin $skin
123 * @param object $result Result row
124 * @return string
126 function formatResult( $skin, $result ) {
127 $title = Title::newFromRow( $result );
128 $ret = Linker::link( $title, null, array(), array(), array( 'known' ) );
129 if ( $result->pp_value !== '' ) {
130 $propValue = Html::element( 'span', array( 'class' => 'prop-value' ), $result->pp_value );
131 $value = $this->msg( 'parentheses' )->rawParams( $propValue )->escaped();
132 $ret .= " $value";
135 return $ret;
138 protected function getGroupName() {
139 return 'pages';