MediaWiki
REL1_21
|
00001 <?php 00032 class SpecialPagesWithProp extends QueryPage { 00033 private $propName = null; 00034 00035 function __construct( $name = 'PagesWithProp' ) { 00036 parent::__construct( $name ); 00037 } 00038 00039 function isCacheable() { 00040 return false; 00041 } 00042 00043 function execute( $par ) { 00044 $this->setHeaders(); 00045 $this->outputHeader(); 00046 00047 $request = $this->getRequest(); 00048 $propname = $request->getVal( 'propname', $par ); 00049 00050 $dbr = wfGetDB( DB_SLAVE ); 00051 $res = $dbr->select( 00052 'page_props', 00053 'pp_propname', 00054 '', 00055 __METHOD__, 00056 array( 'DISTINCT', 'ORDER BY' => 'pp_propname' ) 00057 ); 00058 foreach ( $res as $row ) { 00059 $propnames[$row->pp_propname] = $row->pp_propname; 00060 } 00061 00062 $form = new HTMLForm( array( 00063 'propname' => array( 00064 'type' => 'selectorother', 00065 'name' => 'propname', 00066 'options' => $propnames, 00067 'default' => $propname, 00068 'label-message' => 'pageswithprop-prop', 00069 'required' => true, 00070 ), 00071 ), $this->getContext() ); 00072 $form->setMethod( 'get' ); 00073 $form->setAction( $this->getTitle()->getFullUrl() ); 00074 $form->setSubmitCallback( array( $this, 'onSubmit' ) ); 00075 $form->setWrapperLegend( $this->msg( 'pageswithprop-legend' ) ); 00076 $form->addHeaderText( $this->msg( 'pageswithprop-text' )->parseAsBlock() ); 00077 $form->setSubmitTextMsg( 'pageswithprop-submit' ); 00078 00079 $form->prepareForm(); 00080 $form->displayForm( false ); 00081 if ( $propname !== '' && $propname !== null ) { 00082 $form->trySubmit(); 00083 } 00084 } 00085 00086 public function onSubmit( $data, $form ) { 00087 $this->propName = $data['propname']; 00088 parent::execute( $data['propname'] ); 00089 } 00090 00095 function isSyndicated() { 00096 return false; 00097 } 00098 00099 function getQueryInfo() { 00100 return array( 00101 'tables' => array( 'page_props', 'page' ), 00102 'fields' => array( 00103 'page_id' => 'pp_page', 00104 'page_namespace', 00105 'page_title', 00106 'page_len', 00107 'page_is_redirect', 00108 'page_latest', 00109 'pp_value', 00110 ), 00111 'conds' => array( 00112 'page_id = pp_page', 00113 'pp_propname' => $this->propName, 00114 ), 00115 'options' => array() 00116 ); 00117 } 00118 00119 function getOrderFields() { 00120 return array( 'page_id' ); 00121 } 00122 00123 function formatResult( $skin, $result ) { 00124 $title = Title::newFromRow( $result ); 00125 $ret = Linker::link( $title, null, array(), array(), array( 'known' ) ); 00126 if ( $result->pp_value !== '' ) { 00127 $value = $this->msg( 'parentheses' ) 00128 ->rawParams( Xml::span( $result->pp_value, 'prop-value' ) ) 00129 ->escaped(); 00130 $ret .= " $value"; 00131 } 00132 return $ret; 00133 } 00134 00135 protected function getGroupName() { 00136 return 'pages'; 00137 } 00138 }