MediaWiki  1.29.2
InputBox.classes.php
Go to the documentation of this file.
1 <?php
9 // InputBox class
10 class InputBox {
11 
12  /* Fields */
13 
14  private $mParser;
15  private $mType = '';
16  private $mWidth = 50;
17  private $mPreload = '';
18  private $mPreloadparams = array();
19  private $mEditIntro = '';
20  private $mUseVE = '';
21  private $mSummary = '';
22  private $mNosummary = '';
23  private $mMinor = '';
24  private $mPage = '';
25  private $mBR = 'yes';
26  private $mDefaultText = '';
27  private $mPlaceholderText = '';
28  private $mBGColor = 'transparent';
29  private $mButtonLabel = '';
30  private $mSearchButtonLabel = '';
31  private $mFullTextButton = '';
32  private $mLabelText = '';
33  private $mHidden = '';
34  private $mNamespaces = '';
35  private $mID = '';
36  private $mInline = false;
37  private $mPrefix = '';
38  private $mDir = '';
39 
40  /* Functions */
41 
42  public function __construct( $parser ) {
43  $this->mParser = $parser;
44  // Default value for dir taken from the page language (bug 37018)
45  $this->mDir = $this->mParser->getTargetLanguage()->getDir();
46  // Split caches by language, to make sure visitors do not see a cached
47  // version in a random language (since labels are in the user language)
48  $this->mParser->getOptions()->getUserLangObj();
49  $this->mParser->getOutput()->addModuleStyles( array(
50  'ext.inputBox.styles',
51  'mediawiki.ui.input',
52  'mediawiki.ui.checkbox',
53  ) );
54  }
55 
56  public function render() {
57  // Handle various types
58  switch ( $this->mType ) {
59  case 'create':
60  case 'comment':
61  $this->mParser->getOutput()->addModules( 'ext.inputBox' );
62  return $this->getCreateForm();
63  case 'move':
64  return $this->getMoveForm();
65  case 'commenttitle':
66  return $this->getCommentForm();
67  case 'search':
68  return $this->getSearchForm('search');
69  case 'fulltext':
70  return $this->getSearchForm('fulltext');
71  case 'search2':
72  return $this->getSearchForm2();
73  default:
74  return Xml::tags( 'div', null,
75  Xml::element( 'strong',
76  array(
77  'class' => 'error'
78  ),
79  strlen( $this->mType ) > 0
80  ? wfMessage( 'inputbox-error-bad-type', $this->mType )->text()
81  : wfMessage( 'inputbox-error-no-type' )->text()
82  )
83  );
84  }
85  }
86 
87  /*
88  * Returns the action name and value to use in inputboxes which redirects to edit pages.
89  * Decides, if the link should redirect to VE edit page (veaction=edit) or to wikitext editor
90  * (action=edit).
91  *
92  * @return Array Array with name and value data
93  */
94  private function getEditActionArgs() {
95  // default is wikitext editor
96  $args = array(
97  'name' => 'action',
98  'value' => 'edit',
99  );
100  // check, if VE is installed and VE editor is requested
101  if ( ExtensionRegistry::getInstance()->isLoaded( 'VisualEditor' ) && $this->mUseVE ) {
102  $args = array(
103  'name' => 'veaction',
104  'value' => 'edit',
105  );
106  }
107  return $args;
108  }
109 
116  private function getLinebreakClasses() {
117  return strtolower( $this->mBR ) === '<br />' ? 'mw-inputbox-input ' : '';
118  }
119 
125  public function getSearchForm( $type ) {
127 
128  // Use button label fallbacks
129  if ( !$this->mButtonLabel ) {
130  $this->mButtonLabel = wfMessage( 'inputbox-tryexact' )->text();
131  }
132  if ( !$this->mSearchButtonLabel ) {
133  $this->mSearchButtonLabel = wfMessage( 'inputbox-searchfulltext' )->text();
134  }
135  if ( $this->mID !== '' ) {
136  $idArray = array( 'id' => Sanitizer::escapeId( $this->mID ) );
137  } else {
138  $idArray = array();
139  }
140  // We need a unqiue id to link <label> to checkboxes, but also
141  // want multiple <inputbox>'s to not be invalid html
142  $idRandStr = Sanitizer::escapeId( '-' . $this->mID . wfRandom(), 'noninitial' );
143 
144  // Build HTML
145  $htmlOut = Xml::openElement( 'div',
146  array(
147  'class' => 'mw-inputbox-centered',
148  'style' => $this->bgColorStyle(),
149  )
150  );
151  $htmlOut .= Xml::openElement( 'form',
152  array(
153  'name' => 'searchbox',
154  'class' => 'searchbox',
155  'action' => SpecialPage::getTitleFor( 'Search' )->getLocalUrl(),
156  ) + $idArray
157  );
158  $htmlOut .= Xml::element( 'input',
159  array(
160  'class' => $this->getLinebreakClasses() . 'searchboxInput mw-ui-input mw-ui-input-inline',
161  'name' => 'search',
162  'type' => $this->mHidden ? 'hidden' : 'text',
163  'value' => $this->mDefaultText,
164  'placeholder' => $this->mPlaceholderText,
165  'size' => $this->mWidth,
166  'dir' => $this->mDir,
167  )
168  );
169 
170  if ( $this->mPrefix != '' ) {
171  $htmlOut .= Html::hidden( 'prefix', $this->mPrefix );
172  }
173 
174  $htmlOut .= $this->mBR;
175 
176  // Determine namespace checkboxes
177  $namespacesArray = explode( ',', $this->mNamespaces );
178  if ( $this->mNamespaces ) {
179  $namespaces = $wgContLang->getNamespaces();
180  $nsAliases = array_merge( $wgContLang->getNamespaceAliases(), $wgNamespaceAliases );
181  $showNamespaces = array();
182  $checkedNS = array();
183  # Check for valid namespaces
184  foreach ( $namespacesArray as $userNS ) {
185  $userNS = trim( $userNS ); # no whitespace
186 
187  # Namespace needs to be checked if flagged with "**"
188  if ( strpos( $userNS, '**' ) ) {
189  $userNS = str_replace( '**', '', $userNS );
190  $checkedNS[$userNS] = true;
191  }
192 
193  $mainMsg = wfMessage( 'inputbox-ns-main' )->inContentLanguage()->text();
194  if ( $userNS == 'Main' || $userNS == $mainMsg ) {
195  $i = 0;
196  } elseif ( array_search( $userNS, $namespaces ) ) {
197  $i = array_search( $userNS, $namespaces );
198  } elseif ( isset( $nsAliases[$userNS] ) ) {
199  $i = $nsAliases[$userNS];
200  } else {
201  continue; # Namespace not recognized, skip
202  }
203  $showNamespaces[$i] = $userNS;
204  if ( isset( $checkedNS[$userNS] ) && $checkedNS[$userNS] ) {
205  $checkedNS[$i] = true;
206  }
207  }
208 
209  # Show valid namespaces
210  foreach ( $showNamespaces as $i => $name ) {
211  $checked = array();
212  // Namespace flagged with "**" or if it's the only one
213  if ( ( isset( $checkedNS[$i] ) && $checkedNS[$i] ) || count( $showNamespaces ) == 1 ) {
214  $checked = array( 'checked' => 'checked' );
215  }
216 
217  if ( count( $showNamespaces ) == 1 ) {
218  // Checkbox
219  $htmlOut .= Xml::element( 'input',
220  array(
221  'type' => 'hidden',
222  'name' => 'ns' . $i,
223  'value' => 1,
224  'id' => 'mw-inputbox-ns' . $i . $idRandStr
225  ) + $checked
226  );
227  } else {
228  // Checkbox
229  $htmlOut .= ' <div class="mw-inputbox-element mw-ui-checkbox">';
230  $htmlOut .= Xml::element( 'input',
231  array(
232  'type' => 'checkbox',
233  'name' => 'ns' . $i,
234  'value' => 1,
235  'id' => 'mw-inputbox-ns' . $i . $idRandStr
236  ) + $checked
237  );
238  // Label
239  $htmlOut .= Xml::label( $name, 'mw-inputbox-ns' . $i . $idRandStr );
240  $htmlOut .= '</div> ';
241  }
242  }
243 
244  // Line break
245  $htmlOut .= $this->mBR;
246  } elseif ( $type == 'search' ) {
247  // Go button
248  $htmlOut .= Xml::element( 'input',
249  array(
250  'type' => 'submit',
251  'name' => 'go',
252  'class' => 'mw-ui-button',
253  'value' => $this->mButtonLabel
254  )
255  );
256  $htmlOut .= '&#160;';
257  }
258 
259  // Search button
260  $htmlOut .= Xml::element( 'input',
261  array(
262  'type' => 'submit',
263  'name' => 'fulltext',
264  'class' => 'mw-ui-button',
265  'value' => $this->mSearchButtonLabel
266  )
267  );
268 
269  // Hidden fulltext param for IE (bug 17161)
270  if ( $type == 'fulltext' ) {
271  $htmlOut .= Html::hidden( 'fulltext', 'Search' );
272  }
273 
274  $htmlOut .= Xml::closeElement( 'form' );
275  $htmlOut .= Xml::closeElement( 'div' );
276 
277  // Return HTML
278  return $htmlOut;
279  }
280 
284  public function getSearchForm2() {
285  // Use button label fallbacks
286  if ( !$this->mButtonLabel ) {
287  $this->mButtonLabel = wfMessage( 'inputbox-tryexact' )->text();
288  }
289 
290  if ( $this->mID !== '' ) {
291  $unescapedID = $this->mID;
292  } else {
293  // The label element needs a unique id, use
294  // random number to avoid multiple input boxes
295  // having conflicts.
296  $unescapedID = wfRandom();
297  }
298  $id = Sanitizer::escapeId( $unescapedID, 'noninitial' );
299  $htmlLabel = '';
300  if ( isset( $this->mLabelText ) && strlen( trim( $this->mLabelText ) ) ) {
301  $this->mLabelText = $this->mParser->recursiveTagParse( $this->mLabelText );
302  $htmlLabel = Xml::openElement( 'label', array( 'for' => 'bodySearchInput' . $id ) );
303  $htmlLabel .= $this->mLabelText;
304  $htmlLabel .= Xml::closeElement( 'label' );
305  }
306  $htmlOut = Xml::openElement( 'form',
307  array(
308  'name' => 'bodySearch' . $id,
309  'id' => 'bodySearch' . $id,
310  'class' => 'bodySearch' . ( $this->mInline ? ' mw-inputbox-inline' : '' ),
311  'action' => SpecialPage::getTitleFor( 'Search' )->getLocalUrl(),
312  )
313  );
314  $htmlOut .= Xml::openElement( 'div',
315  array(
316  'class' => 'bodySearchWrap' . ( $this->mInline ? ' mw-inputbox-inline' : '' ),
317  'style' => $this->bgColorStyle(),
318  )
319  );
320  $htmlOut .= $htmlLabel;
321  $htmlOut .= Xml::element( 'input',
322  array(
323  'type' => $this->mHidden ? 'hidden' : 'text',
324  'name' => 'search',
325  'class' => 'mw-ui-input mw-ui-input-inline',
326  'size' => $this->mWidth,
327  'id' => 'bodySearchInput' . $id,
328  'dir' => $this->mDir,
329  )
330  );
331  $htmlOut .= '&#160;' . Xml::element( 'input',
332  array(
333  'type' => 'submit',
334  'name' => 'go',
335  'value' => $this->mButtonLabel,
336  'class' => 'mw-ui-button',
337  )
338  );
339 
340  // Better testing needed here!
341  if ( !empty( $this->mFullTextButton ) ) {
342  $htmlOut .= Xml::element( 'input',
343  array(
344  'type' => 'submit',
345  'name' => 'fulltext',
346  'class' => 'mw-ui-button',
347  'value' => $this->mSearchButtonLabel
348  )
349  );
350  }
351 
352  $htmlOut .= Xml::closeElement( 'div' );
353  $htmlOut .= Xml::closeElement( 'form' );
354 
355  // Return HTML
356  return $htmlOut;
357  }
358 
362  public function getCreateForm() {
364 
365  if ( $this->mType == "comment" ) {
366  if ( !$this->mButtonLabel ) {
367  $this->mButtonLabel = wfMessage( 'inputbox-postcomment' )->text();
368  }
369  } else {
370  if ( !$this->mButtonLabel ) {
371  $this->mButtonLabel = wfMessage( 'inputbox-createarticle' )->text();
372  }
373  }
374 
375  $htmlOut = Xml::openElement( 'div',
376  array(
377  'class' => 'mw-inputbox-centered',
378  'style' => $this->bgColorStyle(),
379  )
380  );
381  $createBoxParams = array(
382  'name' => 'createbox',
383  'class' => 'createbox',
384  'action' => $wgScript,
385  'method' => 'get'
386  );
387  if ( $this->mID !== '' ) {
388  $createBoxParams['id'] = Sanitizer::escapeId( $this->mID );
389  }
390  $htmlOut .= Xml::openElement( 'form', $createBoxParams );
391  $editArgs = $this->getEditActionArgs();
392  $htmlOut .= Html::hidden( $editArgs['name'], $editArgs['value'] );
393  $htmlOut .= Html::hidden( 'preload', $this->mPreload );
394  foreach ( $this->mPreloadparams as $preloadparams ) {
395  $htmlOut .= Html::hidden( 'preloadparams[]', $preloadparams );
396  }
397  $htmlOut .= Html::hidden( 'editintro', $this->mEditIntro );
398  $htmlOut .= Html::hidden( 'summary', $this->mSummary );
399  $htmlOut .= Html::hidden( 'nosummary', $this->mNosummary );
400  $htmlOut .= Html::hidden( 'prefix', $this->mPrefix );
401  $htmlOut .= Html::hidden( 'minor', $this->mMinor );
402  if ( $this->mType == 'comment' ) {
403  $htmlOut .= Html::hidden( 'section', 'new' );
404  }
405  $htmlOut .= Xml::openElement( 'input',
406  array(
407  'type' => $this->mHidden ? 'hidden' : 'text',
408  'name' => 'title',
409  'class' => $this->getLinebreakClasses() .
410  'mw-ui-input mw-ui-input-inline createboxInput',
411  'value' => $this->mDefaultText,
412  'placeholder' => $this->mPlaceholderText,
413  'size' => $this->mWidth,
414  'dir' => $this->mDir,
415  )
416  );
417  $htmlOut .= $this->mBR;
418  $htmlOut .= Xml::openElement( 'input',
419  array(
420  'type' => 'submit',
421  'name' => 'create',
422  'class' => 'mw-ui-button mw-ui-progressive createboxButton',
423  'value' => $this->mButtonLabel
424  )
425  );
426  $htmlOut .= Xml::closeElement( 'form' );
427  $htmlOut .= Xml::closeElement( 'div' );
428 
429  // Return HTML
430  return $htmlOut;
431  }
432 
436  public function getMoveForm() {
438 
439  if ( !$this->mButtonLabel ) {
440  $this->mButtonLabel = wfMessage( 'inputbox-movearticle' )->text();
441  }
442 
443  $htmlOut = Xml::openElement( 'div',
444  array(
445  'class' => 'mw-inputbox-centered',
446  'style' => $this->bgColorStyle(),
447  )
448  );
449  $moveBoxParams = array(
450  'name' => 'movebox',
451  'class' => 'mw-movebox',
452  'action' => $wgScript,
453  'method' => 'get'
454  );
455  if ( $this->mID !== '' ) {
456  $moveBoxParams['id'] = Sanitizer::escapeId( $this->mID );
457  }
458  $htmlOut .= Xml::openElement( 'form', $moveBoxParams );
459  $htmlOut .= Html::hidden( 'title', SpecialPage::getTitleFor( 'Movepage', $this->mPage )->getPrefixedText() );
460  $htmlOut .= Html::hidden( 'wpReason', $this->mSummary );
461  $htmlOut .= Html::hidden( 'prefix', $this->mPrefix );
462  $htmlOut .= Xml::openElement( 'input',
463  array(
464  'type' => $this->mHidden ? 'hidden' : 'text',
465  'name' => 'wpNewTitle',
466  'class' => $this->getLinebreakClasses() . 'mw-moveboxInput mw-ui-input mw-ui-input-inline',
467  'value' => $this->mDefaultText,
468  'placeholder' => $this->mPlaceholderText,
469  'size' => $this->mWidth,
470  'dir' => $this->mDir,
471  )
472  );
473  $htmlOut .= $this->mBR;
474  $htmlOut .= Xml::openElement( 'input',
475  array(
476  'type' => 'submit',
477  'class' => 'mw-ui-button mw-ui-progressive',
478  'value' => $this->mButtonLabel
479  )
480  );
481  $htmlOut .= Xml::closeElement( 'form' );
482  $htmlOut .= Xml::closeElement( 'div' );
483 
484  // Return HTML
485  return $htmlOut;
486  }
487 
491  public function getCommentForm() {
493 
494  if ( !$this->mButtonLabel ) {
495  $this->mButtonLabel = wfMessage( 'inputbox-postcommenttitle' )->text();
496  }
497 
498  $htmlOut = Xml::openElement( 'div',
499  array(
500  'class' => 'mw-inputbox-centered',
501  'style' => $this->bgColorStyle(),
502  )
503  );
504  $commentFormParams = array(
505  'name' => 'commentbox',
506  'class' => 'commentbox',
507  'action' => $wgScript,
508  'method' => 'get'
509  );
510  if ( $this->mID !== '' ) {
511  $commentFormParams['id'] = Sanitizer::escapeId( $this->mID );
512  }
513  $htmlOut .= Xml::openElement( 'form', $commentFormParams );
514  $editArgs = $this->getEditActionArgs();
515  $htmlOut .= Html::hidden( $editArgs['name'], $editArgs['value'] );
516  $htmlOut .= Html::hidden( 'preload', $this->mPreload );
517  foreach ( $this->mPreloadparams as $preloadparams ) {
518  $htmlOut .= Html::hidden( 'preloadparams[]', $preloadparams );
519  }
520  $htmlOut .= Html::hidden( 'editintro', $this->mEditIntro );
521  $htmlOut .= Xml::openElement( 'input',
522  array(
523  'type' => $this->mHidden ? 'hidden' : 'text',
524  'name' => 'preloadtitle',
525  'class' => $this->getLinebreakClasses() . 'commentboxInput mw-ui-input mw-ui-input-inline',
526  'value' => $this->mDefaultText,
527  'placeholder' => $this->mPlaceholderText,
528  'size' => $this->mWidth,
529  'dir' => $this->mDir,
530  )
531  );
532  $htmlOut .= Html::hidden( 'section', 'new' );
533  $htmlOut .= Html::hidden( 'title', $this->mPage );
534  $htmlOut .= $this->mBR;
535  $htmlOut .= Xml::openElement( 'input',
536  array(
537  'type' => 'submit',
538  'name' => 'create',
539  'class' => 'mw-ui-button mw-ui-progressive',
540  'value' => $this->mButtonLabel
541  )
542  );
543  $htmlOut .= Xml::closeElement( 'form' );
544  $htmlOut .= Xml::closeElement( 'div' );
545 
546  // Return HTML
547  return $htmlOut;
548  }
549 
555  public function extractOptions( $text ) {
556  // Parse all possible options
557  $values = array();
558  foreach ( explode( "\n", $text ) as $line ) {
559  if ( strpos( $line, '=' ) === false )
560  continue;
561  list( $name, $value ) = explode( '=', $line, 2 );
562  $name = strtolower( trim( $name ) );
563  $value = Sanitizer::decodeCharReferences( trim( $value ) );
564  if ( $name == 'preloadparams[]' ) {
565  // We have to special-case this one because it's valid for it to appear more than once.
566  $this->mPreloadparams[] = $value;
567  } else {
568  $values[ $name ] = $value;
569  }
570  }
571 
572  // Validate the dir value.
573  if ( isset( $values['dir'] ) && !in_array( $values['dir'], array( 'ltr', 'rtl' ) ) ) {
574  unset( $values['dir'] );
575  }
576 
577  // Build list of options, with local member names
578  $options = array(
579  'type' => 'mType',
580  'width' => 'mWidth',
581  'preload' => 'mPreload',
582  'page' => 'mPage',
583  'editintro' => 'mEditIntro',
584  'useve' => 'mUseVE',
585  'summary' => 'mSummary',
586  'nosummary' => 'mNosummary',
587  'minor' => 'mMinor',
588  'break' => 'mBR',
589  'default' => 'mDefaultText',
590  'placeholder' => 'mPlaceholderText',
591  'bgcolor' => 'mBGColor',
592  'buttonlabel' => 'mButtonLabel',
593  'searchbuttonlabel' => 'mSearchButtonLabel',
594  'fulltextbutton' => 'mFullTextButton',
595  'namespaces' => 'mNamespaces',
596  'labeltext' => 'mLabelText',
597  'hidden' => 'mHidden',
598  'id' => 'mID',
599  'inline' => 'mInline',
600  'prefix' => 'mPrefix',
601  'dir' => 'mDir',
602  );
603  foreach ( $options as $name => $var ) {
604  if ( isset( $values[$name] ) ) {
605  $this->$var = $values[$name];
606  }
607  }
608 
609  // Insert a line break if configured to do so
610  $this->mBR = ( strtolower( $this->mBR ) == "no" ) ? ' ' : '<br />';
611 
612  // Validate the width; make sure it's a valid, positive integer
613  $this->mWidth = intval( $this->mWidth <= 0 ? 50 : $this->mWidth );
614 
615  // Validate background color
616  if ( !$this->isValidColor( $this->mBGColor ) ) {
617  $this->mBGColor = 'transparent';
618  }
619  }
620 
624  public function isValidColor( $color ) {
625  $regex = <<<REGEX
626  /^ (
627  [a-zA-Z]* | # color names
628  \# [0-9a-f]{3} | # short hexadecimal
629  \# [0-9a-f]{6} | # long hexadecimal
630  rgb \s* \( \s* (
631  \d+ \s* , \s* \d+ \s* , \s* \d+ | # rgb integer
632  [0-9.]+% \s* , \s* [0-9.]+% \s* , \s* [0-9.]+% # rgb percent
633  ) \s* \)
634  ) $ /xi
635 REGEX;
636  return (bool) preg_match( $regex, $color );
637  }
638 
639  private function bgColorStyle() {
640  if ( $this->mBGColor != 'transparent' ) {
641  return 'background-color: ' . $this->mBGColor . ';';
642  }
643  return '';
644  }
645 }
InputBox::$mUseVE
$mUseVE
Definition: InputBox.classes.php:20
InputBox::$mDefaultText
$mDefaultText
Definition: InputBox.classes.php:26
InputBox::isValidColor
isValidColor( $color)
Do a security check on the bgcolor parameter.
Definition: InputBox.classes.php:624
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
InputBox::$mHidden
$mHidden
Definition: InputBox.classes.php:33
InputBox::bgColorStyle
bgColorStyle()
Definition: InputBox.classes.php:639
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
InputBox::$mType
$mType
Definition: InputBox.classes.php:15
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
$wgScript
$wgScript
The URL path to index.php.
Definition: DefaultSettings.php:202
InputBox::$mInline
$mInline
Definition: InputBox.classes.php:36
$namespaces
namespace and then decline to actually register it & $namespaces
Definition: hooks.txt:934
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:82
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
$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
names
alter the names
Definition: COPYING.txt:329
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
InputBox::$mWidth
$mWidth
Definition: InputBox.classes.php:16
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
InputBox
Definition: InputBox.classes.php:10
ExtensionRegistry\getInstance
static getInstance()
Definition: ExtensionRegistry.php:80
InputBox::$mPrefix
$mPrefix
Definition: InputBox.classes.php:37
InputBox::getSearchForm
getSearchForm( $type)
Generate search form.
Definition: InputBox.classes.php:125
InputBox::$mNosummary
$mNosummary
Definition: InputBox.classes.php:22
InputBox::$mPreload
$mPreload
Definition: InputBox.classes.php:17
a
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > ! end ! test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! end ! test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
Definition: parserTests.txt:89
InputBox::getLinebreakClasses
getLinebreakClasses()
Get common classes, that could be added and depend on, if a line break between a button and an input ...
Definition: InputBox.classes.php:116
InputBox::getEditActionArgs
getEditActionArgs()
Definition: InputBox.classes.php:94
not
if not
Definition: COPYING.txt:307
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
div
div
Definition: parserTests.txt:6533
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:2536
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
InputBox::$mNamespaces
$mNamespaces
Definition: InputBox.classes.php:34
InputBox::$mPage
$mPage
Definition: InputBox.classes.php:24
InputBox::getCommentForm
getCommentForm()
Generate new section form.
Definition: InputBox.classes.php:491
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
InputBox::render
render()
Definition: InputBox.classes.php:56
InputBox::getSearchForm2
getSearchForm2()
Generate search form version 2.
Definition: InputBox.classes.php:284
InputBox::getCreateForm
getCreateForm()
Generate create page form.
Definition: InputBox.classes.php:362
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:746
$line
$line
Definition: cdb.php:58
InputBox::$mSearchButtonLabel
$mSearchButtonLabel
Definition: InputBox.classes.php:30
$value
$value
Definition: styleTest.css.php:45
InputBox::getMoveForm
getMoveForm()
Generate move page form.
Definition: InputBox.classes.php:436
$wgNamespaceAliases
$wgNamespaceAliases['Image']
The canonical names of namespaces 6 and 7 are, as of v1.14, "File" and "File_talk".
Definition: Setup.php:164
InputBox::$mBR
$mBR
Definition: InputBox.classes.php:25
InputBox::$mMinor
$mMinor
Definition: InputBox.classes.php:23
title
title
Definition: parserTests.txt:211
InputBox::$mSummary
$mSummary
Definition: InputBox.classes.php:21
InputBox::$mButtonLabel
$mButtonLabel
Definition: InputBox.classes.php:29
InputBox::__construct
__construct( $parser)
Definition: InputBox.classes.php:42
InputBox::$mPreloadparams
$mPreloadparams
Definition: InputBox.classes.php:18
style
Bar style
Definition: parserTests.txt:184
$args
if( $line===false) $args
Definition: cdb.php:63
wfRandom
wfRandom()
Get a random decimal value between 0 and 1, in a way not likely to give duplicate values for any real...
Definition: GlobalFunctions.php:318
Image
! test dummy test ! input< imagemap > Image
Definition: imageMapParserTests.txt:8
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
InputBox::$mDir
$mDir
Definition: InputBox.classes.php:38
InputBox::$mFullTextButton
$mFullTextButton
Definition: InputBox.classes.php:31
InputBox::$mID
$mID
Definition: InputBox.classes.php:35
color
in the sidebar</td >< td > font color
Definition: All_system_messages.txt:425
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
width
width
Definition: parserTests.txt:155
wfMessage
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 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
InputBox::$mBGColor
$mBGColor
Definition: InputBox.classes.php:28
InputBox::$mEditIntro
$mEditIntro
Definition: InputBox.classes.php:19
InputBox::extractOptions
extractOptions( $text)
Extract options from a blob of text.
Definition: InputBox.classes.php:555
InputBox::$mPlaceholderText
$mPlaceholderText
Definition: InputBox.classes.php:27
InputBox::$mLabelText
$mLabelText
Definition: InputBox.classes.php:32
href
shown</td >< td > a href
Definition: All_system_messages.txt:2667
$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
array
the array() calling protocol came about after MediaWiki 1.4rc1.
$wgContLang
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 and the content language as $wgContLang
Definition: design.txt:56
InputBox::$mParser
$mParser
Definition: InputBox.classes.php:14