42 private $propName =
null;
47 private $existingPropNames =
null;
57 private $reverse =
false;
62 private $sortByValue =
false;
65 parent::__construct(
'PagesWithProp' );
76 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
79 $propname = $request->getVal(
'propname', $par );
80 $this->ns = $request->getIntOrNull(
'namespace' );
81 $this->reverse = $request->getBool(
'reverse' );
82 $this->sortByValue = $request->getBool(
'sortbyvalue' );
90 'options' => $propnames,
91 'default' => $propname,
92 'label-message' =>
'pageswithprop-prop',
96 'type' =>
'namespaceselect',
97 'name' =>
'namespace',
98 'label-message' =>
'namespace',
100 'default' => $this->ns,
105 'default' => $this->reverse,
106 'label-message' =>
'pageswithprop-reverse',
111 'name' =>
'sortbyvalue',
112 'default' => $this->sortByValue,
113 'label-message' =>
'pageswithprop-sortbyvalue',
118 $form = HTMLForm::factory(
'ooui', $fields, $this->
getContext() )
121 ->setSubmitCallback( [ $this,
'onSubmit' ] )
122 ->setWrapperLegendMsg(
'pageswithprop-legend' )
123 ->addHeaderHtml( $this->
msg(
'pageswithprop-text' )->parseAsBlock() )
124 ->setSubmitTextMsg(
'pageswithprop-submit' )
126 $form->displayForm(
false );
127 if ( $propname !==
'' && $propname !==
null ) {
133 $this->propName = $data[
'propname'];
134 parent::execute( $data[
'propname'] );
164 'reverse' => $this->reverse,
165 'sortbyvalue' => $this->sortByValue,
167 if ( $this->ns !==
null ) {
168 $params[
'namespace'] = $this->ns;
175 'tables' => [
'page_props',
'page' ],
177 'page_id' =>
'pp_page',
186 'pp_propname' => $this->propName,
189 'page' => [
'JOIN',
'page_id = pp_page' ]
194 if ( $this->ns !==
null ) {
195 $query[
'conds'][
'page_namespace'] = $this->ns;
202 $sort = [
'page_id' ];
203 if ( $this->sortByValue ) {
204 array_unshift( $sort,
'pp_sortkey' );
213 return !$this->reverse;
222 $title = Title::newFromRow( $result );
224 if ( $result->pp_value !==
'' ) {
226 $valueLength = strlen( $result->pp_value );
227 $isBinary = str_contains( $result->pp_value,
"\0" );
228 $isTooLong = $valueLength > 1024;
230 if ( $isBinary || $isTooLong ) {
232 ->msg( $isBinary ?
'pageswithprop-prophidden-binary' :
'pageswithprop-prophidden-long' )
233 ->sizeParams( $valueLength );
235 $propValue =
Html::element(
'span', [
'class' =>
'prop-value-hidden' ], $message->text() );
237 $propValue =
Html::element(
'span', [
'class' =>
'prop-value' ], $result->pp_value );
240 $ret .= $this->
msg(
'colon-separator' )->escaped() . $propValue;
247 if ( $this->existingPropNames ===
null ) {
250 return $this->existingPropNames;
255 ->getReplicaDatabase()
256 ->newSelectQueryBuilder()
257 ->select(
'pp_propname' )
259 ->from(
'page_props' )
260 ->orderBy(
'pp_propname' );
263 $queryBuilder->limit(
$limit );
266 $queryBuilder->offset(
$offset );
268 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
271 foreach ( $res as $row ) {
272 $propnames[$row->pp_propname] = $row->pp_propname;
287class_alias( SpecialPagesWithProp::class,
'SpecialPagesWithProp' );
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
setDatabaseProvider(IConnectionProvider $databaseProvider)
int $offset
The offset and limit in use, as passed to the query() function.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
static prefixSearchArray( $search, $limit, array $subpages, $offset)
Helper function for implementations of prefixSearchSubpages() that filter the values in memory (as op...
getPageTitle( $subpage=false)
Get a self-referential title object.
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
Special:PagesWithProp to search the page_props table.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
__construct(IConnectionProvider $dbProvider)
getOrderFields()
Subclasses return an array of fields to order by here.
isCacheable()
Is the output of this query cacheable? Non-cacheable expensive pages will be disabled in miser mode a...
formatResult( $skin, $result)
isSyndicated()
Disable RSS/Atom feeds.
linkParameters()
If using extra form wheely-dealies, return a set of parameters here as an associative array....
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
execute( $par)
This is the actual workhorse.
queryExistingProps( $limit=null, $offset=0)