MediaWiki  1.23.2
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  $attribs['rel'] = Parser::getExternalLinkRel( $url, $title );
1053  $link = '';
1054  $success = wfRunHooks( 'LinkerMakeExternalLink',
1055  array( &$url, &$text, &$link, &$attribs, $linktype ) );
1056  if ( !$success ) {
1057  wfDebug( "Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}\n", true );
1058  return $link;
1059  }
1060  $attribs['href'] = $url;
1061  return Html::rawElement( 'a', $attribs, $text );
1062  }
1063 
1072  public static function userLink( $userId, $userName, $altUserName = false ) {
1073  if ( $userId == 0 ) {
1074  $page = SpecialPage::getTitleFor( 'Contributions', $userName );
1075  if ( $altUserName === false ) {
1076  $altUserName = IP::prettifyIP( $userName );
1077  }
1078  } else {
1079  $page = Title::makeTitle( NS_USER, $userName );
1080  }
1081 
1082  return self::link(
1083  $page,
1084  htmlspecialchars( $altUserName !== false ? $altUserName : $userName ),
1085  array( 'class' => 'mw-userlink' )
1086  );
1087  }
1088 
1100  public static function userToolLinks(
1101  $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
1102  ) {
1103  global $wgUser, $wgDisableAnonTalk, $wgLang;
1104  $talkable = !( $wgDisableAnonTalk && 0 == $userId );
1105  $blockable = !( $flags & self::TOOL_LINKS_NOBLOCK );
1106  $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
1107 
1108  $items = array();
1109  if ( $talkable ) {
1110  $items[] = self::userTalkLink( $userId, $userText );
1111  }
1112  if ( $userId ) {
1113  // check if the user has an edit
1114  $attribs = array();
1115  if ( $redContribsWhenNoEdits ) {
1116  if ( intval( $edits ) === 0 && $edits !== 0 ) {
1117  $user = User::newFromId( $userId );
1118  $edits = $user->getEditCount();
1119  }
1120  if ( $edits === 0 ) {
1121  $attribs['class'] = 'new';
1122  }
1123  }
1124  $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText );
1125 
1126  $items[] = self::link( $contribsPage, wfMessage( 'contribslink' )->escaped(), $attribs );
1127  }
1128  if ( $blockable && $wgUser->isAllowed( 'block' ) ) {
1129  $items[] = self::blockLink( $userId, $userText );
1130  }
1131 
1132  if ( $addEmailLink && $wgUser->canSendEmail() ) {
1133  $items[] = self::emailLink( $userId, $userText );
1134  }
1135 
1136  wfRunHooks( 'UserToolLinksEdit', array( $userId, $userText, &$items ) );
1137 
1138  if ( $items ) {
1139  return wfMessage( 'word-separator' )->plain()
1140  . '<span class="mw-usertoollinks">'
1141  . wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped()
1142  . '</span>';
1143  } else {
1144  return '';
1145  }
1146  }
1147 
1155  public static function userToolLinksRedContribs( $userId, $userText, $edits = null ) {
1156  return self::userToolLinks( $userId, $userText, true, 0, $edits );
1157  }
1158 
1164  public static function userTalkLink( $userId, $userText ) {
1165  $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText );
1166  $userTalkLink = self::link( $userTalkPage, wfMessage( 'talkpagelinktext' )->escaped() );
1167  return $userTalkLink;
1168  }
1169 
1175  public static function blockLink( $userId, $userText ) {
1176  $blockPage = SpecialPage::getTitleFor( 'Block', $userText );
1177  $blockLink = self::link( $blockPage, wfMessage( 'blocklink' )->escaped() );
1178  return $blockLink;
1179  }
1180 
1186  public static function emailLink( $userId, $userText ) {
1187  $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText );
1188  $emailLink = self::link( $emailPage, wfMessage( 'emaillink' )->escaped() );
1189  return $emailLink;
1190  }
1191 
1198  public static function revUserLink( $rev, $isPublic = false ) {
1199  if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
1200  $link = wfMessage( 'rev-deleted-user' )->escaped();
1201  } elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
1203  $rev->getUserText( Revision::FOR_THIS_USER ) );
1204  } else {
1205  $link = wfMessage( 'rev-deleted-user' )->escaped();
1206  }
1207  if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
1208  return '<span class="history-deleted">' . $link . '</span>';
1209  }
1210  return $link;
1211  }
1212 
1219  public static function revUserTools( $rev, $isPublic = false ) {
1220  if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
1221  $link = wfMessage( 'rev-deleted-user' )->escaped();
1222  } elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
1223  $userId = $rev->getUser( Revision::FOR_THIS_USER );
1224  $userText = $rev->getUserText( Revision::FOR_THIS_USER );
1225  $link = self::userLink( $userId, $userText )
1226  . wfMessage( 'word-separator' )->plain()
1227  . self::userToolLinks( $userId, $userText );
1228  } else {
1229  $link = wfMessage( 'rev-deleted-user' )->escaped();
1230  }
1231  if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
1232  return ' <span class="history-deleted">' . $link . '</span>';
1233  }
1234  return $link;
1235  }
1236 
1254  public static function formatComment( $comment, $title = null, $local = false ) {
1255  wfProfileIn( __METHOD__ );
1256 
1257  # Sanitize text a bit:
1258  $comment = str_replace( "\n", " ", $comment );
1259  # Allow HTML entities (for bug 13815)
1261 
1262  # Render autocomments and make links:
1265 
1266  wfProfileOut( __METHOD__ );
1267  return $comment;
1268  }
1269 
1275 
1289  private static function formatAutocomments( $comment, $title = null, $local = false ) {
1290  // Bah!
1291  self::$autocommentTitle = $title;
1292  self::$autocommentLocal = $local;
1293  $comment = preg_replace_callback(
1294  '!(.*)/\*\s*(.*?)\s*\*/(.*)!',
1295  array( 'Linker', 'formatAutocommentsCallback' ),
1296  $comment );
1297  self::$autocommentTitle = null;
1298  self::$autocommentLocal = null;
1299  return $comment;
1300  }
1301 
1307  private static function formatAutocommentsCallback( $match ) {
1308  global $wgLang;
1310  $local = self::$autocommentLocal;
1311 
1312  $pre = $match[1];
1313  $auto = $match[2];
1314  $post = $match[3];
1315  $comment = null;
1316  wfRunHooks( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
1317  if ( $comment === null ) {
1318  $link = '';
1319  if ( $title ) {
1320  $section = $auto;
1321 
1322  # Remove links that a user may have manually put in the autosummary
1323  # This could be improved by copying as much of Parser::stripSectionName as desired.
1324  $section = str_replace( '[[:', '', $section );
1325  $section = str_replace( '[[', '', $section );
1326  $section = str_replace( ']]', '', $section );
1327 
1329  if ( $local ) {
1330  $sectionTitle = Title::newFromText( '#' . $section );
1331  } else {
1332  $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
1333  $title->getDBkey(), $section );
1334  }
1335  if ( $sectionTitle ) {
1336  $link = self::link( $sectionTitle,
1337  $wgLang->getArrow(), array(), array(),
1338  'noclasses' );
1339  } else {
1340  $link = '';
1341  }
1342  }
1343  if ( $pre ) {
1344  # written summary $presep autocomment (summary /* section */)
1345  $pre .= wfMessage( 'autocomment-prefix' )->inContentLanguage()->escaped();
1346  }
1347  if ( $post ) {
1348  # autocomment $postsep written summary (/* section */ summary)
1349  $auto .= wfMessage( 'colon-separator' )->inContentLanguage()->escaped();
1350  }
1351  $auto = '<span class="autocomment">' . $auto . '</span>';
1352  $comment = $pre . $link . $wgLang->getDirMark() . '<span dir="auto">' . $auto . $post . '</span>';
1353  }
1354  return $comment;
1355  }
1356 
1362 
1373  public static function formatLinksInComment( $comment, $title = null, $local = false ) {
1374  self::$commentContextTitle = $title;
1375  self::$commentLocal = $local;
1376  $html = preg_replace_callback(
1377  '/
1378  \[\[
1379  :? # ignore optional leading colon
1380  ([^\]|]+) # 1. link target; page names cannot include ] or |
1381  (?:\|
1382  # 2. a pipe-separated substring; only the last is captured
1383  # Stop matching at | and ]] without relying on backtracking.
1384  ((?:]?[^\]|])*+)
1385  )*
1386  \]\]
1387  ([^[]*) # 3. link trail (the text up until the next link)
1388  /x',
1389  array( 'Linker', 'formatLinksInCommentCallback' ),
1390  $comment );
1391  self::$commentContextTitle = null;
1392  self::$commentLocal = null;
1393  return $html;
1394  }
1395 
1400  protected static function formatLinksInCommentCallback( $match ) {
1402 
1403  $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
1404  $medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
1405 
1406  $comment = $match[0];
1407 
1408  # fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
1409  if ( strpos( $match[1], '%' ) !== false ) {
1410  $match[1] = str_replace( array( '<', '>' ), array( '&lt;', '&gt;' ), rawurldecode( $match[1] ) );
1411  }
1412 
1413  # Handle link renaming [[foo|text]] will show link as "text"
1414  if ( $match[2] != "" ) {
1415  $text = $match[2];
1416  } else {
1417  $text = $match[1];
1418  }
1419  $submatch = array();
1420  $thelink = null;
1421  if ( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
1422  # Media link; trail not supported.
1423  $linkRegexp = '/\[\[(.*?)\]\]/';
1424  $title = Title::makeTitleSafe( NS_FILE, $submatch[1] );
1425  if ( $title ) {
1426  $thelink = self::makeMediaLinkObj( $title, $text );
1427  }
1428  } else {
1429  # Other kind of link
1430  if ( preg_match( $wgContLang->linkTrail(), $match[3], $submatch ) ) {
1431  $trail = $submatch[1];
1432  } else {
1433  $trail = "";
1434  }
1435  $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
1436  if ( isset( $match[1][0] ) && $match[1][0] == ':' ) {
1437  $match[1] = substr( $match[1], 1 );
1438  }
1439  list( $inside, $trail ) = self::splitTrail( $trail );
1440 
1441  $linkText = $text;
1442  $linkTarget = self::normalizeSubpageLink( self::$commentContextTitle,
1443  $match[1], $linkText );
1444 
1445  $target = Title::newFromText( $linkTarget );
1446  if ( $target ) {
1447  if ( $target->getText() == '' && !$target->isExternal()
1448  && !self::$commentLocal && self::$commentContextTitle
1449  ) {
1450  $newTarget = clone ( self::$commentContextTitle );
1451  $newTarget->setFragment( '#' . $target->getFragment() );
1452  $target = $newTarget;
1453  }
1454  $thelink = self::link(
1455  $target,
1456  $linkText . $inside
1457  ) . $trail;
1458  }
1459  }
1460  if ( $thelink ) {
1461  // If the link is still valid, go ahead and replace it in!
1462  $comment = preg_replace( $linkRegexp, StringUtils::escapeRegexReplacement( $thelink ), $comment, 1 );
1463  }
1464 
1465  return $comment;
1466  }
1467 
1474  public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
1475  # Valid link forms:
1476  # Foobar -- normal
1477  # :Foobar -- override special treatment of prefix (images, language links)
1478  # /Foobar -- convert to CurrentPage/Foobar
1479  # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial / from text
1480  # ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
1481  # ../Foobar -- convert to CurrentPage/Foobar, from CurrentPage/CurrentSubPage
1482 
1483  wfProfileIn( __METHOD__ );
1484  $ret = $target; # default return value is no change
1485 
1486  # Some namespaces don't allow subpages,
1487  # so only perform processing if subpages are allowed
1488  if ( $contextTitle && MWNamespace::hasSubpages( $contextTitle->getNamespace() ) ) {
1489  $hash = strpos( $target, '#' );
1490  if ( $hash !== false ) {
1491  $suffix = substr( $target, $hash );
1492  $target = substr( $target, 0, $hash );
1493  } else {
1494  $suffix = '';
1495  }
1496  # bug 7425
1497  $target = trim( $target );
1498  # Look at the first character
1499  if ( $target != '' && $target[0] === '/' ) {
1500  # / at end means we don't want the slash to be shown
1501  $m = array();
1502  $trailingSlashes = preg_match_all( '%(/+)$%', $target, $m );
1503  if ( $trailingSlashes ) {
1504  $noslash = $target = substr( $target, 1, -strlen( $m[0][0] ) );
1505  } else {
1506  $noslash = substr( $target, 1 );
1507  }
1508 
1509  $ret = $contextTitle->getPrefixedText() . '/' . trim( $noslash ) . $suffix;
1510  if ( $text === '' ) {
1511  $text = $target . $suffix;
1512  } # this might be changed for ugliness reasons
1513  } else {
1514  # check for .. subpage backlinks
1515  $dotdotcount = 0;
1516  $nodotdot = $target;
1517  while ( strncmp( $nodotdot, "../", 3 ) == 0 ) {
1518  ++$dotdotcount;
1519  $nodotdot = substr( $nodotdot, 3 );
1520  }
1521  if ( $dotdotcount > 0 ) {
1522  $exploded = explode( '/', $contextTitle->getPrefixedText() );
1523  if ( count( $exploded ) > $dotdotcount ) { # not allowed to go below top level page
1524  $ret = implode( '/', array_slice( $exploded, 0, -$dotdotcount ) );
1525  # / at the end means don't show full path
1526  if ( substr( $nodotdot, -1, 1 ) === '/' ) {
1527  $nodotdot = substr( $nodotdot, 0, -1 );
1528  if ( $text === '' ) {
1529  $text = $nodotdot . $suffix;
1530  }
1531  }
1532  $nodotdot = trim( $nodotdot );
1533  if ( $nodotdot != '' ) {
1534  $ret .= '/' . $nodotdot;
1535  }
1536  $ret .= $suffix;
1537  }
1538  }
1539  }
1540  }
1541 
1542  wfProfileOut( __METHOD__ );
1543  return $ret;
1544  }
1545 
1556  public static function commentBlock( $comment, $title = null, $local = false ) {
1557  // '*' used to be the comment inserted by the software way back
1558  // in antiquity in case none was provided, here for backwards
1559  // compatibility, acc. to brion -ævar
1560  if ( $comment == '' || $comment == '*' ) {
1561  return '';
1562  } else {
1563  $formatted = self::formatComment( $comment, $title, $local );
1564  $formatted = wfMessage( 'parentheses' )->rawParams( $formatted )->escaped();
1565  return " <span class=\"comment\">$formatted</span>";
1566  }
1567  }
1568 
1578  public static function revComment( Revision $rev, $local = false, $isPublic = false ) {
1579  if ( $rev->getRawComment() == "" ) {
1580  return "";
1581  }
1582  if ( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) {
1583  $block = " <span class=\"comment\">" . wfMessage( 'rev-deleted-comment' )->escaped() . "</span>";
1584  } elseif ( $rev->userCan( Revision::DELETED_COMMENT ) ) {
1585  $block = self::commentBlock( $rev->getComment( Revision::FOR_THIS_USER ),
1586  $rev->getTitle(), $local );
1587  } else {
1588  $block = " <span class=\"comment\">" . wfMessage( 'rev-deleted-comment' )->escaped() . "</span>";
1589  }
1590  if ( $rev->isDeleted( Revision::DELETED_COMMENT ) ) {
1591  return " <span class=\"history-deleted\">$block</span>";
1592  }
1593  return $block;
1594  }
1595 
1600  public static function formatRevisionSize( $size ) {
1601  if ( $size == 0 ) {
1602  $stxt = wfMessage( 'historyempty' )->escaped();
1603  } else {
1604  $stxt = wfMessage( 'nbytes' )->numParams( $size )->escaped();
1605  $stxt = wfMessage( 'parentheses' )->rawParams( $stxt )->escaped();
1606  }
1607  return "<span class=\"history-size\">$stxt</span>";
1608  }
1609 
1615  public static function tocIndent() {
1616  return "\n<ul>";
1617  }
1618 
1624  public static function tocUnindent( $level ) {
1625  return "</li>\n" . str_repeat( "</ul>\n</li>\n", $level > 0 ? $level : 0 );
1626  }
1627 
1633  public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
1634  $classes = "toclevel-$level";
1635  if ( $sectionIndex !== false ) {
1636  $classes .= " tocsection-$sectionIndex";
1637  }
1638  return "\n<li class=\"$classes\"><a href=\"#" .
1639  $anchor . '"><span class="tocnumber">' .
1640  $tocnumber . '</span> <span class="toctext">' .
1641  $tocline . '</span></a>';
1642  }
1643 
1650  public static function tocLineEnd() {
1651  return "</li>\n";
1652  }
1653 
1661  public static function tocList( $toc, $lang = false ) {
1662  $lang = wfGetLangObj( $lang );
1663  $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
1664 
1665  return '<div id="toc" class="toc">'
1666  . '<div id="toctitle"><h2>' . $title . "</h2></div>\n"
1667  . $toc
1668  . "</ul>\n</div>\n";
1669  }
1670 
1678  public static function generateTOC( $tree ) {
1679  $toc = '';
1680  $lastLevel = 0;
1681  foreach ( $tree as $section ) {
1682  if ( $section['toclevel'] > $lastLevel ) {
1683  $toc .= self::tocIndent();
1684  } elseif ( $section['toclevel'] < $lastLevel ) {
1685  $toc .= self::tocUnindent(
1686  $lastLevel - $section['toclevel'] );
1687  } else {
1688  $toc .= self::tocLineEnd();
1689  }
1690 
1691  $toc .= self::tocLine( $section['anchor'],
1692  $section['line'], $section['number'],
1693  $section['toclevel'], $section['index'] );
1694  $lastLevel = $section['toclevel'];
1695  }
1696  $toc .= self::tocLineEnd();
1697  return self::tocList( $toc );
1698  }
1699 
1715  public static function makeHeadline( $level, $attribs, $anchor, $html, $link, $legacyAnchor = false ) {
1716  $ret = "<h$level$attribs"
1717  . "<span class=\"mw-headline\" id=\"$anchor\">$html</span>"
1718  . $link
1719  . "</h$level>";
1720  if ( $legacyAnchor !== false ) {
1721  $ret = "<div id=\"$legacyAnchor\"></div>$ret";
1722  }
1723  return $ret;
1724  }
1725 
1731  static function splitTrail( $trail ) {
1733  $regex = $wgContLang->linkTrail();
1734  $inside = '';
1735  if ( $trail !== '' ) {
1736  $m = array();
1737  if ( preg_match( $regex, $trail, $m ) ) {
1738  $inside = $m[1];
1739  $trail = $m[2];
1740  }
1741  }
1742  return array( $inside, $trail );
1743  }
1744 
1770  public static function generateRollback( $rev, IContextSource $context = null, $options = array( 'verify' ) ) {
1771  if ( $context === null ) {
1772  $context = RequestContext::getMain();
1773  }
1774  $editCount = false;
1775  if ( in_array( 'verify', $options ) ) {
1776  $editCount = self::getRollbackEditCount( $rev, true );
1777  if ( $editCount === false ) {
1778  return '';
1779  }
1780  }
1781 
1782  $inner = self::buildRollbackLink( $rev, $context, $editCount );
1783 
1784  if ( !in_array( 'noBrackets', $options ) ) {
1785  $inner = $context->msg( 'brackets' )->rawParams( $inner )->plain();
1786  }
1787 
1788  return '<span class="mw-rollback-link">' . $inner . '</span>';
1789  }
1790 
1806  public static function getRollbackEditCount( $rev, $verify ) {
1807  global $wgShowRollbackEditCount;
1808  if ( !is_int( $wgShowRollbackEditCount ) || !$wgShowRollbackEditCount > 0 ) {
1809  // Nothing has happened, indicate this by returning 'null'
1810  return null;
1811  }
1812 
1813  $dbr = wfGetDB( DB_SLAVE );
1814 
1815  // Up to the value of $wgShowRollbackEditCount revisions are counted
1816  $res = $dbr->select(
1817  'revision',
1818  array( 'rev_user_text', 'rev_deleted' ),
1819  // $rev->getPage() returns null sometimes
1820  array( 'rev_page' => $rev->getTitle()->getArticleID() ),
1821  __METHOD__,
1822  array(
1823  'USE INDEX' => array( 'revision' => 'page_timestamp' ),
1824  'ORDER BY' => 'rev_timestamp DESC',
1825  'LIMIT' => $wgShowRollbackEditCount + 1
1826  )
1827  );
1828 
1829  $editCount = 0;
1830  $moreRevs = false;
1831  foreach ( $res as $row ) {
1832  if ( $rev->getRawUserText() != $row->rev_user_text ) {
1833  if ( $verify && ( $row->rev_deleted & Revision::DELETED_TEXT || $row->rev_deleted & Revision::DELETED_USER ) ) {
1834  // If the user or the text of the revision we might rollback to is deleted in some way we can't rollback
1835  // Similar to the sanity checks in WikiPage::commitRollback
1836  return false;
1837  }
1838  $moreRevs = true;
1839  break;
1840  }
1841  $editCount++;
1842  }
1843 
1844  if ( $verify && $editCount <= $wgShowRollbackEditCount && !$moreRevs ) {
1845  // We didn't find at least $wgShowRollbackEditCount revisions made by the current user
1846  // and there weren't any other revisions. That means that the current user is the only
1847  // editor, so we can't rollback
1848  return false;
1849  }
1850  return $editCount;
1851  }
1852 
1861  public static function buildRollbackLink( $rev, IContextSource $context = null, $editCount = false ) {
1862  global $wgShowRollbackEditCount, $wgMiserMode;
1863 
1864  // To config which pages are effected by miser mode
1865  $disableRollbackEditCountSpecialPage = array( 'Recentchanges', 'Watchlist' );
1866 
1867  if ( $context === null ) {
1868  $context = RequestContext::getMain();
1869  }
1870 
1871  $title = $rev->getTitle();
1872  $query = array(
1873  'action' => 'rollback',
1874  'from' => $rev->getUserText(),
1875  'token' => $context->getUser()->getEditToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
1876  );
1877  if ( $context->getRequest()->getBool( 'bot' ) ) {
1878  $query['bot'] = '1';
1879  $query['hidediff'] = '1'; // bug 15999
1880  }
1881 
1882  $disableRollbackEditCount = false;
1883  if ( $wgMiserMode ) {
1884  foreach ( $disableRollbackEditCountSpecialPage as $specialPage ) {
1885  if ( $context->getTitle()->isSpecial( $specialPage ) ) {
1886  $disableRollbackEditCount = true;
1887  break;
1888  }
1889  }
1890  }
1891 
1892  if ( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
1893  if ( !is_numeric( $editCount ) ) {
1894  $editCount = self::getRollbackEditCount( $rev, false );
1895  }
1896 
1897  if ( $editCount > $wgShowRollbackEditCount ) {
1898  $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )->numParams( $wgShowRollbackEditCount )->parse();
1899  } else {
1900  $editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
1901  }
1902 
1903  return self::link(
1904  $title,
1905  $editCount_output,
1906  array( 'title' => $context->msg( 'tooltip-rollback' )->text() ),
1907  $query,
1908  array( 'known', 'noclasses' )
1909  );
1910  } else {
1911  return self::link(
1912  $title,
1913  $context->msg( 'rollbacklink' )->escaped(),
1914  array( 'title' => $context->msg( 'tooltip-rollback' )->text() ),
1915  $query,
1916  array( 'known', 'noclasses' )
1917  );
1918  }
1919  }
1920 
1936  public static function formatTemplates( $templates, $preview = false, $section = false, $more = null ) {
1937  global $wgLang;
1938  wfProfileIn( __METHOD__ );
1939 
1940  $outText = '';
1941  if ( count( $templates ) > 0 ) {
1942  # Do a batch existence check
1943  $batch = new LinkBatch;
1944  foreach ( $templates as $title ) {
1945  $batch->addObj( $title );
1946  }
1947  $batch->execute();
1948 
1949  # Construct the HTML
1950  $outText = '<div class="mw-templatesUsedExplanation">';
1951  if ( $preview ) {
1952  $outText .= wfMessage( 'templatesusedpreview' )->numParams( count( $templates ) )
1953  ->parseAsBlock();
1954  } elseif ( $section ) {
1955  $outText .= wfMessage( 'templatesusedsection' )->numParams( count( $templates ) )
1956  ->parseAsBlock();
1957  } else {
1958  $outText .= wfMessage( 'templatesused' )->numParams( count( $templates ) )
1959  ->parseAsBlock();
1960  }
1961  $outText .= "</div><ul>\n";
1962 
1963  usort( $templates, 'Title::compare' );
1964  foreach ( $templates as $titleObj ) {
1965  $protected = '';
1966  $restrictions = $titleObj->getRestrictions( 'edit' );
1967  if ( $restrictions ) {
1968  // Check backwards-compatible messages
1969  $msg = null;
1970  if ( $restrictions === array( 'sysop' ) ) {
1971  $msg = wfMessage( 'template-protected' );
1972  } elseif ( $restrictions === array( 'autoconfirmed' ) ) {
1973  $msg = wfMessage( 'template-semiprotected' );
1974  }
1975  if ( $msg && !$msg->isDisabled() ) {
1976  $protected = $msg->parse();
1977  } else {
1978  // Construct the message from restriction-level-*
1979  // e.g. restriction-level-sysop, restriction-level-autoconfirmed
1980  $msgs = array();
1981  foreach ( $restrictions as $r ) {
1982  $msgs[] = wfMessage( "restriction-level-$r" )->parse();
1983  }
1984  $protected = wfMessage( 'parentheses' )
1985  ->rawParams( $wgLang->commaList( $msgs ) )->escaped();
1986  }
1987  }
1988  if ( $titleObj->quickUserCan( 'edit' ) ) {
1989  $editLink = self::link(
1990  $titleObj,
1991  wfMessage( 'editlink' )->text(),
1992  array(),
1993  array( 'action' => 'edit' )
1994  );
1995  } else {
1996  $editLink = self::link(
1997  $titleObj,
1998  wfMessage( 'viewsourcelink' )->text(),
1999  array(),
2000  array( 'action' => 'edit' )
2001  );
2002  }
2003  $outText .= '<li>' . self::link( $titleObj )
2004  . wfMessage( 'word-separator' )->escaped()
2005  . wfMessage( 'parentheses' )->rawParams( $editLink )->escaped()
2006  . wfMessage( 'word-separator' )->escaped()
2007  . $protected . '</li>';
2008  }
2009 
2010  if ( $more instanceof Title ) {
2011  $outText .= '<li>' . self::link( $more, wfMessage( 'moredotdotdot' ) ) . '</li>';
2012  } elseif ( $more ) {
2013  $outText .= "<li>$more</li>";
2014  }
2015 
2016  $outText .= '</ul>';
2017  }
2018  wfProfileOut( __METHOD__ );
2019  return $outText;
2020  }
2021 
2029  public static function formatHiddenCategories( $hiddencats ) {
2030  wfProfileIn( __METHOD__ );
2031 
2032  $outText = '';
2033  if ( count( $hiddencats ) > 0 ) {
2034  # Construct the HTML
2035  $outText = '<div class="mw-hiddenCategoriesExplanation">';
2036  $outText .= wfMessage( 'hiddencategories' )->numParams( count( $hiddencats ) )->parseAsBlock();
2037  $outText .= "</div><ul>\n";
2038 
2039  foreach ( $hiddencats as $titleObj ) {
2040  $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
2041  }
2042  $outText .= '</ul>';
2043  }
2044  wfProfileOut( __METHOD__ );
2045  return $outText;
2046  }
2047 
2055  public static function formatSize( $size ) {
2056  global $wgLang;
2057  return htmlspecialchars( $wgLang->formatSize( $size ) );
2058  }
2059 
2072  public static function titleAttrib( $name, $options = null ) {
2073  wfProfileIn( __METHOD__ );
2074 
2075  $message = wfMessage( "tooltip-$name" );
2076 
2077  if ( !$message->exists() ) {
2078  $tooltip = false;
2079  } else {
2080  $tooltip = $message->text();
2081  # Compatibility: formerly some tooltips had [alt-.] hardcoded
2082  $tooltip = preg_replace( "/ ?\[alt-.\]$/", '', $tooltip );
2083  # Message equal to '-' means suppress it.
2084  if ( $tooltip == '-' ) {
2085  $tooltip = false;
2086  }
2087  }
2088 
2089  if ( $options == 'withaccess' ) {
2090  $accesskey = self::accesskey( $name );
2091  if ( $accesskey !== false ) {
2092  if ( $tooltip === false || $tooltip === '' ) {
2093  $tooltip = wfMessage( 'brackets', $accesskey )->escaped();
2094  } else {
2095  $tooltip .= wfMessage( 'word-separator' )->escaped();
2096  $tooltip .= wfMessage( 'brackets', $accesskey )->escaped();
2097  }
2098  }
2099  }
2100 
2101  wfProfileOut( __METHOD__ );
2102  return $tooltip;
2103  }
2104 
2105  static $accesskeycache;
2106 
2117  public static function accesskey( $name ) {
2118  if ( isset( self::$accesskeycache[$name] ) ) {
2119  return self::$accesskeycache[$name];
2120  }
2121  wfProfileIn( __METHOD__ );
2122 
2123  $message = wfMessage( "accesskey-$name" );
2124 
2125  if ( !$message->exists() ) {
2126  $accesskey = false;
2127  } else {
2128  $accesskey = $message->plain();
2129  if ( $accesskey === '' || $accesskey === '-' ) {
2130  # @todo FIXME: Per standard MW behavior, a value of '-' means to suppress the
2131  # attribute, but this is broken for accesskey: that might be a useful
2132  # value.
2133  $accesskey = false;
2134  }
2135  }
2136 
2137  wfProfileOut( __METHOD__ );
2138  self::$accesskeycache[$name] = $accesskey;
2139  return self::$accesskeycache[$name];
2140  }
2141 
2155  public static function getRevDeleteLink( User $user, Revision $rev, Title $title ) {
2156  $canHide = $user->isAllowed( 'deleterevision' );
2157  if ( !$canHide && !( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
2158  return '';
2159  }
2160 
2161  if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
2162  return Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
2163  } else {
2164  if ( $rev->getId() ) {
2165  // RevDelete links using revision ID are stable across
2166  // page deletion and undeletion; use when possible.
2167  $query = array(
2168  'type' => 'revision',
2169  'target' => $title->getPrefixedDBkey(),
2170  'ids' => $rev->getId()
2171  );
2172  } else {
2173  // Older deleted entries didn't save a revision ID.
2174  // We have to refer to these by timestamp, ick!
2175  $query = array(
2176  'type' => 'archive',
2177  'target' => $title->getPrefixedDBkey(),
2178  'ids' => $rev->getTimestamp()
2179  );
2180  }
2181  return Linker::revDeleteLink( $query,
2182  $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
2183  }
2184  }
2185 
2196  public static function revDeleteLink( $query = array(), $restricted = false, $delete = true ) {
2197  $sp = SpecialPage::getTitleFor( 'Revisiondelete' );
2198  $msgKey = $delete ? 'rev-delundel' : 'rev-showdeleted';
2199  $html = wfMessage( $msgKey )->escaped();
2200  $tag = $restricted ? 'strong' : 'span';
2201  $link = self::link( $sp, $html, array(), $query, array( 'known', 'noclasses' ) );
2202  return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), wfMessage( 'parentheses' )->rawParams( $link )->escaped() );
2203  }
2204 
2213  public static function revDeleteLinkDisabled( $delete = true ) {
2214  $msgKey = $delete ? 'rev-delundel' : 'rev-showdeleted';
2215  $html = wfMessage( $msgKey )->escaped();
2216  $htmlParentheses = wfMessage( 'parentheses' )->rawParams( $html )->escaped();
2217  return Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), $htmlParentheses );
2218  }
2219 
2220  /* Deprecated methods */
2221 
2238  static function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
2239  wfDeprecated( __METHOD__, '1.21' );
2240 
2241  wfProfileIn( __METHOD__ );
2242  $query = wfCgiToArray( $query );
2243  list( $inside, $trail ) = self::splitTrail( $trail );
2244  if ( $text === '' ) {
2245  $text = self::linkText( $nt );
2246  }
2247 
2248  $ret = self::link( $nt, "$prefix$text$inside", array(), $query ) . $trail;
2249 
2250  wfProfileOut( __METHOD__ );
2251  return $ret;
2252  }
2253 
2270  static function makeKnownLinkObj(
2271  $title, $text = '', $query = '', $trail = '', $prefix = '', $aprops = '', $style = ''
2272  ) {
2273  wfDeprecated( __METHOD__, '1.21' );
2274 
2275  wfProfileIn( __METHOD__ );
2276 
2277  if ( $text == '' ) {
2278  $text = self::linkText( $title );
2279  }
2281  Sanitizer::decodeTagAttributes( $aprops ),
2283  );
2284  $query = wfCgiToArray( $query );
2285  list( $inside, $trail ) = self::splitTrail( $trail );
2286 
2287  $ret = self::link( $title, "$prefix$text$inside", $attribs, $query,
2288  array( 'known', 'noclasses' ) ) . $trail;
2289 
2290  wfProfileOut( __METHOD__ );
2291  return $ret;
2292  }
2293 
2298  public static function tooltipAndAccesskeyAttribs( $name ) {
2299  # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
2300  # no attribute" instead of "output '' as value for attribute", this
2301  # would be three lines.
2302  $attribs = array(
2303  'title' => self::titleAttrib( $name, 'withaccess' ),
2304  'accesskey' => self::accesskey( $name )
2305  );
2306  if ( $attribs['title'] === false ) {
2307  unset( $attribs['title'] );
2308  }
2309  if ( $attribs['accesskey'] === false ) {
2310  unset( $attribs['accesskey'] );
2311  }
2312  return $attribs;
2313  }
2314 
2319  public static function tooltip( $name, $options = null ) {
2320  # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
2321  # no attribute" instead of "output '' as value for attribute", this
2322  # would be two lines.
2323  $tooltip = self::titleAttrib( $name, $options );
2324  if ( $tooltip === false ) {
2325  return '';
2326  }
2327  return Xml::expandAttributes( array(
2328  'title' => $tooltip
2329  ) );
2330  }
2331 }
2332 
2337 
2346  public function __call( $fname, $args ) {
2347  return call_user_func_array( array( 'Linker', $fname ), $args );
2348  }
2349 }
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:552
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:1770
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:411
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
ID
occurs before session is loaded can be modified ID
Definition: hooks.txt:2818
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:1556
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:1373
Linker\TOOL_LINKS_NOBLOCK
const TOOL_LINKS_NOBLOCK
Flags for userToolLinks()
Definition: Linker.php:37
Linker\userTalkLink
static userTalkLink( $userId, $userText)
Definition: Linker.php:1164
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:2196
Linker\userToolLinksRedContribs
static userToolLinksRedContribs( $userId, $userText, $edits=null)
Alias for userToolLinks( $userId, $userText, true );.
Definition: Linker.php:1155
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:1186
$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:1198
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:1072
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:2346
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:1615
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3650
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
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
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:1280
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:1400
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:1254
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:2238
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2113
$link
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
Definition: hooks.txt:2149
Linker\$commentLocal
static $commentLocal
Definition: Linker.php:1361
Linker\tocLine
static tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex=false)
parameter level defines if we are on an indentation level
Definition: Linker.php:1633
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:1289
Linker\formatHiddenCategories
static formatHiddenCategories( $hiddencats)
Returns HTML for the "hidden categories on this page" list.
Definition: Linker.php:2029
$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:459
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:2298
$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:1307
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1127
Html\element
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:148
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:1219
Linker\tocList
static tocList( $toc, $lang=false)
Wraps the TOC in a table and provides the hide/collapse javascript.
Definition: Linker.php:1661
Linker\getRollbackEditCount
static getRollbackEditCount( $rev, $verify)
This function will return the number of revisions which a rollback would revert and,...
Definition: Linker.php:1806
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:1956
$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:1650
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4001
wfGetLangObj
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
Definition: GlobalFunctions.php:1352
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:412
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:2213
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:1274
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:1731
IP\prettifyIP
static prettifyIP( $ip)
Prettify an IP for display to end users.
Definition: IP.php:187
$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:2270
$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:933
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:1578
$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:1175
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:1100
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:1600
$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:1715
$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:2573
Linker\formatTemplates
static formatTemplates( $templates, $preview=false, $section=false, $more=null)
Returns HTML for the "templates used on this page" list.
Definition: Linker.php:1936
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:2336
$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:2697
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
Linker\$autocommentTitle
static $autocommentTitle
Definition: Linker.php:1273
Linker\tooltip
static tooltip( $name, $options=null)
Returns raw bits of HTML, use titleAttrib()
Definition: Linker.php:2319
$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:2072
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:1624
wfFindFile
wfFindFile( $title, $options=array())
Find a file.
Definition: GlobalFunctions.php:3693
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:1474
Sanitizer\decodeTagAttributes
static decodeTagAttributes( $text)
Return an associative array of attribute names and values from a partial tag string.
Definition: Sanitizer.php:1166
$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:1678
Html\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:124
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:1861
$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:1360
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:1141
$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:1956