X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fskins%2FSkinTemplate.php;h=203326f126374fb6f09d30341f2774ae3efe3832;hb=ea2f3d1c3adfa62b67f905d2795bc997b424a3f8;hp=4fcc8657b030ac5f9f7ac492664a56f487b896c6;hpb=616913584de2272c56684d41afa18c65fe8d8dc4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index 4fcc8657b0..203326f126 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -46,7 +46,7 @@ class SkinTemplate extends Skin { * @var string For QuickTemplate, the name of the subclass which will * actually fill the template. Child classes should override the default. */ - public $template = 'QuickTemplate'; + public $template = QuickTemplate::class; public $thispage; public $titletxt; @@ -174,7 +174,7 @@ class SkinTemplate extends Skin { )->text(); } - $ilInterwikiCodeBCP47 = wfBCP47( $ilInterwikiCode ); + $ilInterwikiCodeBCP47 = LanguageCode::bcp47( $ilInterwikiCode ); $languageLink = [ 'href' => $languageLinkTitle->getFullURL(), 'text' => $ilLangName, @@ -524,15 +524,48 @@ class SkinTemplate extends Skin { * @return string */ public function getPersonalToolsList() { + return $this->makePersonalToolsList(); + } + + /** + * Get the HTML for the personal tools list + * + * @since 1.31 + * + * @param array $personalTools + * @param array $options + * @return string + */ + public function makePersonalToolsList( $personalTools = null, $options = [] ) { $tpl = $this->setupTemplateForOutput(); $tpl->set( 'personal_urls', $this->buildPersonalUrls() ); $html = ''; - foreach ( $tpl->getPersonalTools() as $key => $item ) { - $html .= $tpl->makeListItem( $key, $item ); + + if ( $personalTools === null ) { + $personalTools = $tpl->getPersonalTools(); } + + foreach ( $personalTools as $key => $item ) { + $html .= $tpl->makeListItem( $key, $item, $options ); + } + return $html; } + /** + * Get personal tools for the user + * + * @since 1.31 + * + * @return array Array of personal tools + */ + public function getStructuredPersonalTools() { + $tpl = $this->setupTemplateForOutput(); + $tpl->set( 'personal_urls', $this->buildPersonalUrls() ); + + return $tpl->getPersonalTools(); + } + /** * Format language name for use in sidebar interlanguage links list. * By default it is capitalized. @@ -594,21 +627,24 @@ class SkinTemplate extends Skin { $page = Title::newFromText( $request->getVal( 'title', '' ) ); } $page = $request->getVal( 'returnto', $page ); - $a = []; + $returnto = []; if ( strval( $page ) !== '' ) { - $a['returnto'] = $page; + $returnto['returnto'] = $page; $query = $request->getVal( 'returntoquery', $this->thisquery ); + $paramsArray = wfCgiToArray( $query ); + unset( $paramsArray['logoutToken'] ); + $query = wfArrayToCgi( $paramsArray ); if ( $query != '' ) { - $a['returntoquery'] = $query; + $returnto['returntoquery'] = $query; } } - $returnto = wfArrayToCgi( $a ); if ( $this->loggedin ) { $personal_urls['userpage'] = [ 'text' => $this->username, 'href' => &$this->userpageUrlDetails['href'], 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', + 'exists' => $this->userpageUrlDetails['exists'], 'active' => ( $this->userpageUrlDetails['href'] == $pageurl ), 'dir' => 'auto' ]; @@ -617,6 +653,7 @@ class SkinTemplate extends Skin { 'text' => $this->msg( 'mytalk' )->text(), 'href' => &$usertalkUrlDetails['href'], 'class' => $usertalkUrlDetails['exists'] ? false : 'new', + 'exists' => $usertalkUrlDetails['exists'], 'active' => ( $usertalkUrlDetails['href'] == $pageurl ) ]; $href = self::makeSpecialUrl( 'Preferences' ); @@ -664,9 +701,10 @@ class SkinTemplate extends Skin { $personal_urls['logout'] = [ 'text' => $this->msg( 'pt-userlogout' )->text(), 'href' => self::makeSpecialUrl( 'Userlogout', - // userlogout link must always contain an & character, otherwise we might not be able + // Note: userlogout link must always contain an & character, otherwise we might not be able // to detect a buggy precaching proxy (T19790) - $title->isSpecial( 'Preferences' ) ? 'noreturnto' : $returnto ), + ( $title->isSpecial( 'Preferences' ) ? [] : $returnto ) + + [ 'logoutToken' => $this->getUser()->getEditToken( 'logoutToken', $this->getRequest() ) ] ), 'active' => false ]; } @@ -729,7 +767,7 @@ class SkinTemplate extends Skin { } } - Hooks::run( 'PersonalUrls', [ &$personal_urls, &$title, $this ] ); + Hooks::runWithoutAbort( 'PersonalUrls', [ &$personal_urls, &$title, $this ] ); return $personal_urls; } @@ -749,8 +787,10 @@ class SkinTemplate extends Skin { if ( $selected ) { $classes[] = 'selected'; } + $exists = true; if ( $checkEdit && !$title->isKnown() ) { $classes[] = 'new'; + $exists = false; if ( $query !== '' ) { $query = 'action=edit&redlink=1&' . $query; } else { @@ -788,6 +828,7 @@ class SkinTemplate extends Skin { 'class' => implode( ' ', $classes ), 'text' => $text, 'href' => $title->getLocalURL( $query ), + 'exists' => $exists, 'primary' => true ]; if ( $linkClass !== '' ) { $result['link-class'] = $linkClass; @@ -1095,7 +1136,10 @@ class SkinTemplate extends Skin { // Avoid PHP 7.1 warning of passing $this by reference $skinTemplate = $this; - Hooks::run( 'SkinTemplateNavigation', [ &$skinTemplate, &$content_navigation ] ); + Hooks::runWithoutAbort( + 'SkinTemplateNavigation', + [ &$skinTemplate, &$content_navigation ] + ); if ( $userCanRead && !$wgDisableLangConversion ) { $pageLang = $title->getPageLanguage(); @@ -1122,8 +1166,8 @@ class SkinTemplate extends Skin { 'class' => ( $code == $preferred ) ? 'selected' : false, 'text' => $varname, 'href' => $title->getLocalURL( [ 'variant' => $code ] + $params ), - 'lang' => wfBCP47( $code ), - 'hreflang' => wfBCP47( $code ), + 'lang' => LanguageCode::bcp47( $code ), + 'hreflang' => LanguageCode::bcp47( $code ), ]; } } @@ -1139,14 +1183,15 @@ class SkinTemplate extends Skin { // Avoid PHP 7.1 warning of passing $this by reference $skinTemplate = $this; - Hooks::run( 'SkinTemplateNavigation::SpecialPage', + Hooks::runWithoutAbort( 'SkinTemplateNavigation::SpecialPage', [ &$skinTemplate, &$content_navigation ] ); } // Avoid PHP 7.1 warning of passing $this by reference $skinTemplate = $this; // Equiv to SkinTemplateContentActions - Hooks::run( 'SkinTemplateNavigation::Universal', [ &$skinTemplate, &$content_navigation ] ); + Hooks::runWithoutAbort( 'SkinTemplateNavigation::Universal', + [ &$skinTemplate, &$content_navigation ] ); // Setup xml ids and tooltip info foreach ( $content_navigation as $section => &$links ) {