MediaWiki  1.33.0
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  [],
75  Html::element(
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  // Messages: restriction-level-sysop, restriction-level-autoconfirmed
89  $description = $this->msg( 'restriction-level-' . $row->pt_create_perm )->escaped();
90  $lang = $this->getLanguage();
91  $expiry = strlen( $row->pt_expiry ) ?
92  $lang->formatExpiry( $row->pt_expiry, TS_MW ) :
93  'infinity';
94 
95  if ( $expiry !== 'infinity' ) {
96  $user = $this->getUser();
97  $description .= $this->msg( 'comma-separator' )->escaped() . $this->msg(
98  'protect-expiring-local',
99  $lang->userTimeAndDate( $expiry, $user ),
100  $lang->userDate( $expiry, $user ),
101  $lang->userTime( $expiry, $user )
102  )->escaped();
103  }
104 
105  return '<li>' . $lang->specialList( $link, $description ) . "</li>\n";
106  }
107 
115  function showOptions( $namespace, $type, $level ) {
116  $formDescriptor = [
117  'namespace' => [
118  'class' => 'HTMLSelectNamespace',
119  'name' => 'namespace',
120  'id' => 'namespace',
121  'cssclass' => 'namespaceselector',
122  'all' => '',
123  'label' => $this->msg( 'namespace' )->text()
124  ],
125  'levelmenu' => $this->getLevelMenu( $level )
126  ];
127 
128  $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
129  $htmlForm
130  ->setMethod( 'get' )
131  ->setWrapperLegendMsg( 'protectedtitles' )
132  ->setSubmitText( $this->msg( 'protectedtitles-submit' )->text() );
133 
134  return $htmlForm->prepareForm()->getHTML( false );
135  }
136 
142  function getLevelMenu( $pr_level ) {
143  // Temporary array
144  $m = [ $this->msg( 'restriction-level-all' )->text() => 0 ];
145  $options = [];
146 
147  // First pass to load the log names
148  foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) {
149  if ( $type != '' && $type != '*' ) {
150  // Messages: restriction-level-sysop, restriction-level-autoconfirmed
151  $text = $this->msg( "restriction-level-$type" )->text();
152  $m[$text] = $type;
153  }
154  }
155 
156  // Is there only one level (aside from "all")?
157  if ( count( $m ) <= 2 ) {
158  return '';
159  }
160  // Third pass generates sorted XHTML content
161  foreach ( $m as $text => $type ) {
162  $options[ $text ] = $type;
163  }
164 
165  return [
166  'type' => 'select',
167  'options' => $options,
168  'label' => $this->msg( 'restriction-level' )->text(),
169  'name' => $this->IdLevel,
170  'id' => $this->IdLevel
171  ];
172  }
173 
174  protected function getGroupName() {
175  return 'maintenance';
176  }
177 }
$user
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1476
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:796
SpecialProtectedtitles\$IdLevel
$IdLevel
Definition: SpecialProtectedtitles.php:30
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:725
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
captcha-old.count
count
Definition: captcha-old.py:249
SpecialProtectedtitles\__construct
__construct()
Definition: SpecialProtectedtitles.php:33
SpecialProtectedtitles
A special page that list protected titles from creation.
Definition: SpecialProtectedtitles.php:29
$formDescriptor
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead & $formDescriptor
Definition: hooks.txt:2064
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:755
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:191
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:174
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:764
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
HTMLForm\factory
static factory( $displayFormat)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:286
SpecialProtectedtitles\execute
execute( $par)
Default execute method Checks user permissions.
Definition: SpecialProtectedtitles.php:37
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:531
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:735
SpecialProtectedtitles\showOptions
showOptions( $namespace, $type, $level)
Definition: SpecialProtectedtitles.php:115
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:698
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2636
SpecialProtectedtitles\getLevelMenu
getLevelMenu( $pr_level)
Definition: SpecialProtectedtitles.php:142
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:604
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:715
ProtectedTitlesPager
Definition: ProtectedTitlesPager.php:25
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:908
text
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Definition: All_system_messages.txt:1267
$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:1985
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
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3053
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:633
$type
$type
Definition: testCompression.php:48