* @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;
)->text();
}
- $ilInterwikiCodeBCP47 = wfBCP47( $ilInterwikiCode );
+ $ilInterwikiCodeBCP47 = LanguageCode::bcp47( $ilInterwikiCode );
$languageLink = [
'href' => $languageLinkTitle->getFullURL(),
'text' => $ilLangName,
* @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.
$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'
];
'text' => $this->msg( 'mytalk' )->text(),
'href' => &$usertalkUrlDetails['href'],
'class' => $usertalkUrlDetails['exists'] ? false : 'new',
+ 'exists' => $usertalkUrlDetails['exists'],
'active' => ( $usertalkUrlDetails['href'] == $pageurl )
];
$href = self::makeSpecialUrl( 'Preferences' );
$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
];
}
}
}
- Hooks::run( 'PersonalUrls', [ &$personal_urls, &$title, $this ] );
+ Hooks::runWithoutAbort( 'PersonalUrls', [ &$personal_urls, &$title, $this ] );
return $personal_urls;
}
if ( $selected ) {
$classes[] = 'selected';
}
+ $exists = true;
if ( $checkEdit && !$title->isKnown() ) {
$classes[] = 'new';
+ $exists = false;
if ( $query !== '' ) {
$query = 'action=edit&redlink=1&' . $query;
} else {
'class' => implode( ' ', $classes ),
'text' => $text,
'href' => $title->getLocalURL( $query ),
+ 'exists' => $exists,
'primary' => true ];
if ( $linkClass !== '' ) {
$result['link-class'] = $linkClass;
/**
* @todo is this even used?
+ * @param string $name
+ * @param string $urlaction
+ * @return array
*/
function makeArticleUrlDetails( $name, $urlaction = '' ) {
$title = Title::newFromText( $name );
// 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();
'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 ),
];
}
}
// 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 ) {