MediaWiki  1.23.8
Skin.php
Go to the documentation of this file.
1 <?php
35 abstract class Skin extends ContextSource {
36  protected $skinname = 'standard';
37  protected $mRelevantTitle = null;
38  protected $mRelevantUser = null;
39 
44  static function getSkinNames() {
46  static $skinsInitialised = false;
47 
48  if ( !$skinsInitialised || !count( $wgValidSkinNames ) ) {
49  # Get a list of available skins
50  # Build using the regular expression '^(.*).php$'
51  # Array keys are all lower case, array value keep the case used by filename
52  #
53  wfProfileIn( __METHOD__ . '-init' );
54 
55  global $wgStyleDirectory;
56 
57  $skinDir = dir( $wgStyleDirectory );
58 
59  if ( $skinDir !== false && $skinDir !== null ) {
60  # while code from www.php.net
61  while ( false !== ( $file = $skinDir->read() ) ) {
62  // Skip non-PHP files, hidden files, and '.dep' includes
63  $matches = array();
64 
65  if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
66  $aSkin = $matches[1];
67 
68  // We're still loading core skins via the autodiscovery mechanism... :(
69  if ( !in_array( $aSkin, array( 'CologneBlue', 'Modern', 'MonoBook', 'Vector' ) ) ) {
71  "A skin using autodiscovery mechanism, $aSkin, was found in your skins/ directory. " .
72  "The mechanism will be removed in MediaWiki 1.25 and the skin will no longer be recognized. " .
73  "See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for information how to fix this."
74  );
75  }
76 
77  $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
78  }
79  }
80  $skinDir->close();
81  }
82  $skinsInitialised = true;
83  wfProfileOut( __METHOD__ . '-init' );
84  }
85  return $wgValidSkinNames;
86  }
87 
92  static function getSkinNameMessages() {
93  $messages = array();
94  foreach ( self::getSkinNames() as $skinKey => $skinName ) {
95  // Messages: skinname-cologneblue, skinname-monobook, skinname-modern, skinname-vector
96  $messages[] = "skinname-$skinKey";
97  }
98  return $messages;
99  }
100 
108  public static function getAllowedSkins() {
109  global $wgSkipSkins;
110 
111  $allowedSkins = self::getSkinNames();
112 
113  foreach ( $wgSkipSkins as $skip ) {
114  unset( $allowedSkins[$skip] );
115  }
116 
117  return $allowedSkins;
118  }
119 
124  public static function getUsableSkins() {
125  wfDeprecated( __METHOD__, '1.23' );
126  return self::getAllowedSkins();
127  }
128 
136  static function normalizeKey( $key ) {
137  global $wgDefaultSkin;
138 
139  $skinNames = Skin::getSkinNames();
140 
141  if ( $key == '' || $key == 'default' ) {
142  // Don't return the default immediately;
143  // in a misconfiguration we need to fall back.
144  $key = $wgDefaultSkin;
145  }
146 
147  if ( isset( $skinNames[$key] ) ) {
148  return $key;
149  }
150 
151  // Older versions of the software used a numeric setting
152  // in the user preferences.
153  $fallback = array(
154  0 => $wgDefaultSkin,
155  2 => 'cologneblue'
156  );
157 
158  if ( isset( $fallback[$key] ) ) {
159  $key = $fallback[$key];
160  }
161 
162  if ( isset( $skinNames[$key] ) ) {
163  return $key;
164  } elseif ( isset( $skinNames[$wgDefaultSkin] ) ) {
165  return $wgDefaultSkin;
166  } else {
167  return 'vector';
168  }
169  }
170 
176  static function &newFromKey( $key ) {
177  global $wgStyleDirectory;
178 
179  $key = Skin::normalizeKey( $key );
180 
181  $skinNames = Skin::getSkinNames();
182  $skinName = $skinNames[$key];
183  $className = "Skin{$skinName}";
184 
185  # Grab the skin class and initialise it.
186  if ( !class_exists( $className ) ) {
187 
188  require_once "{$wgStyleDirectory}/{$skinName}.php";
189 
190  # Check if we got if not fallback to default skin
191  if ( !class_exists( $className ) ) {
192  # DO NOT die if the class isn't found. This breaks maintenance
193  # scripts and can cause a user account to be unrecoverable
194  # except by SQL manipulation if a previously valid skin name
195  # is no longer valid.
196  wfDebug( "Skin class does not exist: $className\n" );
197  $className = 'SkinVector';
198  require_once "{$wgStyleDirectory}/Vector.php";
199  }
200  }
201  $skin = new $className( $key );
202  return $skin;
203  }
204 
208  public function getSkinName() {
209  return $this->skinname;
210  }
211 
215  function initPage( OutputPage $out ) {
216  wfProfileIn( __METHOD__ );
217 
218  $this->preloadExistence();
219 
220  wfProfileOut( __METHOD__ );
221  }
222 
229  public function getDefaultModules() {
230  global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
231  $wgAjaxWatch, $wgEnableAPI, $wgEnableWriteAPI;
232 
233  $out = $this->getOutput();
234  $user = $out->getUser();
235  $modules = array(
236  // modules that enhance the page content in some way
237  'content' => array(
238  'mediawiki.page.ready',
239  ),
240  // modules that exist for legacy reasons
241  'legacy' => array(),
242  // modules relating to search functionality
243  'search' => array(),
244  // modules relating to functionality relating to watching an article
245  'watch' => array(),
246  // modules which relate to the current users preferences
247  'user' => array(),
248  );
249  if ( $wgIncludeLegacyJavaScript ) {
250  $modules['legacy'][] = 'mediawiki.legacy.wikibits';
251  }
252 
253  if ( $wgPreloadJavaScriptMwUtil ) {
254  $modules['legacy'][] = 'mediawiki.util';
255  }
256 
257  // Add various resources if required
258  if ( $wgUseAjax ) {
259  $modules['legacy'][] = 'mediawiki.legacy.ajax';
260 
261  if ( $wgEnableAPI ) {
262  if ( $wgEnableWriteAPI && $wgAjaxWatch && $user->isLoggedIn()
263  && $user->isAllowed( 'writeapi' )
264  ) {
265  $modules['watch'][] = 'mediawiki.page.watch.ajax';
266  }
267 
268  $modules['search'][] = 'mediawiki.searchSuggest';
269  }
270  }
271 
272  if ( $user->getBoolOption( 'editsectiononrightclick' ) ) {
273  $modules['user'][] = 'mediawiki.action.view.rightClickEdit';
274  }
275 
276  // Crazy edit-on-double-click stuff
277  if ( $out->isArticle() && $user->getOption( 'editondblclick' ) ) {
278  $modules['user'][] = 'mediawiki.action.view.dblClickEdit';
279  }
280  return $modules;
281  }
282 
286  function preloadExistence() {
287  $user = $this->getUser();
288 
289  // User/talk link
290  $titles = array( $user->getUserPage(), $user->getTalkPage() );
291 
292  // Other tab link
293  if ( $this->getTitle()->isSpecialPage() ) {
294  // nothing
295  } elseif ( $this->getTitle()->isTalkPage() ) {
296  $titles[] = $this->getTitle()->getSubjectPage();
297  } else {
298  $titles[] = $this->getTitle()->getTalkPage();
299  }
300 
301  $lb = new LinkBatch( $titles );
302  $lb->setCaller( __METHOD__ );
303  $lb->execute();
304  }
305 
311  public function getRevisionId() {
312  return $this->getOutput()->getRevisionId();
313  }
314 
320  public function isRevisionCurrent() {
321  $revID = $this->getRevisionId();
322  return $revID == 0 || $revID == $this->getTitle()->getLatestRevID();
323  }
324 
330  public function setRelevantTitle( $t ) {
331  $this->mRelevantTitle = $t;
332  }
333 
344  public function getRelevantTitle() {
345  if ( isset( $this->mRelevantTitle ) ) {
346  return $this->mRelevantTitle;
347  }
348  return $this->getTitle();
349  }
350 
356  public function setRelevantUser( $u ) {
357  $this->mRelevantUser = $u;
358  }
359 
368  public function getRelevantUser() {
369  if ( isset( $this->mRelevantUser ) ) {
370  return $this->mRelevantUser;
371  }
372  $title = $this->getRelevantTitle();
373  if ( $title->hasSubjectNamespace( NS_USER ) ) {
374  $rootUser = $title->getRootText();
375  if ( User::isIP( $rootUser ) ) {
376  $this->mRelevantUser = User::newFromName( $rootUser, false );
377  } else {
378  $user = User::newFromName( $rootUser, false );
379  if ( $user && $user->isLoggedIn() ) {
380  $this->mRelevantUser = $user;
381  }
382  }
383  return $this->mRelevantUser;
384  }
385  return null;
386  }
387 
392  abstract function outputPage( OutputPage $out = null );
393 
398  static function makeVariablesScript( $data ) {
399  if ( $data ) {
400  return Html::inlineScript(
402  );
403  } else {
404  return '';
405  }
406  }
407 
415  public static function makeGlobalVariablesScript( $unused ) {
416  global $wgOut;
417 
418  wfDeprecated( __METHOD__, '1.19' );
419 
420  return self::makeVariablesScript( $wgOut->getJSVars() );
421  }
422 
428  public static function getDynamicStylesheetQuery() {
429  global $wgSquidMaxage;
430 
431  return array(
432  'action' => 'raw',
433  'maxage' => $wgSquidMaxage,
434  'usemsgcache' => 'yes',
435  'ctype' => 'text/css',
436  'smaxage' => $wgSquidMaxage,
437  );
438  }
439 
448  abstract function setupSkinUserCss( OutputPage $out );
449 
455  function getPageClasses( $title ) {
456  $numeric = 'ns-' . $title->getNamespace();
457 
458  if ( $title->isSpecialPage() ) {
459  $type = 'ns-special';
460  // bug 23315: provide a class based on the canonical special page name without subpages
461  list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
462  if ( $canonicalName ) {
463  $type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
464  } else {
465  $type .= ' mw-invalidspecialpage';
466  }
467  } elseif ( $title->isTalkPage() ) {
468  $type = 'ns-talk';
469  } else {
470  $type = 'ns-subject';
471  }
472 
473  $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
474 
475  return "$numeric $type $name";
476  }
477 
478  /*
479  * Return values for <html> element
480  * @return array of associative name-to-value elements for <html> element
481  */
482  public function getHtmlElementAttributes() {
483  $lang = $this->getLanguage();
484  return array(
485  'lang' => $lang->getHtmlCode(),
486  'dir' => $lang->getDir(),
487  'class' => 'client-nojs',
488  );
489  }
490 
498  function addToBodyAttributes( $out, &$bodyAttrs ) {
499  // does nothing by default
500  }
501 
506  function getLogo() {
507  global $wgLogo;
508  return $wgLogo;
509  }
510 
514  function getCategoryLinks() {
515  global $wgUseCategoryBrowser;
516 
517  $out = $this->getOutput();
518  $allCats = $out->getCategoryLinks();
519 
520  if ( !count( $allCats ) ) {
521  return '';
522  }
523 
524  $embed = "<li>";
525  $pop = "</li>";
526 
527  $s = '';
528  $colon = $this->msg( 'colon-separator' )->escaped();
529 
530  if ( !empty( $allCats['normal'] ) ) {
531  $t = $embed . implode( "{$pop}{$embed}", $allCats['normal'] ) . $pop;
532 
533  $msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
534  $linkPage = wfMessage( 'pagecategorieslink' )->inContentLanguage()->text();
535  $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
536  Linker::link( Title::newFromText( $linkPage ), $msg )
537  . $colon . '<ul>' . $t . '</ul>' . '</div>';
538  }
539 
540  # Hidden categories
541  if ( isset( $allCats['hidden'] ) ) {
542  if ( $this->getUser()->getBoolOption( 'showhiddencats' ) ) {
543  $class = ' mw-hidden-cats-user-shown';
544  } elseif ( $this->getTitle()->getNamespace() == NS_CATEGORY ) {
545  $class = ' mw-hidden-cats-ns-shown';
546  } else {
547  $class = ' mw-hidden-cats-hidden';
548  }
549 
550  $s .= "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks$class\">" .
551  $this->msg( 'hidden-categories' )->numParams( count( $allCats['hidden'] ) )->escaped() .
552  $colon . '<ul>' . $embed . implode( "{$pop}{$embed}", $allCats['hidden'] ) . $pop . '</ul>' .
553  '</div>';
554  }
555 
556  # optional 'dmoz-like' category browser. Will be shown under the list
557  # of categories an article belong to
558  if ( $wgUseCategoryBrowser ) {
559  $s .= '<br /><hr />';
560 
561  # get a big array of the parents tree
562  $parenttree = $this->getTitle()->getParentCategoryTree();
563  # Skin object passed by reference cause it can not be
564  # accessed under the method subfunction drawCategoryBrowser
565  $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree ) );
566  # Clean out bogus first entry and sort them
567  unset( $tempout[0] );
568  asort( $tempout );
569  # Output one per line
570  $s .= implode( "<br />\n", $tempout );
571  }
572 
573  return $s;
574  }
575 
581  function drawCategoryBrowser( $tree ) {
582  $return = '';
583 
584  foreach ( $tree as $element => $parent ) {
585  if ( empty( $parent ) ) {
586  # element start a new list
587  $return .= "\n";
588  } else {
589  # grab the others elements
590  $return .= $this->drawCategoryBrowser( $parent ) . ' &gt; ';
591  }
592 
593  # add our current element to the list
594  $eltitle = Title::newFromText( $element );
595  $return .= Linker::link( $eltitle, htmlspecialchars( $eltitle->getText() ) );
596  }
597 
598  return $return;
599  }
600 
604  function getCategories() {
605  $out = $this->getOutput();
606 
607  $catlinks = $this->getCategoryLinks();
608 
609  $classes = 'catlinks';
610 
611  // Check what we're showing
612  $allCats = $out->getCategoryLinks();
613  $showHidden = $this->getUser()->getBoolOption( 'showhiddencats' ) ||
614  $this->getTitle()->getNamespace() == NS_CATEGORY;
615 
616  if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
617  $classes .= ' catlinks-allhidden';
618  }
619 
620  return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
621  }
622 
637  protected function afterContentHook() {
638  $data = '';
639 
640  if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
641  // adding just some spaces shouldn't toggle the output
642  // of the whole <div/>, so we use trim() here
643  if ( trim( $data ) != '' ) {
644  // Doing this here instead of in the skins to
645  // ensure that the div has the same ID in all
646  // skins
647  $data = "<div id='mw-data-after-content'>\n" .
648  "\t$data\n" .
649  "</div>\n";
650  }
651  } else {
652  wfDebug( "Hook SkinAfterContent changed output processing.\n" );
653  }
654 
655  return $data;
656  }
657 
663  protected function generateDebugHTML() {
664  return MWDebug::getHTMLDebugLog();
665  }
666 
672  function bottomScripts() {
673  // TODO and the suckage continues. This function is really just a wrapper around
674  // OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
675  // up at some point
676  $bottomScriptText = $this->getOutput()->getBottomScripts();
677  wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
678 
679  return $bottomScriptText;
680  }
681 
688  function printSource() {
689  $oldid = $this->getRevisionId();
690  if ( $oldid ) {
691  $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid ) ) );
692  } else {
693  // oldid not available for non existing pages
694  $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL() ) );
695  }
696  return $this->msg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' )->text();
697  }
698 
702  function getUndeleteLink() {
703  $action = $this->getRequest()->getVal( 'action', 'view' );
704 
705  if ( $this->getUser()->isAllowed( 'deletedhistory' ) &&
706  ( $this->getTitle()->getArticleID() == 0 || $action == 'history' ) ) {
707  $n = $this->getTitle()->isDeleted();
708 
709  if ( $n ) {
710  if ( $this->getUser()->isAllowed( 'undelete' ) ) {
711  $msg = 'thisisdeleted';
712  } else {
713  $msg = 'viewdeleted';
714  }
715 
716  return $this->msg( $msg )->rawParams(
718  SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
719  $this->msg( 'restorelink' )->numParams( $n )->escaped() )
720  )->text();
721  }
722  }
723 
724  return '';
725  }
726 
730  function subPageSubtitle() {
731  global $wgLang;
732  $out = $this->getOutput();
733  $subpages = '';
734 
735  if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
736  return $subpages;
737  }
738 
739  if ( $out->isArticle() && MWNamespace::hasSubpages( $out->getTitle()->getNamespace() ) ) {
740  $ptext = $this->getTitle()->getPrefixedText();
741  if ( preg_match( '/\//', $ptext ) ) {
742  $links = explode( '/', $ptext );
743  array_pop( $links );
744  $c = 0;
745  $growinglink = '';
746  $display = '';
747 
748  foreach ( $links as $link ) {
749  $growinglink .= $link;
750  $display .= $link;
751  $linkObj = Title::newFromText( $growinglink );
752 
753  if ( is_object( $linkObj ) && $linkObj->isKnown() ) {
754  $getlink = Linker::linkKnown(
755  $linkObj,
756  htmlspecialchars( $display )
757  );
758 
759  $c++;
760 
761  if ( $c > 1 ) {
762  $subpages .= $wgLang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
763  } else {
764  $subpages .= '&lt; ';
765  }
766 
767  $subpages .= $getlink;
768  $display = '';
769  } else {
770  $display .= '/';
771  }
772  $growinglink .= '/';
773  }
774  }
775  }
776 
777  return $subpages;
778  }
779 
784  function showIPinHeader() {
785  global $wgShowIPinHeader;
786  return $wgShowIPinHeader && session_id() != '';
787  }
788 
792  function getSearchLink() {
793  $searchPage = SpecialPage::getTitleFor( 'Search' );
794  return $searchPage->getLocalURL();
795  }
796 
800  function escapeSearchLink() {
801  return htmlspecialchars( $this->getSearchLink() );
802  }
803 
808  function getCopyright( $type = 'detect' ) {
809  global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgContLang;
810 
811  if ( $type == 'detect' ) {
812  if ( !$this->isRevisionCurrent() && !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled() ) {
813  $type = 'history';
814  } else {
815  $type = 'normal';
816  }
817  }
818 
819  if ( $type == 'history' ) {
820  $msg = 'history_copyright';
821  } else {
822  $msg = 'copyright';
823  }
824 
825  if ( $wgRightsPage ) {
826  $title = Title::newFromText( $wgRightsPage );
827  $link = Linker::linkKnown( $title, $wgRightsText );
828  } elseif ( $wgRightsUrl ) {
829  $link = Linker::makeExternalLink( $wgRightsUrl, $wgRightsText );
830  } elseif ( $wgRightsText ) {
831  $link = $wgRightsText;
832  } else {
833  # Give up now
834  return '';
835  }
836 
837  // Allow for site and per-namespace customization of copyright notice.
838  $forContent = true;
839 
840  wfRunHooks( 'SkinCopyrightFooter', array( $this->getTitle(), $type, &$msg, &$link, &$forContent ) );
841 
842  $msgObj = $this->msg( $msg )->rawParams( $link );
843  if ( $forContent ) {
844  $msg = $msgObj->inContentLanguage()->text();
845  if ( $this->getLanguage()->getCode() !== $wgContLang->getCode() ) {
846  $msg = Html::rawElement( 'span', array( 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $msg );
847  }
848  return $msg;
849  } else {
850  return $msgObj->text();
851  }
852  }
853 
857  function getCopyrightIcon() {
858  global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
859 
860  $out = '';
861 
862  if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
863  $out = $wgCopyrightIcon;
864  } elseif ( $wgRightsIcon ) {
865  $icon = htmlspecialchars( $wgRightsIcon );
866 
867  if ( $wgRightsUrl ) {
868  $url = htmlspecialchars( $wgRightsUrl );
869  $out .= '<a href="' . $url . '">';
870  }
871 
872  $text = htmlspecialchars( $wgRightsText );
873  $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
874 
875  if ( $wgRightsUrl ) {
876  $out .= '</a>';
877  }
878  }
879 
880  return $out;
881  }
882 
887  function getPoweredBy() {
888  global $wgStylePath;
889 
890  $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
891  $text = '<a href="//www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
892  wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
893  return $text;
894  }
895 
901  protected function lastModified() {
902  $timestamp = $this->getOutput()->getRevisionTimestamp();
903 
904  # No cached timestamp, load it from the database
905  if ( $timestamp === null ) {
907  }
908 
909  if ( $timestamp ) {
910  $d = $this->getLanguage()->userDate( $timestamp, $this->getUser() );
911  $t = $this->getLanguage()->userTime( $timestamp, $this->getUser() );
912  $s = ' ' . $this->msg( 'lastmodifiedat', $d, $t )->text();
913  } else {
914  $s = '';
915  }
916 
917  if ( wfGetLB()->getLaggedSlaveMode() ) {
918  $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->text() . '</strong>';
919  }
920 
921  return $s;
922  }
923 
928  function logoText( $align = '' ) {
929  if ( $align != '' ) {
930  $a = " style='float: {$align};'";
931  } else {
932  $a = '';
933  }
934 
935  $mp = $this->msg( 'mainpage' )->escaped();
936  $mptitle = Title::newMainPage();
937  $url = ( is_object( $mptitle ) ? htmlspecialchars( $mptitle->getLocalURL() ) : '' );
938 
939  $logourl = $this->getLogo();
940  $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
941 
942  return $s;
943  }
944 
951  function makeFooterIcon( $icon, $withImage = 'withImage' ) {
952  if ( is_string( $icon ) ) {
953  $html = $icon;
954  } else { // Assuming array
955  $url = isset( $icon["url"] ) ? $icon["url"] : null;
956  unset( $icon["url"] );
957  if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
958  $html = Html::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
959  } else {
960  $html = htmlspecialchars( $icon["alt"] );
961  }
962  if ( $url ) {
963  $html = Html::rawElement( 'a', array( "href" => $url ), $html );
964  }
965  }
966  return $html;
967  }
968 
973  function mainPageLink() {
976  $this->msg( 'mainpage' )->escaped()
977  );
978 
979  return $s;
980  }
981 
988  public function footerLink( $desc, $page ) {
989  // if the link description has been set to "-" in the default language,
990  if ( $this->msg( $desc )->inContentLanguage()->isDisabled() ) {
991  // then it is disabled, for all languages.
992  return '';
993  } else {
994  // Otherwise, we display the link for the user, described in their
995  // language (which may or may not be the same as the default language),
996  // but we make the link target be the one site-wide page.
997  $title = Title::newFromText( $this->msg( $page )->inContentLanguage()->text() );
998 
999  return Linker::linkKnown(
1000  $title,
1001  $this->msg( $desc )->escaped()
1002  );
1003  }
1004  }
1005 
1010  function privacyLink() {
1011  return $this->footerLink( 'privacy', 'privacypage' );
1012  }
1013 
1018  function aboutLink() {
1019  return $this->footerLink( 'aboutsite', 'aboutpage' );
1020  }
1021 
1026  function disclaimerLink() {
1027  return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1028  }
1029 
1037  function editUrlOptions() {
1038  $options = array( 'action' => 'edit' );
1039 
1040  if ( !$this->isRevisionCurrent() ) {
1041  $options['oldid'] = intval( $this->getRevisionId() );
1042  }
1043 
1044  return $options;
1045  }
1046 
1051  function showEmailUser( $id ) {
1052  if ( $id instanceof User ) {
1053  $targetUser = $id;
1054  } else {
1055  $targetUser = User::newFromId( $id );
1056  }
1057  return $this->getUser()->canSendEmail() && # the sending user must have a confirmed email address
1058  $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1059  }
1060 
1069  global $wgStylePath, $wgStyleVersion;
1070  return "$wgStylePath/common/$name?$wgStyleVersion";
1071  }
1072 
1080  function getSkinStylePath( $name ) {
1081  global $wgStylePath, $wgStyleVersion;
1082  return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
1083  }
1084 
1085  /* these are used extensively in SkinTemplate, but also some other places */
1086 
1091  static function makeMainPageUrl( $urlaction = '' ) {
1093  self::checkTitle( $title, '' );
1094 
1095  return $title->getLocalURL( $urlaction );
1096  }
1097 
1109  static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
1111  if ( is_null( $proto ) ) {
1112  return $title->getLocalURL( $urlaction );
1113  } else {
1114  return $title->getFullURL( $urlaction, false, $proto );
1115  }
1116  }
1117 
1124  static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1125  $title = SpecialPage::getSafeTitleFor( $name, $subpage );
1126  return $title->getLocalURL( $urlaction );
1127  }
1128 
1134  static function makeI18nUrl( $name, $urlaction = '' ) {
1135  $title = Title::newFromText( wfMessage( $name )->inContentLanguage()->text() );
1137  return $title->getLocalURL( $urlaction );
1138  }
1139 
1145  static function makeUrl( $name, $urlaction = '' ) {
1148 
1149  return $title->getLocalURL( $urlaction );
1150  }
1151 
1158  static function makeInternalOrExternalUrl( $name ) {
1159  if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $name ) ) {
1160  return $name;
1161  } else {
1162  return self::makeUrl( $name );
1163  }
1164  }
1165 
1173  static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
1174  $title = Title::makeTitleSafe( $namespace, $name );
1176 
1177  return $title->getLocalURL( $urlaction );
1178  }
1179 
1186  static function makeUrlDetails( $name, $urlaction = '' ) {
1189 
1190  return array(
1191  'href' => $title->getLocalURL( $urlaction ),
1192  'exists' => $title->getArticleID() != 0,
1193  );
1194  }
1195 
1202  static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1205 
1206  return array(
1207  'href' => $title->getLocalURL( $urlaction ),
1208  'exists' => true
1209  );
1210  }
1211 
1218  static function checkTitle( &$title, $name ) {
1219  if ( !is_object( $title ) ) {
1221  if ( !is_object( $title ) ) {
1222  $title = Title::newFromText( '--error: link target missing--' );
1223  }
1224  }
1225  }
1226 
1248  function buildSidebar() {
1249  global $wgMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1250  wfProfileIn( __METHOD__ );
1251 
1252  $key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() );
1253 
1254  if ( $wgEnableSidebarCache ) {
1255  $cachedsidebar = $wgMemc->get( $key );
1256  if ( $cachedsidebar ) {
1257  wfProfileOut( __METHOD__ );
1258  return $cachedsidebar;
1259  }
1260  }
1261 
1262  $bar = array();
1263  $this->addToSidebar( $bar, 'sidebar' );
1264 
1265  wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
1266  if ( $wgEnableSidebarCache ) {
1267  $wgMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1268  }
1269 
1270  wfProfileOut( __METHOD__ );
1271  return $bar;
1272  }
1273 
1283  function addToSidebar( &$bar, $message ) {
1284  $this->addToSidebarPlain( $bar, wfMessage( $message )->inContentLanguage()->plain() );
1285  }
1286 
1294  function addToSidebarPlain( &$bar, $text ) {
1295  $lines = explode( "\n", $text );
1296 
1297  $heading = '';
1298 
1299  foreach ( $lines as $line ) {
1300  if ( strpos( $line, '*' ) !== 0 ) {
1301  continue;
1302  }
1303  $line = rtrim( $line, "\r" ); // for Windows compat
1304 
1305  if ( strpos( $line, '**' ) !== 0 ) {
1306  $heading = trim( $line, '* ' );
1307  if ( !array_key_exists( $heading, $bar ) ) {
1308  $bar[$heading] = array();
1309  }
1310  } else {
1311  $line = trim( $line, '* ' );
1312 
1313  if ( strpos( $line, '|' ) !== false ) { // sanity check
1314  $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
1315  $line = array_map( 'trim', explode( '|', $line, 2 ) );
1316  if ( count( $line ) !== 2 ) {
1317  // Second sanity check, could be hit by people doing
1318  // funky stuff with parserfuncs... (bug 33321)
1319  continue;
1320  }
1321 
1322  $extraAttribs = array();
1323 
1324  $msgLink = $this->msg( $line[0] )->inContentLanguage();
1325  if ( $msgLink->exists() ) {
1326  $link = $msgLink->text();
1327  if ( $link == '-' ) {
1328  continue;
1329  }
1330  } else {
1331  $link = $line[0];
1332  }
1333  $msgText = $this->msg( $line[1] );
1334  if ( $msgText->exists() ) {
1335  $text = $msgText->text();
1336  } else {
1337  $text = $line[1];
1338  }
1339 
1340  if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $link ) ) {
1341  $href = $link;
1342 
1343  // Parser::getExternalLinkAttribs won't work here because of the Namespace things
1344  global $wgNoFollowLinks, $wgNoFollowDomainExceptions;
1345  if ( $wgNoFollowLinks && !wfMatchesDomainList( $href, $wgNoFollowDomainExceptions ) ) {
1346  $extraAttribs['rel'] = 'nofollow';
1347  }
1348 
1349  global $wgExternalLinkTarget;
1350  if ( $wgExternalLinkTarget ) {
1351  $extraAttribs['target'] = $wgExternalLinkTarget;
1352  }
1353  } else {
1355 
1356  if ( $title ) {
1357  $title = $title->fixSpecialName();
1358  $href = $title->getLinkURL();
1359  } else {
1360  $href = 'INVALID-TITLE';
1361  }
1362  }
1363 
1364  $bar[$heading][] = array_merge( array(
1365  'text' => $text,
1366  'href' => $href,
1367  'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
1368  'active' => false
1369  ), $extraAttribs );
1370  } else {
1371  continue;
1372  }
1373  }
1374  }
1375 
1376  return $bar;
1377  }
1378 
1390  public function commonPrintStylesheet() {
1391  wfDeprecated( __METHOD__, '1.22' );
1392  return false;
1393  }
1394 
1400  function getNewtalks() {
1401 
1402  $newMessagesAlert = '';
1403  $user = $this->getUser();
1404  $newtalks = $user->getNewMessageLinks();
1405  $out = $this->getOutput();
1406 
1407  // Allow extensions to disable or modify the new messages alert
1408  if ( !wfRunHooks( 'GetNewMessagesAlert', array( &$newMessagesAlert, $newtalks, $user, $out ) ) ) {
1409  return '';
1410  }
1411  if ( $newMessagesAlert ) {
1412  return $newMessagesAlert;
1413  }
1414 
1415  if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
1416  $uTalkTitle = $user->getTalkPage();
1417  $lastSeenRev = isset( $newtalks[0]['rev'] ) ? $newtalks[0]['rev'] : null;
1418  $nofAuthors = 0;
1419  if ( $lastSeenRev !== null ) {
1420  $plural = true; // Default if we have a last seen revision: if unknown, use plural
1421  $latestRev = Revision::newFromTitle( $uTalkTitle, false, Revision::READ_NORMAL );
1422  if ( $latestRev !== null ) {
1423  // Singular if only 1 unseen revision, plural if several unseen revisions.
1424  $plural = $latestRev->getParentId() !== $lastSeenRev->getId();
1425  $nofAuthors = $uTalkTitle->countAuthorsBetween(
1426  $lastSeenRev, $latestRev, 10, 'include_new' );
1427  }
1428  } else {
1429  // Singular if no revision -> diff link will show latest change only in any case
1430  $plural = false;
1431  }
1432  $plural = $plural ? 999 : 1;
1433  // 999 signifies "more than one revision". We don't know how many, and even if we did,
1434  // the number of revisions or authors is not necessarily the same as the number of
1435  // "messages".
1436  $newMessagesLink = Linker::linkKnown(
1437  $uTalkTitle,
1438  $this->msg( 'newmessageslinkplural' )->params( $plural )->escaped(),
1439  array(),
1440  array( 'redirect' => 'no' )
1441  );
1442 
1443  $newMessagesDiffLink = Linker::linkKnown(
1444  $uTalkTitle,
1445  $this->msg( 'newmessagesdifflinkplural' )->params( $plural )->escaped(),
1446  array(),
1447  $lastSeenRev !== null
1448  ? array( 'oldid' => $lastSeenRev->getId(), 'diff' => 'cur' )
1449  : array( 'diff' => 'cur' )
1450  );
1451 
1452  if ( $nofAuthors >= 1 && $nofAuthors <= 10 ) {
1453  $newMessagesAlert = $this->msg(
1454  'youhavenewmessagesfromusers',
1455  $newMessagesLink,
1456  $newMessagesDiffLink
1457  )->numParams( $nofAuthors, $plural );
1458  } else {
1459  // $nofAuthors === 11 signifies "11 or more" ("more than 10")
1460  $newMessagesAlert = $this->msg(
1461  $nofAuthors > 10 ? 'youhavenewmessagesmanyusers' : 'youhavenewmessages',
1462  $newMessagesLink,
1463  $newMessagesDiffLink
1464  )->numParams( $plural );
1465  }
1466  $newMessagesAlert = $newMessagesAlert->text();
1467  # Disable Squid cache
1468  $out->setSquidMaxage( 0 );
1469  } elseif ( count( $newtalks ) ) {
1470  $sep = $this->msg( 'newtalkseparator' )->escaped();
1471  $msgs = array();
1472 
1473  foreach ( $newtalks as $newtalk ) {
1474  $msgs[] = Xml::element(
1475  'a',
1476  array( 'href' => $newtalk['link'] ), $newtalk['wiki']
1477  );
1478  }
1479  $parts = implode( $sep, $msgs );
1480  $newMessagesAlert = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped();
1481  $out->setSquidMaxage( 0 );
1482  }
1483 
1484  return $newMessagesAlert;
1485  }
1486 
1493  private function getCachedNotice( $name ) {
1494  global $wgRenderHashAppend, $parserMemc, $wgContLang;
1495 
1496  wfProfileIn( __METHOD__ );
1497 
1498  $needParse = false;
1499 
1500  if ( $name === 'default' ) {
1501  // special case
1502  global $wgSiteNotice;
1503  $notice = $wgSiteNotice;
1504  if ( empty( $notice ) ) {
1505  wfProfileOut( __METHOD__ );
1506  return false;
1507  }
1508  } else {
1509  $msg = $this->msg( $name )->inContentLanguage();
1510  if ( $msg->isDisabled() ) {
1511  wfProfileOut( __METHOD__ );
1512  return false;
1513  }
1514  $notice = $msg->plain();
1515  }
1516 
1517  // Use the extra hash appender to let eg SSL variants separately cache.
1518  $key = wfMemcKey( $name . $wgRenderHashAppend );
1519  $cachedNotice = $parserMemc->get( $key );
1520  if ( is_array( $cachedNotice ) ) {
1521  if ( md5( $notice ) == $cachedNotice['hash'] ) {
1522  $notice = $cachedNotice['html'];
1523  } else {
1524  $needParse = true;
1525  }
1526  } else {
1527  $needParse = true;
1528  }
1529 
1530  if ( $needParse ) {
1531  $parsed = $this->getOutput()->parse( $notice );
1532  $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
1533  $notice = $parsed;
1534  }
1535 
1536  $notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
1537  'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $notice );
1538  wfProfileOut( __METHOD__ );
1539  return $notice;
1540  }
1541 
1547  function getNamespaceNotice() {
1548  wfProfileIn( __METHOD__ );
1549 
1550  $key = 'namespacenotice-' . $this->getTitle()->getNsText();
1551  $namespaceNotice = $this->getCachedNotice( $key );
1552  if ( $namespaceNotice && substr( $namespaceNotice, 0, 7 ) != '<p>&lt;' ) {
1553  $namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . '</div>';
1554  } else {
1555  $namespaceNotice = '';
1556  }
1557 
1558  wfProfileOut( __METHOD__ );
1559  return $namespaceNotice;
1560  }
1561 
1567  function getSiteNotice() {
1568  wfProfileIn( __METHOD__ );
1569  $siteNotice = '';
1570 
1571  if ( wfRunHooks( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
1572  if ( is_object( $this->getUser() ) && $this->getUser()->isLoggedIn() ) {
1573  $siteNotice = $this->getCachedNotice( 'sitenotice' );
1574  } else {
1575  $anonNotice = $this->getCachedNotice( 'anonnotice' );
1576  if ( !$anonNotice ) {
1577  $siteNotice = $this->getCachedNotice( 'sitenotice' );
1578  } else {
1579  $siteNotice = $anonNotice;
1580  }
1581  }
1582  if ( !$siteNotice ) {
1583  $siteNotice = $this->getCachedNotice( 'default' );
1584  }
1585  }
1586 
1587  wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
1588  wfProfileOut( __METHOD__ );
1589  return $siteNotice;
1590  }
1591 
1605  public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
1606  // HTML generated here should probably have userlangattributes
1607  // added to it for LTR text on RTL pages
1608 
1609  $lang = wfGetLangObj( $lang );
1610 
1611  $attribs = array();
1612  if ( !is_null( $tooltip ) ) {
1613  # Bug 25462: undo double-escaping.
1614  $tooltip = Sanitizer::decodeCharReferences( $tooltip );
1615  $attribs['title'] = wfMessage( 'editsectionhint' )->rawParams( $tooltip )
1616  ->inLanguage( $lang )->text();
1617  }
1618  $link = Linker::link( $nt, wfMessage( 'editsection' )->inLanguage( $lang )->text(),
1619  $attribs,
1620  array( 'action' => 'edit', 'section' => $section ),
1621  array( 'noclasses', 'known' )
1622  );
1623 
1624  # Add the brackets and the span and run the hook.
1625  $result = '<span class="mw-editsection">'
1626  . '<span class="mw-editsection-bracket">[</span>'
1627  . $link
1628  . '<span class="mw-editsection-bracket">]</span>'
1629  . '</span>';
1630 
1631  wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) );
1632  return $result;
1633  }
1634 
1644  function __call( $fname, $args ) {
1645  $realFunction = array( 'Linker', $fname );
1646  if ( is_callable( $realFunction ) ) {
1647  wfDeprecated( get_class( $this ) . '::' . $fname, '1.21' );
1648  return call_user_func_array( $realFunction, $args );
1649  } else {
1650  $className = get_class( $this );
1651  throw new MWException( "Call to undefined method $className::$fname" );
1652  }
1653  }
1654 
1655 }
ResourceLoader\makeLoaderConditionalScript
static makeLoaderConditionalScript( $script)
Returns JS code which runs given JS code if the client-side framework is present.
Definition: ResourceLoader.php:1138
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1528
Skin\editUrlOptions
editUrlOptions()
Return URL options for the 'edit page' link.
Definition: Skin.php:1037
Skin\showEmailUser
showEmailUser( $id)
Definition: Skin.php:1051
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:412
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
Skin\makeUrlDetails
static makeUrlDetails( $name, $urlaction='')
these return an array with the 'href' and boolean 'exists'
Definition: Skin.php:1186
Skin\getSiteNotice
getSiteNotice()
Get the site notice.
Definition: Skin.php:1567
Skin\getNamespaceNotice
getNamespaceNotice()
Get a notice based on page's namespace.
Definition: Skin.php:1547
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
ResourceLoader\makeConfigSetScript
static makeConfigSetScript(array $configuration)
Returns JS code which will set the MediaWiki configuration array to the given value.
Definition: ResourceLoader.php:1149
$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
ContextSource\msg
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:175
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:30
Skin\doEditSectionLink
doEditSectionLink(Title $nt, $section, $tooltip=null, $lang=false)
Create a section edit link.
Definition: Skin.php:1605
Skin\getPoweredBy
getPoweredBy()
Gets the powered by MediaWiki icon.
Definition: Skin.php:887
$wgMemc
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
Definition: globals.txt:25
wfGetLB
wfGetLB( $wiki=false)
Get a load balancer object.
Definition: GlobalFunctions.php:3669
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
$timestamp
if( $limit) $timestamp
Definition: importImages.php:104
Title\newMainPage
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:441
$fallback
$fallback
Definition: MessagesAb.php:12
Skin\lastModified
lastModified()
Get the timestamp of the latest revision, formatted in user language.
Definition: Skin.php:901
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
Skin\checkTitle
static checkTitle(&$title, $name)
make sure we have some title to operate on
Definition: Skin.php:1218
$n
$n
Definition: RandomTest.php:76
Skin\subPageSubtitle
subPageSubtitle()
Definition: Skin.php:730
MWDebug\getHTMLDebugLog
static getHTMLDebugLog()
Generate debug log in HTML for displaying at the bottom of the main content area.
Definition: Debug.php:427
$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
Skin\makeSpecialUrl
static makeSpecialUrl( $name, $urlaction='', $proto=null)
Make a URL for a Special Page using the given query and protocol.
Definition: Skin.php:1109
Skin\getCategoryLinks
getCategoryLinks()
Definition: Skin.php:514
Skin\aboutLink
aboutLink()
Gets the link to the wiki's about page.
Definition: Skin.php:1018
Skin\getDynamicStylesheetQuery
static getDynamicStylesheetQuery()
Get the query to generate a dynamic stylesheet.
Definition: Skin.php:428
Skin\makeSpecialUrlSubpage
static makeSpecialUrlSubpage( $name, $subpage, $urlaction='')
Definition: Skin.php:1124
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:389
Skin\addToBodyAttributes
addToBodyAttributes( $out, &$bodyAttrs)
This will be called by OutputPage::headElement when it is creating the "<body>" tag,...
Definition: Skin.php:498
$parserMemc
controlled by $wgMainCacheType * $parserMemc
Definition: memcached.txt:78
$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
Sanitizer\escapeClass
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
Definition: Sanitizer.php:1143
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1154
ContextSource\getRequest
getRequest()
Get the WebRequest object.
Definition: ContextSource.php:77
$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
Skin\$mRelevantUser
$mRelevantUser
Definition: Skin.php:38
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:132
$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
ContextSource\getTitle
getTitle()
Get the Title object.
Definition: ContextSource.php:87
wfExpandIRI
wfExpandIRI( $url)
Take a URL, make sure it's expanded to fully qualified, and replace any encoded non-ASCII Unicode cha...
Definition: GlobalFunctions.php:825
$messages
$messages
Definition: LogTests.i18n.php:8
Skin\makeI18nUrl
static makeI18nUrl( $name, $urlaction='')
Definition: Skin.php:1134
Skin\getHtmlElementAttributes
getHtmlElementAttributes()
Definition: Skin.php:482
Html\inlineScript
static inlineScript( $contents)
Output a "<script>" tag with the given contents.
Definition: Html.php:570
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
true
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 true
Definition: hooks.txt:1530
Skin\bottomScripts
bottomScripts()
This gets called shortly before the "</body>" tag.
Definition: Skin.php:672
Skin\mainPageLink
mainPageLink()
Gets the link to the wiki's main page.
Definition: Skin.php:973
Revision\getTimestampFromId
static getTimestampFromId( $title, $id)
Get rev_timestamp from rev_id, without loading the rest of the row.
Definition: Revision.php:1668
Skin\getSkinNames
static getSkinNames()
Fetch the set of available skins.
Definition: Skin.php:44
Skin\afterContentHook
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e....
Definition: Skin.php:637
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
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:154
Skin\getCommonStylePath
getCommonStylePath( $name)
Return a fully resolved style path url to images or styles stored in the common folder.
Definition: Skin.php:1068
SpecialPage\getSafeTitleFor
static getSafeTitleFor( $name, $subpage=false)
Get a localised Title object for a page name with a possibly unvalidated subpage.
Definition: SpecialPage.php:87
NS_MAIN
const NS_MAIN
Definition: Defines.php:79
Skin\getCachedNotice
getCachedNotice( $name)
Get a cached notice.
Definition: Skin.php:1493
IDBAccessObject\READ_NORMAL
const READ_NORMAL
Definition: IDBAccessObject.php:53
$lb
if( $wgAPIRequestLog) $lb
Definition: api.php:126
MWException
MediaWiki exception.
Definition: MWException.php:26
wfMemcKey
wfMemcKey()
Get a cache key.
Definition: GlobalFunctions.php:3580
$out
$out
Definition: UtfNormalGenerate.php:167
Skin\buildSidebar
buildSidebar()
Build an array that represents the sidebar(s), the navigation bar among them.
Definition: Skin.php:1248
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1127
Skin\privacyLink
privacyLink()
Gets the link to the wiki's privacy policy page.
Definition: Skin.php:1010
$titles
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Definition: linkcache.txt:17
Skin\getSkinNameMessages
static getSkinNameMessages()
Fetch the skinname messages for available skins.
Definition: Skin.php:92
Skin\normalizeKey
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.
Definition: Skin.php:136
Skin\footerLink
footerLink( $desc, $page)
Returns an HTML link for use in the footer.
Definition: Skin.php:988
Skin\generateDebugHTML
generateDebugHTML()
Generate debug data HTML for displaying at the bottom of the main content area.
Definition: Skin.php:663
Html\element
static element( $element, $attribs=array(), $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:148
Skin\getCategories
getCategories()
Definition: Skin.php:604
Skin\setRelevantUser
setRelevantUser( $u)
Set the "relevant" user.
Definition: Skin.php:356
ContextSource\getOutput
getOutput()
Get the OutputPage object.
Definition: ContextSource.php:122
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:30
$wgValidSkinNames
This technique is used by the more ambitious MediaWiki site to create complex custom skins for their wikis It should be preferred over editing the core Monobook skin directly See enabled via LocalSettings php This is done by adding it to $wgValidSkinNames
Definition: skin.txt:75
Skin\addToSidebar
addToSidebar(&$bar, $message)
Add content from a sidebar system message Currently only used for MediaWiki:Sidebar (but may be used ...
Definition: Skin.php:1283
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
$wgOut
$wgOut
Definition: Setup.php:562
$siteNotice
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 or change the value of $siteNotice and return false to alter it & $siteNotice
Definition: hooks.txt:2149
wfMessage
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4010
User\isIP
static isIP( $name)
Does the string match an anonymous IPv4 address?
Definition: User.php:555
Skin\isRevisionCurrent
isRevisionCurrent()
Whether the revision displayed is the latest revision of the page.
Definition: Skin.php:320
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
Skin\drawCategoryBrowser
drawCategoryBrowser( $tree)
Render the array as a series of links.
Definition: Skin.php:581
Skin\makeNSUrl
static makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN)
this can be passed the NS number as defined in Language.php
Definition: Skin.php:1173
$lines
$lines
Definition: router.php:65
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Skin\preloadExistence
preloadExistence()
Preload the existence of three commonly-requested pages in a single query.
Definition: Skin.php:286
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:93
Skin\disclaimerLink
disclaimerLink()
Gets the link to the wiki's general disclaimers page.
Definition: Skin.php:1026
Skin\getLogo
getLogo()
URL to the logo.
Definition: Skin.php:506
Skin\$skinname
$skinname
Definition: Skin.php:36
OutputPage
This class should be covered by a general architecture document which does not exist as of January 20...
Definition: OutputPage.php:38
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
Skin\outputPage
outputPage(OutputPage $out=null)
Outputs the HTML generated by other functions.
MessageCache\singleton
static singleton()
Get the signleton instance of this class.
Definition: MessageCache.php:101
Skin\$mRelevantTitle
$mRelevantTitle
Definition: Skin.php:37
Sanitizer\escapeId
static escapeId( $id, $options=array())
Given a value, escape it so that it can be used in an id attribute and return it.
Definition: Sanitizer.php:1099
$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
$section
$section
Definition: Utf8Test.php:88
wfUrlProtocols
wfUrlProtocols( $includeProtocolRelative=true)
Returns a regular expression of url protocols.
Definition: GlobalFunctions.php:695
$line
$line
Definition: cdb.php:57
Revision\newFromTitle
static newFromTitle( $title, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given title.
Definition: Revision.php:106
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
wfWikiID
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition: GlobalFunctions.php:3613
Skin\getRelevantTitle
getRelevantTitle()
Return the "relevant" title.
Definition: Skin.php:344
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
Skin\getSkinStylePath
getSkinStylePath( $name)
Return a fully resolved style path url to images or styles stored in the current skins's folder.
Definition: Skin.php:1080
Skin\getPageClasses
getPageClasses( $title)
TODO: document.
Definition: Skin.php:455
Skin\showIPinHeader
showIPinHeader()
Returns true if the IP should be shown in the header.
Definition: Skin.php:784
user
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 and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Definition: distributors.txt:9
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
$matches
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
Definition: NoLocalSettings.php:33
Skin\getDefaultModules
getDefaultModules()
Defines the ResourceLoader modules that should be added to the skin It is recommended that skins wish...
Definition: Skin.php:229
Skin\getUsableSkins
static getUsableSkins()
Definition: Skin.php:124
Skin\getSearchLink
getSearchLink()
Definition: Skin.php:792
Skin\printSource
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition: Skin.php:688
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
Skin\makeVariablesScript
static makeVariablesScript( $data)
Definition: Skin.php:398
$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
Skin\logoText
logoText( $align='')
Definition: Skin.php:928
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
$skin
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 $skin
Definition: hooks.txt:1530
Skin\getNewtalks
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition: Skin.php:1400
$args
if( $line===false) $args
Definition: cdb.php:62
Title
Represents a title within MediaWiki.
Definition: Title.php:35
Skin\makeUrl
static makeUrl( $name, $urlaction='')
Definition: Skin.php:1145
$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
Skin\__call
__call( $fname, $args)
Use PHP's magic __call handler to intercept legacy calls to the linker for backwards compatibility.
Definition: Skin.php:1644
wfMatchesDomainList
wfMatchesDomainList( $url, $domains)
Check whether a given URL has a domain that occurs in a given set of domains.
Definition: GlobalFunctions.php:902
Skin\commonPrintStylesheet
commonPrintStylesheet()
This function previously controlled whether the 'mediawiki.legacy.wikiprintable' module should be loa...
Definition: Skin.php:1390
Skin\escapeSearchLink
escapeSearchLink()
Definition: Skin.php:800
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
Skin\getCopyright
getCopyright( $type='detect')
Definition: Skin.php:808
Skin\getRelevantUser
getRelevantUser()
Return the "relevant" user.
Definition: Skin.php:368
NS_USER
const NS_USER
Definition: Defines.php:81
Skin\getUndeleteLink
getUndeleteLink()
Definition: Skin.php:702
Skin\makeKnownUrlDetails
static makeKnownUrlDetails( $name, $urlaction='')
Make URL details where the article exists (or at least it's convenient to think so)
Definition: Skin.php:1202
Skin\setupSkinUserCss
setupSkinUserCss(OutputPage $out)
Add skin specific stylesheets Calling this method with an $out of anything but the same OutputPage in...
Skin\makeMainPageUrl
static makeMainPageUrl( $urlaction='')
Definition: Skin.php:1091
from
Please log in again after you receive it</td >< td > s a saved copy from
Definition: All_system_messages.txt:3297
$t
$t
Definition: testCompression.php:65
Skin\getCopyrightIcon
getCopyrightIcon()
Definition: Skin.php:857
Sanitizer\decodeCharReferences
static decodeCharReferences( $text)
Decode any character references, numeric or named entities, in the text and return a UTF-8 string.
Definition: Sanitizer.php:1413
Skin\getSkinName
getSkinName()
Definition: Skin.php:208
Skin\getAllowedSkins
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
Definition: Skin.php:108
Skin
The main skin class which provides methods and properties for all other skins.
Definition: Skin.php:35
Html\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:124
Skin\initPage
initPage(OutputPage $out)
Definition: Skin.php:215
$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
Skin\setRelevantTitle
setRelevantTitle( $t)
Set the "relevant" title.
Definition: Skin.php:330
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:59
Skin\getRevisionId
getRevisionId()
Get the current revision ID.
Definition: Skin.php:311
Skin\addToSidebarPlain
addToSidebarPlain(&$bar, $text)
Add content from plain text.
Definition: Skin.php:1294
Skin\newFromKey
static & newFromKey( $key)
Factory method for loading a skin of a given type.
Definition: Skin.php:176
Skin\makeInternalOrExternalUrl
static makeInternalOrExternalUrl( $name)
If url string starts with http, consider as external URL, else internal.
Definition: Skin.php:1158
$newtalks
if the prop value should be in the metadata multi language array can modify can modify indexed by page_id indexed by prefixed DB keys can modify can modify can modify this should be populated with an alert message to that effect $newtalks
Definition: hooks.txt:1230
Skin\makeFooterIcon
makeFooterIcon( $icon, $withImage='withImage')
Renders a $wgFooterIcons icon according to the method's arguments.
Definition: Skin.php:951
$type
$type
Definition: testCompression.php:46
Skin\makeGlobalVariablesScript
static makeGlobalVariablesScript( $unused)
Make a "<script>" tag containing global variables.
Definition: Skin.php:415