MediaWiki REL1_29
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
157 public function getDefaultModules() {
159
160 $out = $this->getOutput();
161 $user = $out->getUser();
162 $modules = [
163 // modules that enhance the page content in some way
164 'content' => [
165 'mediawiki.page.ready',
166 ],
167 // modules relating to search functionality
168 'search' => [],
169 // modules relating to functionality relating to watching an article
170 'watch' => [],
171 // modules which relate to the current users preferences
172 'user' => [],
173 ];
174
175 // Preload jquery.tablesorter for mediawiki.page.ready
176 if ( strpos( $out->getHTML(), 'sortable' ) !== false ) {
177 $modules['content'][] = 'jquery.tablesorter';
178 }
179
180 // Preload jquery.makeCollapsible for mediawiki.page.ready
181 if ( strpos( $out->getHTML(), 'mw-collapsible' ) !== false ) {
182 $modules['content'][] = 'jquery.makeCollapsible';
183 }
184
185 // Add various resources if required
186 if ( $wgUseAjax && $wgEnableAPI ) {
187 if ( $wgEnableWriteAPI && $user->isLoggedIn()
188 && $user->isAllowedAll( 'writeapi', 'viewmywatchlist', 'editmywatchlist' )
189 && $this->getRelevantTitle()->canExist()
190 ) {
191 $modules['watch'][] = 'mediawiki.page.watch.ajax';
192 }
193
194 $modules['search'][] = 'mediawiki.searchSuggest';
195 }
196
197 if ( $user->getBoolOption( 'editsectiononrightclick' ) ) {
198 $modules['user'][] = 'mediawiki.action.view.rightClickEdit';
199 }
200
201 // Crazy edit-on-double-click stuff
202 if ( $out->isArticle() && $user->getOption( 'editondblclick' ) ) {
203 $modules['user'][] = 'mediawiki.action.view.dblClickEdit';
204 }
205 return $modules;
206 }
207
211 protected function preloadExistence() {
212 $titles = [];
213
214 // User/talk link
215 $user = $this->getUser();
216 if ( $user->isLoggedIn() ) {
217 $titles[] = $user->getUserPage();
218 $titles[] = $user->getTalkPage();
219 }
220
221 // Check, if the page can hold some kind of content, otherwise do nothing
222 $title = $this->getRelevantTitle();
223 if ( $title->canExist() ) {
224 if ( $title->isTalkPage() ) {
225 $titles[] = $title->getSubjectPage();
226 } else {
227 $titles[] = $title->getTalkPage();
228 }
229 }
230
231 // Footer links (used by SkinTemplate::prepareQuickTemplate)
232 foreach ( [
233 $this->footerLinkTitle( 'privacy', 'privacypage' ),
234 $this->footerLinkTitle( 'aboutsite', 'aboutpage' ),
235 $this->footerLinkTitle( 'disclaimers', 'disclaimerpage' ),
236 ] as $title ) {
237 if ( $title ) {
238 $titles[] = $title;
239 }
240 }
241
242 Hooks::run( 'SkinPreloadExistence', [ &$titles, $this ] );
243
244 if ( $titles ) {
245 $lb = new LinkBatch( $titles );
246 $lb->setCaller( __METHOD__ );
247 $lb->execute();
248 }
249 }
250
256 public function getRevisionId() {
257 return $this->getOutput()->getRevisionId();
258 }
259
265 public function isRevisionCurrent() {
266 $revID = $this->getRevisionId();
267 return $revID == 0 || $revID == $this->getTitle()->getLatestRevID();
268 }
269
275 public function setRelevantTitle( $t ) {
276 $this->mRelevantTitle = $t;
277 }
278
289 public function getRelevantTitle() {
290 if ( isset( $this->mRelevantTitle ) ) {
292 }
293 return $this->getTitle();
294 }
295
301 public function setRelevantUser( $u ) {
302 $this->mRelevantUser = $u;
303 }
304
313 public function getRelevantUser() {
314 if ( isset( $this->mRelevantUser ) ) {
316 }
317 $title = $this->getRelevantTitle();
318 if ( $title->hasSubjectNamespace( NS_USER ) ) {
319 $rootUser = $title->getRootText();
320 if ( User::isIP( $rootUser ) ) {
321 $this->mRelevantUser = User::newFromName( $rootUser, false );
322 } else {
323 $user = User::newFromName( $rootUser, false );
324
325 if ( $user ) {
326 $user->load( User::READ_NORMAL );
327
328 if ( $user->isLoggedIn() ) {
329 $this->mRelevantUser = $user;
330 }
331 }
332 }
334 }
335 return null;
336 }
337
342 abstract function outputPage( OutputPage $out = null );
343
348 static function makeVariablesScript( $data ) {
349 if ( $data ) {
352 );
353 } else {
354 return '';
355 }
356 }
357
363 public static function getDynamicStylesheetQuery() {
365
366 return [
367 'action' => 'raw',
368 'maxage' => $wgSquidMaxage,
369 'usemsgcache' => 'yes',
370 'ctype' => 'text/css',
371 'smaxage' => $wgSquidMaxage,
372 ];
373 }
374
383 abstract function setupSkinUserCss( OutputPage $out );
384
390 function getPageClasses( $title ) {
391 $numeric = 'ns-' . $title->getNamespace();
392
393 if ( $title->isSpecialPage() ) {
394 $type = 'ns-special';
395 // T25315: provide a class based on the canonical special page name without subpages
396 list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
397 if ( $canonicalName ) {
398 $type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
399 } else {
400 $type .= ' mw-invalidspecialpage';
401 }
402 } elseif ( $title->isTalkPage() ) {
403 $type = 'ns-talk';
404 } else {
405 $type = 'ns-subject';
406 }
407
408 $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
409 $root = Sanitizer::escapeClass( 'rootpage-' . $title->getRootTitle()->getPrefixedText() );
410
411 return "$numeric $type $name $root";
412 }
413
418 public function getHtmlElementAttributes() {
419 $lang = $this->getLanguage();
420 return [
421 'lang' => $lang->getHtmlCode(),
422 'dir' => $lang->getDir(),
423 'class' => 'client-nojs',
424 ];
425 }
426
434 function addToBodyAttributes( $out, &$bodyAttrs ) {
435 // does nothing by default
436 }
437
442 function getLogo() {
444 return $wgLogo;
445 }
446
450 function getCategoryLinks() {
452
453 $out = $this->getOutput();
454 $allCats = $out->getCategoryLinks();
455
456 if ( !count( $allCats ) ) {
457 return '';
458 }
459
460 $embed = "<li>";
461 $pop = "</li>";
462
463 $s = '';
464 $colon = $this->msg( 'colon-separator' )->escaped();
465
466 if ( !empty( $allCats['normal'] ) ) {
467 $t = $embed . implode( "{$pop}{$embed}", $allCats['normal'] ) . $pop;
468
469 $msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
470 $linkPage = wfMessage( 'pagecategorieslink' )->inContentLanguage()->text();
471 $title = Title::newFromText( $linkPage );
472 $link = $title ? Linker::link( $title, $msg ) : $msg;
473 $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
474 $link . $colon . '<ul>' . $t . '</ul>' . '</div>';
475 }
476
477 # Hidden categories
478 if ( isset( $allCats['hidden'] ) ) {
479 if ( $this->getUser()->getBoolOption( 'showhiddencats' ) ) {
480 $class = ' mw-hidden-cats-user-shown';
481 } elseif ( $this->getTitle()->getNamespace() == NS_CATEGORY ) {
482 $class = ' mw-hidden-cats-ns-shown';
483 } else {
484 $class = ' mw-hidden-cats-hidden';
485 }
486
487 $s .= "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks$class\">" .
488 $this->msg( 'hidden-categories' )->numParams( count( $allCats['hidden'] ) )->escaped() .
489 $colon . '<ul>' . $embed . implode( "{$pop}{$embed}", $allCats['hidden'] ) . $pop . '</ul>' .
490 '</div>';
491 }
492
493 # optional 'dmoz-like' category browser. Will be shown under the list
494 # of categories an article belong to
495 if ( $wgUseCategoryBrowser ) {
496 $s .= '<br /><hr />';
497
498 # get a big array of the parents tree
499 $parenttree = $this->getTitle()->getParentCategoryTree();
500 # Skin object passed by reference cause it can not be
501 # accessed under the method subfunction drawCategoryBrowser
502 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree ) );
503 # Clean out bogus first entry and sort them
504 unset( $tempout[0] );
505 asort( $tempout );
506 # Output one per line
507 $s .= implode( "<br />\n", $tempout );
508 }
509
510 return $s;
511 }
512
518 function drawCategoryBrowser( $tree ) {
519 $return = '';
520
521 foreach ( $tree as $element => $parent ) {
522 if ( empty( $parent ) ) {
523 # element start a new list
524 $return .= "\n";
525 } else {
526 # grab the others elements
527 $return .= $this->drawCategoryBrowser( $parent ) . ' &gt; ';
528 }
529
530 # add our current element to the list
531 $eltitle = Title::newFromText( $element );
532 $return .= Linker::link( $eltitle, htmlspecialchars( $eltitle->getText() ) );
533 }
534
535 return $return;
536 }
537
541 function getCategories() {
542 $out = $this->getOutput();
543 $catlinks = $this->getCategoryLinks();
544
545 // Check what we're showing
546 $allCats = $out->getCategoryLinks();
547 $showHidden = $this->getUser()->getBoolOption( 'showhiddencats' ) ||
548 $this->getTitle()->getNamespace() == NS_CATEGORY;
549
550 $classes = [ 'catlinks' ];
551 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
552 $classes[] = 'catlinks-allhidden';
553 }
554
555 return Html::rawElement(
556 'div',
557 [ 'id' => 'catlinks', 'class' => $classes, 'data-mw' => 'interface' ],
558 $catlinks
559 );
560 }
561
576 protected function afterContentHook() {
577 $data = '';
578
579 if ( Hooks::run( 'SkinAfterContent', [ &$data, $this ] ) ) {
580 // adding just some spaces shouldn't toggle the output
581 // of the whole <div/>, so we use trim() here
582 if ( trim( $data ) != '' ) {
583 // Doing this here instead of in the skins to
584 // ensure that the div has the same ID in all
585 // skins
586 $data = "<div id='mw-data-after-content'>\n" .
587 "\t$data\n" .
588 "</div>\n";
589 }
590 } else {
591 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
592 }
593
594 return $data;
595 }
596
602 protected function generateDebugHTML() {
603 return MWDebug::getHTMLDebugLog();
604 }
605
611 function bottomScripts() {
612 // TODO and the suckage continues. This function is really just a wrapper around
613 // OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
614 // up at some point
615 $bottomScriptText = $this->getOutput()->getBottomScripts();
616 Hooks::run( 'SkinAfterBottomScripts', [ $this, &$bottomScriptText ] );
617
618 return $bottomScriptText;
619 }
620
627 function printSource() {
628 $oldid = $this->getRevisionId();
629 if ( $oldid ) {
630 $canonicalUrl = $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid );
631 $url = htmlspecialchars( wfExpandIRI( $canonicalUrl ) );
632 } else {
633 // oldid not available for non existing pages
634 $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL() ) );
635 }
636
637 return $this->msg( 'retrievedfrom' )
638 ->rawParams( '<a dir="ltr" href="' . $url . '">' . $url . '</a>' )
639 ->parse();
640 }
641
645 function getUndeleteLink() {
646 $action = $this->getRequest()->getVal( 'action', 'view' );
647
648 if ( $this->getTitle()->userCan( 'deletedhistory', $this->getUser() ) &&
649 ( !$this->getTitle()->exists() || $action == 'history' ) ) {
650 $n = $this->getTitle()->isDeleted();
651
652 if ( $n ) {
653 if ( $this->getTitle()->quickUserCan( 'undelete', $this->getUser() ) ) {
654 $msg = 'thisisdeleted';
655 } else {
656 $msg = 'viewdeleted';
657 }
658
659 return $this->msg( $msg )->rawParams(
661 SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
662 $this->msg( 'restorelink' )->numParams( $n )->escaped() )
663 )->escaped();
664 }
665 }
666
667 return '';
668 }
669
674 function subPageSubtitle( $out = null ) {
675 if ( $out === null ) {
676 $out = $this->getOutput();
677 }
678 $title = $out->getTitle();
679 $subpages = '';
680
681 if ( !Hooks::run( 'SkinSubPageSubtitle', [ &$subpages, $this, $out ] ) ) {
682 return $subpages;
683 }
684
685 if ( $out->isArticle() && MWNamespace::hasSubpages( $title->getNamespace() ) ) {
686 $ptext = $title->getPrefixedText();
687 if ( strpos( $ptext, '/' ) !== false ) {
688 $links = explode( '/', $ptext );
689 array_pop( $links );
690 $c = 0;
691 $growinglink = '';
692 $display = '';
693 $lang = $this->getLanguage();
694
695 foreach ( $links as $link ) {
696 $growinglink .= $link;
697 $display .= $link;
698 $linkObj = Title::newFromText( $growinglink );
699
700 if ( is_object( $linkObj ) && $linkObj->isKnown() ) {
701 $getlink = Linker::linkKnown(
702 $linkObj,
703 htmlspecialchars( $display )
704 );
705
706 $c++;
707
708 if ( $c > 1 ) {
709 $subpages .= $lang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
710 } else {
711 $subpages .= '&lt; ';
712 }
713
714 $subpages .= $getlink;
715 $display = '';
716 } else {
717 $display .= '/';
718 }
719 $growinglink .= '/';
720 }
721 }
722 }
723
724 return $subpages;
725 }
726
731 function showIPinHeader() {
732 wfDeprecated( __METHOD__, '1.27' );
733 return false;
734 }
735
739 function getSearchLink() {
741 return $searchPage->getLocalURL();
742 }
743
747 function escapeSearchLink() {
748 return htmlspecialchars( $this->getSearchLink() );
749 }
750
755 function getCopyright( $type = 'detect' ) {
757
758 if ( $type == 'detect' ) {
759 if ( !$this->isRevisionCurrent()
760 && !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled()
761 ) {
762 $type = 'history';
763 } else {
764 $type = 'normal';
765 }
766 }
767
768 if ( $type == 'history' ) {
769 $msg = 'history_copyright';
770 } else {
771 $msg = 'copyright';
772 }
773
774 if ( $wgRightsPage ) {
775 $title = Title::newFromText( $wgRightsPage );
777 } elseif ( $wgRightsUrl ) {
779 } elseif ( $wgRightsText ) {
781 } else {
782 # Give up now
783 return '';
784 }
785
786 // Allow for site and per-namespace customization of copyright notice.
787 // @todo Remove deprecated $forContent param from hook handlers and then remove here.
788 $forContent = true;
789
790 Hooks::run(
791 'SkinCopyrightFooter',
792 [ $this->getTitle(), $type, &$msg, &$link, &$forContent ]
793 );
794
795 return $this->msg( $msg )->rawParams( $link )->text();
796 }
797
801 function getCopyrightIcon() {
803
804 $out = '';
805
806 if ( $wgFooterIcons['copyright']['copyright'] ) {
807 $out = $wgFooterIcons['copyright']['copyright'];
808 } elseif ( $wgRightsIcon ) {
809 $icon = htmlspecialchars( $wgRightsIcon );
810
811 if ( $wgRightsUrl ) {
812 $url = htmlspecialchars( $wgRightsUrl );
813 $out .= '<a href="' . $url . '">';
814 }
815
816 $text = htmlspecialchars( $wgRightsText );
817 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
818
819 if ( $wgRightsUrl ) {
820 $out .= '</a>';
821 }
822 }
823
824 return $out;
825 }
826
831 function getPoweredBy() {
833
834 $url1 = htmlspecialchars(
835 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png"
836 );
837 $url1_5 = htmlspecialchars(
838 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png"
839 );
840 $url2 = htmlspecialchars(
841 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png"
842 );
843 $text = '<a href="//www.mediawiki.org/"><img src="' . $url1
844 . '" srcset="' . $url1_5 . ' 1.5x, ' . $url2 . ' 2x" '
845 . 'height="31" width="88" alt="Powered by MediaWiki" /></a>';
846 Hooks::run( 'SkinGetPoweredBy', [ &$text, $this ] );
847 return $text;
848 }
849
855 protected function lastModified() {
856 $timestamp = $this->getOutput()->getRevisionTimestamp();
857
858 # No cached timestamp, load it from the database
859 if ( $timestamp === null ) {
860 $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
861 }
862
863 if ( $timestamp ) {
864 $d = $this->getLanguage()->userDate( $timestamp, $this->getUser() );
865 $t = $this->getLanguage()->userTime( $timestamp, $this->getUser() );
866 $s = ' ' . $this->msg( 'lastmodifiedat', $d, $t )->parse();
867 } else {
868 $s = '';
869 }
870
871 if ( wfGetLB()->getLaggedReplicaMode() ) {
872 $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->parse() . '</strong>';
873 }
874
875 return $s;
876 }
877
882 function logoText( $align = '' ) {
883 if ( $align != '' ) {
884 $a = " style='float: {$align};'";
885 } else {
886 $a = '';
887 }
888
889 $mp = $this->msg( 'mainpage' )->escaped();
890 $mptitle = Title::newMainPage();
891 $url = ( is_object( $mptitle ) ? htmlspecialchars( $mptitle->getLocalURL() ) : '' );
892
893 $logourl = $this->getLogo();
894 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
895
896 return $s;
897 }
898
907 function makeFooterIcon( $icon, $withImage = 'withImage' ) {
908 if ( is_string( $icon ) ) {
909 $html = $icon;
910 } else { // Assuming array
911 $url = isset( $icon["url"] ) ? $icon["url"] : null;
912 unset( $icon["url"] );
913 if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
914 // do this the lazy way, just pass icon data as an attribute array
915 $html = Html::element( 'img', $icon );
916 } else {
917 $html = htmlspecialchars( $icon["alt"] );
918 }
919 if ( $url ) {
921 $html = Html::rawElement( 'a',
922 [ "href" => $url, "target" => $wgExternalLinkTarget ],
923 $html );
924 }
925 }
926 return $html;
927 }
928
933 function mainPageLink() {
935 Title::newMainPage(),
936 $this->msg( 'mainpage' )->escaped()
937 );
938
939 return $s;
940 }
941
948 public function footerLink( $desc, $page ) {
949 $title = $this->footerLinkTitle( $desc, $page );
950 if ( !$title ) {
951 return '';
952 }
953
954 return Linker::linkKnown(
955 $title,
956 $this->msg( $desc )->escaped()
957 );
958 }
959
965 private function footerLinkTitle( $desc, $page ) {
966 // If the link description has been set to "-" in the default language,
967 if ( $this->msg( $desc )->inContentLanguage()->isDisabled() ) {
968 // then it is disabled, for all languages.
969 return null;
970 }
971 // Otherwise, we display the link for the user, described in their
972 // language (which may or may not be the same as the default language),
973 // but we make the link target be the one site-wide page.
974 $title = Title::newFromText( $this->msg( $page )->inContentLanguage()->text() );
975
976 return $title ?: null;
977 }
978
983 function privacyLink() {
984 return $this->footerLink( 'privacy', 'privacypage' );
985 }
986
991 function aboutLink() {
992 return $this->footerLink( 'aboutsite', 'aboutpage' );
993 }
994
999 function disclaimerLink() {
1000 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1001 }
1002
1010 function editUrlOptions() {
1011 $options = [ 'action' => 'edit' ];
1012
1013 if ( !$this->isRevisionCurrent() ) {
1014 $options['oldid'] = intval( $this->getRevisionId() );
1015 }
1016
1017 return $options;
1018 }
1019
1024 function showEmailUser( $id ) {
1025 if ( $id instanceof User ) {
1026 $targetUser = $id;
1027 } else {
1028 $targetUser = User::newFromId( $id );
1029 }
1030
1031 # The sending user must have a confirmed email address and the target
1032 # user must have a confirmed email address and allow emails from users.
1033 return $this->getUser()->canSendEmail() &&
1034 $targetUser->canReceiveEmail();
1035 }
1036
1048 function getSkinStylePath( $name ) {
1050
1051 if ( $this->stylename === null ) {
1052 $class = static::class;
1053 throw new MWException( "$class::\$stylename must be set to use getSkinStylePath()" );
1054 }
1055
1056 return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
1057 }
1058
1059 /* these are used extensively in SkinTemplate, but also some other places */
1060
1065 static function makeMainPageUrl( $urlaction = '' ) {
1066 $title = Title::newMainPage();
1067 self::checkTitle( $title, '' );
1068
1069 return $title->getLocalURL( $urlaction );
1070 }
1071
1083 static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
1085 if ( is_null( $proto ) ) {
1086 return $title->getLocalURL( $urlaction );
1087 } else {
1088 return $title->getFullURL( $urlaction, false, $proto );
1089 }
1090 }
1091
1098 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1100 return $title->getLocalURL( $urlaction );
1101 }
1102
1108 static function makeI18nUrl( $name, $urlaction = '' ) {
1109 $title = Title::newFromText( wfMessage( $name )->inContentLanguage()->text() );
1111 return $title->getLocalURL( $urlaction );
1112 }
1113
1119 static function makeUrl( $name, $urlaction = '' ) {
1120 $title = Title::newFromText( $name );
1122
1123 return $title->getLocalURL( $urlaction );
1124 }
1125
1132 static function makeInternalOrExternalUrl( $name ) {
1133 if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $name ) ) {
1134 return $name;
1135 } else {
1136 return self::makeUrl( $name );
1137 }
1138 }
1139
1147 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
1148 $title = Title::makeTitleSafe( $namespace, $name );
1150
1151 return $title->getLocalURL( $urlaction );
1152 }
1153
1160 static function makeUrlDetails( $name, $urlaction = '' ) {
1161 $title = Title::newFromText( $name );
1163
1164 return [
1165 'href' => $title->getLocalURL( $urlaction ),
1166 'exists' => $title->isKnown(),
1167 ];
1168 }
1169
1176 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1177 $title = Title::newFromText( $name );
1179
1180 return [
1181 'href' => $title->getLocalURL( $urlaction ),
1182 'exists' => true
1183 ];
1184 }
1185
1192 static function checkTitle( &$title, $name ) {
1193 if ( !is_object( $title ) ) {
1194 $title = Title::newFromText( $name );
1195 if ( !is_object( $title ) ) {
1196 $title = Title::newFromText( '--error: link target missing--' );
1197 }
1198 }
1199 }
1200
1222 function buildSidebar() {
1224
1225 $that = $this;
1226 $callback = function () use ( $that ) {
1227 $bar = [];
1228 $that->addToSidebar( $bar, 'sidebar' );
1229 Hooks::run( 'SkinBuildSidebar', [ $that, &$bar ] );
1230
1231 return $bar;
1232 };
1233
1234 if ( $wgEnableSidebarCache ) {
1235 $cache = ObjectCache::getMainWANInstance();
1236 $sidebar = $cache->getWithSetCallback(
1237 $cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
1238 MessageCache::singleton()->isDisabled()
1239 ? $cache::TTL_UNCACHEABLE // bug T133069
1241 $callback,
1242 [ 'lockTSE' => 30 ]
1243 );
1244 } else {
1245 $sidebar = $callback();
1246 }
1247
1248 // Apply post-processing to the cached value
1249 Hooks::run( 'SidebarBeforeOutput', [ $this, &$sidebar ] );
1250
1251 return $sidebar;
1252 }
1253
1263 public function addToSidebar( &$bar, $message ) {
1264 $this->addToSidebarPlain( $bar, wfMessage( $message )->inContentLanguage()->plain() );
1265 }
1266
1274 function addToSidebarPlain( &$bar, $text ) {
1275 $lines = explode( "\n", $text );
1276
1277 $heading = '';
1278 $messageTitle = $this->getConfig()->get( 'EnableSidebarCache' )
1279 ? Title::newMainPage() : $this->getTitle();
1280
1281 foreach ( $lines as $line ) {
1282 if ( strpos( $line, '*' ) !== 0 ) {
1283 continue;
1284 }
1285 $line = rtrim( $line, "\r" ); // for Windows compat
1286
1287 if ( strpos( $line, '**' ) !== 0 ) {
1288 $heading = trim( $line, '* ' );
1289 if ( !array_key_exists( $heading, $bar ) ) {
1290 $bar[$heading] = [];
1291 }
1292 } else {
1293 $line = trim( $line, '* ' );
1294
1295 if ( strpos( $line, '|' ) !== false ) { // sanity check
1296 $line = MessageCache::singleton()->transform( $line, false, null, $messageTitle );
1297 $line = array_map( 'trim', explode( '|', $line, 2 ) );
1298 if ( count( $line ) !== 2 ) {
1299 // Second sanity check, could be hit by people doing
1300 // funky stuff with parserfuncs... (T35321)
1301 continue;
1302 }
1303
1304 $extraAttribs = [];
1305
1306 $msgLink = $this->msg( $line[0] )->title( $messageTitle )->inContentLanguage();
1307 if ( $msgLink->exists() ) {
1308 $link = $msgLink->text();
1309 if ( $link == '-' ) {
1310 continue;
1311 }
1312 } else {
1313 $link = $line[0];
1314 }
1315 $msgText = $this->msg( $line[1] )->title( $messageTitle );
1316 if ( $msgText->exists() ) {
1317 $text = $msgText->text();
1318 } else {
1319 $text = $line[1];
1320 }
1321
1322 if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $link ) ) {
1323 $href = $link;
1324
1325 // Parser::getExternalLinkAttribs won't work here because of the Namespace things
1328 $extraAttribs['rel'] = 'nofollow';
1329 }
1330
1332 if ( $wgExternalLinkTarget ) {
1333 $extraAttribs['target'] = $wgExternalLinkTarget;
1334 }
1335 } else {
1336 $title = Title::newFromText( $link );
1337
1338 if ( $title ) {
1339 $title = $title->fixSpecialName();
1340 $href = $title->getLinkURL();
1341 } else {
1342 $href = 'INVALID-TITLE';
1343 }
1344 }
1345
1346 $bar[$heading][] = array_merge( [
1347 'text' => $text,
1348 'href' => $href,
1349 'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
1350 'active' => false
1351 ], $extraAttribs );
1352 } else {
1353 continue;
1354 }
1355 }
1356 }
1357
1358 return $bar;
1359 }
1360
1366 function getNewtalks() {
1367
1368 $newMessagesAlert = '';
1369 $user = $this->getUser();
1370 $newtalks = $user->getNewMessageLinks();
1371 $out = $this->getOutput();
1372
1373 // Allow extensions to disable or modify the new messages alert
1374 if ( !Hooks::run( 'GetNewMessagesAlert', [ &$newMessagesAlert, $newtalks, $user, $out ] ) ) {
1375 return '';
1376 }
1377 if ( $newMessagesAlert ) {
1378 return $newMessagesAlert;
1379 }
1380
1381 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
1382 $uTalkTitle = $user->getTalkPage();
1383 $lastSeenRev = isset( $newtalks[0]['rev'] ) ? $newtalks[0]['rev'] : null;
1384 $nofAuthors = 0;
1385 if ( $lastSeenRev !== null ) {
1386 $plural = true; // Default if we have a last seen revision: if unknown, use plural
1387 $latestRev = Revision::newFromTitle( $uTalkTitle, false, Revision::READ_NORMAL );
1388 if ( $latestRev !== null ) {
1389 // Singular if only 1 unseen revision, plural if several unseen revisions.
1390 $plural = $latestRev->getParentId() !== $lastSeenRev->getId();
1391 $nofAuthors = $uTalkTitle->countAuthorsBetween(
1392 $lastSeenRev, $latestRev, 10, 'include_new' );
1393 }
1394 } else {
1395 // Singular if no revision -> diff link will show latest change only in any case
1396 $plural = false;
1397 }
1398 $plural = $plural ? 999 : 1;
1399 // 999 signifies "more than one revision". We don't know how many, and even if we did,
1400 // the number of revisions or authors is not necessarily the same as the number of
1401 // "messages".
1402 $newMessagesLink = Linker::linkKnown(
1403 $uTalkTitle,
1404 $this->msg( 'newmessageslinkplural' )->params( $plural )->escaped(),
1405 [],
1406 [ 'redirect' => 'no' ]
1407 );
1408
1409 $newMessagesDiffLink = Linker::linkKnown(
1410 $uTalkTitle,
1411 $this->msg( 'newmessagesdifflinkplural' )->params( $plural )->escaped(),
1412 [],
1413 $lastSeenRev !== null
1414 ? [ 'oldid' => $lastSeenRev->getId(), 'diff' => 'cur' ]
1415 : [ 'diff' => 'cur' ]
1416 );
1417
1418 if ( $nofAuthors >= 1 && $nofAuthors <= 10 ) {
1419 $newMessagesAlert = $this->msg(
1420 'youhavenewmessagesfromusers',
1421 $newMessagesLink,
1422 $newMessagesDiffLink
1423 )->numParams( $nofAuthors, $plural );
1424 } else {
1425 // $nofAuthors === 11 signifies "11 or more" ("more than 10")
1426 $newMessagesAlert = $this->msg(
1427 $nofAuthors > 10 ? 'youhavenewmessagesmanyusers' : 'youhavenewmessages',
1428 $newMessagesLink,
1429 $newMessagesDiffLink
1430 )->numParams( $plural );
1431 }
1432 $newMessagesAlert = $newMessagesAlert->text();
1433 # Disable CDN cache
1434 $out->setCdnMaxage( 0 );
1435 } elseif ( count( $newtalks ) ) {
1436 $sep = $this->msg( 'newtalkseparator' )->escaped();
1437 $msgs = [];
1438
1439 foreach ( $newtalks as $newtalk ) {
1440 $msgs[] = Xml::element(
1441 'a',
1442 [ 'href' => $newtalk['link'] ], $newtalk['wiki']
1443 );
1444 }
1445 $parts = implode( $sep, $msgs );
1446 $newMessagesAlert = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped();
1447 $out->setCdnMaxage( 0 );
1448 }
1449
1450 return $newMessagesAlert;
1451 }
1452
1460 private function getCachedNotice( $name ) {
1462
1463 $needParse = false;
1464
1465 if ( $name === 'default' ) {
1466 // special case
1468 $notice = $wgSiteNotice;
1469 if ( empty( $notice ) ) {
1470 return false;
1471 }
1472 } else {
1473 $msg = $this->msg( $name )->inContentLanguage();
1474 if ( $msg->isBlank() ) {
1475 return '';
1476 } elseif ( $msg->isDisabled() ) {
1477 return false;
1478 }
1479 $notice = $msg->plain();
1480 }
1481
1482 // Use the extra hash appender to let eg SSL variants separately cache.
1484 $cachedNotice = $parserMemc->get( $key );
1485 if ( is_array( $cachedNotice ) ) {
1486 if ( md5( $notice ) == $cachedNotice['hash'] ) {
1487 $notice = $cachedNotice['html'];
1488 } else {
1489 $needParse = true;
1490 }
1491 } else {
1492 $needParse = true;
1493 }
1494
1495 if ( $needParse ) {
1496 $parsed = $this->getOutput()->parse( $notice );
1497 $parserMemc->set( $key, [ 'html' => $parsed, 'hash' => md5( $notice ) ], 600 );
1498 $notice = $parsed;
1499 }
1500
1501 $notice = Html::rawElement( 'div', [ 'id' => 'localNotice',
1502 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ], $notice );
1503 return $notice;
1504 }
1505
1511 function getSiteNotice() {
1512 $siteNotice = '';
1513
1514 if ( Hooks::run( 'SiteNoticeBefore', [ &$siteNotice, $this ] ) ) {
1515 if ( is_object( $this->getUser() ) && $this->getUser()->isLoggedIn() ) {
1516 $siteNotice = $this->getCachedNotice( 'sitenotice' );
1517 } else {
1518 $anonNotice = $this->getCachedNotice( 'anonnotice' );
1519 if ( $anonNotice === false ) {
1520 $siteNotice = $this->getCachedNotice( 'sitenotice' );
1521 } else {
1522 $siteNotice = $anonNotice;
1523 }
1524 }
1525 if ( $siteNotice === false ) {
1526 $siteNotice = $this->getCachedNotice( 'default' );
1527 }
1528 }
1529
1530 Hooks::run( 'SiteNoticeAfter', [ &$siteNotice, $this ] );
1531 return $siteNotice;
1532 }
1533
1547 public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
1548 // HTML generated here should probably have userlangattributes
1549 // added to it for LTR text on RTL pages
1550
1552
1553 $attribs = [];
1554 if ( !is_null( $tooltip ) ) {
1555 # T27462: undo double-escaping.
1556 $tooltip = Sanitizer::decodeCharReferences( $tooltip );
1557 $attribs['title'] = wfMessage( 'editsectionhint' )->rawParams( $tooltip )
1558 ->inLanguage( $lang )->text();
1559 }
1560
1561 $links = [
1562 'editsection' => [
1563 'text' => wfMessage( 'editsection' )->inLanguage( $lang )->escaped(),
1564 'targetTitle' => $nt,
1565 'attribs' => $attribs,
1566 'query' => [ 'action' => 'edit', 'section' => $section ],
1567 'options' => [ 'noclasses', 'known' ]
1568 ]
1569 ];
1570
1571 Hooks::run( 'SkinEditSectionLinks', [ $this, $nt, $section, $tooltip, &$links, $lang ] );
1572
1573 $result = '<span class="mw-editsection"><span class="mw-editsection-bracket">[</span>';
1574
1575 $linksHtml = [];
1576 foreach ( $links as $k => $linkDetails ) {
1577 $linksHtml[] = Linker::link(
1578 $linkDetails['targetTitle'],
1579 $linkDetails['text'],
1580 $linkDetails['attribs'],
1581 $linkDetails['query'],
1582 $linkDetails['options']
1583 );
1584 }
1585
1586 $result .= implode(
1587 '<span class="mw-editsection-divider">'
1588 . wfMessage( 'pipe-separator' )->inLanguage( $lang )->text()
1589 . '</span>',
1590 $linksHtml
1591 );
1592
1593 $result .= '<span class="mw-editsection-bracket">]</span></span>';
1594 // Deprecated, use SkinEditSectionLinks hook instead
1595 Hooks::run(
1596 'DoEditSectionLink',
1597 [ $this, $nt, $section, $tooltip, &$result, $lang ],
1598 '1.25'
1599 );
1600 return $result;
1601 }
1602
1603}
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:58
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:34
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition Linker.php:107
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition Linker.php:159
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
Definition Linker.php:838
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:134
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:991
isRevisionCurrent()
Whether the revision displayed is the latest revision of the page.
Definition Skin.php:265
static makeInternalOrExternalUrl( $name)
If url string starts with http, consider as external URL, else internal.
Definition Skin.php:1132
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e....
Definition Skin.php:576
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:1366
mainPageLink()
Gets the link to the wiki's main page.
Definition Skin.php:933
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:1048
getCachedNotice( $name)
Get a cached notice.
Definition Skin.php:1460
static makeMainPageUrl( $urlaction='')
Definition Skin.php:1065
static makeKnownUrlDetails( $name, $urlaction='')
Make URL details where the article exists (or at least it's convenient to think so)
Definition Skin.php:1176
generateDebugHTML()
Generate debug data HTML for displaying at the bottom of the main content area.
Definition Skin.php:602
getCopyrightIcon()
Definition Skin.php:801
privacyLink()
Gets the link to the wiki's privacy policy page.
Definition Skin.php:983
footerLinkTitle( $desc, $page)
Definition Skin.php:965
getSiteNotice()
Get the site notice.
Definition Skin.php:1511
getHtmlElementAttributes()
Return values for <html> element.
Definition Skin.php:418
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:645
getPoweredBy()
Gets the powered by MediaWiki icon.
Definition Skin.php:831
getCategoryLinks()
Definition Skin.php:450
escapeSearchLink()
Definition Skin.php:747
static makeUrlDetails( $name, $urlaction='')
these return an array with the 'href' and boolean 'exists'
Definition Skin.php:1160
getLogo()
URL to the logo.
Definition Skin.php:442
$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:1263
static makeSpecialUrlSubpage( $name, $subpage, $urlaction='')
Definition Skin.php:1098
getRelevantUser()
Return the "relevant" user.
Definition Skin.php:313
setRelevantTitle( $t)
Set the "relevant" title.
Definition Skin.php:275
logoText( $align='')
Definition Skin.php:882
addToBodyAttributes( $out, &$bodyAttrs)
This will be called by OutputPage::headElement when it is creating the "<body>" tag,...
Definition Skin.php:434
$mRelevantUser
Definition Skin.php:37
drawCategoryBrowser( $tree)
Render the array as a series of links.
Definition Skin.php:518
$skinname
Definition Skin.php:35
static checkTitle(&$title, $name)
make sure we have some title to operate on
Definition Skin.php:1192
static makeUrl( $name, $urlaction='')
Definition Skin.php:1119
showIPinHeader()
Definition Skin.php:731
getPageClasses( $title)
TODO: document.
Definition Skin.php:390
getSearchLink()
Definition Skin.php:739
editUrlOptions()
Return URL options for the 'edit page' link.
Definition Skin.php:1010
static makeVariablesScript( $data)
Definition Skin.php:348
showEmailUser( $id)
Definition Skin.php:1024
static makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN)
this can be passed the NS number as defined in Language.php
Definition Skin.php:1147
buildSidebar()
Build an array that represents the sidebar(s), the navigation bar among them.
Definition Skin.php:1222
getCopyright( $type='detect')
Definition Skin.php:755
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition Skin.php:627
setRelevantUser( $u)
Set the "relevant" user.
Definition Skin.php:301
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:907
getRevisionId()
Get the current revision ID.
Definition Skin.php:256
preloadExistence()
Preload the existence of three commonly-requested pages in a single query.
Definition Skin.php:211
bottomScripts()
This gets called shortly before the "</body>" tag.
Definition Skin.php:611
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:1547
disclaimerLink()
Gets the link to the wiki's general disclaimers page.
Definition Skin.php:999
getDefaultModules()
Defines the ResourceLoader modules that should be added to the skin It is recommended that skins wish...
Definition Skin.php:157
static makeSpecialUrl( $name, $urlaction='', $proto=null)
Make a URL for a Special Page using the given query and protocol.
Definition Skin.php:1083
lastModified()
Get the timestamp of the latest revision, formatted in user language.
Definition Skin.php:855
initPage(OutputPage $out)
Definition Skin.php:144
static getDynamicStylesheetQuery()
Get the query to generate a dynamic stylesheet.
Definition Skin.php:363
subPageSubtitle( $out=null)
Definition Skin.php:674
addToSidebarPlain(&$bar, $text)
Add content from plain text.
Definition Skin.php:1274
footerLink( $desc, $page)
Returns an HTML link for use in the footer.
Definition Skin.php:948
static makeI18nUrl( $name, $urlaction='')
Definition Skin.php:1108
getRelevantTitle()
Return the "relevant" title.
Definition Skin.php:289
getCategories()
Definition Skin.php:541
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:39
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:50
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:64
const NS_MAIN
Definition Defines.php:62
const NS_CATEGORY
Definition Defines.php:76
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
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:2578
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:Array with elements of the form "language:title" in the order that they will be output. & $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:1954
either a plain
Definition hooks.txt:2007
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition hooks.txt:1102
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
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:1967
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2604
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:864
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:1974
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2937
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
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:1703
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:1975
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:2938
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:61
if(!isset( $args[0])) $lang