| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
namespace MonoBook; |
| 24 |
|
| 25 |
use MediaWiki\Hook\SkinTemplateNavigation__UniversalHook; |
| 26 |
use MediaWiki\Output\Hook\OutputPageBodyAttributesHook; |
| 27 |
use MediaWiki\Output\OutputPage; |
| 28 |
use Skin; |
| 29 |
use SkinTemplate; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
class Hooks implements |
| 35 |
OutputPageBodyAttributesHook, |
| 36 |
SkinTemplateNavigation__UniversalHook |
| 37 |
{ |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public function onOutputPageBodyAttributes( $out, $skin, &$bodyAttrs ): void { |
| 50 |
$lang = $skin->getLanguage(); |
| 51 |
if ( |
| 52 |
$skin->getSkinName() === 'monobook' && ( |
| 53 |
$lang->getCode() === 'de' || |
| 54 |
in_array( 'de', $lang->getFallbackLanguages() ) |
| 55 |
) |
| 56 |
) { |
| 57 |
$bodyAttrs['class'] .= ' monobook-capitalize-all-nouns'; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
public function onSkinTemplateNavigation__Universal( $skin, &$content_navigation ): void { |
| 68 |
$title = $skin->getTitle(); |
| 69 |
if ( $skin->getSkinName() === 'monobook' ) { |
| 70 |
$tabs = []; |
| 71 |
$namespaces = $content_navigation['namespaces']; |
| 72 |
foreach ( $namespaces as $nsid => $attribs ) { |
| 73 |
$id = $nsid . '-mobile'; |
| 74 |
$tabs[$id] = [] + $attribs; |
| 75 |
$tabs[$id]['title'] = $attribs['text']; |
| 76 |
$tabs[$id]['id'] = $id; |
| 77 |
} |
| 78 |
|
| 79 |
if ( !$title->isSpecialPage() ) { |
| 80 |
$tabs['more'] = [ |
| 81 |
'text' => $skin->msg( 'monobook-more-actions' )->text(), |
| 82 |
'href' => '#p-cactions', |
| 83 |
'id' => 'ca-more' |
| 84 |
]; |
| 85 |
} |
| 86 |
|
| 87 |
$tabs['toolbox'] = [ |
| 88 |
'text' => $skin->msg( 'toolbox' )->text(), |
| 89 |
'href' => '#p-tb', |
| 90 |
'id' => 'ca-tools', |
| 91 |
'title' => $skin->msg( 'toolbox' )->text() |
| 92 |
]; |
| 93 |
|
| 94 |
$languages = $skin->getLanguages(); |
| 95 |
if ( count( $languages ) > 0 ) { |
| 96 |
$tabs['languages'] = [ |
| 97 |
'text' => $skin->msg( 'otherlanguages' )->text(), |
| 98 |
'href' => '#p-lang', |
| 99 |
'id' => 'ca-languages', |
| 100 |
'title' => $skin->msg( 'otherlanguages' )->text() |
| 101 |
]; |
| 102 |
} |
| 103 |
|
| 104 |
$content_navigation['cactions-mobile'] = $tabs; |
| 105 |
} |
| 106 |
} |
| 107 |
} |