MediaWiki  1.27.2
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 
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 }
this hook is for auditing only RecentChangesLinked and Watchlist $special
Definition: hooks.txt:965
getNamespaceMenu($namespace=null)
Prepare the namespace filter drop-down; standard namespace selector, sans the MediaWiki namespace...
getContext()
Gets the context this SpecialPage is executed in.
wfScript($script= 'index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Definition: Html.php:210
if(!isset($args[0])) $lang
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:759
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
static submitButton($value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:460
static label($label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:359
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
Definition: hooks.txt:2581
Parent class for all special pages.
Definition: SpecialPage.php:36
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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:1004
static option($text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:485
A special page that list protected titles from creation.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:548
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
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
showOptions($namespace, $type= 'edit', $level)
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
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 local account $user
Definition: hooks.txt:242
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition: Linker.php:195
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
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
static tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2418
getUser()
Shortcut to get the User executing this instance.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
formatRow($row)
Callback function to output a restriction.
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:432
getRequest()
Get the WebRequest being used for this instance.
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:230
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 one of or reset 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:2338
getPageTitle($subpage=false)
Get a self-referential title object.
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:847