MediaWiki  1.23.15
Linker.php
Go to the documentation of this file.
1 <?php
32 class Linker {
33 
37  const TOOL_LINKS_NOBLOCK = 1;
38  const TOOL_LINKS_EMAIL = 2;
39 
49  static function getExternalLinkAttributes( $class = 'external' ) {
50  wfDeprecated( __METHOD__, '1.18' );
51  return self::getLinkAttributesInternal( '', $class );
52  }
53 
64  static function getInterwikiLinkAttributes( $title, $unused = null, $class = 'external' ) {
66 
67  # @todo FIXME: We have a whole bunch of handling here that doesn't happen in
68  # getExternalLinkAttributes, why?
69  $title = urldecode( $title );
70  $title = $wgContLang->checkTitleEncoding( $title );
71  $title = preg_replace( '/[\\x00-\\x1f]/', ' ', $title );
72 
73  return self::getLinkAttributesInternal( $title, $class );
74  }
75 
85  static function getInternalLinkAttributes( $title, $unused = null, $class = '' ) {
86  $title = urldecode( $title );
87  $title = str_replace( '_', ' ', $title );
88  return self::getLinkAttributesInternal( $title, $class );
89  }
90 
102  static function getInternalLinkAttributesObj( $nt, $unused = null, $class = '', $title = false ) {
103  if ( $title === false ) {
104  $title = $nt->getPrefixedText();
105  }
106  return self::getLinkAttributesInternal( $title, $class );
107  }
108 
117  private static function getLinkAttributesInternal( $title, $class ) {
118  $title = htmlspecialchars( $title );
119  $class = htmlspecialchars( $class );
120  $r = '';
121  if ( $class != '' ) {
122  $r .= " class=\"$class\"";
123  }
124  if ( $title != '' ) {
125  $r .= " title=\"$title\"";
126  }
127  return $r;
128  }
129 
137  public static function getLinkColour( $t, $threshold ) {
138  $colour = '';
139  if ( $t->isRedirect() ) {
140  # Page is a redirect
141  $colour = 'mw-redirect';
142  } elseif ( $threshold > 0 && $t->isContentPage() &&
143  $t->exists() && $t->getLength() < $threshold
144  ) {
145  # Page is a stub
146  $colour = 'stub';
147  }
148  return $colour;
149  }
150 
192  public static function link(
193  $target, $html = null, $customAttribs = array(), $query = array(), $options = array()
194  ) {
195  wfProfileIn( __METHOD__ );
196  if ( !$target instanceof Title ) {
197  wfProfileOut( __METHOD__ );
198  return "<!-- ERROR -->$html";
199  }
200 
201  if ( is_string( $query ) ) {
202  // some functions withing core using this still hand over query strings
203  wfDeprecated( __METHOD__ . ' with parameter $query as string (should be array)', '1.20' );
205  }
207 
208  $dummy = new DummyLinker; // dummy linker instance for bc on the hooks
209 
210  $ret = null;
211  if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$html,
212  &$customAttribs, &$query, &$options, &$ret ) ) ) {
213  wfProfileOut( __METHOD__ );
214  return $ret;
215  }
216 
217  # Normalize the Title if it's a special page
218  $target = self::normaliseSpecialPage( $target );
219 
220  # If we don't know whether the page exists, let's find out.
221  wfProfileIn( __METHOD__ . '-checkPageExistence' );
222  if ( !in_array( 'known', $options ) and !in_array( 'broken', $options ) ) {
223  if ( $target->isKnown() ) {
224  $options[] = 'known';
225  } else {
226  $options[] = 'broken';
227  }
228  }
229  wfProfileOut( __METHOD__ . '-checkPageExistence' );
230 
231  $oldquery = array();
232  if ( in_array( "forcearticlepath", $options ) && $query ) {
233  $oldquery = $query;
234  $query = array();
235  }
236 
237  # Note: we want the href attribute first, for prettiness.
238  $attribs = array( 'href' => self::linkUrl( $target, $query, $options ) );
239  if ( in_array( 'forcearticlepath', $options ) && $oldquery ) {
240  $attribs['href'] = wfAppendQuery( $attribs['href'], $oldquery );
241  }
242 
243  $attribs = array_merge(
244  $attribs,
245  self::linkAttribs( $target, $customAttribs, $options )
246  );
247  if ( is_null( $html ) ) {
248  $html = self::linkText( $target );
249  }
250 
251  $ret = null;
252  if ( wfRunHooks( 'LinkEnd', array( $dummy, $target, $options, &$html, &$attribs, &$ret ) ) ) {
253  $ret = Html::rawElement( 'a', $attribs, $html );
254  }
255 
256  wfProfileOut( __METHOD__ );
257  return $ret;
258  }
259 
264  public static function linkKnown(
265  $target, $html = null, $customAttribs = array(),
266  $query = array(), $options = array( 'known', 'noclasses' )
267  ) {
268  return self::link( $target, $html, $customAttribs, $query, $options );
269  }
270 
279  private static function linkUrl( $target, $query, $options ) {
280  wfProfileIn( __METHOD__ );
281  # We don't want to include fragments for broken links, because they
282  # generally make no sense.
283  if ( in_array( 'broken', $options ) && $target->hasFragment() ) {
284  $target = clone $target;
285  $target->setFragment( '' );
286  }
287 
288  # If it's a broken link, add the appropriate query pieces, unless
289  # there's already an action specified, or unless 'edit' makes no sense
290  # (i.e., for a nonexistent special page).
291  if ( in_array( 'broken', $options ) && empty( $query['action'] )
292  && !$target->isSpecialPage() ) {
293  $query['action'] = 'edit';
294  $query['redlink'] = '1';
295  }
296 
297  if ( in_array( 'http', $options ) ) {
298  $proto = PROTO_HTTP;
299  } elseif ( in_array( 'https', $options ) ) {
300  $proto = PROTO_HTTPS;
301  } else {
302  $proto = PROTO_RELATIVE;
303  }
304 
305  $ret = $target->getLinkURL( $query, false, $proto );
306  wfProfileOut( __METHOD__ );
307  return $ret;
308  }
309 
319  private static function linkAttribs( $target, $attribs, $options ) {
320  wfProfileIn( __METHOD__ );
321  global $wgUser;
322  $defaults = array();
323 
324  if ( !in_array( 'noclasses', $options ) ) {
325  wfProfileIn( __METHOD__ . '-getClasses' );
326  # Now build the classes.
327  $classes = array();
328 
329  if ( in_array( 'broken', $options ) ) {
330  $classes[] = 'new';
331  }
332 
333  if ( $target->isExternal() ) {
334  $classes[] = 'extiw';
335  }
336 
337  if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387)
338  $colour = self::getLinkColour( $target, $wgUser->getStubThreshold() );
339  if ( $colour !== '' ) {
340  $classes[] = $colour; # mw-redirect or stub
341  }
342  }
343  if ( $classes != array() ) {
344  $defaults['class'] = implode( ' ', $classes );
345  }
346  wfProfileOut( __METHOD__ . '-getClasses' );
347  }
348 
349  # Get a default title attribute.
350  if ( $target->getPrefixedText() == '' ) {
351  # A link like [[#Foo]]. This used to mean an empty title
352  # attribute, but that's silly. Just don't output a title.
353  } elseif ( in_array( 'known', $options ) ) {
354  $defaults['title'] = $target->getPrefixedText();
355  } else {
356  $defaults['title'] = wfMessage( 'red-link-title', $target->getPrefixedText() )->text();
357  }
358 
359  # Finally, merge the custom attribs with the default ones, and iterate
360  # over that, deleting all "false" attributes.
361  $ret = array();
362  $merged = Sanitizer::mergeAttributes( $defaults, $attribs );
363  foreach ( $merged as $key => $val ) {
364  # A false value suppresses the attribute, and we don't want the
365  # href attribute to be overridden.
366  if ( $key != 'href' and $val !== false ) {
367  $ret[$key] = $val;
368  }
369  }
370  wfProfileOut( __METHOD__ );
371  return $ret;
372  }
373 
381  private static function linkText( $target ) {
382  // We might be passed a non-Title by make*LinkObj(). Fail gracefully.
383  if ( !$target instanceof Title ) {
384  return '';
385  }
386 
387  // If the target is just a fragment, with no title, we return the fragment
388  // text. Otherwise, we return the title text itself.
389  if ( $target->getPrefixedText() === '' && $target->hasFragment() ) {
390  return htmlspecialchars( $target->getFragment() );
391  }
392  return htmlspecialchars( $target->getPrefixedText() );
393  }
394 
409  public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
410  if ( $html == '' ) {
411  $html = htmlspecialchars( $nt->getPrefixedText() );
412  }
413  list( $inside, $trail ) = self::splitTrail( $trail );
414  return "<strong class=\"selflink\">{$prefix}{$html}{$inside}</strong>{$trail}";
415  }
416 
427  public static function getInvalidTitleDescription( IContextSource $context, $namespace, $title ) {
429 
430  // First we check whether the namespace exists or not.
431  if ( MWNamespace::exists( $namespace ) ) {
432  if ( $namespace == NS_MAIN ) {
433  $name = $context->msg( 'blanknamespace' )->text();
434  } else {
435  $name = $wgContLang->getFormattedNsText( $namespace );
436  }
437  return $context->msg( 'invalidtitle-knownnamespace', $namespace, $name, $title )->text();
438  } else {
439  return $context->msg( 'invalidtitle-unknownnamespace', $namespace, $title )->text();
440  }
441  }
442 
447  static function normaliseSpecialPage( Title $title ) {
448  if ( $title->isSpecialPage() ) {
449  list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
450  if ( !$name ) {
451  return $title;
452  }
453  $ret = SpecialPage::getTitleFor( $name, $subpage, $title->getFragment() );
454  return $ret;
455  } else {
456  return $title;
457  }
458  }
459 
468  private static function fnamePart( $url ) {
469  $basename = strrchr( $url, '/' );
470  if ( false === $basename ) {
471  $basename = $url;
472  } else {
473  $basename = substr( $basename, 1 );
474  }
475  return $basename;
476  }
477 
487  public static function makeExternalImage( $url, $alt = '' ) {
488  if ( $alt == '' ) {
489  $alt = self::fnamePart( $url );
490  }
491  $img = '';
492  $success = wfRunHooks( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
493  if ( !$success ) {
494  wfDebug( "Hook LinkerMakeExternalImage changed the output of external image with url {$url} and alt text {$alt} to {$img}\n", true );
495  return $img;
496  }
497  return Html::element( 'img',
498  array(
499  'src' => $url,
500  'alt' => $alt ) );
501  }
502 
539  public static function makeImageLink( /*Parser*/ $parser, Title $title, $file, $frameParams = array(),
540  $handlerParams = array(), $time = false, $query = "", $widthOption = null
541  ) {
542  $res = null;
543  $dummy = new DummyLinker;
544  if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$dummy, &$title,
545  &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) {
546  return $res;
547  }
548 
549  if ( $file && !$file->allowInlineDisplay() ) {
550  wfDebug( __METHOD__ . ': ' . $title->getPrefixedDBkey() . " does not allow inline display\n" );
551  return self::link( $title );
552  }
553 
554  // Shortcuts
555  $fp =& $frameParams;
556  $hp =& $handlerParams;
557 
558  // Clean up parameters
559  $page = isset( $hp['page'] ) ? $hp['page'] : false;
560  if ( !isset( $fp['align'] ) ) {
561  $fp['align'] = '';
562  }
563  if ( !isset( $fp['alt'] ) ) {
564  $fp['alt'] = '';
565  }
566  if ( !isset( $fp['title'] ) ) {
567  $fp['title'] = '';
568  }
569  if ( !isset( $fp['class'] ) ) {
570  $fp['class'] = '';
571  }
572 
573  $prefix = $postfix = '';
574 
575  if ( 'center' == $fp['align'] ) {
576  $prefix = '<div class="center">';
577  $postfix = '</div>';
578  $fp['align'] = 'none';
579  }
580  if ( $file && !isset( $hp['width'] ) ) {
581  if ( isset( $hp['height'] ) && $file->isVectorized() ) {
582  // If its a vector image, and user only specifies height
583  // we don't want it to be limited by its "normal" width.
584  global $wgSVGMaxSize;
585  $hp['width'] = $wgSVGMaxSize;
586  } else {
587  $hp['width'] = $file->getWidth( $page );
588  }
589 
590  if ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
591  global $wgThumbLimits, $wgThumbUpright;
592  if ( $widthOption === null || !isset( $wgThumbLimits[$widthOption] ) ) {
593  $widthOption = User::getDefaultOption( 'thumbsize' );
594  }
595 
596  // Reduce width for upright images when parameter 'upright' is used
597  if ( isset( $fp['upright'] ) && $fp['upright'] == 0 ) {
598  $fp['upright'] = $wgThumbUpright;
599  }
600  // For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs
601  $prefWidth = isset( $fp['upright'] ) ?
602  round( $wgThumbLimits[$widthOption] * $fp['upright'], -1 ) :
603  $wgThumbLimits[$widthOption];
604 
605  // Use width which is smaller: real image width or user preference width
606  // Unless image is scalable vector.
607  if ( !isset( $hp['height'] ) && ( $hp['width'] <= 0 ||
608  $prefWidth < $hp['width'] || $file->isVectorized() ) ) {
609  $hp['width'] = $prefWidth;
610  }
611  }
612  }
613 
614  if ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) ) {
615  # Create a thumbnail. Alignment depends on the writing direction of
616  # the page content language (right-aligned for LTR languages,
617  # left-aligned for RTL languages)
618  #
619  # If a thumbnail width has not been provided, it is set
620  # to the default user option as specified in Language*.php
621  if ( $fp['align'] == '' ) {
622  if ( $parser instanceof Parser ) {
623  $fp['align'] = $parser->getTargetLanguage()->alignEnd();
624  } else {
625  # backwards compatibility, remove with makeImageLink2()
627  $fp['align'] = $wgContLang->alignEnd();
628  }
629  }
630  return $prefix . self::makeThumbLink2( $title, $file, $fp, $hp, $time, $query ) . $postfix;
631  }
632 
633  if ( $file && isset( $fp['frameless'] ) ) {
634  $srcWidth = $file->getWidth( $page );
635  # For "frameless" option: do not present an image bigger than the source (for bitmap-style images)
636  # This is the same behavior as the "thumb" option does it already.
637  if ( $srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth ) {
638  $hp['width'] = $srcWidth;
639  }
640  }
641 
642  if ( $file && isset( $hp['width'] ) ) {
643  # Create a resized image, without the additional thumbnail features
644  $thumb = $file->transform( $hp );
645  } else {
646  $thumb = false;
647  }
648 
649  if ( !$thumb ) {
650  $s = self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true );
651  } else {
652  self::processResponsiveImages( $file, $thumb, $hp );
653  $params = array(
654  'alt' => $fp['alt'],
655  'title' => $fp['title'],
656  'valign' => isset( $fp['valign'] ) ? $fp['valign'] : false,
657  'img-class' => $fp['class'] );
658  if ( isset( $fp['border'] ) ) {
659  $params['img-class'] .= ( $params['img-class'] !== '' ? ' ' : '' ) . 'thumbborder';
660  }
662 
663  $s = $thumb->toHtml( $params );
664  }
665  if ( $fp['align'] != '' ) {
666  $s = "<div class=\"float{$fp['align']}\">{$s}</div>";
667  }
668  return str_replace( "\n", ' ', $prefix . $s . $postfix );
669  }
670 
676  public static function makeImageLink2( Title $title, $file, $frameParams = array(),
677  $handlerParams = array(), $time = false, $query = "", $widthOption = null ) {
678  return self::makeImageLink( null, $title, $file, $frameParams,
679  $handlerParams, $time, $query, $widthOption );
680  }
681 
689  private static function getImageLinkMTOParams( $frameParams, $query = '', $parser = null ) {
690  $mtoParams = array();
691  if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) {
692  $mtoParams['custom-url-link'] = $frameParams['link-url'];
693  if ( isset( $frameParams['link-target'] ) ) {
694  $mtoParams['custom-target-link'] = $frameParams['link-target'];
695  }
696  if ( $parser ) {
697  $extLinkAttrs = $parser->getExternalLinkAttribs( $frameParams['link-url'] );
698  foreach ( $extLinkAttrs as $name => $val ) {
699  // Currently could include 'rel' and 'target'
700  $mtoParams['parser-extlink-' . $name] = $val;
701  }
702  }
703  } elseif ( isset( $frameParams['link-title'] ) && $frameParams['link-title'] !== '' ) {
704  $mtoParams['custom-title-link'] = self::normaliseSpecialPage( $frameParams['link-title'] );
705  } elseif ( !empty( $frameParams['no-link'] ) ) {
706  // No link
707  } else {
708  $mtoParams['desc-link'] = true;
709  $mtoParams['desc-query'] = $query;
710  }
711  return $mtoParams;
712  }
713 
726  public static function makeThumbLinkObj( Title $title, $file, $label = '', $alt,
727  $align = 'right', $params = array(), $framed = false, $manualthumb = ""
728  ) {
729  $frameParams = array(
730  'alt' => $alt,
731  'caption' => $label,
732  'align' => $align
733  );
734  if ( $framed ) {
735  $frameParams['framed'] = true;
736  }
737  if ( $manualthumb ) {
738  $frameParams['manualthumb'] = $manualthumb;
739  }
740  return self::makeThumbLink2( $title, $file, $frameParams, $params );
741  }
742 
752  public static function makeThumbLink2( Title $title, $file, $frameParams = array(),
753  $handlerParams = array(), $time = false, $query = ""
754  ) {
755  global $wgStylePath, $wgContLang;
756  $exists = $file && $file->exists();
757 
758  # Shortcuts
759  $fp =& $frameParams;
760  $hp =& $handlerParams;
761 
762  $page = isset( $hp['page'] ) ? $hp['page'] : false;
763  if ( !isset( $fp['align'] ) ) {
764  $fp['align'] = 'right';
765  }
766  if ( !isset( $fp['alt'] ) ) {
767  $fp['alt'] = '';
768  }
769  if ( !isset( $fp['title'] ) ) {
770  $fp['title'] = '';
771  }
772  if ( !isset( $fp['caption'] ) ) {
773  $fp['caption'] = '';
774  }
775 
776  if ( empty( $hp['width'] ) ) {
777  // Reduce width for upright images when parameter 'upright' is used
778  $hp['width'] = isset( $fp['upright'] ) ? 130 : 180;
779  }
780  $thumb = false;
781  $noscale = false;
782  $manualthumb = false;
783 
784  if ( !$exists ) {
785  $outerWidth = $hp['width'] + 2;
786  } else {
787  if ( isset( $fp['manualthumb'] ) ) {
788  # Use manually specified thumbnail
789  $manual_title = Title::makeTitleSafe( NS_FILE, $fp['manualthumb'] );
790  if ( $manual_title ) {
791  $manual_img = wfFindFile( $manual_title );
792  if ( $manual_img ) {
793  $thumb = $manual_img->getUnscaledThumb( $hp );
794  $manualthumb = true;
795  } else {
796  $exists = false;
797  }
798  }
799  } elseif ( isset( $fp['framed'] ) ) {
800  // Use image dimensions, don't scale
801  $thumb = $file->getUnscaledThumb( $hp );
802  $noscale = true;
803  } else {
804  # Do not present an image bigger than the source, for bitmap-style images
805  # This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
806  $srcWidth = $file->getWidth( $page );
807  if ( $srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth ) {
808  $hp['width'] = $srcWidth;
809  }
810  $thumb = $file->transform( $hp );
811  }
812 
813  if ( $thumb ) {
814  $outerWidth = $thumb->getWidth() + 2;
815  } else {
816  $outerWidth = $hp['width'] + 2;
817  }
818  }
819 
820  # ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
821  # So we don't need to pass it here in $query. However, the URL for the
822  # zoom icon still needs it, so we make a unique query for it. See bug 14771
823  $url = $title->getLocalURL( $query );
824  if ( $page ) {
825  $url = wfAppendQuery( $url, array( 'page' => $page ) );
826  }
827  if ( $manualthumb
828  && !isset( $fp['link-title'] )
829  && !isset( $fp['link-url'] )
830  && !isset( $fp['no-link'] ) ) {
831  $fp['link-url'] = $url;
832  }
833 
834  $s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
835  if ( !$exists ) {
836  $s .= self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true );
837  $zoomIcon = '';
838  } elseif ( !$thumb ) {
839  $s .= wfMessage( 'thumbnail_error', '' )->escaped();
840  $zoomIcon = '';
841  } else {
842  if ( !$noscale && !$manualthumb ) {
843  self::processResponsiveImages( $file, $thumb, $hp );
844  }
845  $params = array(
846  'alt' => $fp['alt'],
847  'title' => $fp['title'],
848  'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== '' ? $fp['class'] . ' ' : '' ) . 'thumbimage'
849  );
851  $s .= $thumb->toHtml( $params );
852  if ( isset( $fp['framed'] ) ) {
853  $zoomIcon = "";
854  } else {
855  $zoomIcon = Html::rawElement( 'div', array( 'class' => 'magnify' ),
856  Html::rawElement( 'a', array(
857  'href' => $url,
858  'class' => 'internal',
859  'title' => wfMessage( 'thumbnail-more' )->text() ),
860  Html::element( 'img', array(
861  'src' => $wgStylePath . '/common/images/magnify-clip' . ( $wgContLang->isRTL() ? '-rtl' : '' ) . '.png',
862  'width' => 15,
863  'height' => 11,
864  'alt' => "" ) ) ) );
865  }
866  }
867  $s .= ' <div class="thumbcaption">' . $zoomIcon . $fp['caption'] . "</div></div></div>";
868  return str_replace( "\n", ' ', $s );
869  }
870 
879  public static function processResponsiveImages( $file, $thumb, $hp ) {
880  global $wgResponsiveImages;
881  if ( $wgResponsiveImages ) {
882  $hp15 = $hp;
883  $hp15['width'] = round( $hp['width'] * 1.5 );
884  $hp20 = $hp;
885  $hp20['width'] = $hp['width'] * 2;
886  if ( isset( $hp['height'] ) ) {
887  $hp15['height'] = round( $hp['height'] * 1.5 );
888  $hp20['height'] = $hp['height'] * 2;
889  }
890 
891  $thumb15 = $file->transform( $hp15 );
892  $thumb20 = $file->transform( $hp20 );
893  if ( $thumb15 && $thumb15->getUrl() !== $thumb->getUrl() ) {
894  $thumb->responsiveUrls['1.5'] = $thumb15->getUrl();
895  }
896  if ( $thumb20 && $thumb20->getUrl() !== $thumb->getUrl() ) {
897  $thumb->responsiveUrls['2'] = $thumb20->getUrl();
898  }
899  }
900  }
901 
913  public static function makeBrokenImageLinkObj( $title, $label = '', $query = '', $unused1 = '', $unused2 = '', $time = false ) {
914  global $wgEnableUploads, $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
915  if ( ! $title instanceof Title ) {
916  return "<!-- ERROR -->" . htmlspecialchars( $label );
917  }
918  wfProfileIn( __METHOD__ );
919  if ( $label == '' ) {
920  $label = $title->getPrefixedText();
921  }
922  $encLabel = htmlspecialchars( $label );
923  $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
924 
925  if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads ) && !$currentExists ) {
926  $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
927 
928  if ( $redir ) {
929  wfProfileOut( __METHOD__ );
930  return self::linkKnown( $title, $encLabel, array(), wfCgiToArray( $query ) );
931  }
932 
933  $href = self::getUploadUrl( $title, $query );
934 
935  wfProfileOut( __METHOD__ );
936  return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
937  htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
938  $encLabel . '</a>';
939  }
940 
941  wfProfileOut( __METHOD__ );
942  return self::linkKnown( $title, $encLabel, array(), wfCgiToArray( $query ) );
943  }
944 
952  protected static function getUploadUrl( $destFile, $query = '' ) {
953  global $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
954  $q = 'wpDestFile=' . $destFile->getPartialURL();
955  if ( $query != '' ) {
956  $q .= '&' . $query;
957  }
958 
959  if ( $wgUploadMissingFileUrl ) {
960  return wfAppendQuery( $wgUploadMissingFileUrl, $q );
961  } elseif ( $wgUploadNavigationUrl ) {
962  return wfAppendQuery( $wgUploadNavigationUrl, $q );
963  } else {
964  $upload = SpecialPage::getTitleFor( 'Upload' );
965  return $upload->getLocalURL( $q );
966  }
967  }
968 
977  public static function makeMediaLinkObj( $title, $html = '', $time = false ) {
978  $img = wfFindFile( $title, array( 'time' => $time ) );
979  return self::makeMediaLinkFile( $title, $img, $html );
980  }
981 
993  public static function makeMediaLinkFile( Title $title, $file, $html = '' ) {
994  if ( $file && $file->exists() ) {
995  $url = $file->getURL();
996  $class = 'internal';
997  } else {
998  $url = self::getUploadUrl( $title );
999  $class = 'new';
1000  }
1001  $alt = htmlspecialchars( $title->getText(), ENT_QUOTES );
1002  if ( $html == '' ) {
1003  $html = $alt;
1004  }
1005  $u = htmlspecialchars( $url );
1006  return "<a href=\"{$u}\" class=\"$class\" title=\"{$alt}\">{$html}</a>";
1007  }
1008 
1016  public static function specialLink( $name, $key = '' ) {
1017  if ( $key == '' ) {
1018  $key = strtolower( $name );
1019  }
1020 
1021  return self::linkKnown( SpecialPage::getTitleFor( $name ), wfMessage( $key )->text() );
1022  }
1023 
1034  public static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array(), $title = null ) {
1035  global $wgTitle;
1036  $class = "external";
1037  if ( $linktype ) {
1038  $class .= " $linktype";
1039  }
1040  if ( isset( $attribs['class'] ) && $attribs['class'] ) {
1041  $class .= " {$attribs['class']}";
1042  }
1043  $attribs['class'] = $class;
1044 
1045  if ( $escape ) {
1046  $text = htmlspecialchars( $text );
1047  }
1048 
1049  if ( !$title ) {
1050  $title = $wgTitle;
1051  }
1052  $newRel = Parser::getExternalLinkRel( $url, $title );
1053  if ( !isset( $attribs['rel'] ) || $attribs['rel'] === '' ) {
1054  $attribs['rel'] = $newRel;
1055  } elseif( $newRel !== '' ) {
1056  // Merge the rel attributes.
1057  $newRels = explode( ' ', $newRel );
1058  $oldRels = explode( ' ', $attribs['rel'] );
1059  $combined = array_unique( array_merge( $newRels, $oldRels ) );
1060  $attribs['rel'] = implode( ' ', $combined );
1061  }
1062  $link = '';
1063  $success = wfRunHooks( 'LinkerMakeExternalLink',
1064  array( &$url, &$text, &$link, &$attribs, $linktype ) );
1065  if ( !$success ) {
1066  wfDebug( "Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}\n", true );
1067  return $link;
1068  }
1069  $attribs['href'] = $url;
1070  return Html::rawElement( 'a', $attribs, $text );
1071  }
1072 
1081  public static function userLink( $userId, $userName, $altUserName = false ) {
1082  if ( $userId == 0 ) {
1083  $page = SpecialPage::getTitleFor( 'Contributions', $userName );
1084  if ( $altUserName === false ) {
1085  $altUserName = IP::prettifyIP( $userName );
1086  }
1087  } else {
1088  $page = Title::makeTitle( NS_USER, $userName );
1089  }
1090 
1091  return self::link(
1092  $page,
1093  htmlspecialchars( $altUserName !== false ? $altUserName : $userName ),
1094  array( 'class' => 'mw-userlink' )
1095  );
1096  }
1097 
1109  public static function userToolLinks(
1110  $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
1111  ) {
1112  global $wgUser, $wgDisableAnonTalk, $wgLang;
1113  $talkable = !( $wgDisableAnonTalk && 0 == $userId );
1114  $blockable = !( $flags & self::TOOL_LINKS_NOBLOCK );
1115  $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
1116 
1117  $items = array();
1118  if ( $talkable ) {
1119  $items[] = self::userTalkLink( $userId, $userText );
1120  }
1121  if ( $userId ) {
1122  // check if the user has an edit
1123  $attribs = array();
1124  if ( $redContribsWhenNoEdits ) {
1125  if ( intval( $edits ) === 0 && $edits !== 0 ) {
1126  $user = User::newFromId( $userId );
1127  $edits = $user->getEditCount();
1128  }
1129  if ( $edits === 0 ) {
1130  $attribs['class'] = 'new';
1131  }
1132  }
1133  $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText );
1134 
1135  $items[] = self::link( $contribsPage, wfMessage( 'contribslink' )->escaped(), $attribs );
1136  }
1137  if ( $blockable && $wgUser->isAllowed( 'block' ) ) {
1138  $items[] = self::blockLink( $userId, $userText );
1139  }
1140 
1141  if ( $addEmailLink && $wgUser->canSendEmail() ) {
1142  $items[] = self::emailLink( $userId, $userText );
1143  }
1144 
1145  wfRunHooks( 'UserToolLinksEdit', array( $userId, $userText, &$items ) );
1146 
1147  if ( $items ) {
1148  return wfMessage( 'word-separator' )->plain()
1149  . '<span class="mw-usertoollinks">'
1150  . wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped()
1151  . '</span>';
1152  } else {
1153  return '';
1154  }
1155  }
1156 
1164  public static function userToolLinksRedContribs( $userId, $userText, $edits = null ) {
1165  return self::userToolLinks( $userId, $userText, true, 0, $edits );
1166  }
1167 
1173  public static function userTalkLink( $userId, $userText ) {
1174  $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText );
1175  $userTalkLink = self::link( $userTalkPage, wfMessage( 'talkpagelinktext' )->escaped() );
1176  return $userTalkLink;
1177  }
1178 
1184  public static function blockLink( $userId, $userText ) {
1185  $blockPage = SpecialPage::getTitleFor( 'Block', $userText );
1186  $blockLink = self::link( $blockPage, wfMessage( 'blocklink' )->escaped() );
1187  return $blockLink;
1188  }
1189 
1195  public static function emailLink( $userId, $userText ) {
1196  $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText );
1197  $emailLink = self::link( $emailPage, wfMessage( 'emaillink' )->escaped() );
1198  return $emailLink;
1199  }
1200 
1207  public static function revUserLink( $rev, $isPublic = false ) {
1208  if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
1209  $link = wfMessage( 'rev-deleted-user' )->escaped();
1210  } elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
1212  $rev->getUserText( Revision::FOR_THIS_USER ) );
1213  } else {
1214  $link = wfMessage( 'rev-deleted-user' )->escaped();
1215  }
1216  if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
1217  return '<span class="history-deleted">' . $link . '</span>';
1218  }
1219  return $link;
1220  }
1221 
1228  public static function revUserTools( $rev, $isPublic = false ) {
1229  if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
1230  $link = wfMessage( 'rev-deleted-user' )->escaped();
1231  } elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
1232  $userId = $rev->getUser( Revision::FOR_THIS_USER );
1233  $userText = $rev->getUserText( Revision::FOR_THIS_USER );
1234  $link = self::userLink( $userId, $userText )
1235  . wfMessage( 'word-separator' )->plain()
1236  . self::userToolLinks( $userId, $userText );
1237  } else {
1238  $link = wfMessage( 'rev-deleted-user' )->escaped();
1239  }
1240  if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
1241  return ' <span class="history-deleted">' . $link . '</span>';
1242  }
1243  return $link;
1244  }
1245 
1263  public static function formatComment( $comment, $title = null, $local = false ) {
1264  wfProfileIn( __METHOD__ );
1265 
1266  # Sanitize text a bit:
1267  $comment = str_replace( "\n", " ", $comment );
1268  # Allow HTML entities (for bug 13815)
1270 
1271  # Render autocomments and make links:
1274 
1275  wfProfileOut( __METHOD__ );
1276  return $comment;
1277  }
1278 
1284 
1298  private static function formatAutocomments( $comment, $title = null, $local = false ) {
1299  // Bah!
1300  self::$autocommentTitle = $title;
1301  self::$autocommentLocal = $local;
1302  $comment = preg_replace_callback(
1303  '!(.*)/\*\s*(.*?)\s*\*/(.*)!',
1304  array( 'Linker', 'formatAutocommentsCallback' ),
1305  $comment );
1306  self::$autocommentTitle = null;
1307  self::$autocommentLocal = null;
1308  return $comment;
1309  }
1310 
1316  private static function formatAutocommentsCallback( $match ) {
1317  global $wgLang;
1319  $local = self::$autocommentLocal;
1320 
1321  $pre = $match[1];
1322  $auto = $match[2];
1323  $post = $match[3];
1324  $comment = null;
1325  wfRunHooks( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
1326  if ( $comment === null ) {
1327  $link = '';
1328  if ( $title ) {
1329  $section = $auto;
1330 
1331  # Remove links that a user may have manually put in the autosummary
1332  # This could be improved by copying as much of Parser::stripSectionName as desired.
1333  $section = str_replace( '[[:', '', $section );
1334  $section = str_replace( '[[', '', $section );
1335  $section = str_replace( ']]', '', $section );
1336 
1338  if ( $local ) {
1339  $sectionTitle = Title::newFromText( '#' . $section );
1340  } else {
1341  $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
1342  $title->getDBkey(), $section );
1343  }
1344  if ( $sectionTitle ) {
1345  $link = self::link( $sectionTitle,
1346  $wgLang->getArrow(), array(), array(),
1347  'noclasses' );
1348  } else {
1349  $link = '';
1350  }
1351  }
1352  if ( $pre ) {
1353  # written summary $presep autocomment (summary /* section */)
1354  $pre .= wfMessage( 'autocomment-prefix' )->inContentLanguage()->escaped();
1355  }
1356  if ( $post ) {
1357  # autocomment $postsep written summary (/* section */ summary)
1358  $auto .= wfMessage( 'colon-separator' )->inContentLanguage()->escaped();
1359  }
1360  $auto = '<span class="autocomment">' . $auto . '</span>';
1361  $comment = $pre . $link . $wgLang->getDirMark() . '<span dir="auto">' . $auto . $post . '</span>';
1362  }
1363  return $comment;
1364  }
1365 
1371 
1382  public static function formatLinksInComment( $comment, $title = null, $local = false ) {
1383  self::$commentContextTitle = $title;
1384  self::$commentLocal = $local;
1385  $html = preg_replace_callback(
1386  '/
1387  \[\[
1388  :? # ignore optional leading colon
1389  ([^\]|]+) # 1. link target; page names cannot include ] or |
1390  (?:\|
1391  # 2. a pipe-separated substring; only the last is captured
1392  # Stop matching at | and ]] without relying on backtracking.
1393  ((?:]?[^\]|])*+)
1394  )*
1395  \]\]
1396  ([^[]*) # 3. link trail (the text up until the next link)
1397  /x',
1398  array( 'Linker', 'formatLinksInCommentCallback' ),
1399  $comment );
1400  self::$commentContextTitle = null;
1401  self::$commentLocal = null;
1402  return $html;
1403  }
1404 
1409  protected static function formatLinksInCommentCallback( $match ) {
1411 
1412  $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
1413  $medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
1414 
1415  $comment = $match[0];
1416 
1417  # fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
1418  if ( strpos( $match[1], '%' ) !== false ) {
1419  $match[1] = str_replace( array( '<', '>' ), array( '&lt;', '&gt;' ), rawurldecode( $match[1] ) );
1420  }
1421 
1422  # Handle link renaming [[foo|text]] will show link as "text"
1423  if ( $match[2] != "" ) {
1424  $text = $match[2];
1425  } else {
1426  $text = $match[1];
1427  }
1428  $submatch = array();
1429  $thelink = null;
1430  if ( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
1431  # Media link; trail not supported.
1432  $linkRegexp = '/\[\[(.*?)\]\]/';
1433  $title = Title::makeTitleSafe( NS_FILE, $submatch[1] );
1434  if ( $title ) {
1435  $thelink = self::makeMediaLinkObj( $title, $text );
1436  }
1437  } else {
1438  # Other kind of link
1439  if ( preg_match( $wgContLang->linkTrail(), $match[3], $submatch ) ) {
1440  $trail = $submatch[1];
1441  } else {
1442  $trail = "";
1443  }
1444  $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
1445  if ( isset( $match[1][0] ) && $match[1][0] == ':' ) {
1446  $match[1] = substr( $match[1], 1 );
1447  }
1448  list( $inside, $trail ) = self::splitTrail( $trail );
1449 
1450  $linkText = $text;
1451  $linkTarget = self::normalizeSubpageLink( self::$commentContextTitle,
1452  $match[1], $linkText );
1453 
1454  $target = Title::newFromText( $linkTarget );
1455  if ( $target ) {
1456  if ( $target->getText() == '' && !$target->isExternal()
1457  && !self::$commentLocal && self::$commentContextTitle
1458  ) {
1459  $newTarget = clone ( self::$commentContextTitle );
1460  $newTarget->setFragment( '#' . $target->getFragment() );
1461  $target = $newTarget;
1462  }
1463  $thelink = self::link(
1464  $target,
1465  $linkText . $inside
1466  ) . $trail;
1467  }
1468  }
1469  if ( $thelink ) {
1470  // If the link is still valid, go ahead and replace it in!
1471  $comment = preg_replace( $linkRegexp, StringUtils::escapeRegexReplacement( $thelink ), $comment, 1 );
1472  }
1473 
1474  return $comment;
1475  }
1476 
1483  public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
1484  # Valid link forms:
1485  # Foobar -- normal
1486  # :Foobar -- override special treatment of prefix (images, language links)
1487  # /Foobar -- convert to CurrentPage/Foobar
1488  # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial / from text
1489  # ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
1490  # ../Foobar -- convert to CurrentPage/Foobar, from CurrentPage/CurrentSubPage
1491 
1492  wfProfileIn( __METHOD__ );
1493  $ret = $target; # default return value is no change
1494 
1495  # Some namespaces don't allow subpages,
1496  # so only perform processing if subpages are allowed
1497  if ( $contextTitle && MWNamespace::hasSubpages( $contextTitle->getNamespace() ) ) {
1498  $hash = strpos( $target, '#' );
1499  if ( $hash !== false ) {
1500  $suffix = substr( $target, $hash );
1501  $target = substr( $target, 0, $hash );
1502  } else {
1503  $suffix = '';
1504  }
1505  # bug 7425
1506  $target = trim( $target );
1507  # Look at the first character
1508  if ( $target != '' && $target[0] === '/' ) {
1509  # / at end means we don't want the slash to be shown
1510  $m = array();
1511  $trailingSlashes = preg_match_all( '%(/+)$%', $target, $m );
1512  if ( $trailingSlashes ) {
1513  $noslash = $target = substr( $target, 1, -strlen( $m[0][0] ) );
1514  } else {
1515  $noslash = substr( $target, 1 );
1516  }
1517 
1518  $ret = $contextTitle->getPrefixedText() . '/' . trim( $noslash ) . $suffix;
1519  if ( $text === '' ) {
1520  $text = $target . $suffix;
1521  } # this might be changed for ugliness reasons
1522  } else {
1523  # check for .. subpage backlinks
1524  $dotdotcount = 0;
1525  $nodotdot = $target;
1526  while ( strncmp( $nodotdot, "../", 3 ) == 0 ) {
1527  ++$dotdotcount;
1528  $nodotdot = substr( $nodotdot, 3 );
1529  }
1530  if ( $dotdotcount > 0 ) {
1531  $exploded = explode( '/', $contextTitle->getPrefixedText() );
1532  if ( count( $exploded ) > $dotdotcount ) { # not allowed to go below top level page
1533  $ret = implode( '/', array_slice( $exploded, 0, -$dotdotcount ) );
1534  # / at the end means don't show full path
1535  if ( substr( $nodotdot, -1, 1 ) === '/' ) {
1536  $nodotdot = substr( $nodotdot, 0, -1 );
1537  if ( $text === '' ) {
1538  $text = $nodotdot . $suffix;
1539  }
1540  }
1541  $nodotdot = trim( $nodotdot );
1542  if ( $nodotdot != '' ) {
1543  $ret .= '/' . $nodotdot;
1544  }
1545  $ret .= $suffix;
1546  }
1547  }
1548  }
1549  }
1550 
1551  wfProfileOut( __METHOD__ );
1552  return $ret;
1553  }
1554 
1565  public static function commentBlock( $comment, $title = null, $local = false ) {
1566  // '*' used to be the comment inserted by the software way back
1567  // in antiquity in case none was provided, here for backwards
1568  // compatibility, acc. to brion -ævar
1569  if ( $comment == '' || $comment == '*' ) {
1570  return '';
1571  } else {
1572  $formatted = self::formatComment( $comment, $title, $local );
1573  $formatted = wfMessage( 'parentheses' )->rawParams( $formatted )->escaped();
1574  return " <span class=\"comment\">$formatted</span>";
1575  }
1576  }
1577 
1587  public static function revComment( Revision $rev, $local = false, $isPublic = false ) {
1588  if ( $rev->getRawComment() == "" ) {
1589  return "";
1590  }
1591  if ( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) {
1592  $block = " <span class=\"comment\">" . wfMessage( 'rev-deleted-comment' )->escaped() . "</span>";
1593  } elseif ( $rev->userCan( Revision::DELETED_COMMENT ) ) {
1594  $block = self::commentBlock( $rev->getComment( Revision::FOR_THIS_USER ),
1595  $rev->getTitle(), $local );
1596  } else {
1597  $block = " <span class=\"comment\">" . wfMessage( 'rev-deleted-comment' )->escaped() . "</span>";
1598  }
1599  if ( $rev->isDeleted( Revision::DELETED_COMMENT ) ) {
1600  return " <span class=\"history-deleted\">$block</span>";
1601  }
1602  return $block;
1603  }
1604 
1609  public static function formatRevisionSize( $size ) {
1610  if ( $size == 0 ) {
1611  $stxt = wfMessage( 'historyempty' )->escaped();
1612  } else {
1613  $stxt = wfMessage( 'nbytes' )->numParams( $size )->escaped();
1614  $stxt = wfMessage( 'parentheses' )->rawParams( $stxt )->escaped();
1615  }
1616  return "<span class=\"history-size\">$stxt</span>";
1617  }
1618 
1624  public static function tocIndent() {
1625  return "\n<ul>";
1626  }
1627 
1633  public static function tocUnindent( $level ) {
1634  return "</li>\n" . str_repeat( "</ul>\n</li>\n", $level > 0 ? $level : 0 );
1635  }
1636 
1642  public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
1643  $classes = "toclevel-$level";
1644  if ( $sectionIndex !== false ) {
1645  $classes .= " tocsection-$sectionIndex";
1646  }
1647  return "\n<li class=\"$classes\"><a href=\"#" .
1648  $anchor . '"><span class="tocnumber">' .
1649  $tocnumber . '</span> <span class="toctext">' .
1650  $tocline . '</span></a>';
1651  }
1652 
1659  public static function tocLineEnd() {
1660  return "</li>\n";
1661  }
1662 
1670  public static function tocList( $toc, $lang = false ) {
1671  $lang = wfGetLangObj( $lang );
1672  $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
1673 
1674  return '<div id="toc" class="toc">'
1675  . '<div id="toctitle"><h2>' . $title . "</h2></div>\n"
1676  . $toc
1677  . "</ul>\n</div>\n";
1678  }
1679 
1687  public static function generateTOC( $tree ) {
1688  $toc = '';
1689  $lastLevel = 0;
1690  foreach ( $tree as $section ) {
1691  if ( $section['toclevel'] > $lastLevel ) {
1692  $toc .= self::tocIndent();
1693  } elseif ( $section['toclevel'] < $lastLevel ) {
1694  $toc .= self::tocUnindent(
1695  $lastLevel - $section['toclevel'] );
1696  } else {
1697  $toc .= self::tocLineEnd();
1698  }
1699 
1700  $toc .= self::tocLine( $section['anchor'],
1701  $section['line'], $section['number'],
1702  $section['toclevel'], $section['index'] );
1703  $lastLevel = $section['toclevel'];
1704  }
1705  $toc .= self::tocLineEnd();
1706  return self::tocList( $toc );
1707  }
1708 
1724  public static function makeHeadline( $level, $attribs, $anchor, $html, $link, $legacyAnchor = false ) {
1725  $ret = "<h$level$attribs"
1726  . "<span class=\"mw-headline\" id=\"$anchor\">$html</span>"
1727  . $link
1728  . "</h$level>";
1729  if ( $legacyAnchor !== false ) {
1730  $ret = "<div id=\"$legacyAnchor\"></div>$ret";
1731  }
1732  return $ret;
1733  }
1734 
1740  static function splitTrail( $trail ) {
1742  $regex = $wgContLang->linkTrail();
1743  $inside = '';
1744  if ( $trail !== '' ) {
1745  $m = array();
1746  if ( preg_match( $regex, $trail, $m ) ) {
1747  $inside = $m[1];
1748  $trail = $m[2];
1749  }
1750  }
1751  return array( $inside, $trail );
1752  }
1753 
1779  public static function generateRollback( $rev, IContextSource $context = null, $options = array( 'verify' ) ) {
1780  if ( $context === null ) {
1781  $context = RequestContext::getMain();
1782  }
1783  $editCount = false;
1784  if ( in_array( 'verify', $options ) ) {
1785  $editCount = self::getRollbackEditCount( $rev, true );
1786  if ( $editCount === false ) {
1787  return '';
1788  }
1789  }
1790 
1791  $inner = self::buildRollbackLink( $rev, $context, $editCount );
1792 
1793  if ( !in_array( 'noBrackets', $options ) ) {
1794  $inner = $context->msg( 'brackets' )->rawParams( $inner )->plain();
1795  }
1796 
1797  return '<span class="mw-rollback-link">' . $inner . '</span>';
1798  }
1799 
1815  public static function getRollbackEditCount( $rev, $verify ) {
1816  global $wgShowRollbackEditCount;
1817  if ( !is_int( $wgShowRollbackEditCount ) || !$wgShowRollbackEditCount > 0 ) {
1818  // Nothing has happened, indicate this by returning 'null'
1819  return null;
1820  }
1821 
1822  $dbr = wfGetDB( DB_SLAVE );
1823 
1824  // Up to the value of $wgShowRollbackEditCount revisions are counted
1825  $res = $dbr->select(
1826  'revision',
1827  array( 'rev_user_text', 'rev_deleted' ),
1828  // $rev->getPage() returns null sometimes
1829  array( 'rev_page' => $rev->getTitle()->getArticleID() ),
1830  __METHOD__,
1831  array(
1832  'USE INDEX' => array( 'revision' => 'page_timestamp' ),
1833  'ORDER BY' => 'rev_timestamp DESC',
1834  'LIMIT' => $wgShowRollbackEditCount + 1
1835  )
1836  );
1837 
1838  $editCount = 0;
1839  $moreRevs = false;
1840  foreach ( $res as $row ) {
1841  if ( $rev->getRawUserText() != $row->rev_user_text ) {
1842  if ( $verify && ( $row->rev_deleted & Revision::DELETED_TEXT || $row->rev_deleted & Revision::DELETED_USER ) ) {
1843  // If the user or the text of the revision we might rollback to is deleted in some way we can't rollback
1844  // Similar to the sanity checks in WikiPage::commitRollback
1845  return false;
1846  }
1847  $moreRevs = true;
1848  break;
1849  }
1850  $editCount++;
1851  }
1852 
1853  if ( $verify && $editCount <= $wgShowRollbackEditCount && !$moreRevs ) {
1854  // We didn't find at least $wgShowRollbackEditCount revisions made by the current user
1855  // and there weren't any other revisions. That means that the current user is the only
1856  // editor, so we can't rollback
1857  return false;
1858  }
1859  return $editCount;
1860  }
1861 
1870  public static function buildRollbackLink( $rev, IContextSource $context = null, $editCount = false ) {
1871  global $wgShowRollbackEditCount, $wgMiserMode;
1872 
1873  // To config which pages are effected by miser mode
1874  $disableRollbackEditCountSpecialPage = array( 'Recentchanges', 'Watchlist' );
1875 
1876  if ( $context === null ) {
1877  $context = RequestContext::getMain();
1878  }
1879 
1880  $title = $rev->getTitle();
1881  $query = array(
1882  'action' => 'rollback',
1883  'from' => $rev->getUserText(),
1884  'token' => $context->getUser()->getEditToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
1885  );
1886  if ( $context->getRequest()->getBool( 'bot' ) ) {
1887  $query['bot'] = '1';
1888  $query['hidediff'] = '1'; // bug 15999
1889  }
1890 
1891  $disableRollbackEditCount = false;
1892  if ( $wgMiserMode ) {
1893  foreach ( $disableRollbackEditCountSpecialPage as $specialPage ) {
1894  if ( $context->getTitle()->isSpecial( $specialPage ) ) {
1895  $disableRollbackEditCount = true;
1896  break;
1897  }
1898  }
1899  }
1900 
1901  if ( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
1902  if ( !is_numeric( $editCount ) ) {
1903  $editCount = self::getRollbackEditCount( $rev, false );
1904  }
1905 
1906  if ( $editCount > $wgShowRollbackEditCount ) {
1907  $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )->numParams( $wgShowRollbackEditCount )->parse();
1908  } else {
1909  $editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
1910  }
1911 
1912  return self::link(
1913  $title,
1914  $editCount_output,
1915  array( 'title' => $context->msg( 'tooltip-rollback' )->text() ),
1916  $query,
1917  array( 'known', 'noclasses' )
1918  );
1919  } else {
1920  return self::link(
1921  $title,
1922  $context->msg( 'rollbacklink' )->escaped(),
1923  array( 'title' => $context->msg( 'tooltip-rollback' )->text() ),
1924  $query,
1925  array( 'known', 'noclasses' )
1926  );
1927  }
1928  }
1929 
1945  public static function formatTemplates( $templates, $preview = false, $section = false, $more = null ) {
1946  global $wgLang;
1947  wfProfileIn( __METHOD__ );
1948 
1949  $outText = '';
1950  if ( count( $templates ) > 0 ) {
1951  # Do a batch existence check
1952  $batch = new LinkBatch;
1953  foreach ( $templates as $title ) {
1954  $batch->addObj( $title );
1955  }
1956  $batch->execute();
1957 
1958  # Construct the HTML
1959  $outText = '<div class="mw-templatesUsedExplanation">';
1960  if ( $preview ) {
1961  $outText .= wfMessage( 'templatesusedpreview' )->numParams( count( $templates ) )
1962  ->parseAsBlock();
1963  } elseif ( $section ) {
1964  $outText .= wfMessage( 'templatesusedsection' )->numParams( count( $templates ) )
1965  ->parseAsBlock();
1966  } else {
1967  $outText .= wfMessage( 'templatesused' )->numParams( count( $templates ) )
1968  ->parseAsBlock();
1969  }
1970  $outText .= "</div><ul>\n";
1971 
1972  usort( $templates, 'Title::compare' );
1973  foreach ( $templates as $titleObj ) {
1974  $protected = '';
1975  $restrictions = $titleObj->getRestrictions( 'edit' );
1976  if ( $restrictions ) {
1977  // Check backwards-compatible messages
1978  $msg = null;
1979  if ( $restrictions === array( 'sysop' ) ) {
1980  $msg = wfMessage( 'template-protected' );
1981  } elseif ( $restrictions === array( 'autoconfirmed' ) ) {
1982  $msg = wfMessage( 'template-semiprotected' );
1983  }
1984  if ( $msg && !$msg->isDisabled() ) {
1985  $protected = $msg->parse();
1986  } else {
1987  // Construct the message from restriction-level-*
1988  // e.g. restriction-level-sysop, restriction-level-autoconfirmed
1989  $msgs = array();
1990  foreach ( $restrictions as $r ) {
1991  $msgs[] = wfMessage( "restriction-level-$r" )->parse();
1992  }
1993  $protected = wfMessage( 'parentheses' )
1994  ->rawParams( $wgLang->commaList( $msgs ) )->escaped();
1995  }
1996  }
1997  if ( $titleObj->quickUserCan( 'edit' ) ) {
1998  $editLink = self::link(
1999  $titleObj,
2000  wfMessage( 'editlink' )->text(),
2001  array(),
2002  array( 'action' => 'edit' )
2003  );
2004  } else {
2005  $editLink = self::link(
2006  $titleObj,
2007  wfMessage( 'viewsourcelink' )->text(),
2008  array(),
2009  array( 'action' => 'edit' )
2010  );
2011  }
2012  $outText .= '<li>' . self::link( $titleObj )
2013  . wfMessage( 'word-separator' )->escaped()
2014  . wfMessage( 'parentheses' )->rawParams( $editLink )->escaped()
2015  . wfMessage( 'word-separator' )->escaped()
2016  . $protected . '</li>';
2017  }
2018 
2019  if ( $more instanceof Title ) {
2020  $outText .= '<li>' . self::link( $more, wfMessage( 'moredotdotdot' ) ) . '</li>';
2021  } elseif ( $more ) {
2022  $outText .= "<li>$more</li>";
2023  }
2024 
2025  $outText .= '</ul>';
2026  }
2027  wfProfileOut( __METHOD__ );
2028  return $outText;
2029  }
2030 
2038  public static function formatHiddenCategories( $hiddencats ) {
2039  wfProfileIn( __METHOD__ );
2040 
2041  $outText = '';
2042  if ( count( $hiddencats ) > 0 ) {
2043  # Construct the HTML
2044  $outText = '<div class="mw-hiddenCategoriesExplanation">';
2045  $outText .= wfMessage( 'hiddencategories' )->numParams( count( $hiddencats ) )->parseAsBlock();
2046  $outText .= "</div><ul>\n";
2047 
2048  foreach ( $hiddencats as $titleObj ) {
2049  $outText .= '<li>' . self::link( $titleObj, null, array(), array(), 'known' ) . "</li>\n"; # If it's hidden, it must exist - no need to check with a LinkBatch
2050  }
2051  $outText .= '</ul>';
2052  }
2053  wfProfileOut( __METHOD__ );
2054  return $outText;
2055  }
2056 
2064  public static function formatSize( $size ) {
2065  global $wgLang;
2066  return htmlspecialchars( $wgLang->formatSize( $size ) );
2067  }
2068 
2081  public static function titleAttrib( $name, $options = null ) {
2082  wfProfileIn( __METHOD__ );
2083 
2084  $message = wfMessage( "tooltip-$name" );
2085 
2086  if ( !$message->exists() ) {
2087  $tooltip = false;
2088  } else {
2089  $tooltip = $message->text();
2090  # Compatibility: formerly some tooltips had [alt-.] hardcoded
2091  $tooltip = preg_replace( "/ ?\[alt-.\]$/", '', $tooltip );
2092  # Message equal to '-' means suppress it.
2093  if ( $tooltip == '-' ) {
2094  $tooltip = false;
2095  }
2096  }
2097 
2098  if ( $options == 'withaccess' ) {
2099  $accesskey = self::accesskey( $name );
2100  if ( $accesskey !== false ) {
2101  if ( $tooltip === false || $tooltip === '' ) {
2102  $tooltip = wfMessage( 'brackets', $accesskey )->escaped();
2103  } else {
2104  $tooltip .= wfMessage( 'word-separator' )->escaped();
2105  $tooltip .= wfMessage( 'brackets', $accesskey )->escaped();
2106  }
2107  }
2108  }
2109 
2110  wfProfileOut( __METHOD__ );
2111  return $tooltip;
2112  }
2113 
2114  static $accesskeycache;
2115 
2126  public static function accesskey( $name ) {
2127  if ( isset( self::$accesskeycache[$name] ) ) {
2128  return self::$accesskeycache[$name];
2129  }
2130  wfProfileIn( __METHOD__ );
2131 
2132  $message = wfMessage( "accesskey-$name" );
2133 
2134  if ( !$message->exists() ) {
2135  $accesskey = false;
2136  } else {
2137  $accesskey = $message->plain();
2138  if ( $accesskey === '' || $accesskey === '-' ) {
2139  # @todo FIXME: Per standard MW behavior, a value of '-' means to suppress the
2140  # attribute, but this is broken for accesskey: that might be a useful
2141  # value.
2142  $accesskey = false;
2143  }
2144  }
2145 
2146  wfProfileOut( __METHOD__ );
2147  self::$accesskeycache[$name] = $accesskey;
2148  return self::$accesskeycache[$name];
2149  }
2150 
2164  public static function getRevDeleteLink( User $user, Revision $rev, Title $title ) {
2165  $canHide = $user->isAllowed( 'deleterevision' );
2166  if ( !$canHide && !( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
2167  return '';
2168  }
2169 
2170  if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
2171  return Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
2172  } else {
2173  if ( $rev->getId() ) {
2174  // RevDelete links using revision ID are stable across
2175  // page deletion and undeletion; use when possible.
2176  $query = array(
2177  'type' => 'revision',
2178  'target' => $title->getPrefixedDBkey(),
2179  'ids' => $rev->getId()
2180  );
2181  } else {
2182  // Older deleted entries didn't save a revision ID.
2183  // We have to refer to these by timestamp, ick!
2184  $query = array(
2185  'type' => 'archive',
2186  'target' => $title->getPrefixedDBkey(),
2187  'ids' => $rev->getTimestamp()
2188  );
2189  }
2190  return Linker::revDeleteLink( $query,
2191  $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
2192  }
2193  }
2194 
2205  public static function revDeleteLink( $query = array(), $restricted = false, $delete = true ) {
2206  $sp = SpecialPage::getTitleFor( 'Revisiondelete' );
2207  $msgKey = $delete ? 'rev-delundel' : 'rev-showdeleted';
2208  $html = wfMessage( $msgKey )->escaped();
2209  $tag = $restricted ? 'strong' : 'span';
2210  $link = self::link( $sp, $html, array(), $query, array( 'known', 'noclasses' ) );
2211  return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), wfMessage( 'parentheses' )->rawParams( $link )->escaped() );
2212  }
2213 
2222  public static function revDeleteLinkDisabled( $delete = true ) {
2223  $msgKey = $delete ? 'rev-delundel' : 'rev-showdeleted';
2224  $html = wfMessage( $msgKey )->escaped();
2225  $htmlParentheses = wfMessage( 'parentheses' )->rawParams( $html )->escaped();
2226  return Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), $htmlParentheses );
2227  }
2228 
2229  /* Deprecated methods */
2230 
2247  static function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
2248  wfDeprecated( __METHOD__, '1.21' );
2249 
2250  wfProfileIn( __METHOD__ );
2251  $query = wfCgiToArray( $query );
2252  list( $inside, $trail ) = self::splitTrail( $trail );
2253  if ( $text === '' ) {
2254  $text = self::linkText( $nt );
2255  }
2256 
2257  $ret = self::link( $nt, "$prefix$text$inside", array(), $query ) . $trail;
2258 
2259  wfProfileOut( __METHOD__ );
2260  return $ret;
2261  }
2262 
2279  static function makeKnownLinkObj(
2280  $title, $text = '', $query = '', $trail = '', $prefix = '', $aprops = '', $style = ''
2281  ) {
2282  wfDeprecated( __METHOD__, '1.21' );
2283 
2284  wfProfileIn( __METHOD__ );
2285 
2286  if ( $text == '' ) {
2287  $text = self::linkText( $title );
2288  }
2290  Sanitizer::decodeTagAttributes( $aprops ),
2292  );
2293  $query = wfCgiToArray( $query );
2294  list( $inside, $trail ) = self::splitTrail( $trail );
2295 
2296  $ret = self::link( $title, "$prefix$text$inside", $attribs, $query,
2297  array( 'known', 'noclasses' ) ) . $trail;
2298 
2299  wfProfileOut( __METHOD__ );
2300  return $ret;
2301  }
2302 
2307  public static function tooltipAndAccesskeyAttribs( $name ) {
2308  # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
2309  # no attribute" instead of "output '' as value for attribute", this
2310  # would be three lines.
2311  $attribs = array(
2312  'title' => self::titleAttrib( $name, 'withaccess' ),
2313  'accesskey' => self::accesskey( $name )
2314  );
2315  if ( $attribs['title'] === false ) {
2316  unset( $attribs['title'] );
2317  }
2318  if ( $attribs['accesskey'] === false ) {
2319  unset( $attribs['accesskey'] );
2320  }
2321  return $attribs;
2322  }
2323 
2328  public static function tooltip( $name, $options = null ) {
2329  # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
2330  # no attribute" instead of "output '' as value for attribute", this
2331  # would be two lines.
2332  $tooltip = self::titleAttrib( $name, $options );
2333  if ( $tooltip === false ) {
2334  return '';
2335  }
2336  return Xml::expandAttributes( array(
2337  'title' => $tooltip
2338  ) );
2339  }
2340 }
2341 
2346 
2355  public function __call( $fname, $args ) {
2356  return call_user_func_array( array( 'Linker', $fname ), $args );
2357  }
2358 }
User\getDefaultOption
static getDefaultOption( $opt)
Get a given default option value.
Definition: User.php:1383
Linker\getImageLinkMTOParams
static getImageLinkMTOParams( $frameParams, $query='', $parser=null)
Get the link parameters for MediaTransformOutput::toHtml() from given frame parameters supplied by th...
Definition: Linker.php:689
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:67
LinkCache
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition: LinkCache.php:29
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
save
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 save
Definition: deferred.txt:4
$wgUser
$wgUser
Definition: Setup.php:572
Revision\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: Revision.php:68
Linker\generateRollback
static generateRollback( $rev, IContextSource $context=null, $options=array( 'verify'))
Generate a rollback link for a given revision.
Definition: Linker.php:1779
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:412
ID
occurs before session is loaded can be modified ID
Definition: hooks.txt:2829
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
Linker\commentBlock
static commentBlock( $comment, $title=null, $local=false)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
Definition: Linker.php:1565
Linker
Some internal bits split of from Skin.php.
Definition: Linker.php:32
Linker\formatLinksInComment
static formatLinksInComment( $comment, $title=null, $local=false)
Formats wiki links and media links in text; all other wiki formatting is ignored.
Definition: Linker.php:1382
Linker\TOOL_LINKS_NOBLOCK
const TOOL_LINKS_NOBLOCK
Flags for userToolLinks()
Definition: Linker.php:37
Linker\userTalkLink
static userTalkLink( $userId, $userText)
Definition: Linker.php:1173
RepoGroup\singleton
static singleton()
Get a RepoGroup instance.
Definition: RepoGroup.php:53
Xml\expandAttributes
static expandAttributes( $attribs)
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : att...
Definition: Xml.php:65
Revision\DELETED_COMMENT
const DELETED_COMMENT
Definition: Revision.php:66
Linker\revDeleteLink
static revDeleteLink( $query=array(), $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
Definition: Linker.php:2205
Linker\userToolLinksRedContribs
static userToolLinksRedContribs( $userId, $userText, $edits=null)
Alias for userToolLinks( $userId, $userText, true );.
Definition: Linker.php:1164
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
Linker\emailLink
static emailLink( $userId, $userText)
Definition: Linker.php:1195
$html
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 & $html
Definition: hooks.txt:1530
Linker\revUserLink
static revUserLink( $rev, $isPublic=false)
Generate a user link if the current user is allowed to view it.
Definition: Linker.php:1207
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:30
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:1081
DummyLinker\__call
__call( $fname, $args)
Use PHP's magic __call handler to transform instance calls to a dummy instance into static calls to t...
Definition: Linker.php:2355
is
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for except in special pages derived from QueryPage It s a common pitfall for new developers to submit code containing SQL queries which examine huge numbers of rows Remember that COUNT * is(N), counting rows in atable is like counting beans in a bucket.------------------------------------------------------------------------ Replication------------------------------------------------------------------------The largest installation of MediaWiki, Wikimedia, uses a large set ofslave MySQL servers replicating writes made to a master MySQL server. Itis important to understand the issues associated with this setup if youwant to write code destined for Wikipedia.It 's often the case that the best algorithm to use for a given taskdepends on whether or not replication is in use. Due to our unabashedWikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use wfGetLB() ->getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves. The master writes thequery to the binlog when the transaction is committed. The slaves pollthe binlog and start executing the query as soon as it appears. They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes. Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load. MediaWiki 's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database. All edits and other write operations will berefused, with an error returned to the user. This gives the slaves achance to catch up. Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order. A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests. This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it. Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in "lagged slave mode". Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode(). The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time. Multi-row INSERT ...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it 's not practical to guarantee a low-lagenvironment. Lag will usually be less than one second, but mayoccasionally be up to 30 seconds. For scalability, it 's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer. So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn 't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum. In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------ Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks. By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent. Locks willbe held from the time when the query is done until the commit. So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction. Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
Linker\makeSelfLinkObj
static makeSelfLinkObj( $nt, $html='', $query='', $trail='', $prefix='')
Make appropriate markup for a link to the current article.
Definition: Linker.php:409
Linker\getUploadUrl
static getUploadUrl( $destFile, $query='')
Get the URL to upload a certain file.
Definition: Linker.php:952
Linker\tocIndent
static tocIndent()
Add another level to the Table of Contents.
Definition: Linker.php:1624
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3714
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
Sanitizer\mergeAttributes
static mergeAttributes( $a, $b)
Merge two sets of HTML attributes.
Definition: Sanitizer.php:807
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
Linker\fnamePart
static fnamePart( $url)
Returns the filename part of an url.
Definition: Linker.php:468
$ret
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 & $ret
Definition: hooks.txt:1530
Linker\getLinkColour
static getLinkColour( $t, $threshold)
Return the CSS colour of a known link.
Definition: Linker.php:137
Linker\specialLink
static specialLink( $name, $key='')
Make a link to a special page given its name and, optionally, a message key from the link text.
Definition: Linker.php:1016
$customAttribs
null means default & $customAttribs
Definition: hooks.txt:1530
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
StringUtils\escapeRegexReplacement
static escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
Definition: StringUtils.php:296
$fname
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition: Setup.php:35
Sanitizer\normalizeSectionNameWhitespace
static normalizeSectionNameWhitespace( $section)
Normalizes whitespace in a section name, such as might be returned by Parser::stripSectionName(),...
Definition: Sanitizer.php:1297
NS_FILE
const NS_FILE
Definition: Defines.php:85
$params
$params
Definition: styleTest.css.php:40
IContextSource\msg
msg()
Get a Message object with context set.
$s
$s
Definition: mergeMessageFileList.php:156
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
Linker\processResponsiveImages
static processResponsiveImages( $file, $thumb, $hp)
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
Definition: Linker.php:879
Linker\getInterwikiLinkAttributes
static getInterwikiLinkAttributes( $title, $unused=null, $class='external')
Get the appropriate HTML attributes to add to the "a" element of an interwiki link.
Definition: Linker.php:64
$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
Linker\formatLinksInCommentCallback
static formatLinksInCommentCallback( $match)
Definition: Linker.php:1409
Linker\formatComment
static formatComment( $comment, $title=null, $local=false)
This function is called by all recent changes variants, by the page history, and by the user contribu...
Definition: Linker.php:1263
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:427
Linker\makeThumbLinkObj
static makeThumbLinkObj(Title $title, $file, $label='', $alt, $align='right', $params=array(), $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
Definition: Linker.php:726
Linker\makeLinkObj
static makeLinkObj( $nt, $text='', $query='', $trail='', $prefix='')
Definition: Linker.php:2247
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2124
$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:2160
Linker\$commentLocal
static $commentLocal
Definition: Linker.php:1370
Linker\tocLine
static tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex=false)
parameter level defines if we are on an indentation level
Definition: Linker.php:1642
Linker\linkKnown
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:264
Linker\makeExternalLink
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=array(), $title=null)
Make an external link.
Definition: Linker.php:1034
Linker\formatAutocomments
static formatAutocomments( $comment, $title=null, $local=false)
Converts autogenerated comments in edit summaries into section links.
Definition: Linker.php:1298
Linker\formatHiddenCategories
static formatHiddenCategories( $hiddencats)
Returns HTML for the "hidden categories on this page" list.
Definition: Linker.php:2038
$dbr
$dbr
Definition: testCompression.php:48
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
below
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned below
Definition: memcached.txt:96
Revision\FOR_THIS_USER
const FOR_THIS_USER
Definition: Revision.php:73
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:506
Revision
Definition: Revision.php:26
NS_MAIN
const NS_MAIN
Definition: Defines.php:79
Linker\tooltipAndAccesskeyAttribs
static tooltipAndAccesskeyAttribs( $name)
Returns the attributes for the tooltip and access key.
Definition: Linker.php:2307
$success
$success
Definition: Utf8Test.php:91
Linker\makeMediaLinkObj
static makeMediaLinkObj( $title, $html='', $time=false)
Create a direct link to a given uploaded file.
Definition: Linker.php:977
Linker\formatAutocommentsCallback
static formatAutocommentsCallback( $match)
Helper function for Linker::formatAutocomments.
Definition: Linker.php:1316
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1174
Html\element
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:141
reasons
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 in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database etc For and for historical reasons
Definition: design.txt:25
Linker\revUserTools
static revUserTools( $rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
Definition: Linker.php:1228
Linker\tocList
static tocList( $toc, $lang=false)
Wraps the TOC in a table and provides the hide/collapse javascript.
Definition: Linker.php:1670
Linker\getRollbackEditCount
static getRollbackEditCount( $rev, $verify)
This function will return the number of revisions which a rollback would revert and,...
Definition: Linker.php:1815
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:1961
$pre
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped $pre
Definition: hooks.txt:1105
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
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
Linker\tocLineEnd
static tocLineEnd()
End a Table Of Contents line.
Definition: Linker.php:1659
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4066
wfGetLangObj
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
Definition: GlobalFunctions.php:1399
MWNamespace\hasSubpages
static hasSubpages( $index)
Does the namespace allow subpages?
Definition: Namespace.php:325
wfCgiToArray
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
Definition: GlobalFunctions.php:459
Linker\makeImageLink2
static makeImageLink2(Title $title, $file, $frameParams=array(), $handlerParams=array(), $time=false, $query="", $widthOption=null)
See makeImageLink() When this function is removed, remove if( $parser instanceof Parser ) check there...
Definition: Linker.php:676
Linker\revDeleteLinkDisabled
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
Definition: Linker.php:2222
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Linker\getInternalLinkAttributesObj
static getInternalLinkAttributesObj( $nt, $unused=null, $class='', $title=false)
Get the appropriate HTML attributes to add to the "a" element of an internal link,...
Definition: Linker.php:102
Linker\normaliseSpecialPage
static normaliseSpecialPage(Title $title)
Definition: Linker.php:447
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$comment
$comment
Definition: importImages.php:107
Linker\$autocommentLocal
static $autocommentLocal
Definition: Linker.php:1283
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
PROTO_HTTPS
const PROTO_HTTPS
Definition: Defines.php:268
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:188
Linker\splitTrail
static splitTrail( $trail)
Split a link trail, return the "inside" portion and the remainder of the trail as a two-element array...
Definition: Linker.php:1740
IP\prettifyIP
static prettifyIP( $ip)
Prettify an IP for display to end users.
Definition: IP.php:196
$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
Linker\makeKnownLinkObj
static makeKnownLinkObj( $title, $text='', $query='', $trail='', $prefix='', $aprops='', $style='')
Definition: Linker.php:2279
$section
$section
Definition: Utf8Test.php:88
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:980
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:422
Linker\revComment
static revComment(Revision $rev, $local=false, $isPublic=false)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
Definition: Linker.php:1587
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
Linker\blockLink
static blockLink( $userId, $userText)
Definition: Linker.php:1184
see
Some information about database access in MediaWiki By Tim January Database layout For information about the MediaWiki database such as a description of the tables and their please see
Definition: database.txt:2
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:82
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
$size
$size
Definition: RandomTest.php:75
Linker\userToolLinks
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition: Linker.php:1109
Linker\TOOL_LINKS_EMAIL
const TOOL_LINKS_EMAIL
Definition: Linker.php:38
Linker\getInternalLinkAttributes
static getInternalLinkAttributes( $title, $unused=null, $class='')
Get the appropriate HTML attributes to add to the "a" element of an internal link.
Definition: Linker.php:85
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:67
Linker\makeThumbLink2
static makeThumbLink2(Title $title, $file, $frameParams=array(), $handlerParams=array(), $time=false, $query="")
Definition: Linker.php:752
Linker\formatRevisionSize
static formatRevisionSize( $size)
Definition: Linker.php:1609
$handlerParams
see documentation in includes Linker php for Linker::makeImageLink & $handlerParams
Definition: hooks.txt:1356
PROTO_HTTP
const PROTO_HTTP
Definition: Defines.php:267
SpecialPageFactory\resolveAlias
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
Definition: SpecialPageFactory.php:271
Linker\linkAttribs
static linkAttribs( $target, $attribs, $options)
Returns the array of attributes used when linking to the Title $target.
Definition: Linker.php:319
PROTO_RELATIVE
const PROTO_RELATIVE
Definition: Defines.php:269
Linker\makeHeadline
static makeHeadline( $level, $attribs, $anchor, $html, $link, $legacyAnchor=false)
Create a headline for content.
Definition: Linker.php:1724
$upload
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object $upload
Definition: hooks.txt:2584
Linker\formatTemplates
static formatTemplates( $templates, $preview=false, $section=false, $more=null)
Returns HTML for the "templates used on this page" list.
Definition: Linker.php:1945
MWNamespace\exists
static exists( $index)
Returns whether the specified namespace exists.
Definition: Namespace.php:171
RequestContext\getMain
static getMain()
Static methods.
Definition: RequestContext.php:420
DummyLinker
Definition: Linker.php:2345
$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:237
Linker\linkUrl
static linkUrl( $target, $query, $options)
Returns the Url used to link to a Title.
Definition: Linker.php:279
IContextSource
Interface for objects which can provide a context on request.
Definition: IContextSource.php:29
$hash
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
Definition: hooks.txt:2708
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
Linker\$autocommentTitle
static $autocommentTitle
Definition: Linker.php:1282
Linker\tooltip
static tooltip( $name, $options=null)
Returns raw bits of HTML, use titleAttrib()
Definition: Linker.php:2328
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1337
it
=Architecture==Two class hierarchies are used to provide the functionality associated with the different content models:*Content interface(and AbstractContent base class) define functionality that acts on the concrete content of a page, and *ContentHandler base class provides functionality specific to a content model, but not acting on concrete content. The most important function of ContentHandler is to act as a factory for the appropriate implementation of Content. These Content objects are to be used by MediaWiki everywhere, instead of passing page content around as text. All manipulation and analysis of page content must be done via the appropriate methods of the Content object. For each content model, a subclass of ContentHandler has to be registered with $wgContentHandlers. The ContentHandler object for a given content model can be obtained using ContentHandler::getForModelID($id). Also Title, WikiPage and Revision now have getContentHandler() methods for convenience. ContentHandler objects are singletons that provide functionality specific to the content type, but not directly acting on the content of some page. ContentHandler::makeEmptyContent() and ContentHandler::unserializeContent() can be used to create a Content object of the appropriate type. However, it is recommended to instead use WikiPage::getContent() resp. Revision::getContent() to get a page 's content as a Content object. These two methods should be the ONLY way in which page content is accessed. Another important function of ContentHandler objects is to define custom action handlers for a content model, see ContentHandler::getActionOverrides(). This is similar to what WikiPage::getActionOverrides() was already doing.==Serialization==With the ContentHandler facility, page content no longer has to be text based. Objects implementing the Content interface are used to represent and handle the content internally. For storage and data exchange, each content model supports at least one serialization format via ContentHandler::serializeContent($content). The list of supported formats for a given content model can be accessed using ContentHandler::getSupportedFormats(). Content serialization formats are identified using MIME type like strings. The following formats are built in:*text/x-wiki - wikitext *text/javascript - for js pages *text/css - for css pages *text/plain - for future use, e.g. with plain text messages. *text/html - for future use, e.g. with plain html messages. *application/vnd.php.serialized - for future use with the api and for extensions *application/json - for future use with the api, and for use by extensions *application/xml - for future use with the api, and for use by extensions In PHP, use the corresponding CONTENT_FORMAT_XXX constant. Note that when using the API to access page content, especially action=edit, action=parse and action=query &prop=revisions, the model and format of the content should always be handled explicitly. Without that information, interpretation of the provided content is not reliable. The same applies to XML dumps generated via maintenance/dumpBackup.php or Special:Export. Also note that the API will provide encapsulated, serialized content - so if the API was called with format=json, and contentformat is also json(or rather, application/json), the page content is represented as a string containing an escaped json structure. Extensions that use JSON to serialize some types of page content may provide specialized API modules that allow access to that content in a more natural form.==Compatibility==The ContentHandler facility is introduced in a way that should allow all existing code to keep functioning at least for pages that contain wikitext or other text based content. However, a number of functions and hooks have been deprecated in favor of new versions that are aware of the page 's content model, and will now generate warnings when used. Most importantly, the following functions have been deprecated:*Revisions::getText() and Revisions::getRawText() is deprecated in favor Revisions::getContent() *WikiPage::getText() is deprecated in favor WikiPage::getContent() Also, the old Article::getContent()(which returns text) is superceded by Article::getContentObject(). However, both methods should be avoided since they do not provide clean access to the page 's actual content. For instance, they may return a system message for non-existing pages. Use WikiPage::getContent() instead. Code that relies on a textual representation of the page content should eventually be rewritten. However, ContentHandler::getContentText() provides a stop-gap that can be used to get text for a page. Its behavior is controlled by $wgContentHandlerTextFallback it
Definition: contenthandler.txt:107
$args
if( $line===false) $args
Definition: cdb.php:62
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
Title
Represents a title within MediaWiki.
Definition: Title.php:35
$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
type
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition: postgres.txt:22
Linker\titleAttrib
static titleAttrib( $name, $options=null)
Given the id of an interface element, constructs the appropriate title attribute from the system mess...
Definition: Linker.php:2081
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
Linker\tocUnindent
static tocUnindent( $level)
Finish one or more sublevels on the Table of Contents.
Definition: Linker.php:1633
wfFindFile
wfFindFile( $title, $options=array())
Find a file.
Definition: GlobalFunctions.php:3757
Linker\makeMediaLinkFile
static makeMediaLinkFile(Title $title, $file, $html='')
Create a direct link to a given uploaded file.
Definition: Linker.php:993
Linker\makeImageLink
static makeImageLink($parser, Title $title, $file, $frameParams=array(), $handlerParams=array(), $time=false, $query="", $widthOption=null)
Given parameters derived from [[Image:Foo|options...]], generate the HTML that that syntax inserts in...
Definition: Linker.php:539
NS_USER
const NS_USER
Definition: Defines.php:81
$batch
$batch
Definition: linkcache.txt:23
Linker\normalizeSubpageLink
static normalizeSubpageLink( $contextTitle, $target, &$text)
Definition: Linker.php:1483
Sanitizer\decodeTagAttributes
static decodeTagAttributes( $text)
Return an associative array of attribute names and values from a partial tag string.
Definition: Sanitizer.php:1183
$t
$t
Definition: testCompression.php:65
Linker\getExternalLinkAttributes
static getExternalLinkAttributes( $class='external')
Get the appropriate HTML attributes to add to the "a" element of an external link,...
Definition: Linker.php:49
change
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 change
Definition: distributors.txt:9
Linker\generateTOC
static generateTOC( $tree)
Generate a table of contents from a section tree Currently unused.
Definition: Linker.php:1687
Html\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:121
Linker\getLinkAttributesInternal
static getLinkAttributesInternal( $title, $class)
Common code for getLinkAttributesX functions.
Definition: Linker.php:117
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
$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
Linker\buildRollbackLink
static buildRollbackLink( $rev, IContextSource $context=null, $editCount=false)
Build a raw rollback link, useful for collections of "tool" links.
Definition: Linker.php:1870
$res
$res
Definition: database.txt:21
Linker\makeExternalImage
static makeExternalImage( $url, $alt='')
Return the code for images which were added via external links, via Parser::maybeMakeExternalImage().
Definition: Linker.php:487
redirect
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 redirect
Definition: All_system_messages.txt:1267
MWNamespace\getCanonicalName
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
Definition: Namespace.php:237
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:65
Linker\linkText
static linkText( $target)
Default text of the links to the Title $target.
Definition: Linker.php:381
Linker\$commentContextTitle
static $commentContextTitle
Definition: Linker.php:1369
Linker\makeBrokenImageLinkObj
static makeBrokenImageLinkObj( $title, $label='', $query='', $unused1='', $unused2='', $time=false)
Make a "broken" link to an image.
Definition: Linker.php:913
Sanitizer\escapeHtmlAllowEntities
static escapeHtmlAllowEntities( $html)
Given HTML input, escape with htmlspecialchars but un-escape entities.
Definition: Sanitizer.php:1158
$wgTitle
if(! $wgRequest->checkUrlExtension()) if(! $wgEnableAPI) $wgTitle
Definition: api.php:63
page
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 my talk page
Definition: hooks.txt:1961