MediaWiki  1.23.15
SpecialProtectedtitles.php
Go to the documentation of this file.
1 <?php
30  protected $IdLevel = 'level';
31  protected $IdType = 'type';
32 
33  public function __construct() {
34  parent::__construct( 'Protectedtitles' );
35  }
36 
37  function execute( $par ) {
38  $this->setHeaders();
39  $this->outputHeader();
40 
41  // Purge expired entries on one in every 10 queries
42  if ( !mt_rand( 0, 10 ) ) {
44  }
45 
46  $request = $this->getRequest();
47  $type = $request->getVal( $this->IdType );
48  $level = $request->getVal( $this->IdLevel );
49  $sizetype = $request->getVal( 'sizetype' );
50  $size = $request->getIntOrNull( 'size' );
51  $NS = $request->getIntOrNull( 'namespace' );
52 
53  $pager = new ProtectedTitlesPager( $this, array(), $type, $level, $NS, $sizetype, $size );
54 
55  $this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level ) );
56 
57  if ( $pager->getNumRows() ) {
58  $this->getOutput()->addHTML(
59  $pager->getNavigationBar() .
60  '<ul>' . $pager->getBody() . '</ul>' .
61  $pager->getNavigationBar()
62  );
63  } else {
64  $this->getOutput()->addWikiMsg( 'protectedtitlesempty' );
65  }
66  }
67 
74  function formatRow( $row ) {
75  wfProfileIn( __METHOD__ );
76 
77  static $infinity = null;
78 
79  if ( is_null( $infinity ) ) {
80  $infinity = wfGetDB( DB_SLAVE )->getInfinity();
81  }
82 
83  $title = Title::makeTitleSafe( $row->pt_namespace, $row->pt_title );
84  if ( !$title ) {
85  wfProfileOut( __METHOD__ );
86 
87  return Html::rawElement(
88  'li',
89  array(),
91  'span',
92  array( 'class' => 'mw-invalidtitle' ),
94  $this->getContext(),
95  $row->pt_namespace,
96  $row->pt_title
97  )
98  )
99  ) . "\n";
100  }
101 
103  $description_items = array();
104  // Messages: restriction-level-sysop, restriction-level-autoconfirmed
105  $protType = $this->msg( 'restriction-level-' . $row->pt_create_perm )->escaped();
106  $description_items[] = $protType;
107  $lang = $this->getLanguage();
108  $expiry = strlen( $row->pt_expiry ) ?
109  $lang->formatExpiry( $row->pt_expiry, TS_MW ) :
110  $infinity;
111 
112  if ( $expiry != $infinity ) {
113  $user = $this->getUser();
114  $description_items[] = $this->msg(
115  'protect-expiring-local',
116  $lang->userTimeAndDate( $expiry, $user ),
117  $lang->userDate( $expiry, $user ),
118  $lang->userTime( $expiry, $user )
119  )->escaped();
120  }
121 
122  wfProfileOut( __METHOD__ );
123 
124  // @todo i18n: This should use a comma separator instead of a hard coded comma, right?
125  return '<li>' . $lang->specialList( $link, implode( $description_items, ', ' ) ) . "</li>\n";
126  }
127 
135  function showOptions( $namespace, $type = 'edit', $level ) {
136  global $wgScript;
137  $action = htmlspecialchars( $wgScript );
138  $title = $this->getPageTitle();
139  $special = htmlspecialchars( $title->getPrefixedDBkey() );
140 
141  return "<form action=\"$action\" method=\"get\">\n" .
142  '<fieldset>' .
143  Xml::element( 'legend', array(), $this->msg( 'protectedtitles' )->text() ) .
144  Html::hidden( 'title', $special ) . "&#160;\n" .
145  $this->getNamespaceMenu( $namespace ) . "&#160;\n" .
146  $this->getLevelMenu( $level ) . "&#160;\n" .
147  "&#160;" . Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n" .
148  "</fieldset></form>";
149  }
150 
158  function getNamespaceMenu( $namespace = null ) {
160  array(
161  'selected' => $namespace,
162  'all' => '',
163  'label' => $this->msg( 'namespace' )->text()
164  ), array(
165  'name' => 'namespace',
166  'id' => 'namespace',
167  'class' => 'namespaceselector',
168  )
169  );
170  }
171 
177  function getLevelMenu( $pr_level ) {
178  global $wgRestrictionLevels;
179 
180  // Temporary array
181  $m = array( $this->msg( 'restriction-level-all' )->text() => 0 );
182  $options = array();
183 
184  // First pass to load the log names
185  foreach ( $wgRestrictionLevels as $type ) {
186  if ( $type != '' && $type != '*' ) {
187  // Messages: restriction-level-sysop, restriction-level-autoconfirmed
188  $text = $this->msg( "restriction-level-$type" )->text();
189  $m[$text] = $type;
190  }
191  }
192 
193  // Is there only one level (aside from "all")?
194  if ( count( $m ) <= 2 ) {
195  return '';
196  }
197  // Third pass generates sorted XHTML content
198  foreach ( $m as $text => $type ) {
199  $selected = ( $type == $pr_level );
200  $options[] = Xml::option( $text, $type, $selected );
201  }
202 
203  return Xml::label( $this->msg( 'restriction-level' )->text(), $this->IdLevel ) . '&#160;' .
204  Xml::tags( 'select',
205  array( 'id' => $this->IdLevel, 'name' => $this->IdLevel ),
206  implode( "\n", $options ) );
207  }
208 
209  protected function getGroupName() {
210  return 'maintenance';
211  }
212 }
213 
219  public $mForm, $mConds;
220 
221  function __construct( $form, $conds = array(), $type, $level, $namespace,
222  $sizetype = '', $size = 0
223  ) {
224  $this->mForm = $form;
225  $this->mConds = $conds;
226  $this->level = $level;
227  $this->namespace = $namespace;
228  $this->size = intval( $size );
229  parent::__construct( $form->getContext() );
230  }
231 
232  function getStartBody() {
233  wfProfileIn( __METHOD__ );
234  # Do a link batch query
235  $this->mResult->seek( 0 );
236  $lb = new LinkBatch;
237 
238  foreach ( $this->mResult as $row ) {
239  $lb->add( $row->pt_namespace, $row->pt_title );
240  }
241 
242  $lb->execute();
243  wfProfileOut( __METHOD__ );
244 
245  return '';
246  }
247 
251  function getTitle() {
252  return $this->mForm->getTitle();
253  }
254 
255  function formatRow( $row ) {
256  return $this->mForm->formatRow( $row );
257  }
258 
262  function getQueryInfo() {
263  $conds = $this->mConds;
264  $conds[] = 'pt_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() );
265  if ( $this->level ) {
266  $conds['pt_create_perm'] = $this->level;
267  }
268 
269  if ( !is_null( $this->namespace ) ) {
270  $conds[] = 'pt_namespace=' . $this->mDb->addQuotes( $this->namespace );
271  }
272 
273  return array(
274  'tables' => 'protected_titles',
275  'fields' => array( 'pt_namespace', 'pt_title', 'pt_create_perm',
276  'pt_expiry', 'pt_timestamp' ),
277  'conds' => $conds
278  );
279  }
280 
281  function getIndexField() {
282  return 'pt_timestamp';
283  }
284 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:488
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled also a ContextSource error or success you ll probably need to make sure the header is varied on WebRequest $request
Definition: hooks.txt:1961
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ProtectedTitlesPager\getTitle
getTitle()
Definition: SpecialProtectedtitles.php:251
SpecialProtectedtitles\showOptions
showOptions( $namespace, $type='edit', $level)
Definition: SpecialProtectedtitles.php:135
SpecialProtectedtitles\$IdLevel
$IdLevel
Definition: SpecialProtectedtitles.php:30
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:30
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:535
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3714
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
$form
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead $form
Definition: hooks.txt:2584
Xml\option
static option( $text, $value=null, $selected=false, $attribs=array())
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:475
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
AlphabeticPager
IndexPager with an alphabetic list and a formatted navigation bar.
Definition: Pager.php:743
SpecialProtectedtitles\__construct
__construct()
Definition: SpecialProtectedtitles.php:33
SpecialProtectedtitles
A special page that list protected titles from creation.
Definition: SpecialProtectedtitles.php:29
Html\hidden
static hidden( $name, $value, $attribs=array())
Convenience function to produce an input element with type=hidden.
Definition: Html.php:607
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:578
ProtectedTitlesPager\getIndexField
getIndexField()
This function should be overridden to return the name of the index fi- eld.
Definition: SpecialProtectedtitles.php:281
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:427
$link
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
Definition: hooks.txt:2160
ProtectedTitlesPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition: SpecialProtectedtitles.php:232
SpecialProtectedtitles\formatRow
formatRow( $row)
Callback function to output a restriction.
Definition: SpecialProtectedtitles.php:74
Linker\link
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
Definition: Linker.php:192
ProtectedTitlesPager\getQueryInfo
getQueryInfo()
Definition: SpecialProtectedtitles.php:262
$lb
if( $wgAPIRequestLog) $lb
Definition: api.php:126
SpecialProtectedtitles\$IdType
$IdType
Definition: SpecialProtectedtitles.php:31
ProtectedTitlesPager\formatRow
formatRow( $row)
Abstract formatting function.
Definition: SpecialProtectedtitles.php:255
SpecialProtectedtitles\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialProtectedtitles.php:209
Html\element
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:141
SpecialProtectedtitles\getNamespaceMenu
getNamespaceMenu( $namespace=null)
Prepare the namespace filter drop-down; standard namespace selector, sans the MediaWiki namespace.
Definition: SpecialProtectedtitles.php:158
SpecialProtectedtitles\execute
execute( $par)
Default execute method Checks user permissions, calls the function given in mFunction.
Definition: SpecialProtectedtitles.php:37
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:352
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:545
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:508
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1530
SpecialProtectedtitles\getLevelMenu
getLevelMenu( $pr_level)
Definition: SpecialProtectedtitles.php:177
TS_MW
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
Definition: GlobalFunctions.php:2478
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:422
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$size
$size
Definition: RandomTest.php:75
ProtectedTitlesPager\$mForm
$mForm
Definition: SpecialProtectedtitles.php:219
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:609
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:33
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:525
ProtectedTitlesPager
Definition: SpecialProtectedtitles.php:218
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
ProtectedTitlesPager\__construct
__construct( $form, $conds=array(), $type, $level, $namespace, $sizetype='', $size=0)
Definition: SpecialProtectedtitles.php:221
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Html\namespaceSelector
static namespaceSelector(array $params=array(), array $selectAttribs=array())
Build a drop-down box for selecting a namespace.
Definition: Html.php:652
Xml\submitButton
static submitButton( $value, $attribs=array())
Convenience function to build an HTML submit button.
Definition: Xml.php:463
ProtectedTitlesPager\$mConds
$mConds
Definition: SpecialProtectedtitles.php:219
Html\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:121
Xml\label
static label( $label, $id, $attribs=array())
Convenience function to build an HTML form label.
Definition: Xml.php:374
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:443
$special
namespace and then decline to actually register it RecentChangesLinked and Watchlist $special
Definition: hooks.txt:815
Title\purgeExpiredRestrictions
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
Definition: Title.php:2994
$type
$type
Definition: testCompression.php:46