MediaWiki  1.29.1
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  $request = $this->getRequest();
42  $type = $request->getVal( $this->IdType );
43  $level = $request->getVal( $this->IdLevel );
44  $sizetype = $request->getVal( 'sizetype' );
45  $size = $request->getIntOrNull( 'size' );
46  $NS = $request->getIntOrNull( 'namespace' );
47 
48  $pager = new ProtectedTitlesPager( $this, [], $type, $level, $NS, $sizetype, $size );
49 
50  $this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level ) );
51 
52  if ( $pager->getNumRows() ) {
53  $this->getOutput()->addHTML(
54  $pager->getNavigationBar() .
55  '<ul>' . $pager->getBody() . '</ul>' .
56  $pager->getNavigationBar()
57  );
58  } else {
59  $this->getOutput()->addWikiMsg( 'protectedtitlesempty' );
60  }
61  }
62 
69  function formatRow( $row ) {
70  $title = Title::makeTitleSafe( $row->pt_namespace, $row->pt_title );
71  if ( !$title ) {
72  return Html::rawElement(
73  'li',
74  [],
76  'span',
77  [ 'class' => 'mw-invalidtitle' ],
79  $this->getContext(),
80  $row->pt_namespace,
81  $row->pt_title
82  )
83  )
84  ) . "\n";
85  }
86 
87  $link = $this->getLinkRenderer()->makeLink( $title );
88  $description_items = [];
89  // Messages: restriction-level-sysop, restriction-level-autoconfirmed
90  $protType = $this->msg( 'restriction-level-' . $row->pt_create_perm )->escaped();
91  $description_items[] = $protType;
92  $lang = $this->getLanguage();
93  $expiry = strlen( $row->pt_expiry ) ?
94  $lang->formatExpiry( $row->pt_expiry, TS_MW ) :
95  'infinity';
96 
97  if ( $expiry !== 'infinity' ) {
98  $user = $this->getUser();
99  $description_items[] = $this->msg(
100  'protect-expiring-local',
101  $lang->userTimeAndDate( $expiry, $user ),
102  $lang->userDate( $expiry, $user ),
103  $lang->userTime( $expiry, $user )
104  )->escaped();
105  }
106 
107  // @todo i18n: This should use a comma separator instead of a hard coded comma, right?
108  return '<li>' . $lang->specialList( $link, implode( $description_items, ', ' ) ) . "</li>\n";
109  }
110 
118  function showOptions( $namespace, $type = 'edit', $level ) {
119  $action = htmlspecialchars( wfScript() );
120  $title = $this->getPageTitle();
121  $special = htmlspecialchars( $title->getPrefixedDBkey() );
122 
123  return "<form action=\"$action\" method=\"get\">\n" .
124  '<fieldset>' .
125  Xml::element( 'legend', [], $this->msg( 'protectedtitles' )->text() ) .
126  Html::hidden( 'title', $special ) . "&#160;\n" .
127  $this->getNamespaceMenu( $namespace ) . "&#160;\n" .
128  $this->getLevelMenu( $level ) . "&#160;\n" .
129  "&#160;" . Xml::submitButton( $this->msg( 'protectedtitles-submit' )->text() ) . "\n" .
130  "</fieldset></form>";
131  }
132 
140  function getNamespaceMenu( $namespace = null ) {
142  [
143  'selected' => $namespace,
144  'all' => '',
145  'label' => $this->msg( 'namespace' )->text()
146  ], [
147  'name' => 'namespace',
148  'id' => 'namespace',
149  'class' => 'namespaceselector',
150  ]
151  );
152  }
153 
159  function getLevelMenu( $pr_level ) {
160  // Temporary array
161  $m = [ $this->msg( 'restriction-level-all' )->text() => 0 ];
162  $options = [];
163 
164  // First pass to load the log names
165  foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) {
166  if ( $type != '' && $type != '*' ) {
167  // Messages: restriction-level-sysop, restriction-level-autoconfirmed
168  $text = $this->msg( "restriction-level-$type" )->text();
169  $m[$text] = $type;
170  }
171  }
172 
173  // Is there only one level (aside from "all")?
174  if ( count( $m ) <= 2 ) {
175  return '';
176  }
177  // Third pass generates sorted XHTML content
178  foreach ( $m as $text => $type ) {
179  $selected = ( $type == $pr_level );
180  $options[] = Xml::option( $text, $type, $selected );
181  }
182 
183  return Xml::label( $this->msg( 'restriction-level' )->text(), $this->IdLevel ) . '&#160;' .
184  Xml::tags( 'select',
185  [ 'id' => $this->IdLevel, 'name' => $this->IdLevel ],
186  implode( "\n", $options ) );
187  }
188 
189  protected function getGroupName() {
190  return 'maintenance';
191  }
192 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:628
$request
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2612
SpecialProtectedtitles\showOptions
showOptions( $namespace, $type='edit', $level)
Definition: SpecialProtectedtitles.php:118
SpecialProtectedtitles\$IdLevel
$IdLevel
Definition: SpecialProtectedtitles.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:675
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:358
captcha-old.count
count
Definition: captcha-old.py:225
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
$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:246
Xml\option
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:484
SpecialProtectedtitles\__construct
__construct()
Definition: SpecialProtectedtitles.php:33
SpecialProtectedtitles
A special page that list protected titles from creation.
Definition: SpecialProtectedtitles.php:29
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:705
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:204
$type
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 before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
SpecialProtectedtitles\formatRow
formatRow( $row)
Callback function to output a restriction.
Definition: SpecialProtectedtitles.php:69
SpecialProtectedtitles\$IdType
$IdType
Definition: SpecialProtectedtitles.php:31
SpecialProtectedtitles\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialProtectedtitles.php:189
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:714
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:3138
SpecialProtectedtitles\getNamespaceMenu
getNamespaceMenu( $namespace=null)
Prepare the namespace filter drop-down; standard namespace selector, sans the MediaWiki namespace.
Definition: SpecialProtectedtitles.php:140
SpecialProtectedtitles\execute
execute( $par)
Default execute method Checks user permissions.
Definition: SpecialProtectedtitles.php:37
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
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:484
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:685
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:648
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:746
SpecialProtectedtitles\getLevelMenu
getLevelMenu( $pr_level)
Definition: SpecialProtectedtitles.php:159
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:538
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
Html\namespaceSelector
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:834
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:665
ProtectedTitlesPager
Definition: ProtectedTitlesPager.php:25
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:856
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\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
$special
this hook is for auditing only RecentChangesLinked and Watchlist $special
Definition: hooks.txt:990
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
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:583
$options
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
Xml\submitButton
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:459