MediaWiki REL1_28
Skin.php
Go to the documentation of this file.
1<?php
34abstract class Skin extends ContextSource {
35 protected $skinname = null;
36 protected $mRelevantTitle = null;
37 protected $mRelevantUser = null;
38
43 public $stylename = null;
44
49 static function getSkinNames() {
50 return SkinFactory::getDefaultInstance()->getSkinNames();
51 }
52
57 static function getSkinNameMessages() {
58 $messages = [];
59 foreach ( self::getSkinNames() as $skinKey => $skinName ) {
60 $messages[] = "skinname-$skinKey";
61 }
62 return $messages;
63 }
64
72 public static function getAllowedSkins() {
74
75 $allowedSkins = self::getSkinNames();
76
77 foreach ( $wgSkipSkins as $skip ) {
78 unset( $allowedSkins[$skip] );
79 }
80
81 return $allowedSkins;
82 }
83
93 static function normalizeKey( $key ) {
95
96 $skinNames = Skin::getSkinNames();
97
98 // Make keys lowercase for case-insensitive matching.
99 $skinNames = array_change_key_case( $skinNames, CASE_LOWER );
100 $key = strtolower( $key );
101 $defaultSkin = strtolower( $wgDefaultSkin );
102 $fallbackSkin = strtolower( $wgFallbackSkin );
103
104 if ( $key == '' || $key == 'default' ) {
105 // Don't return the default immediately;
106 // in a misconfiguration we need to fall back.
107 $key = $defaultSkin;
108 }
109
110 if ( isset( $skinNames[$key] ) ) {
111 return $key;
112 }
113
114 // Older versions of the software used a numeric setting
115 // in the user preferences.
116 $fallback = [
117 0 => $defaultSkin,
118 2 => 'cologneblue'
119 ];
120
121 if ( isset( $fallback[$key] ) ) {
122 $key = $fallback[$key];
123 }
124
125 if ( isset( $skinNames[$key] ) ) {
126 return $key;
127 } elseif ( isset( $skinNames[$defaultSkin] ) ) {
128 return $defaultSkin;
129 } else {
130 return $fallbackSkin;
131 }
132 }
133
137 public function getSkinName() {
138 return $this->skinname;
139 }
140
144 public function initPage( OutputPage $out ) {
145 $this->preloadExistence();
146 }
147
154 public function getDefaultModules() {
156
157 $out = $this->getOutput();
158 $user = $out->getUser();
159 $modules = [
160 // modules that enhance the page content in some way
161 'content' => [
162 'mediawiki.page.ready',
163 ],
164 // modules that exist for legacy reasons
166 // modules relating to search functionality
167 'search' => [],
168 // modules relating to functionality relating to watching an article
169 'watch' => [],
170 // modules which relate to the current users preferences
171 'user' => [],
172 ];
173
174 // Add various resources if required
175 if ( $wgUseAjax && $wgEnableAPI ) {
176 if ( $wgEnableWriteAPI && $user->isLoggedIn()
177 && $user->isAllowedAll( 'writeapi', 'viewmywatchlist', 'editmywatchlist' )
178 && $this->getRelevantTitle()->canExist()
179 ) {
180 $modules['watch'][] = 'mediawiki.page.watch.ajax';
181 }
182
183 $modules['search'][] = 'mediawiki.searchSuggest';
184 }
185
186 if ( $user->getBoolOption( 'editsectiononrightclick' ) ) {
187 $modules['user'][] = 'mediawiki.action.view.rightClickEdit';
188 }
189
190 // Crazy edit-on-double-click stuff
191 if ( $out->isArticle() && $user->getOption( 'editondblclick' ) ) {
192 $modules['user'][] = 'mediawiki.action.view.dblClickEdit';
193 }
194 return $modules;
195 }
196
200 protected function preloadExistence() {
201 $titles = [];
202
203 // User/talk link
204 $user = $this->getUser();
205 if ( $user->isLoggedIn() ) {
206 $titles[] = $user->getUserPage();
207 $titles[] = $user->getTalkPage();
208 }
209
210 // Check, if the page can hold some kind of content, otherwise do nothing
211 $title = $this->getRelevantTitle();
212 if ( $title->canExist() ) {
213 if ( $title->isTalkPage() ) {
214 $titles[] = $title->getSubjectPage();
215 } else {
216 $titles[] = $title->getTalkPage();
217 }
218 }
219
220 Hooks::run( 'SkinPreloadExistence', [ &$titles, $this ] );
221
222 if ( $titles ) {
223 $lb = new LinkBatch( $titles );
224 $lb->setCaller( __METHOD__ );
225 $lb->execute();
226 }
227 }
228
234 public function getRevisionId() {
235 return $this->getOutput()->getRevisionId();
236 }
237
243 public function isRevisionCurrent() {
244 $revID = $this->getRevisionId();
245 return $revID == 0 || $revID == $this->getTitle()->getLatestRevID();
246 }
247
253 public function setRelevantTitle( $t ) {
254 $this->mRelevantTitle = $t;
255 }
256
267 public function getRelevantTitle() {
268 if ( isset( $this->mRelevantTitle ) ) {
270 }
271 return $this->getTitle();
272 }
273
279 public function setRelevantUser( $u ) {
280 $this->mRelevantUser = $u;
281 }
282
291 public function getRelevantUser() {
292 if ( isset( $this->mRelevantUser ) ) {
294 }
295 $title = $this->getRelevantTitle();
296 if ( $title->hasSubjectNamespace( NS_USER ) ) {
297 $rootUser = $title->getRootText();
298 if ( User::isIP( $rootUser ) ) {
299 $this->mRelevantUser = User::newFromName( $rootUser, false );
300 } else {
301 $user = User::newFromName( $rootUser, false );
302
303 if ( $user ) {
304 $user->load( User::READ_NORMAL );
305
306 if ( $user->isLoggedIn() ) {
307 $this->mRelevantUser = $user;
308 }
309 }
310 }
312 }
313 return null;
314 }
315
320 abstract function outputPage( OutputPage $out = null );
321
326 static function makeVariablesScript( $data ) {
327 if ( $data ) {
330 );
331 } else {
332 return '';
333 }
334 }
335
341 public static function getDynamicStylesheetQuery() {
343
344 return [
345 'action' => 'raw',
346 'maxage' => $wgSquidMaxage,
347 'usemsgcache' => 'yes',
348 'ctype' => 'text/css',
349 'smaxage' => $wgSquidMaxage,
350 ];
351 }
352
361 abstract function setupSkinUserCss( OutputPage $out );
362
368 function getPageClasses( $title ) {
369 $numeric = 'ns-' . $title->getNamespace();
370
371 if ( $title->isSpecialPage() ) {
372 $type = 'ns-special';
373 // bug 23315: provide a class based on the canonical special page name without subpages
374 list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
375 if ( $canonicalName ) {
376 $type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
377 } else {
378 $type .= ' mw-invalidspecialpage';
379 }
380 } elseif ( $title->isTalkPage() ) {
381 $type = 'ns-talk';
382 } else {
383 $type = 'ns-subject';
384 }
385
386 $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
387 $root = Sanitizer::escapeClass( 'rootpage-' . $title->getRootTitle()->getPrefixedText() );
388
389 return "$numeric $type $name $root";
390 }
391
396 public function getHtmlElementAttributes() {
397 $lang = $this->getLanguage();
398 return [
399 'lang' => $lang->getHtmlCode(),
400 'dir' => $lang->getDir(),
401 'class' => 'client-nojs',
402 ];
403 }
404
412 function addToBodyAttributes( $out, &$bodyAttrs ) {
413 // does nothing by default
414 }
415
420 function getLogo() {
422 return $wgLogo;
423 }
424
428 function getCategoryLinks() {
430
431 $out = $this->getOutput();
432 $allCats = $out->getCategoryLinks();
433
434 if ( !count( $allCats ) ) {
435 return '';
436 }
437
438 $embed = "<li>";
439 $pop = "</li>";
440
441 $s = '';
442 $colon = $this->msg( 'colon-separator' )->escaped();
443
444 if ( !empty( $allCats['normal'] ) ) {
445 $t = $embed . implode( "{$pop}{$embed}", $allCats['normal'] ) . $pop;
446
447 $msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
448 $linkPage = wfMessage( 'pagecategorieslink' )->inContentLanguage()->text();
449 $title = Title::newFromText( $linkPage );
450 $link = $title ? Linker::link( $title, $msg ) : $msg;
451 $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
452 $link . $colon . '<ul>' . $t . '</ul>' . '</div>';
453 }
454
455 # Hidden categories
456 if ( isset( $allCats['hidden'] ) ) {
457 if ( $this->getUser()->getBoolOption( 'showhiddencats' ) ) {
458 $class = ' mw-hidden-cats-user-shown';
459 } elseif ( $this->getTitle()->getNamespace() == NS_CATEGORY ) {
460 $class = ' mw-hidden-cats-ns-shown';
461 } else {
462 $class = ' mw-hidden-cats-hidden';
463 }
464
465 $s .= "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks$class\">" .
466 $this->msg( 'hidden-categories' )->numParams( count( $allCats['hidden'] ) )->escaped() .
467 $colon . '<ul>' . $embed . implode( "{$pop}{$embed}", $allCats['hidden'] ) . $pop . '</ul>' .
468 '</div>';
469 }
470
471 # optional 'dmoz-like' category browser. Will be shown under the list
472 # of categories an article belong to
473 if ( $wgUseCategoryBrowser ) {
474 $s .= '<br /><hr />';
475
476 # get a big array of the parents tree
477 $parenttree = $this->getTitle()->getParentCategoryTree();
478 # Skin object passed by reference cause it can not be
479 # accessed under the method subfunction drawCategoryBrowser
480 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree ) );
481 # Clean out bogus first entry and sort them
482 unset( $tempout[0] );
483 asort( $tempout );
484 # Output one per line
485 $s .= implode( "<br />\n", $tempout );
486 }
487
488 return $s;
489 }
490
496 function drawCategoryBrowser( $tree ) {
497 $return = '';
498
499 foreach ( $tree as $element => $parent ) {
500 if ( empty( $parent ) ) {
501 # element start a new list
502 $return .= "\n";
503 } else {
504 # grab the others elements
505 $return .= $this->drawCategoryBrowser( $parent ) . ' &gt; ';
506 }
507
508 # add our current element to the list
509 $eltitle = Title::newFromText( $element );
510 $return .= Linker::link( $eltitle, htmlspecialchars( $eltitle->getText() ) );
511 }
512
513 return $return;
514 }
515
519 function getCategories() {
520 $out = $this->getOutput();
521 $catlinks = $this->getCategoryLinks();
522
523 // Check what we're showing
524 $allCats = $out->getCategoryLinks();
525 $showHidden = $this->getUser()->getBoolOption( 'showhiddencats' ) ||
526 $this->getTitle()->getNamespace() == NS_CATEGORY;
527
528 $classes = [ 'catlinks' ];
529 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
530 $classes[] = 'catlinks-allhidden';
531 }
532
533 return Html::rawElement(
534 'div',
535 [ 'id' => 'catlinks', 'class' => $classes, 'data-mw' => 'interface' ],
536 $catlinks
537 );
538 }
539
554 protected function afterContentHook() {
555 $data = '';
556
557 if ( Hooks::run( 'SkinAfterContent', [ &$data, $this ] ) ) {
558 // adding just some spaces shouldn't toggle the output
559 // of the whole <div/>, so we use trim() here
560 if ( trim( $data ) != '' ) {
561 // Doing this here instead of in the skins to
562 // ensure that the div has the same ID in all
563 // skins
564 $data = "<div id='mw-data-after-content'>\n" .
565 "\t$data\n" .
566 "</div>\n";
567 }
568 } else {
569 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
570 }
571
572 return $data;
573 }
574
580 protected function generateDebugHTML() {
581 return MWDebug::getHTMLDebugLog();
582 }
583
589 function bottomScripts() {
590 // TODO and the suckage continues. This function is really just a wrapper around
591 // OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
592 // up at some point
593 $bottomScriptText = $this->getOutput()->getBottomScripts();
594 Hooks::run( 'SkinAfterBottomScripts', [ $this, &$bottomScriptText ] );
595
596 return $bottomScriptText;
597 }
598
605 function printSource() {
606 $oldid = $this->getRevisionId();
607 if ( $oldid ) {
608 $canonicalUrl = $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid );
609 $url = htmlspecialchars( wfExpandIRI( $canonicalUrl ) );
610 } else {
611 // oldid not available for non existing pages
612 $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL() ) );
613 }
614
615 return $this->msg( 'retrievedfrom' )
616 ->rawParams( '<a dir="ltr" href="' . $url . '">' . $url . '</a>' )
617 ->parse();
618 }
619
623 function getUndeleteLink() {
624 $action = $this->getRequest()->getVal( 'action', 'view' );
625
626 if ( $this->getTitle()->userCan( 'deletedhistory', $this->getUser() ) &&
627 ( !$this->getTitle()->exists() || $action == 'history' ) ) {
628 $n = $this->getTitle()->isDeleted();
629
630 if ( $n ) {
631 if ( $this->getTitle()->quickUserCan( 'undelete', $this->getUser() ) ) {
632 $msg = 'thisisdeleted';
633 } else {
634 $msg = 'viewdeleted';
635 }
636
637 return $this->msg( $msg )->rawParams(
639 SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
640 $this->msg( 'restorelink' )->numParams( $n )->escaped() )
641 )->escaped();
642 }
643 }
644
645 return '';
646 }
647
652 function subPageSubtitle( $out = null ) {
653 if ( $out === null ) {
654 $out = $this->getOutput();
655 }
656 $title = $out->getTitle();
657 $subpages = '';
658
659 if ( !Hooks::run( 'SkinSubPageSubtitle', [ &$subpages, $this, $out ] ) ) {
660 return $subpages;
661 }
662
663 if ( $out->isArticle() && MWNamespace::hasSubpages( $title->getNamespace() ) ) {
664 $ptext = $title->getPrefixedText();
665 if ( strpos( $ptext, '/' ) !== false ) {
666 $links = explode( '/', $ptext );
667 array_pop( $links );
668 $c = 0;
669 $growinglink = '';
670 $display = '';
671 $lang = $this->getLanguage();
672
673 foreach ( $links as $link ) {
674 $growinglink .= $link;
675 $display .= $link;
676 $linkObj = Title::newFromText( $growinglink );
677
678 if ( is_object( $linkObj ) && $linkObj->isKnown() ) {
679 $getlink = Linker::linkKnown(
680 $linkObj,
681 htmlspecialchars( $display )
682 );
683
684 $c++;
685
686 if ( $c > 1 ) {
687 $subpages .= $lang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
688 } else {
689 $subpages .= '&lt; ';
690 }
691
692 $subpages .= $getlink;
693 $display = '';
694 } else {
695 $display .= '/';
696 }
697 $growinglink .= '/';
698 }
699 }
700 }
701
702 return $subpages;
703 }
704
709 function showIPinHeader() {
710 wfDeprecated( __METHOD__, '1.27' );
711 return false;
712 }
713
717 function getSearchLink() {
719 return $searchPage->getLocalURL();
720 }
721
725 function escapeSearchLink() {
726 return htmlspecialchars( $this->getSearchLink() );
727 }
728
733 function getCopyright( $type = 'detect' ) {
735
736 if ( $type == 'detect' ) {
737 if ( !$this->isRevisionCurrent()
738 && !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled()
739 ) {
740 $type = 'history';
741 } else {
742 $type = 'normal';
743 }
744 }
745
746 if ( $type == 'history' ) {
747 $msg = 'history_copyright';
748 } else {
749 $msg = 'copyright';
750 }
751
752 if ( $wgRightsPage ) {
753 $title = Title::newFromText( $wgRightsPage );
755 } elseif ( $wgRightsUrl ) {
757 } elseif ( $wgRightsText ) {
759 } else {
760 # Give up now
761 return '';
762 }
763
764 // Allow for site and per-namespace customization of copyright notice.
765 // @todo Remove deprecated $forContent param from hook handlers and then remove here.
766 $forContent = true;
767
768 Hooks::run(
769 'SkinCopyrightFooter',
770 [ $this->getTitle(), $type, &$msg, &$link, &$forContent ]
771 );
772
773 return $this->msg( $msg )->rawParams( $link )->text();
774 }
775
779 function getCopyrightIcon() {
781
782 $out = '';
783
784 if ( $wgFooterIcons['copyright']['copyright'] ) {
785 $out = $wgFooterIcons['copyright']['copyright'];
786 } elseif ( $wgRightsIcon ) {
787 $icon = htmlspecialchars( $wgRightsIcon );
788
789 if ( $wgRightsUrl ) {
790 $url = htmlspecialchars( $wgRightsUrl );
791 $out .= '<a href="' . $url . '">';
792 }
793
794 $text = htmlspecialchars( $wgRightsText );
795 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
796
797 if ( $wgRightsUrl ) {
798 $out .= '</a>';
799 }
800 }
801
802 return $out;
803 }
804
809 function getPoweredBy() {
811
812 $url1 = htmlspecialchars(
813 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png"
814 );
815 $url1_5 = htmlspecialchars(
816 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png"
817 );
818 $url2 = htmlspecialchars(
819 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png"
820 );
821 $text = '<a href="//www.mediawiki.org/"><img src="' . $url1
822 . '" srcset="' . $url1_5 . ' 1.5x, ' . $url2 . ' 2x" '
823 . 'height="31" width="88" alt="Powered by MediaWiki" /></a>';
824 Hooks::run( 'SkinGetPoweredBy', [ &$text, $this ] );
825 return $text;
826 }
827
833 protected function lastModified() {
834 $timestamp = $this->getOutput()->getRevisionTimestamp();
835
836 # No cached timestamp, load it from the database
837 if ( $timestamp === null ) {
839 }
840
841 if ( $timestamp ) {
842 $d = $this->getLanguage()->userDate( $timestamp, $this->getUser() );
843 $t = $this->getLanguage()->userTime( $timestamp, $this->getUser() );
844 $s = ' ' . $this->msg( 'lastmodifiedat', $d, $t )->parse();
845 } else {
846 $s = '';
847 }
848
849 if ( wfGetLB()->getLaggedReplicaMode() ) {
850 $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->parse() . '</strong>';
851 }
852
853 return $s;
854 }
855
860 function logoText( $align = '' ) {
861 if ( $align != '' ) {
862 $a = " style='float: {$align};'";
863 } else {
864 $a = '';
865 }
866
867 $mp = $this->msg( 'mainpage' )->escaped();
868 $mptitle = Title::newMainPage();
869 $url = ( is_object( $mptitle ) ? htmlspecialchars( $mptitle->getLocalURL() ) : '' );
870
871 $logourl = $this->getLogo();
872 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
873
874 return $s;
875 }
876
885 function makeFooterIcon( $icon, $withImage = 'withImage' ) {
886 if ( is_string( $icon ) ) {
887 $html = $icon;
888 } else { // Assuming array
889 $url = isset( $icon["url"] ) ? $icon["url"] : null;
890 unset( $icon["url"] );
891 if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
892 // do this the lazy way, just pass icon data as an attribute array
893 $html = Html::element( 'img', $icon );
894 } else {
895 $html = htmlspecialchars( $icon["alt"] );
896 }
897 if ( $url ) {
898 $html = Html::rawElement( 'a', [ "href" => $url ], $html );
899 }
900 }
901 return $html;
902 }
903
908 function mainPageLink() {
910 Title::newMainPage(),
911 $this->msg( 'mainpage' )->escaped()
912 );
913
914 return $s;
915 }
916
923 public function footerLink( $desc, $page ) {
924 // if the link description has been set to "-" in the default language,
925 if ( $this->msg( $desc )->inContentLanguage()->isDisabled() ) {
926 // then it is disabled, for all languages.
927 return '';
928 } else {
929 // Otherwise, we display the link for the user, described in their
930 // language (which may or may not be the same as the default language),
931 // but we make the link target be the one site-wide page.
932 $title = Title::newFromText( $this->msg( $page )->inContentLanguage()->text() );
933
934 if ( !$title ) {
935 return '';
936 }
937
938 return Linker::linkKnown(
939 $title,
940 $this->msg( $desc )->escaped()
941 );
942 }
943 }
944
949 function privacyLink() {
950 return $this->footerLink( 'privacy', 'privacypage' );
951 }
952
957 function aboutLink() {
958 return $this->footerLink( 'aboutsite', 'aboutpage' );
959 }
960
965 function disclaimerLink() {
966 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
967 }
968
976 function editUrlOptions() {
977 $options = [ 'action' => 'edit' ];
978
979 if ( !$this->isRevisionCurrent() ) {
980 $options['oldid'] = intval( $this->getRevisionId() );
981 }
982
983 return $options;
984 }
985
990 function showEmailUser( $id ) {
991 if ( $id instanceof User ) {
992 $targetUser = $id;
993 } else {
994 $targetUser = User::newFromId( $id );
995 }
996
997 # The sending user must have a confirmed email address and the target
998 # user must have a confirmed email address and allow emails from users.
999 return $this->getUser()->canSendEmail() &&
1000 $targetUser->canReceiveEmail();
1001 }
1002
1014 function getSkinStylePath( $name ) {
1016
1017 if ( $this->stylename === null ) {
1018 $class = get_class( $this );
1019 throw new MWException( "$class::\$stylename must be set to use getSkinStylePath()" );
1020 }
1021
1022 return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
1023 }
1024
1025 /* these are used extensively in SkinTemplate, but also some other places */
1026
1031 static function makeMainPageUrl( $urlaction = '' ) {
1032 $title = Title::newMainPage();
1033 self::checkTitle( $title, '' );
1034
1035 return $title->getLocalURL( $urlaction );
1036 }
1037
1049 static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
1051 if ( is_null( $proto ) ) {
1052 return $title->getLocalURL( $urlaction );
1053 } else {
1054 return $title->getFullURL( $urlaction, false, $proto );
1055 }
1056 }
1057
1064 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1066 return $title->getLocalURL( $urlaction );
1067 }
1068
1074 static function makeI18nUrl( $name, $urlaction = '' ) {
1075 $title = Title::newFromText( wfMessage( $name )->inContentLanguage()->text() );
1077 return $title->getLocalURL( $urlaction );
1078 }
1079
1085 static function makeUrl( $name, $urlaction = '' ) {
1086 $title = Title::newFromText( $name );
1088
1089 return $title->getLocalURL( $urlaction );
1090 }
1091
1098 static function makeInternalOrExternalUrl( $name ) {
1099 if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $name ) ) {
1100 return $name;
1101 } else {
1102 return self::makeUrl( $name );
1103 }
1104 }
1105
1113 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
1114 $title = Title::makeTitleSafe( $namespace, $name );
1116
1117 return $title->getLocalURL( $urlaction );
1118 }
1119
1126 static function makeUrlDetails( $name, $urlaction = '' ) {
1127 $title = Title::newFromText( $name );
1129
1130 return [
1131 'href' => $title->getLocalURL( $urlaction ),
1132 'exists' => $title->isKnown(),
1133 ];
1134 }
1135
1142 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1143 $title = Title::newFromText( $name );
1145
1146 return [
1147 'href' => $title->getLocalURL( $urlaction ),
1148 'exists' => true
1149 ];
1150 }
1151
1158 static function checkTitle( &$title, $name ) {
1159 if ( !is_object( $title ) ) {
1160 $title = Title::newFromText( $name );
1161 if ( !is_object( $title ) ) {
1162 $title = Title::newFromText( '--error: link target missing--' );
1163 }
1164 }
1165 }
1166
1188 function buildSidebar() {
1190
1191 $that = $this;
1192 $callback = function () use ( $that ) {
1193 $bar = [];
1194 $that->addToSidebar( $bar, 'sidebar' );
1195 Hooks::run( 'SkinBuildSidebar', [ $that, &$bar ] );
1196
1197 return $bar;
1198 };
1199
1200 if ( $wgEnableSidebarCache ) {
1201 $cache = ObjectCache::getMainWANInstance();
1202 $sidebar = $cache->getWithSetCallback(
1203 $cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
1204 MessageCache::singleton()->isDisabled()
1205 ? $cache::TTL_UNCACHEABLE // bug T133069
1207 $callback,
1208 [ 'lockTSE' => 30 ]
1209 );
1210 } else {
1211 $sidebar = $callback();
1212 }
1213
1214 // Apply post-processing to the cached value
1215 Hooks::run( 'SidebarBeforeOutput', [ $this, &$sidebar ] );
1216
1217 return $sidebar;
1218 }
1219
1229 public function addToSidebar( &$bar, $message ) {
1230 $this->addToSidebarPlain( $bar, wfMessage( $message )->inContentLanguage()->plain() );
1231 }
1232
1240 function addToSidebarPlain( &$bar, $text ) {
1241 $lines = explode( "\n", $text );
1242
1243 $heading = '';
1244 $messageTitle = $this->getConfig()->get( 'EnableSidebarCache' )
1245 ? Title::newMainPage() : $this->getTitle();
1246
1247 foreach ( $lines as $line ) {
1248 if ( strpos( $line, '*' ) !== 0 ) {
1249 continue;
1250 }
1251 $line = rtrim( $line, "\r" ); // for Windows compat
1252
1253 if ( strpos( $line, '**' ) !== 0 ) {
1254 $heading = trim( $line, '* ' );
1255 if ( !array_key_exists( $heading, $bar ) ) {
1256 $bar[$heading] = [];
1257 }
1258 } else {
1259 $line = trim( $line, '* ' );
1260
1261 if ( strpos( $line, '|' ) !== false ) { // sanity check
1262 $line = MessageCache::singleton()->transform( $line, false, null, $messageTitle );
1263 $line = array_map( 'trim', explode( '|', $line, 2 ) );
1264 if ( count( $line ) !== 2 ) {
1265 // Second sanity check, could be hit by people doing
1266 // funky stuff with parserfuncs... (bug 33321)
1267 continue;
1268 }
1269
1270 $extraAttribs = [];
1271
1272 $msgLink = $this->msg( $line[0] )->title( $messageTitle )->inContentLanguage();
1273 if ( $msgLink->exists() ) {
1274 $link = $msgLink->text();
1275 if ( $link == '-' ) {
1276 continue;
1277 }
1278 } else {
1279 $link = $line[0];
1280 }
1281 $msgText = $this->msg( $line[1] )->title( $messageTitle );
1282 if ( $msgText->exists() ) {
1283 $text = $msgText->text();
1284 } else {
1285 $text = $line[1];
1286 }
1287
1288 if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $link ) ) {
1289 $href = $link;
1290
1291 // Parser::getExternalLinkAttribs won't work here because of the Namespace things
1294 $extraAttribs['rel'] = 'nofollow';
1295 }
1296
1298 if ( $wgExternalLinkTarget ) {
1299 $extraAttribs['target'] = $wgExternalLinkTarget;
1300 }
1301 } else {
1302 $title = Title::newFromText( $link );
1303
1304 if ( $title ) {
1305 $title = $title->fixSpecialName();
1306 $href = $title->getLinkURL();
1307 } else {
1308 $href = 'INVALID-TITLE';
1309 }
1310 }
1311
1312 $bar[$heading][] = array_merge( [
1313 'text' => $text,
1314 'href' => $href,
1315 'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
1316 'active' => false
1317 ], $extraAttribs );
1318 } else {
1319 continue;
1320 }
1321 }
1322 }
1323
1324 return $bar;
1325 }
1326
1332 function getNewtalks() {
1333
1334 $newMessagesAlert = '';
1335 $user = $this->getUser();
1336 $newtalks = $user->getNewMessageLinks();
1337 $out = $this->getOutput();
1338
1339 // Allow extensions to disable or modify the new messages alert
1340 if ( !Hooks::run( 'GetNewMessagesAlert', [ &$newMessagesAlert, $newtalks, $user, $out ] ) ) {
1341 return '';
1342 }
1343 if ( $newMessagesAlert ) {
1344 return $newMessagesAlert;
1345 }
1346
1347 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
1348 $uTalkTitle = $user->getTalkPage();
1349 $lastSeenRev = isset( $newtalks[0]['rev'] ) ? $newtalks[0]['rev'] : null;
1350 $nofAuthors = 0;
1351 if ( $lastSeenRev !== null ) {
1352 $plural = true; // Default if we have a last seen revision: if unknown, use plural
1353 $latestRev = Revision::newFromTitle( $uTalkTitle, false, Revision::READ_NORMAL );
1354 if ( $latestRev !== null ) {
1355 // Singular if only 1 unseen revision, plural if several unseen revisions.
1356 $plural = $latestRev->getParentId() !== $lastSeenRev->getId();
1357 $nofAuthors = $uTalkTitle->countAuthorsBetween(
1358 $lastSeenRev, $latestRev, 10, 'include_new' );
1359 }
1360 } else {
1361 // Singular if no revision -> diff link will show latest change only in any case
1362 $plural = false;
1363 }
1364 $plural = $plural ? 999 : 1;
1365 // 999 signifies "more than one revision". We don't know how many, and even if we did,
1366 // the number of revisions or authors is not necessarily the same as the number of
1367 // "messages".
1368 $newMessagesLink = Linker::linkKnown(
1369 $uTalkTitle,
1370 $this->msg( 'newmessageslinkplural' )->params( $plural )->escaped(),
1371 [],
1372 [ 'redirect' => 'no' ]
1373 );
1374
1375 $newMessagesDiffLink = Linker::linkKnown(
1376 $uTalkTitle,
1377 $this->msg( 'newmessagesdifflinkplural' )->params( $plural )->escaped(),
1378 [],
1379 $lastSeenRev !== null
1380 ? [ 'oldid' => $lastSeenRev->getId(), 'diff' => 'cur' ]
1381 : [ 'diff' => 'cur' ]
1382 );
1383
1384 if ( $nofAuthors >= 1 && $nofAuthors <= 10 ) {
1385 $newMessagesAlert = $this->msg(
1386 'youhavenewmessagesfromusers',
1387 $newMessagesLink,
1388 $newMessagesDiffLink
1389 )->numParams( $nofAuthors, $plural );
1390 } else {
1391 // $nofAuthors === 11 signifies "11 or more" ("more than 10")
1392 $newMessagesAlert = $this->msg(
1393 $nofAuthors > 10 ? 'youhavenewmessagesmanyusers' : 'youhavenewmessages',
1394 $newMessagesLink,
1395 $newMessagesDiffLink
1396 )->numParams( $plural );
1397 }
1398 $newMessagesAlert = $newMessagesAlert->text();
1399 # Disable CDN cache
1400 $out->setCdnMaxage( 0 );
1401 } elseif ( count( $newtalks ) ) {
1402 $sep = $this->msg( 'newtalkseparator' )->escaped();
1403 $msgs = [];
1404
1405 foreach ( $newtalks as $newtalk ) {
1406 $msgs[] = Xml::element(
1407 'a',
1408 [ 'href' => $newtalk['link'] ], $newtalk['wiki']
1409 );
1410 }
1411 $parts = implode( $sep, $msgs );
1412 $newMessagesAlert = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped();
1413 $out->setCdnMaxage( 0 );
1414 }
1415
1416 return $newMessagesAlert;
1417 }
1418
1426 private function getCachedNotice( $name ) {
1428
1429 $needParse = false;
1430
1431 if ( $name === 'default' ) {
1432 // special case
1434 $notice = $wgSiteNotice;
1435 if ( empty( $notice ) ) {
1436 return false;
1437 }
1438 } else {
1439 $msg = $this->msg( $name )->inContentLanguage();
1440 if ( $msg->isBlank() ) {
1441 return '';
1442 } elseif ( $msg->isDisabled() ) {
1443 return false;
1444 }
1445 $notice = $msg->plain();
1446 }
1447
1448 // Use the extra hash appender to let eg SSL variants separately cache.
1450 $cachedNotice = $parserMemc->get( $key );
1451 if ( is_array( $cachedNotice ) ) {
1452 if ( md5( $notice ) == $cachedNotice['hash'] ) {
1453 $notice = $cachedNotice['html'];
1454 } else {
1455 $needParse = true;
1456 }
1457 } else {
1458 $needParse = true;
1459 }
1460
1461 if ( $needParse ) {
1462 $parsed = $this->getOutput()->parse( $notice );
1463 $parserMemc->set( $key, [ 'html' => $parsed, 'hash' => md5( $notice ) ], 600 );
1464 $notice = $parsed;
1465 }
1466
1467 $notice = Html::rawElement( 'div', [ 'id' => 'localNotice',
1468 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ], $notice );
1469 return $notice;
1470 }
1471
1477 function getSiteNotice() {
1478 $siteNotice = '';
1479
1480 if ( Hooks::run( 'SiteNoticeBefore', [ &$siteNotice, $this ] ) ) {
1481 if ( is_object( $this->getUser() ) && $this->getUser()->isLoggedIn() ) {
1482 $siteNotice = $this->getCachedNotice( 'sitenotice' );
1483 } else {
1484 $anonNotice = $this->getCachedNotice( 'anonnotice' );
1485 if ( $anonNotice === false ) {
1486 $siteNotice = $this->getCachedNotice( 'sitenotice' );
1487 } else {
1488 $siteNotice = $anonNotice;
1489 }
1490 }
1491 if ( $siteNotice === false ) {
1492 $siteNotice = $this->getCachedNotice( 'default' );
1493 }
1494 }
1495
1496 Hooks::run( 'SiteNoticeAfter', [ &$siteNotice, $this ] );
1497 return $siteNotice;
1498 }
1499
1513 public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
1514 // HTML generated here should probably have userlangattributes
1515 // added to it for LTR text on RTL pages
1516
1518
1519 $attribs = [];
1520 if ( !is_null( $tooltip ) ) {
1521 # Bug 25462: undo double-escaping.
1522 $tooltip = Sanitizer::decodeCharReferences( $tooltip );
1523 $attribs['title'] = wfMessage( 'editsectionhint' )->rawParams( $tooltip )
1524 ->inLanguage( $lang )->text();
1525 }
1526
1527 $links = [
1528 'editsection' => [
1529 'text' => wfMessage( 'editsection' )->inLanguage( $lang )->escaped(),
1530 'targetTitle' => $nt,
1531 'attribs' => $attribs,
1532 'query' => [ 'action' => 'edit', 'section' => $section ],
1533 'options' => [ 'noclasses', 'known' ]
1534 ]
1535 ];
1536
1537 Hooks::run( 'SkinEditSectionLinks', [ $this, $nt, $section, $tooltip, &$links, $lang ] );
1538
1539 $result = '<span class="mw-editsection"><span class="mw-editsection-bracket">[</span>';
1540
1541 $linksHtml = [];
1542 foreach ( $links as $k => $linkDetails ) {
1543 $linksHtml[] = Linker::link(
1544 $linkDetails['targetTitle'],
1545 $linkDetails['text'],
1546 $linkDetails['attribs'],
1547 $linkDetails['query'],
1548 $linkDetails['options']
1549 );
1550 }
1551
1552 $result .= implode(
1553 '<span class="mw-editsection-divider">'
1554 . wfMessage( 'pipe-separator' )->inLanguage( $lang )->text()
1555 . '</span>',
1556 $linksHtml
1557 );
1558
1559 $result .= '<span class="mw-editsection-bracket">]</span></span>';
1560 // Deprecated, use SkinEditSectionLinks hook instead
1561 Hooks::run(
1562 'DoEditSectionLink',
1563 [ $this, $nt, $section, $tooltip, &$result, $lang ],
1564 '1.25'
1565 );
1566 return $result;
1567 }
1568
1569}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgRightsIcon
Override for copyright metadata.
$wgRightsUrl
Set this to specify an external URL containing details about the content license used on your wiki.
$wgRenderHashAppend
Append a configured value to the parser cache and the sitenotice key so that they can be kept separat...
$wgStyleVersion
Bump this number when changing the global style sheets and JavaScript.
$wgUseAjax
Enable AJAX framework.
$wgFallbackSkin
Fallback skin used when the skin defined by $wgDefaultSkin can't be found.
$wgNoFollowLinks
If true, external URL links in wiki text will be given the rel="nofollow" attribute as a hint to sear...
$wgSiteNotice
Site notice shown at the top of each page.
$wgRightsText
If either $wgRightsUrl or $wgRightsPage is specified then this variable gives the text for the link.
$wgEnableWriteAPI
Allow the API to be used to perform write operations (page edits, rollback, etc.) when an authorised ...
$wgResourceBasePath
The default 'remoteBasePath' value for instances of ResourceLoaderFileModule.
$wgSidebarCacheExpiry
Expiry time for the sidebar cache, in seconds.
$wgFooterIcons
Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code You can ad...
$wgEnableSidebarCache
If on, the sidebar navigation links are cached for users with the current language set.
$wgNoFollowDomainExceptions
If this is set to an array of domains, external links to these domain names (or any subdomains) will ...
$wgSkipSkins
Specify the names of skins that should not be presented in the list of available skins in user prefer...
$wgDefaultSkin
Default skin, for new users and anonymous visitors.
$wgSquidMaxage
Cache TTL for the CDN sent as s-maxage (without ESI) or Surrogate-Control (with ESI).
$wgUseCategoryBrowser
Use experimental, DMOZ-like category browser.
$wgExternalLinkTarget
Set a default target for external links, e.g.
$wgEnableAPI
Enable the MediaWiki API for convenient access to machine-readable data via api.php.
$wgStylePath
The URL path of the skins directory.
$wgLogo
The URL path of the wiki logo.
$wgRightsPage
Override for copyright metadata.
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetLB( $wiki=false)
Get a load balancer object.
wfExpandIRI( $url)
Take a URL, make sure it's expanded to fully qualified, and replace any encoded non-ASCII Unicode cha...
wfMemcKey()
Make a cache key for the local wiki.
wfUrlProtocols( $includeProtocolRelative=true)
Returns a regular expression of url protocols.
wfMatchesDomainList( $url, $domains)
Check whether a given URL has a domain that occurs in a given set of domains.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
$messages
$fallback
$line
Definition cdb.php:59
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
getUser()
Get the User object.
getRequest()
Get the WebRequest object.
getConfig()
Get the Config object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getTitle()
Get the Title object.
getOutput()
Get the OutputPage object.
getLanguage()
Get the Language object.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:32
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition Linker.php:203
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition Linker.php:255
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
Definition Linker.php:934
MediaWiki exception.
static singleton()
Get the signleton instance of this class.
This class should be covered by a general architecture document which does not exist as of January 20...
static makeConfigSetScript(array $configuration)
Returns JS code which will set the MediaWiki configuration array to the given value.
static makeInlineScript( $script)
Construct an inline script tag with given JS code.
static getTimestampFromId( $title, $id, $flags=0)
Get rev_timestamp from rev_id, without loading the rest of the row.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
Definition Revision.php:128
The main skin class which provides methods and properties for all other skins.
Definition Skin.php:34
aboutLink()
Gets the link to the wiki's about page.
Definition Skin.php:957
isRevisionCurrent()
Whether the revision displayed is the latest revision of the page.
Definition Skin.php:243
static makeInternalOrExternalUrl( $name)
If url string starts with http, consider as external URL, else internal.
Definition Skin.php:1098
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e....
Definition Skin.php:554
string $stylename
Stylesheets set to use.
Definition Skin.php:43
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition Skin.php:1332
mainPageLink()
Gets the link to the wiki's main page.
Definition Skin.php:908
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
Definition Skin.php:72
getSkinStylePath( $name)
Return a fully resolved style path url to images or styles stored in the current skins's folder.
Definition Skin.php:1014
getCachedNotice( $name)
Get a cached notice.
Definition Skin.php:1426
static makeMainPageUrl( $urlaction='')
Definition Skin.php:1031
static makeKnownUrlDetails( $name, $urlaction='')
Make URL details where the article exists (or at least it's convenient to think so)
Definition Skin.php:1142
generateDebugHTML()
Generate debug data HTML for displaying at the bottom of the main content area.
Definition Skin.php:580
getCopyrightIcon()
Definition Skin.php:779
privacyLink()
Gets the link to the wiki's privacy policy page.
Definition Skin.php:949
getSiteNotice()
Get the site notice.
Definition Skin.php:1477
getHtmlElementAttributes()
Return values for <html> element.
Definition Skin.php:396
static getSkinNames()
Fetch the set of available skins.
Definition Skin.php:49
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.
Definition Skin.php:93
getSkinName()
Definition Skin.php:137
getUndeleteLink()
Definition Skin.php:623
getPoweredBy()
Gets the powered by MediaWiki icon.
Definition Skin.php:809
getCategoryLinks()
Definition Skin.php:428
escapeSearchLink()
Definition Skin.php:725
static makeUrlDetails( $name, $urlaction='')
these return an array with the 'href' and boolean 'exists'
Definition Skin.php:1126
getLogo()
URL to the logo.
Definition Skin.php:420
$mRelevantTitle
Definition Skin.php:36
addToSidebar(&$bar, $message)
Add content from a sidebar system message Currently only used for MediaWiki:Sidebar (but may be used ...
Definition Skin.php:1229
static makeSpecialUrlSubpage( $name, $subpage, $urlaction='')
Definition Skin.php:1064
getRelevantUser()
Return the "relevant" user.
Definition Skin.php:291
setRelevantTitle( $t)
Set the "relevant" title.
Definition Skin.php:253
logoText( $align='')
Definition Skin.php:860
addToBodyAttributes( $out, &$bodyAttrs)
This will be called by OutputPage::headElement when it is creating the "<body>" tag,...
Definition Skin.php:412
$mRelevantUser
Definition Skin.php:37
drawCategoryBrowser( $tree)
Render the array as a series of links.
Definition Skin.php:496
$skinname
Definition Skin.php:35
static checkTitle(&$title, $name)
make sure we have some title to operate on
Definition Skin.php:1158
static makeUrl( $name, $urlaction='')
Definition Skin.php:1085
showIPinHeader()
Definition Skin.php:709
getPageClasses( $title)
TODO: document.
Definition Skin.php:368
getSearchLink()
Definition Skin.php:717
editUrlOptions()
Return URL options for the 'edit page' link.
Definition Skin.php:976
static makeVariablesScript( $data)
Definition Skin.php:326
showEmailUser( $id)
Definition Skin.php:990
static makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN)
this can be passed the NS number as defined in Language.php
Definition Skin.php:1113
buildSidebar()
Build an array that represents the sidebar(s), the navigation bar among them.
Definition Skin.php:1188
getCopyright( $type='detect')
Definition Skin.php:733
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition Skin.php:605
setRelevantUser( $u)
Set the "relevant" user.
Definition Skin.php:279
setupSkinUserCss(OutputPage $out)
Add skin specific stylesheets Calling this method with an $out of anything but the same OutputPage in...
static getSkinNameMessages()
Fetch the skinname messages for available skins.
Definition Skin.php:57
makeFooterIcon( $icon, $withImage='withImage')
Renders a $wgFooterIcons icon according to the method's arguments.
Definition Skin.php:885
getRevisionId()
Get the current revision ID.
Definition Skin.php:234
preloadExistence()
Preload the existence of three commonly-requested pages in a single query.
Definition Skin.php:200
bottomScripts()
This gets called shortly before the "</body>" tag.
Definition Skin.php:589
outputPage(OutputPage $out=null)
Outputs the HTML generated by other functions.
doEditSectionLink(Title $nt, $section, $tooltip=null, $lang=false)
Create a section edit link.
Definition Skin.php:1513
disclaimerLink()
Gets the link to the wiki's general disclaimers page.
Definition Skin.php:965
getDefaultModules()
Defines the ResourceLoader modules that should be added to the skin It is recommended that skins wish...
Definition Skin.php:154
static makeSpecialUrl( $name, $urlaction='', $proto=null)
Make a URL for a Special Page using the given query and protocol.
Definition Skin.php:1049
lastModified()
Get the timestamp of the latest revision, formatted in user language.
Definition Skin.php:833
initPage(OutputPage $out)
Definition Skin.php:144
static getDynamicStylesheetQuery()
Get the query to generate a dynamic stylesheet.
Definition Skin.php:341
subPageSubtitle( $out=null)
Definition Skin.php:652
addToSidebarPlain(&$bar, $text)
Add content from plain text.
Definition Skin.php:1240
footerLink( $desc, $page)
Returns an HTML link for use in the footer.
Definition Skin.php:923
static makeI18nUrl( $name, $urlaction='')
Definition Skin.php:1074
getRelevantTitle()
Return the "relevant" title.
Definition Skin.php:267
getCategories()
Definition Skin.php:519
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
static getSafeTitleFor( $name, $subpage=false)
Get a localised Title object for a page name with a possibly unvalidated subpage.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Represents a title within MediaWiki.
Definition Title.php:36
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:48
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition Xml.php:39
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
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 local content language as $wgContLang
Definition design.txt:57
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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:18
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
const NS_USER
Definition Defines.php:58
const NS_MAIN
Definition Defines.php:56
const NS_CATEGORY
Definition Defines.php:70
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 local account $user
Definition hooks.txt:249
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2568
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. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. '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 '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 '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 '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. '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 IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() '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 Sanitizer::validateEmail(), 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. '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) '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 '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. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. 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:1937
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:986
either a plain
Definition hooks.txt:1990
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition hooks.txt:1096
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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:1950
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:886
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:1957
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2900
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:1686
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:1958
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition hooks.txt:2534
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition hooks.txt:2901
if( $limit) $timestamp
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
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
$cache
Definition mcc.php:33
controlled by $wgMainCacheType * $parserMemc
Definition memcached.txt:78
$searchPage
$lines
Definition router.php:67
if(!isset( $args[0])) $lang