Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Skin often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Skin, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
34 | abstract class Skin extends ContextSource { |
||
35 | protected $skinname = null; |
||
36 | protected $mRelevantTitle = null; |
||
37 | protected $mRelevantUser = null; |
||
38 | |||
39 | /** |
||
40 | * @var string Stylesheets set to use. Subdirectory in skins/ where various stylesheets are |
||
41 | * located. Only needs to be set if you intend to use the getSkinStylePath() method. |
||
42 | */ |
||
43 | public $stylename = null; |
||
44 | |||
45 | /** |
||
46 | * Fetch the set of available skins. |
||
47 | * @return array Associative array of strings |
||
48 | */ |
||
49 | static function getSkinNames() { |
||
52 | |||
53 | /** |
||
54 | * Fetch the skinname messages for available skins. |
||
55 | * @return string[] |
||
56 | */ |
||
57 | static function getSkinNameMessages() { |
||
64 | |||
65 | /** |
||
66 | * Fetch the list of user-selectable skins in regards to $wgSkipSkins. |
||
67 | * Useful for Special:Preferences and other places where you |
||
68 | * only want to show skins users _can_ use. |
||
69 | * @return string[] |
||
70 | * @since 1.23 |
||
71 | */ |
||
72 | public static function getAllowedSkins() { |
||
83 | |||
84 | /** |
||
85 | * Normalize a skin preference value to a form that can be loaded. |
||
86 | * |
||
87 | * If a skin can't be found, it will fall back to the configured default ($wgDefaultSkin), or the |
||
88 | * hardcoded default ($wgFallbackSkin) if the default skin is unavailable too. |
||
89 | * |
||
90 | * @param string $key 'monobook', 'vector', etc. |
||
91 | * @return string |
||
92 | */ |
||
93 | static function normalizeKey( $key ) { |
||
133 | |||
134 | /** |
||
135 | * @return string Skin name |
||
136 | */ |
||
137 | public function getSkinName() { |
||
140 | |||
141 | /** |
||
142 | * @param OutputPage $out |
||
143 | */ |
||
144 | public function initPage( OutputPage $out ) { |
||
145 | $this->preloadExistence(); |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * Defines the ResourceLoader modules that should be added to the skin |
||
150 | * It is recommended that skins wishing to override call parent::getDefaultModules() |
||
151 | * and substitute out any modules they wish to change by using a key to look them up |
||
152 | * @return array Array of modules with helper keys for easy overriding |
||
153 | */ |
||
154 | public function getDefaultModules() { |
||
196 | |||
197 | /** |
||
198 | * Preload the existence of three commonly-requested pages in a single query |
||
199 | */ |
||
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 | |||
229 | /** |
||
230 | * Get the current revision ID |
||
231 | * |
||
232 | * @return int |
||
233 | */ |
||
234 | public function getRevisionId() { |
||
237 | |||
238 | /** |
||
239 | * Whether the revision displayed is the latest revision of the page |
||
240 | * |
||
241 | * @return bool |
||
242 | */ |
||
243 | public function isRevisionCurrent() { |
||
247 | |||
248 | /** |
||
249 | * Set the "relevant" title |
||
250 | * @see self::getRelevantTitle() |
||
251 | * @param Title $t |
||
252 | */ |
||
253 | public function setRelevantTitle( $t ) { |
||
256 | |||
257 | /** |
||
258 | * Return the "relevant" title. |
||
259 | * A "relevant" title is not necessarily the actual title of the page. |
||
260 | * Special pages like Special:MovePage use set the page they are acting on |
||
261 | * as their "relevant" title, this allows the skin system to display things |
||
262 | * such as content tabs which belong to to that page instead of displaying |
||
263 | * a basic special page tab which has almost no meaning. |
||
264 | * |
||
265 | * @return Title |
||
266 | */ |
||
267 | public function getRelevantTitle() { |
||
273 | |||
274 | /** |
||
275 | * Set the "relevant" user |
||
276 | * @see self::getRelevantUser() |
||
277 | * @param User $u |
||
278 | */ |
||
279 | public function setRelevantUser( $u ) { |
||
282 | |||
283 | /** |
||
284 | * Return the "relevant" user. |
||
285 | * A "relevant" user is similar to a relevant title. Special pages like |
||
286 | * Special:Contributions mark the user which they are relevant to so that |
||
287 | * things like the toolbox can display the information they usually are only |
||
288 | * able to display on a user's userpage and talkpage. |
||
289 | * @return User |
||
290 | */ |
||
291 | public function getRelevantUser() { |
||
315 | |||
316 | /** |
||
317 | * Outputs the HTML generated by other functions. |
||
318 | * @param OutputPage $out |
||
319 | */ |
||
320 | abstract function outputPage( OutputPage $out = null ); |
||
321 | |||
322 | /** |
||
323 | * @param array $data |
||
324 | * @return string |
||
325 | */ |
||
326 | static function makeVariablesScript( $data ) { |
||
335 | |||
336 | /** |
||
337 | * Get the query to generate a dynamic stylesheet |
||
338 | * |
||
339 | * @return array |
||
340 | */ |
||
341 | public static function getDynamicStylesheetQuery() { |
||
352 | |||
353 | /** |
||
354 | * Add skin specific stylesheets |
||
355 | * Calling this method with an $out of anything but the same OutputPage |
||
356 | * inside ->getOutput() is deprecated. The $out arg is kept |
||
357 | * for compatibility purposes with skins. |
||
358 | * @param OutputPage $out |
||
359 | * @todo delete |
||
360 | */ |
||
361 | abstract function setupSkinUserCss( OutputPage $out ); |
||
362 | |||
363 | /** |
||
364 | * TODO: document |
||
365 | * @param Title $title |
||
366 | * @return string |
||
367 | */ |
||
368 | function getPageClasses( $title ) { |
||
391 | |||
392 | /** |
||
393 | * Return values for <html> element |
||
394 | * @return array Array of associative name-to-value elements for <html> element |
||
395 | */ |
||
396 | public function getHtmlElementAttributes() { |
||
404 | |||
405 | /** |
||
406 | * This will be called by OutputPage::headElement when it is creating the |
||
407 | * "<body>" tag, skins can override it if they have a need to add in any |
||
408 | * body attributes or classes of their own. |
||
409 | * @param OutputPage $out |
||
410 | * @param array $bodyAttrs |
||
411 | */ |
||
412 | function addToBodyAttributes( $out, &$bodyAttrs ) { |
||
415 | |||
416 | /** |
||
417 | * URL to the logo |
||
418 | * @return string |
||
419 | */ |
||
420 | function getLogo() { |
||
424 | |||
425 | /** |
||
426 | * @return string HTML |
||
427 | */ |
||
428 | function getCategoryLinks() { |
||
490 | |||
491 | /** |
||
492 | * Render the array as a series of links. |
||
493 | * @param array $tree Categories tree returned by Title::getParentCategoryTree |
||
494 | * @return string Separated by >, terminate with "\n" |
||
495 | */ |
||
496 | function drawCategoryBrowser( $tree ) { |
||
515 | |||
516 | /** |
||
517 | * @return string HTML |
||
518 | */ |
||
519 | function getCategories() { |
||
539 | |||
540 | /** |
||
541 | * This runs a hook to allow extensions placing their stuff after content |
||
542 | * and article metadata (e.g. categories). |
||
543 | * Note: This function has nothing to do with afterContent(). |
||
544 | * |
||
545 | * This hook is placed here in order to allow using the same hook for all |
||
546 | * skins, both the SkinTemplate based ones and the older ones, which directly |
||
547 | * use this class to get their data. |
||
548 | * |
||
549 | * The output of this function gets processed in SkinTemplate::outputPage() for |
||
550 | * the SkinTemplate based skins, all other skins should directly echo it. |
||
551 | * |
||
552 | * @return string Empty by default, if not changed by any hook function. |
||
553 | */ |
||
554 | protected function afterContentHook() { |
||
574 | |||
575 | /** |
||
576 | * Generate debug data HTML for displaying at the bottom of the main content |
||
577 | * area. |
||
578 | * @return string HTML containing debug data, if enabled (otherwise empty). |
||
579 | */ |
||
580 | protected function generateDebugHTML() { |
||
583 | |||
584 | /** |
||
585 | * This gets called shortly before the "</body>" tag. |
||
586 | * |
||
587 | * @return string HTML-wrapped JS code to be put before "</body>" |
||
588 | */ |
||
589 | function bottomScripts() { |
||
598 | |||
599 | /** |
||
600 | * Text with the permalink to the source page, |
||
601 | * usually shown on the footer of a printed page |
||
602 | * |
||
603 | * @return string HTML text with an URL |
||
604 | */ |
||
605 | function printSource() { |
||
619 | |||
620 | /** |
||
621 | * @return string HTML |
||
622 | */ |
||
623 | function getUndeleteLink() { |
||
647 | |||
648 | /** |
||
649 | * @param OutputPage $out Defaults to $this->getOutput() if left as null |
||
650 | * @return string |
||
651 | */ |
||
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 .= '< '; |
||
690 | } |
||
691 | |||
692 | $subpages .= $getlink; |
||
693 | $display = ''; |
||
694 | } else { |
||
695 | $display .= '/'; |
||
696 | } |
||
697 | $growinglink .= '/'; |
||
698 | } |
||
699 | } |
||
700 | } |
||
701 | |||
702 | return $subpages; |
||
703 | } |
||
704 | |||
705 | /** |
||
706 | * @deprecated since 1.27, feature removed |
||
707 | * @return bool Always false |
||
708 | */ |
||
709 | function showIPinHeader() { |
||
713 | |||
714 | /** |
||
715 | * @return string |
||
716 | */ |
||
717 | function getSearchLink() { |
||
721 | |||
722 | /** |
||
723 | * @return string |
||
724 | */ |
||
725 | function escapeSearchLink() { |
||
728 | |||
729 | /** |
||
730 | * @param string $type |
||
731 | * @return string |
||
732 | */ |
||
733 | function getCopyright( $type = 'detect' ) { |
||
775 | |||
776 | /** |
||
777 | * @return null|string |
||
778 | */ |
||
779 | function getCopyrightIcon() { |
||
804 | |||
805 | /** |
||
806 | * Gets the powered by MediaWiki icon. |
||
807 | * @return string |
||
808 | */ |
||
809 | function getPoweredBy() { |
||
827 | |||
828 | /** |
||
829 | * Get the timestamp of the latest revision, formatted in user language |
||
830 | * |
||
831 | * @return string |
||
832 | */ |
||
833 | protected function lastModified() { |
||
855 | |||
856 | /** |
||
857 | * @param string $align |
||
858 | * @return string |
||
859 | */ |
||
860 | function logoText( $align = '' ) { |
||
876 | |||
877 | /** |
||
878 | * Renders a $wgFooterIcons icon according to the method's arguments |
||
879 | * @param array $icon The icon to build the html for, see $wgFooterIcons |
||
880 | * for the format of this array. |
||
881 | * @param bool|string $withImage Whether to use the icon's image or output |
||
882 | * a text-only footericon. |
||
883 | * @return string HTML |
||
884 | */ |
||
885 | function makeFooterIcon( $icon, $withImage = 'withImage' ) { |
||
903 | |||
904 | /** |
||
905 | * Gets the link to the wiki's main page. |
||
906 | * @return string |
||
907 | */ |
||
908 | function mainPageLink() { |
||
916 | |||
917 | /** |
||
918 | * Returns an HTML link for use in the footer |
||
919 | * @param string $desc The i18n message key for the link text |
||
920 | * @param string $page The i18n message key for the page to link to |
||
921 | * @return string HTML anchor |
||
922 | */ |
||
923 | public function footerLink( $desc, $page ) { |
||
944 | |||
945 | /** |
||
946 | * Gets the link to the wiki's privacy policy page. |
||
947 | * @return string HTML |
||
948 | */ |
||
949 | function privacyLink() { |
||
952 | |||
953 | /** |
||
954 | * Gets the link to the wiki's about page. |
||
955 | * @return string HTML |
||
956 | */ |
||
957 | function aboutLink() { |
||
960 | |||
961 | /** |
||
962 | * Gets the link to the wiki's general disclaimers page. |
||
963 | * @return string HTML |
||
964 | */ |
||
965 | function disclaimerLink() { |
||
968 | |||
969 | /** |
||
970 | * Return URL options for the 'edit page' link. |
||
971 | * This may include an 'oldid' specifier, if the current page view is such. |
||
972 | * |
||
973 | * @return array |
||
974 | * @private |
||
975 | */ |
||
976 | function editUrlOptions() { |
||
985 | |||
986 | /** |
||
987 | * @param User|int $id |
||
988 | * @return bool |
||
989 | */ |
||
990 | function showEmailUser( $id ) { |
||
1002 | |||
1003 | /** |
||
1004 | * Return a fully resolved style path url to images or styles stored in the current skins's folder. |
||
1005 | * This method returns a url resolved using the configured skin style path |
||
1006 | * and includes the style version inside of the url. |
||
1007 | * |
||
1008 | * Requires $stylename to be set, otherwise throws MWException. |
||
1009 | * |
||
1010 | * @param string $name The name or path of a skin resource file |
||
1011 | * @return string The fully resolved style path url including styleversion |
||
1012 | * @throws MWException |
||
1013 | */ |
||
1014 | function getSkinStylePath( $name ) { |
||
1024 | |||
1025 | /* these are used extensively in SkinTemplate, but also some other places */ |
||
1026 | |||
1027 | /** |
||
1028 | * @param string $urlaction |
||
1029 | * @return string |
||
1030 | */ |
||
1031 | static function makeMainPageUrl( $urlaction = '' ) { |
||
1037 | |||
1038 | /** |
||
1039 | * Make a URL for a Special Page using the given query and protocol. |
||
1040 | * |
||
1041 | * If $proto is set to null, make a local URL. Otherwise, make a full |
||
1042 | * URL with the protocol specified. |
||
1043 | * |
||
1044 | * @param string $name Name of the Special page |
||
1045 | * @param string $urlaction Query to append |
||
1046 | * @param string|null $proto Protocol to use or null for a local URL |
||
1047 | * @return string |
||
1048 | */ |
||
1049 | static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) { |
||
1057 | |||
1058 | /** |
||
1059 | * @param string $name |
||
1060 | * @param string $subpage |
||
1061 | * @param string $urlaction |
||
1062 | * @return string |
||
1063 | */ |
||
1064 | static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) { |
||
1068 | |||
1069 | /** |
||
1070 | * @param string $name |
||
1071 | * @param string $urlaction |
||
1072 | * @return string |
||
1073 | */ |
||
1074 | static function makeI18nUrl( $name, $urlaction = '' ) { |
||
1079 | |||
1080 | /** |
||
1081 | * @param string $name |
||
1082 | * @param string $urlaction |
||
1083 | * @return string |
||
1084 | */ |
||
1085 | static function makeUrl( $name, $urlaction = '' ) { |
||
1091 | |||
1092 | /** |
||
1093 | * If url string starts with http, consider as external URL, else |
||
1094 | * internal |
||
1095 | * @param string $name |
||
1096 | * @return string URL |
||
1097 | */ |
||
1098 | static function makeInternalOrExternalUrl( $name ) { |
||
1105 | |||
1106 | /** |
||
1107 | * this can be passed the NS number as defined in Language.php |
||
1108 | * @param string $name |
||
1109 | * @param string $urlaction |
||
1110 | * @param int $namespace |
||
1111 | * @return string |
||
1112 | */ |
||
1113 | static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) { |
||
1119 | |||
1120 | /** |
||
1121 | * these return an array with the 'href' and boolean 'exists' |
||
1122 | * @param string $name |
||
1123 | * @param string $urlaction |
||
1124 | * @return array |
||
1125 | */ |
||
1126 | View Code Duplication | static function makeUrlDetails( $name, $urlaction = '' ) { |
|
1135 | |||
1136 | /** |
||
1137 | * Make URL details where the article exists (or at least it's convenient to think so) |
||
1138 | * @param string $name Article name |
||
1139 | * @param string $urlaction |
||
1140 | * @return array |
||
1141 | */ |
||
1142 | View Code Duplication | static function makeKnownUrlDetails( $name, $urlaction = '' ) { |
|
1151 | |||
1152 | /** |
||
1153 | * make sure we have some title to operate on |
||
1154 | * |
||
1155 | * @param Title $title |
||
1156 | * @param string $name |
||
1157 | */ |
||
1158 | static function checkTitle( &$title, $name ) { |
||
1166 | |||
1167 | /** |
||
1168 | * Build an array that represents the sidebar(s), the navigation bar among them. |
||
1169 | * |
||
1170 | * BaseTemplate::getSidebar can be used to simplify the format and id generation in new skins. |
||
1171 | * |
||
1172 | * The format of the returned array is [ heading => content, ... ], where: |
||
1173 | * - heading is the heading of a navigation portlet. It is either: |
||
1174 | * - magic string to be handled by the skins ('SEARCH' / 'LANGUAGES' / 'TOOLBOX' / ...) |
||
1175 | * - a message name (e.g. 'navigation'), the message should be HTML-escaped by the skin |
||
1176 | * - plain text, which should be HTML-escaped by the skin |
||
1177 | * - content is the contents of the portlet. It is either: |
||
1178 | * - HTML text (<ul><li>...</li>...</ul>) |
||
1179 | * - array of link data in a format accepted by BaseTemplate::makeListItem() |
||
1180 | * - (for a magic string as a key, any value) |
||
1181 | * |
||
1182 | * Note that extensions can control the sidebar contents using the SkinBuildSidebar hook |
||
1183 | * and can technically insert anything in here; skin creators are expected to handle |
||
1184 | * values described above. |
||
1185 | * |
||
1186 | * @return array |
||
1187 | */ |
||
1188 | function buildSidebar() { |
||
1219 | |||
1220 | /** |
||
1221 | * Add content from a sidebar system message |
||
1222 | * Currently only used for MediaWiki:Sidebar (but may be used by Extensions) |
||
1223 | * |
||
1224 | * This is just a wrapper around addToSidebarPlain() for backwards compatibility |
||
1225 | * |
||
1226 | * @param array $bar |
||
1227 | * @param string $message |
||
1228 | */ |
||
1229 | public function addToSidebar( &$bar, $message ) { |
||
1232 | |||
1233 | /** |
||
1234 | * Add content from plain text |
||
1235 | * @since 1.17 |
||
1236 | * @param array $bar |
||
1237 | * @param string $text |
||
1238 | * @return array |
||
1239 | */ |
||
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 |
||
1292 | global $wgNoFollowLinks, $wgNoFollowDomainExceptions; |
||
1293 | if ( $wgNoFollowLinks && !wfMatchesDomainList( $href, $wgNoFollowDomainExceptions ) ) { |
||
1294 | $extraAttribs['rel'] = 'nofollow'; |
||
1295 | } |
||
1296 | |||
1297 | global $wgExternalLinkTarget; |
||
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 | |||
1327 | /** |
||
1328 | * Gets new talk page messages for the current user and returns an |
||
1329 | * appropriate alert message (or an empty string if there are no messages) |
||
1330 | * @return string |
||
1331 | */ |
||
1332 | function getNewtalks() { |
||
1418 | |||
1419 | /** |
||
1420 | * Get a cached notice |
||
1421 | * |
||
1422 | * @param string $name Message name, or 'default' for $wgSiteNotice |
||
1423 | * @return string|bool HTML fragment, or false to indicate that the caller |
||
1424 | * should fall back to the next notice in its sequence |
||
1425 | */ |
||
1426 | private function getCachedNotice( $name ) { |
||
1471 | |||
1472 | /** |
||
1473 | * Get the site notice |
||
1474 | * |
||
1475 | * @return string HTML fragment |
||
1476 | */ |
||
1477 | function getSiteNotice() { |
||
1499 | |||
1500 | /** |
||
1501 | * Create a section edit link. This supersedes editSectionLink() and |
||
1502 | * editSectionLinkForOther(). |
||
1503 | * |
||
1504 | * @param Title $nt The title being linked to (may not be the same as |
||
1505 | * the current page, if the section is included from a template) |
||
1506 | * @param string $section The designation of the section being pointed to, |
||
1507 | * to be included in the link, like "§ion=$section" |
||
1508 | * @param string $tooltip The tooltip to use for the link: will be escaped |
||
1509 | * and wrapped in the 'editsectionhint' message |
||
1510 | * @param string $lang Language code |
||
1511 | * @return string HTML to use for edit link |
||
1512 | */ |
||
1513 | public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) { |
||
1568 | |||
1569 | } |
||
1570 |