MediaWiki  1.23.2
ProtectionForm.php
Go to the documentation of this file.
1 <?php
32 
34  var $mReason = '';
35 
38 
40  var $mCascade = false;
41 
43  var $mExpiry = array();
44 
50 
53 
56 
59 
60  function __construct( Page $article ) {
62  // Set instance variables.
63  $this->mArticle = $article;
64  $this->mTitle = $article->getTitle();
65  $this->mApplicableTypes = $this->mTitle->getRestrictionTypes();
66 
67  // Check if the form should be disabled.
68  // If it is, the form will be available in read-only to show levels.
69  $this->mPermErrors = $this->mTitle->getUserPermissionsErrors( 'protect', $wgUser );
70  if ( wfReadOnly() ) {
71  $this->mPermErrors[] = array( 'readonlytext', wfReadOnlyReason() );
72  }
73  $this->disabled = $this->mPermErrors != array();
74  $this->disabledAttrib = $this->disabled
75  ? array( 'disabled' => 'disabled' )
76  : array();
77 
78  $this->loadData();
79  }
80 
84  function loadData() {
85  global $wgRequest, $wgUser;
86 
87  $levels = MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace(), $wgUser );
88  $this->mCascade = $this->mTitle->areRestrictionsCascading();
89 
90  $this->mReason = $wgRequest->getText( 'mwProtect-reason' );
91  $this->mReasonSelection = $wgRequest->getText( 'wpProtectReasonSelection' );
92  $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade', $this->mCascade );
93 
94  foreach ( $this->mApplicableTypes as $action ) {
95  // @todo FIXME: This form currently requires individual selections,
96  // but the db allows multiples separated by commas.
97 
98  // Pull the actual restriction from the DB
99  $this->mRestrictions[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
100 
101  if ( !$this->mRestrictions[$action] ) {
102  // No existing expiry
103  $existingExpiry = '';
104  } else {
105  $existingExpiry = $this->mTitle->getRestrictionExpiry( $action );
106  }
107  $this->mExistingExpiry[$action] = $existingExpiry;
108 
109  $requestExpiry = $wgRequest->getText( "mwProtect-expiry-$action" );
110  $requestExpirySelection = $wgRequest->getVal( "wpProtectExpirySelection-$action" );
111 
112  if ( $requestExpiry ) {
113  // Custom expiry takes precedence
114  $this->mExpiry[$action] = $requestExpiry;
115  $this->mExpirySelection[$action] = 'othertime';
116  } elseif ( $requestExpirySelection ) {
117  // Expiry selected from list
118  $this->mExpiry[$action] = '';
119  $this->mExpirySelection[$action] = $requestExpirySelection;
120  } elseif ( $existingExpiry == 'infinity' ) {
121  // Existing expiry is infinite, use "infinite" in drop-down
122  $this->mExpiry[$action] = '';
123  $this->mExpirySelection[$action] = 'infinite';
124  } elseif ( $existingExpiry ) {
125  // Use existing expiry in its own list item
126  $this->mExpiry[$action] = '';
127  $this->mExpirySelection[$action] = $existingExpiry;
128  } else {
129  // Final default: infinite
130  $this->mExpiry[$action] = '';
131  $this->mExpirySelection[$action] = 'infinite';
132  }
133 
134  $val = $wgRequest->getVal( "mwProtect-level-$action" );
135  if ( isset( $val ) && in_array( $val, $levels ) ) {
136  $this->mRestrictions[$action] = $val;
137  }
138  }
139  }
140 
148  function getExpiry( $action ) {
149  if ( $this->mExpirySelection[$action] == 'existing' ) {
150  return $this->mExistingExpiry[$action];
151  } elseif ( $this->mExpirySelection[$action] == 'othertime' ) {
152  $value = $this->mExpiry[$action];
153  } else {
154  $value = $this->mExpirySelection[$action];
155  }
156  if ( $value == 'infinite' || $value == 'indefinite' || $value == 'infinity' ) {
157  $time = wfGetDB( DB_SLAVE )->getInfinity();
158  } else {
159  $unix = strtotime( $value );
160 
161  if ( !$unix || $unix === -1 ) {
162  return false;
163  }
164 
165  // @todo FIXME: Non-qualified absolute times are not in users specified timezone
166  // and there isn't notice about it in the ui
167  $time = wfTimestamp( TS_MW, $unix );
168  }
169  return $time;
170  }
171 
175  function execute() {
176  global $wgRequest, $wgOut;
177 
178  if ( MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) === array( '' ) ) {
179  throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' );
180  }
181 
182  if ( $wgRequest->wasPosted() ) {
183  if ( $this->save() ) {
184  $q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
185  $wgOut->redirect( $this->mTitle->getFullURL( $q ) );
186  }
187  } else {
188  $this->show();
189  }
190  }
191 
197  function show( $err = null ) {
198  global $wgOut;
199 
200  $wgOut->setRobotPolicy( 'noindex,nofollow' );
201  $wgOut->addBacklinkSubtitle( $this->mTitle );
202 
203  if ( is_array( $err ) ) {
204  $wgOut->wrapWikiMsg( "<p class='error'>\n$1\n</p>\n", $err );
205  } elseif ( is_string( $err ) ) {
206  $wgOut->addHTML( "<p class='error'>{$err}</p>\n" );
207  }
208 
209  if ( $this->mTitle->getRestrictionTypes() === array() ) {
210  // No restriction types available for the current title
211  // this might happen if an extension alters the available types
212  $wgOut->setPageTitle( wfMessage( 'protect-norestrictiontypes-title', $this->mTitle->getPrefixedText() ) );
213  $wgOut->addWikiText( wfMessage( 'protect-norestrictiontypes-text' )->text() );
214 
215  // Show the log in case protection was possible once
216  $this->showLogExtract( $wgOut );
217  // return as there isn't anything else we can do
218  return;
219  }
220 
221  list( $cascadeSources, /* $restrictions */ ) = $this->mTitle->getCascadeProtectionSources();
222  if ( $cascadeSources && count( $cascadeSources ) > 0 ) {
223  $titles = '';
224 
225  foreach ( $cascadeSources as $title ) {
226  $titles .= '* [[:' . $title->getPrefixedText() . "]]\n";
227  }
228 
229  $wgOut->wrapWikiMsg( "<div id=\"mw-protect-cascadeon\">\n$1\n" . $titles . "</div>", array( 'protect-cascadeon', count( $cascadeSources ) ) );
230  }
231 
232  # Show an appropriate message if the user isn't allowed or able to change
233  # the protection settings at this time
234  if ( $this->disabled ) {
235  $wgOut->setPageTitle( wfMessage( 'protect-title-notallowed', $this->mTitle->getPrefixedText() ) );
236  $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $this->mPermErrors, 'protect' ) );
237  } else {
238  $wgOut->setPageTitle( wfMessage( 'protect-title', $this->mTitle->getPrefixedText() ) );
239  $wgOut->addWikiMsg( 'protect-text',
240  wfEscapeWikiText( $this->mTitle->getPrefixedText() ) );
241  }
242 
243  $wgOut->addHTML( $this->buildForm() );
244  $this->showLogExtract( $wgOut );
245  }
246 
252  function save() {
253  global $wgRequest, $wgUser, $wgOut;
254 
255  # Permission check!
256  if ( $this->disabled ) {
257  $this->show();
258  return false;
259  }
260 
261  $token = $wgRequest->getVal( 'wpEditToken' );
262  if ( !$wgUser->matchEditToken( $token, array( 'protect', $this->mTitle->getPrefixedDBkey() ) ) ) {
263  $this->show( array( 'sessionfailure' ) );
264  return false;
265  }
266 
267  # Create reason string. Use list and/or custom string.
268  $reasonstr = $this->mReasonSelection;
269  if ( $reasonstr != 'other' && $this->mReason != '' ) {
270  // Entry from drop down menu + additional comment
271  $reasonstr .= wfMessage( 'colon-separator' )->text() . $this->mReason;
272  } elseif ( $reasonstr == 'other' ) {
273  $reasonstr = $this->mReason;
274  }
275  $expiry = array();
276  foreach ( $this->mApplicableTypes as $action ) {
277  $expiry[$action] = $this->getExpiry( $action );
278  if ( empty( $this->mRestrictions[$action] ) ) {
279  continue; // unprotected
280  }
281  if ( !$expiry[$action] ) {
282  $this->show( array( 'protect_expiry_invalid' ) );
283  return false;
284  }
285  if ( $expiry[$action] < wfTimestampNow() ) {
286  $this->show( array( 'protect_expiry_old' ) );
287  return false;
288  }
289  }
290 
291  $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade' );
292 
293  $status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser );
294 
295  if ( !$status->isOK() ) {
296  $this->show( $wgOut->parseInline( $status->getWikiText() ) );
297  return false;
298  }
299 
306  $errorMsg = '';
307  if ( !wfRunHooks( 'ProtectionForm::save', array( $this->mArticle, &$errorMsg, $reasonstr ) ) ) {
308  if ( $errorMsg == '' ) {
309  $errorMsg = array( 'hookaborted' );
310  }
311  }
312  if ( $errorMsg != '' ) {
313  $this->show( $errorMsg );
314  return false;
315  }
316 
317  WatchAction::doWatchOrUnwatch( $wgRequest->getCheck( 'mwProtectWatch' ), $this->mTitle, $wgUser );
318 
319  return true;
320  }
321 
327  function buildForm() {
329 
330  $mProtectreasonother = Xml::label(
331  wfMessage( 'protectcomment' )->text(),
332  'wpProtectReasonSelection'
333  );
334  $mProtectreason = Xml::label(
335  wfMessage( 'protect-otherreason' )->text(),
336  'mwProtect-reason'
337  );
338 
339  $out = '';
340  if ( !$this->disabled ) {
341  $wgOut->addModules( 'mediawiki.legacy.protect' );
342  $out .= Xml::openElement( 'form', array( 'method' => 'post',
343  'action' => $this->mTitle->getLocalURL( 'action=protect' ),
344  'id' => 'mw-Protect-Form', 'onsubmit' => 'ProtectionForm.enableUnchainedInputs(true)' ) );
345  }
346 
347  $out .= Xml::openElement( 'fieldset' ) .
348  Xml::element( 'legend', null, wfMessage( 'protect-legend' )->text() ) .
349  Xml::openElement( 'table', array( 'id' => 'mwProtectSet' ) ) .
350  Xml::openElement( 'tbody' );
351 
352  // Not all languages have V_x <-> N_x relation
353  foreach ( $this->mRestrictions as $action => $selected ) {
354  // Messages:
355  // restriction-edit, restriction-move, restriction-create, restriction-upload
356  $msg = wfMessage( 'restriction-' . $action );
357  $out .= "<tr><td>" .
358  Xml::openElement( 'fieldset' ) .
359  Xml::element( 'legend', null, $msg->exists() ? $msg->text() : $action ) .
360  Xml::openElement( 'table', array( 'id' => "mw-protect-table-$action" ) ) .
361  "<tr><td>" . $this->buildSelector( $action, $selected ) . "</td></tr><tr><td>";
362 
363  $reasonDropDown = Xml::listDropDown( 'wpProtectReasonSelection',
364  wfMessage( 'protect-dropdown' )->inContentLanguage()->text(),
365  wfMessage( 'protect-otherreason-op' )->inContentLanguage()->text(),
366  $this->mReasonSelection,
367  'mwProtect-reason', 4 );
368  $scExpiryOptions = wfMessage( 'protect-expiry-options' )->inContentLanguage()->text();
369 
370  $showProtectOptions = $scExpiryOptions !== '-' && !$this->disabled;
371 
372  $mProtectexpiry = Xml::label(
373  wfMessage( 'protectexpiry' )->text(),
374  "mwProtectExpirySelection-$action"
375  );
376  $mProtectother = Xml::label(
377  wfMessage( 'protect-othertime' )->text(),
378  "mwProtect-$action-expires"
379  );
380 
381  $expiryFormOptions = '';
382  if ( $this->mExistingExpiry[$action] && $this->mExistingExpiry[$action] != 'infinity' ) {
383  $timestamp = $wgLang->timeanddate( $this->mExistingExpiry[$action], true );
384  $d = $wgLang->date( $this->mExistingExpiry[$action], true );
385  $t = $wgLang->time( $this->mExistingExpiry[$action], true );
386  $expiryFormOptions .=
387  Xml::option(
388  wfMessage( 'protect-existing-expiry', $timestamp, $d, $t )->text(),
389  'existing',
390  $this->mExpirySelection[$action] == 'existing'
391  ) . "\n";
392  }
393 
394  $expiryFormOptions .= Xml::option(
395  wfMessage( 'protect-othertime-op' )->text(),
396  "othertime"
397  ) . "\n";
398  foreach ( explode( ',', $scExpiryOptions ) as $option ) {
399  if ( strpos( $option, ":" ) === false ) {
400  $show = $value = $option;
401  } else {
402  list( $show, $value ) = explode( ":", $option );
403  }
404  $show = htmlspecialchars( $show );
405  $value = htmlspecialchars( $value );
406  $expiryFormOptions .= Xml::option( $show, $value, $this->mExpirySelection[$action] === $value ) . "\n";
407  }
408  # Add expiry dropdown
409  if ( $showProtectOptions && !$this->disabled ) {
410  $out .= "
411  <table><tr>
412  <td class='mw-label'>
413  {$mProtectexpiry}
414  </td>
415  <td class='mw-input'>" .
416  Xml::tags( 'select',
417  array(
418  'id' => "mwProtectExpirySelection-$action",
419  'name' => "wpProtectExpirySelection-$action",
420  'onchange' => "ProtectionForm.updateExpiryList(this)",
421  'tabindex' => '2' ) + $this->disabledAttrib,
422  $expiryFormOptions ) .
423  "</td>
424  </tr></table>";
425  }
426  # Add custom expiry field
427  $attribs = array( 'id' => "mwProtect-$action-expires",
428  'onkeyup' => 'ProtectionForm.updateExpiry(this)',
429  'onchange' => 'ProtectionForm.updateExpiry(this)' ) + $this->disabledAttrib;
430  $out .= "<table><tr>
431  <td class='mw-label'>" .
432  $mProtectother .
433  '</td>
434  <td class="mw-input">' .
435  Xml::input( "mwProtect-expiry-$action", 50, $this->mExpiry[$action], $attribs ) .
436  '</td>
437  </tr></table>';
438  $out .= "</td></tr>" .
439  Xml::closeElement( 'table' ) .
440  Xml::closeElement( 'fieldset' ) .
441  "</td></tr>";
442  }
443  # Give extensions a chance to add items to the form
444  wfRunHooks( 'ProtectionForm::buildForm', array( $this->mArticle, &$out ) );
445 
446  $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
447 
448  // JavaScript will add another row with a value-chaining checkbox
449  if ( $this->mTitle->exists() ) {
450  $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) .
451  Xml::openElement( 'tbody' );
452  $out .= '<tr>
453  <td></td>
454  <td class="mw-input">' .
456  wfMessage( 'protect-cascade' )->text(),
457  'mwProtect-cascade',
458  'mwProtect-cascade',
459  $this->mCascade, $this->disabledAttrib
460  ) .
461  "</td>
462  </tr>\n";
463  $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
464  }
465 
466  # Add manual and custom reason field/selects as well as submit
467  if ( !$this->disabled ) {
468  $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table3' ) ) .
469  Xml::openElement( 'tbody' );
470  $out .= "
471  <tr>
472  <td class='mw-label'>
473  {$mProtectreasonother}
474  </td>
475  <td class='mw-input'>
476  {$reasonDropDown}
477  </td>
478  </tr>
479  <tr>
480  <td class='mw-label'>
481  {$mProtectreason}
482  </td>
483  <td class='mw-input'>" .
484  Xml::input( 'mwProtect-reason', 60, $this->mReason, array( 'type' => 'text',
485  'id' => 'mwProtect-reason', 'maxlength' => 180 ) ) .
486  // Limited maxlength as the database trims at 255 bytes and other texts
487  // chosen by dropdown menus on this page are also included in this database field.
488  // The byte limit of 180 bytes is enforced in javascript
489  "</td>
490  </tr>";
491  # Disallow watching is user is not logged in
492  if ( $wgUser->isLoggedIn() ) {
493  $out .= "
494  <tr>
495  <td></td>
496  <td class='mw-input'>" .
497  Xml::checkLabel( wfMessage( 'watchthis' )->text(),
498  'mwProtectWatch', 'mwProtectWatch',
499  $wgUser->isWatched( $this->mTitle ) || $wgUser->getOption( 'watchdefault' ) ) .
500  "</td>
501  </tr>";
502  }
503  $out .= "
504  <tr>
505  <td></td>
506  <td class='mw-submit'>" .
508  wfMessage( 'confirm' )->text(),
509  array( 'id' => 'mw-Protect-submit' )
510  ) .
511  "</td>
512  </tr>\n";
513  $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
514  }
515  $out .= Xml::closeElement( 'fieldset' );
516 
517  if ( $wgUser->isAllowed( 'editinterface' ) ) {
518  $title = Title::makeTitle( NS_MEDIAWIKI, 'Protect-dropdown' );
520  $title,
521  wfMessage( 'protect-edit-reasonlist' )->escaped(),
522  array(),
523  array( 'action' => 'edit' )
524  );
525  $out .= '<p class="mw-protect-editreasons">' . $link . '</p>';
526  }
527 
528  if ( !$this->disabled ) {
529  $out .= Html::hidden( 'wpEditToken', $wgUser->getEditToken( array( 'protect', $this->mTitle->getPrefixedDBkey() ) ) );
530  $out .= Xml::closeElement( 'form' );
531  $wgOut->addScript( $this->buildCleanupScript() );
532  }
533 
534  return $out;
535  }
536 
544  function buildSelector( $action, $selected ) {
545  global $wgUser;
546 
547  // If the form is disabled, display all relevant levels. Otherwise,
548  // just show the ones this user can use.
549  $levels = MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace(),
550  $this->disabled ? null : $wgUser
551  );
552 
553  $id = 'mwProtect-level-' . $action;
554  $attribs = array(
555  'id' => $id,
556  'name' => $id,
557  'size' => count( $levels ),
558  'onchange' => 'ProtectionForm.updateLevels(this)',
559  ) + $this->disabledAttrib;
560 
561  $out = Xml::openElement( 'select', $attribs );
562  foreach ( $levels as $key ) {
563  $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected );
564  }
565  $out .= Xml::closeElement( 'select' );
566  return $out;
567  }
568 
575  private function getOptionLabel( $permission ) {
576  if ( $permission == '' ) {
577  return wfMessage( 'protect-default' )->text();
578  } else {
579  // Messages: protect-level-autoconfirmed, protect-level-sysop
580  $msg = wfMessage( "protect-level-{$permission}" );
581  if ( $msg->exists() ) {
582  return $msg->text();
583  }
584  return wfMessage( 'protect-fallback', $permission )->text();
585  }
586  }
587 
588  function buildCleanupScript() {
589  global $wgCascadingRestrictionLevels, $wgOut;
590 
591  $cascadeableLevels = $wgCascadingRestrictionLevels;
592  $options = array(
593  'tableId' => 'mwProtectSet',
594  'labelText' => wfMessage( 'protect-unchain-permissions' )->plain(),
595  'numTypes' => count( $this->mApplicableTypes ),
596  'existingMatch' => count( array_unique( $this->mExistingExpiry ) ) === 1,
597  );
598 
599  $wgOut->addJsConfigVars( 'wgCascadeableLevels', $cascadeableLevels );
600  $script = Xml::encodeJsCall( 'ProtectionForm.init', array( $options ) );
602  }
603 
610  function showLogExtract( &$out ) {
611  # Show relevant lines from the protection log:
612  $protectLogPage = new LogPage( 'protect' );
613  $out->addHTML( Xml::element( 'h2', null, $protectLogPage->getName()->text() ) );
614  LogEventsList::showLogExtract( $out, 'protect', $this->mTitle );
615  # Let extensions add other relevant log extracts
616  wfRunHooks( 'ProtectionForm::showLogExtract', array( $this->mArticle, $out ) );
617  }
618 }
ProtectionForm\$mExpirySelection
$mExpirySelection
Map of action to value selected in expiry drop-down list.
Definition: ProtectionForm.php:49
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=array())
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:433
ResourceLoader\makeLoaderConditionalScript
static makeLoaderConditionalScript( $script)
Returns JS code which runs given JS code if the client-side framework is present.
Definition: ResourceLoader.php:1138
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
$wgUser
$wgUser
Definition: Setup.php:552
Page
Abstract class for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
Definition: WikiPage.php:26
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
ProtectionForm\$mPermErrors
$mPermErrors
Permissions errors for the protect action.
Definition: ProtectionForm.php:52
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
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
ProtectionForm\$mExpiry
$mExpiry
Map of action to "other" expiry time.
Definition: ProtectionForm.php:43
ProtectionForm\$mCascade
$mCascade
True if the restrictions are cascading, from request or existing protection.
Definition: ProtectionForm.php:40
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3650
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
$timestamp
if( $limit) $timestamp
Definition: importImages.php:104
ProtectionForm\getExpiry
getExpiry( $action)
Get the expiry time for a given action, by combining the relevant inputs.
Definition: ProtectionForm.php:148
ProtectionForm\$mReason
$mReason
The custom/additional protection reason.
Definition: ProtectionForm.php:34
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2483
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
ProtectionForm\$mExistingExpiry
$mExistingExpiry
Map of action to the expiry time of the existing protection.
Definition: ProtectionForm.php:58
ProtectionForm\buildCleanupScript
buildCleanupScript()
Definition: ProtectionForm.php:588
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1313
ProtectionForm\loadData
loadData()
Loads the current state of protection into the object.
Definition: ProtectionForm.php:84
Html\hidden
static hidden( $name, $value, $attribs=array())
Convenience function to produce an input element with type=hidden.
Definition: Html.php:662
$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:2149
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
Html\inlineScript
static inlineScript( $contents)
Output a "<script>" tag with the given contents.
Definition: Html.php:570
ProtectionForm
Handles the page protection UI and backend.
Definition: ProtectionForm.php:29
ProtectionForm\save
save()
Save submitted protection form.
Definition: ProtectionForm.php:252
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
ProtectionForm\__construct
__construct(Page $article)
Definition: ProtectionForm.php:60
Xml\encodeJsCall
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
Definition: Xml.php:665
$out
$out
Definition: UtfNormalGenerate.php:167
$titles
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Definition: linkcache.txt:17
ProtectionForm\getOptionLabel
getOptionLabel( $permission)
Prepare the label for a protection selector option.
Definition: ProtectionForm.php:575
ProtectionForm\showLogExtract
showLogExtract(&$out)
Show protection long extracts for this page.
Definition: ProtectionForm.php:610
$wgOut
$wgOut
Definition: Setup.php:562
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:32
wfMessage
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
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
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4001
WatchAction\doWatchOrUnwatch
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
Definition: WatchAction.php:106
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ProtectionForm\buildForm
buildForm()
Build the input form.
Definition: ProtectionForm.php:327
ProtectionForm\execute
execute()
Main entry point for action=protect and action=unprotect.
Definition: ProtectionForm.php:175
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Definition: GlobalFunctions.php:2514
MWNamespace\getRestrictionLevels
static getRestrictionLevels( $index, User $user=null)
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a use...
Definition: Namespace.php:446
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
$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
TS_MW
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
Definition: GlobalFunctions.php:2431
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$value
$value
Definition: styleTest.css.php:45
ProtectionForm\show
show( $err=null)
Show the input form with optional error message.
Definition: ProtectionForm.php:197
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:2077
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
wfReadOnlyReason
wfReadOnlyReason()
Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
Definition: GlobalFunctions.php:1322
Xml\listDropDown
static listDropDown( $name='', $list='', $other='', $selected='', $class='', $tabindex=null)
Build a drop-down box from a textual list.
Definition: Xml.php:497
ProtectionForm\$mApplicableTypes
$mApplicableTypes
Types (i.e.
Definition: ProtectionForm.php:55
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
ProtectionForm\$mReasonSelection
$mReasonSelection
The reason selected from the list, blank for other/additional.
Definition: ProtectionForm.php:37
Xml\submitButton
static submitButton( $value, $attribs=array())
Convenience function to build an HTML submit button.
Definition: Xml.php:463
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:87
$t
$t
Definition: testCompression.php:65
Xml\input
static input( $name, $size=false, $value=false, $attribs=array())
Convenience function to build an HTML text input field.
Definition: Xml.php:294
Xml\label
static label( $label, $id, $attribs=array())
Convenience function to build an HTML form label.
Definition: Xml.php:374
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
$attribs
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1530
$article
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
Definition: hooks.txt:78
ProtectionForm\$mRestrictions
$mRestrictions
A map of action to restriction level, from request or default.
Definition: ProtectionForm.php:31
ProtectionForm\buildSelector
buildSelector( $action, $selected)
Build protection level selector.
Definition: ProtectionForm.php:544
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=array(), $page='', $user='', $param=array())
Show log extract.
Definition: LogEventsList.php:507