| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
use MediaWiki\ResourceLoader\SkinModule; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
class GreyStuffTemplate extends BaseTemplate { |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public function execute() { |
| 27 |
|
| 28 |
$this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(); |
| 29 |
|
| 30 |
|
| 31 |
if ( isset( $this->data['content_navigation']['actions']['watch'] ) ) { |
| 32 |
$this->data['content_navigation']['views2']['watch'] |
| 33 |
= $this->data['content_navigation']['actions']['watch']; |
| 34 |
unset( $this->data['content_navigation']['actions']['watch'] ); |
| 35 |
} |
| 36 |
if ( isset( $this->data['content_navigation']['actions']['unwatch'] ) ) { |
| 37 |
$this->data['content_navigation']['views2']['unwatch'] |
| 38 |
= $this->data['content_navigation']['actions']['unwatch']; |
| 39 |
unset( $this->data['content_navigation']['actions']['unwatch'] ); |
| 40 |
} |
| 41 |
if ( isset( $this->data['content_navigation']['views']['history'] ) ) { |
| 42 |
$this->data['sidebar']['TOOLBOX']['history'] = $this->data['content_navigation']['views']['history']; |
| 43 |
$this->data['sidebar']['TOOLBOX']['history']['text'] = $this->getMsg( 'greystuff-history' )->text(); |
| 44 |
unset( $this->data['content_navigation']['views']['history'] ); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
$html = ''; |
| 49 |
|
| 50 |
$html .= Html::openElement( 'div', [ 'id' => 'globalWrapper' ] ); |
| 51 |
|
| 52 |
$html .= Html::rawElement( |
| 53 |
'div', |
| 54 |
[ 'id' => 'header-container', 'lang' => $this->get( 'userlang' ), 'dir' => $this->get( 'dir' ) ], |
| 55 |
Html::rawElement( 'div', [ 'id' => 'header-top-container' ], |
| 56 |
Html::rawElement( 'div', [ 'id' => 'header-top' ], |
| 57 |
Html::element( 'a', [ 'href' => '#footer-navigation', 'id' => 'jump-to-end' ] ) . |
| 58 |
Html::rawElement( 'div', [ 'id' => 'main-banner' ], $this->getBanner() ) . |
| 59 |
Html::element( 'div', [ 'id' => 'menus-cover' ] ) . |
| 60 |
Html::element( 'div', [ 'id' => 'main-menu-toggle' ] ) . |
| 61 |
Html::element( 'div', [ 'id' => 'personal-menu-toggle' ] ) . |
| 62 |
Html::element( 'div', [ 'id' => 'tools-menu-toggle' ] ) . |
| 63 |
|
| 64 |
$this->getPersonalNavigation() . |
| 65 |
Html::element( 'div', [ 'class' => 'mobileClear' ] ) . |
| 66 |
$this->getSearch() . |
| 67 |
$this->getClear() |
| 68 |
) |
| 69 |
) |
| 70 |
); |
| 71 |
|
| 72 |
$html .= $this->getClear(); |
| 73 |
|
| 74 |
$html .= Html::rawElement( 'div', [ 'id' => 'header-navigation-container' ], |
| 75 |
Html::rawElement( 'div', [ 'id' => 'header-navigation' ], |
| 76 |
$this->getMainNavigation() |
| 77 |
) |
| 78 |
); |
| 79 |
|
| 80 |
$html .= Html::rawElement( 'div', [ 'id' => 'content-container' ], |
| 81 |
Html::rawElement( 'div', [ 'id' => 'content', 'class' => 'mw-body-primary', 'role' => 'main' ], |
| 82 |
Html::element( 'a', [ 'id' => 'top' ] ) . |
| 83 |
$this->getSiteNotice() . |
| 84 |
$this->getSubtitle() . |
| 85 |
$this->getContentHeader() . |
| 86 |
|
| 87 |
Html::element( 'div', [ 'id' => 'content-header-inner' ] ) . |
| 88 |
|
| 89 |
$this->getClear() . |
| 90 |
|
| 91 |
Html::rawElement( 'div', [ 'id' => 'bodyContent', 'class' => 'mw-body-content' ], |
| 92 |
Html::rawElement( 'div', [ 'id' => 'siteSub' ], $this->getMsg( 'tagline' ) ) . |
| 93 |
$this->get( 'bodytext' ) . |
| 94 |
$this->getClear() |
| 95 |
) . |
| 96 |
$this->getAfterContent() |
| 97 |
) |
| 98 |
); |
| 99 |
|
| 100 |
$html .= Html::rawElement( 'div', [ 'id' => 'footer' ], |
| 101 |
Html::rawElement( 'div', [ 'id' => 'footer-banner' ], $this->getBanner( 'p-banner-footer' ) ) . |
| 102 |
Html::rawElement( 'div', [ 'id' => 'footer-navigation' ], |
| 103 |
Html::element( 'a', [ 'href' => '#header-container', 'id' => 'return-to-top' ] ) . |
| 104 |
$this->getMainNavigation( 'f' ) |
| 105 |
) . |
| 106 |
$this->getClear() . |
| 107 |
$this->getFooterBlock( [ 'id' => 'footer-bottom' ] ) |
| 108 |
); |
| 109 |
|
| 110 |
echo $html; |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
protected function getPortlet( $name, $content, $msg = null, $setOptions = [] ) { |
| 126 |
|
| 127 |
$options = $setOptions + [ |
| 128 |
|
| 129 |
'id' => 'p-' . $name, |
| 130 |
'class' => [ 'mw-portlet', 'emptyPortlet' => !$content ], |
| 131 |
'extra-classes' => [], |
| 132 |
|
| 133 |
'body-wrapper' => 'div', |
| 134 |
'body-id' => '', |
| 135 |
'body-class' => 'mw-portlet-body', |
| 136 |
'body-extra-classes' => [], |
| 137 |
|
| 138 |
'list-item' => [ 'text-wrapper' => [ 'tag' => 'span' ] ], |
| 139 |
|
| 140 |
'list-prepend' => '', |
| 141 |
'extra-header' => false, |
| 142 |
'incontentlanguage' => false, |
| 143 |
'prefix' => 'p' |
| 144 |
]; |
| 145 |
|
| 146 |
|
| 147 |
if ( $msg === null ) { |
| 148 |
$msg = $name; |
| 149 |
} elseif ( is_array( $msg ) ) { |
| 150 |
$msgString = array_shift( $msg ); |
| 151 |
$msgParams = $msg; |
| 152 |
$msg = $msgString; |
| 153 |
} |
| 154 |
if ( $options['incontentlanguage'] ) { |
| 155 |
$msgObj = $this->getMsg( $msg )->inContentLanguage(); |
| 156 |
} else { |
| 157 |
$msgObj = $this->getMsg( $msg ); |
| 158 |
} |
| 159 |
if ( $msgObj->exists() ) { |
| 160 |
if ( !empty( $msgParams ) ) { |
| 161 |
$msgString = $this->getMsg( $msg, $msgParams )->parse(); |
| 162 |
} else { |
| 163 |
$msgString = $msgObj->parse(); |
| 164 |
} |
| 165 |
} else { |
| 166 |
$msgString = htmlspecialchars( $msg ); |
| 167 |
} |
| 168 |
|
| 169 |
$labelId = Sanitizer::escapeIdForAttribute( "{$options['prefix']}-$name-label" ); |
| 170 |
|
| 171 |
if ( is_array( $content ) ) { |
| 172 |
if ( !count( $content ) ) { |
| 173 |
return ''; |
| 174 |
} |
| 175 |
|
| 176 |
$contentText = ''; |
| 177 |
if ( $options['extra-header'] ) { |
| 178 |
$contentText .= Html::rawElement( 'h3', [], $msgString ); |
| 179 |
} |
| 180 |
|
| 181 |
$contentText .= Html::openElement( 'ul', |
| 182 |
[ 'lang' => $this->get( 'userlang' ), 'dir' => $this->get( 'dir' ) ] |
| 183 |
); |
| 184 |
$contentText .= $options['list-prepend']; |
| 185 |
foreach ( $content as $key => $item ) { |
| 186 |
$contentText .= $this->makeListItem( $key, $item, $options['list-item'] ); |
| 187 |
} |
| 188 |
$contentText .= Html::closeElement( 'ul' ); |
| 189 |
} else { |
| 190 |
$contentText = $content; |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
$divOptions = [ |
| 195 |
'role' => 'navigation', |
| 196 |
'class' => $this->mergeClasses( $options['class'], $options['extra-classes'] ), |
| 197 |
'id' => Sanitizer::escapeIdForAttribute( $options['id'] ), |
| 198 |
'title' => Linker::titleAttrib( $options['id'] ), |
| 199 |
'aria-labelledby' => $labelId, |
| 200 |
]; |
| 201 |
|
| 202 |
$labelOptions = [ |
| 203 |
'id' => $labelId, |
| 204 |
'lang' => $this->get( 'userlang' ), |
| 205 |
'dir' => $this->get( 'dir' ) |
| 206 |
]; |
| 207 |
|
| 208 |
|
| 209 |
if ( $options['body-wrapper'] !== 'none' ) { |
| 210 |
$bodyDivOptions = [ 'class' => $this->mergeClasses( |
| 211 |
$options['body-class'], |
| 212 |
$options['body-extra-classes'] |
| 213 |
) ]; |
| 214 |
if ( strlen( $options['body-id'] ) ) { |
| 215 |
$bodyDivOptions['id'] = $options['body-id']; |
| 216 |
} |
| 217 |
$body = Html::rawElement( $options['body-wrapper'], $bodyDivOptions, |
| 218 |
$contentText . |
| 219 |
$this->getSkin()->getAfterPortlet( $name ) |
| 220 |
); |
| 221 |
} else { |
| 222 |
$body = $contentText . $this->getSkin()->getAfterPortlet( $name ); |
| 223 |
} |
| 224 |
|
| 225 |
$html = Html::rawElement( 'div', $divOptions, |
| 226 |
Html::rawElement( 'h3', $labelOptions, $msgString ) . |
| 227 |
$body |
| 228 |
); |
| 229 |
|
| 230 |
return $html; |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
protected function mergeClasses( $class, $extraClasses ) { |
| 245 |
if ( !is_array( $class ) ) { |
| 246 |
$class = [ $class ]; |
| 247 |
} |
| 248 |
if ( !is_array( $extraClasses ) ) { |
| 249 |
$extraClasses = [ $extraClasses ]; |
| 250 |
} |
| 251 |
|
| 252 |
return array_merge( $class, $extraClasses ); |
| 253 |
} |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
protected function getContentHeader() { |
| 261 |
$html = Html::openElement( 'div', [ 'id' => 'content-header' ] ); |
| 262 |
|
| 263 |
$html .= Html::rawElement( |
| 264 |
'h1', |
| 265 |
[ 'id' => 'firstHeading', 'class' => 'firstHeading', 'lang' => $this->get( 'pageLanguage' ) ], |
| 266 |
$this->get( 'title' ) |
| 267 |
); |
| 268 |
$html .= Html::element( 'div', [ 'class' => 'mobileClear' ] ) . |
| 269 |
$this->getIndicators() . |
| 270 |
Html::rawElement( 'div', [ 'id' => 'page-namespaces' ], |
| 271 |
$this->getPortlet( 'namespaces', $this->data['content_navigation']['namespaces'] ) |
| 272 |
); |
| 273 |
|
| 274 |
$pageTools = Html::openElement( 'div', [ 'id' => 'page-tools' ] ); |
| 275 |
$pageTools .= $this->getPortlet( |
| 276 |
'views', |
| 277 |
$this->data['content_navigation']['views'] |
| 278 |
); |
| 279 |
$pageTools .= $this->getPortlet( |
| 280 |
'actions', |
| 281 |
$this->data['content_navigation']['actions'], |
| 282 |
null, |
| 283 |
[ 'body-extra-classes' => [ 'dropdown' ] ] |
| 284 |
); |
| 285 |
if ( isset( $this->data['content_navigation']['views2'] ) ) { |
| 286 |
$pageTools .= $this->getPortlet( |
| 287 |
'more-actions', |
| 288 |
$this->data['content_navigation']['views2'], |
| 289 |
'actions' |
| 290 |
); |
| 291 |
} |
| 292 |
$pageTools .= Html::closeElement( 'div' ); |
| 293 |
|
| 294 |
$html .= $pageTools; |
| 295 |
$html .= Html::closeElement( 'div' ); |
| 296 |
|
| 297 |
return $html; |
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
protected function getMainNavigation( $idPrefix = '' ) { |
| 308 |
$sidebar = $this->data['sidebar']; |
| 309 |
$toolbox = $sidebar['TOOLBOX']; |
| 310 |
$languageUrls = $sidebar['LANGUAGES']; |
| 311 |
$sidebar['SEARCH'] = false; |
| 312 |
$sidebar['TOOLBOX'] = false; |
| 313 |
$sidebar['LANGUAGES'] = false; |
| 314 |
|
| 315 |
|
| 316 |
$skin = $this->getSkin(); |
| 317 |
$title = $skin->getTitle(); |
| 318 |
$toolbox['purge'] = [ |
| 319 |
'text' => $this->getMsg( 'greystuff-purge' )->text(), |
| 320 |
'id' => 't-purge', |
| 321 |
'href' => $title->getLocalURL( [ 'action' => 'purge' ] ), |
| 322 |
'rel' => 'nofollow' |
| 323 |
]; |
| 324 |
|
| 325 |
$html = ''; |
| 326 |
if ( $idPrefix !== '' ) { |
| 327 |
foreach ( $toolbox as $item => $details ) { |
| 328 |
$toolbox[$item]['id'] = $idPrefix . $details['id']; |
| 329 |
} |
| 330 |
} |
| 331 |
|
| 332 |
|
| 333 |
$mainBlock = ''; |
| 334 |
foreach ( $sidebar as $name => $content ) { |
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
if ( $content === false || !is_array( $content ) ) { |
| 339 |
continue; |
| 340 |
} |
| 341 |
|
| 342 |
$name = (string)$name; |
| 343 |
|
| 344 |
if ( $idPrefix !== '' ) { |
| 345 |
foreach ( $content as $item => $details ) { |
| 346 |
$content[$item]['id'] = $idPrefix . $details['id']; |
| 347 |
} |
| 348 |
} |
| 349 |
$mainBlock .= $this->getPortlet( $name, $content, null, [ |
| 350 |
'body-extra-classes' => [ 'dropdown' ], |
| 351 |
'id' => $idPrefix . 'p-' . $name, |
| 352 |
'prefix' => $idPrefix . 'p' |
| 353 |
] ); |
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
$toolsBlock = ''; |
| 358 |
if ( $languageUrls || $this->getSkin()->getAfterPortlet( 'lang' ) !== '' ) { |
| 359 |
$toolsBlock .= $this->getPortlet( 'lang', $languageUrls, 'otherlanguages', [ |
| 360 |
'body-extra-classes' => [ 'dropdown' ], |
| 361 |
'id' => $idPrefix . 'p-lang', |
| 362 |
'prefix' => $idPrefix . 'p' |
| 363 |
] ); |
| 364 |
} |
| 365 |
if ( isset( $this->data['variant_urls'] ) && $this->data['variant_urls'] !== false ) { |
| 366 |
$toolsBlock .= $this->getPortlet( 'variants', $this->data['variant_urls'], null, [ |
| 367 |
'body-extra-classes' => [ 'dropdown' ], |
| 368 |
'id' => $idPrefix . 'p-variants', |
| 369 |
'prefix' => $idPrefix . 'p' |
| 370 |
] ); |
| 371 |
} |
| 372 |
$toolsBlock .= $this->getPortlet( 'tbx', $toolbox, 'toolbox', [ |
| 373 |
'body-extra-classes' => [ 'dropdown' ], |
| 374 |
'id' => $idPrefix . 'p-tbx', |
| 375 |
'prefix' => $idPrefix . 'p' |
| 376 |
] ); |
| 377 |
|
| 378 |
$html .= Html::rawElement( 'div', [ 'class' => 'navigation' ], $mainBlock ); |
| 379 |
$html .= Html::rawElement( 'div', [ 'class' => 'navigation-tools' ], $toolsBlock ); |
| 380 |
|
| 381 |
return $html; |
| 382 |
} |
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
protected function getBanner( $id = 'p-banner' ) { |
| 396 |
$config = $this->getSkin()->getContext()->getConfig(); |
| 397 |
$logos = SkinModule::getAvailableLogos( $config ); |
| 398 |
$html = ''; |
| 399 |
|
| 400 |
if ( $config->get( 'GreyStuffUseLogoImage' ) ) { |
| 401 |
if ( !isset( $logos['icon'] ) ) { |
| 402 |
|
| 403 |
$html .= Html::rawElement( 'div', [ 'class' => 'p-logo', 'role' => 'banner' ], |
| 404 |
Html::element( 'a', array_merge( [ |
| 405 |
'class' => 'mw-wiki-logo', |
| 406 |
'href' => $this->data['nav_urls']['mainpage']['href'] ], |
| 407 |
Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) |
| 408 |
) ) |
| 409 |
); |
| 410 |
|
| 411 |
|
| 412 |
$html .= Html::openElement( 'a', [ 'href' => $this->data['nav_urls']['mainpage']['href'] ] ); |
| 413 |
} else { |
| 414 |
$html .= Html::openElement( 'a', array_merge( |
| 415 |
[ 'href' => $this->data['nav_urls']['mainpage']['href'] ], |
| 416 |
Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) |
| 417 |
) ); |
| 418 |
$html .= Html::element( 'img', [ 'src' => $logos['icon'], 'class' => 'p-logo' ] ); |
| 419 |
} |
| 420 |
} else { |
| 421 |
|
| 422 |
$html .= Html::openElement( 'a', array_merge( |
| 423 |
[ 'href' => $this->data['nav_urls']['mainpage']['href'] ], |
| 424 |
Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) |
| 425 |
) ); |
| 426 |
} |
| 427 |
|
| 428 |
$subtitleText = $this->getMsg( 'sitesubtitle' )->inContentLanguage()->text(); |
| 429 |
$wordmarkText = $this->getMsg( 'sitetitle' )->inContentLanguage()->text(); |
| 430 |
|
| 431 |
$bannerClass = [ 'mw-portlet', 'p-banner' ]; |
| 432 |
if ( isset( $logos['tagline'] ) ) { |
| 433 |
$taglineData = $logos['tagline']; |
| 434 |
$subtitle = Html::rawElement( 'div', [ 'class' => 'sitesubtitle' ], |
| 435 |
Html::element( 'img', [ |
| 436 |
'src' => $taglineData['src'], |
| 437 |
'height' => $taglineData['height'] ?? null, |
| 438 |
'width' => $taglineData['width'] ?? null, |
| 439 |
'alt' => $subtitleText |
| 440 |
] ) |
| 441 |
); |
| 442 |
$bannerClass[] = 'full-banner'; |
| 443 |
} elseif ( strlen( $subtitleText ) > 1 ) { |
| 444 |
$subtitle = Html::element( 'div', [ 'class' => 'sitesubtitle' ], $subtitleText ); |
| 445 |
$bannerClass[] = 'full-banner'; |
| 446 |
} else { |
| 447 |
$subtitle = ''; |
| 448 |
$bannerClass[] = 'title-banner'; |
| 449 |
} |
| 450 |
|
| 451 |
|
| 452 |
if ( isset( $logos['wordmark'] ) ) { |
| 453 |
$wordmarkData = $logos['wordmark']; |
| 454 |
$wordmark = Html::element( 'img', [ |
| 455 |
'src' => $wordmarkData['src'], |
| 456 |
'height' => $wordmarkData['height'] ?? null, |
| 457 |
'width' => $wordmarkData['width'] ?? null, |
| 458 |
'alt' => $wordmarkText |
| 459 |
] ); |
| 460 |
} else { |
| 461 |
$wordmark = Html::element( 'div', [ 'class' => 'wordmark-text' ], $wordmarkText ); |
| 462 |
} |
| 463 |
|
| 464 |
$html .= Html::rawElement( 'div', [ 'class' => $bannerClass, 'id' => $id ], |
| 465 |
Html::rawElement( 'div', [ 'class' => 'sitetitle', 'role' => 'banner' ], |
| 466 |
$wordmark . $subtitle |
| 467 |
) |
| 468 |
); |
| 469 |
|
| 470 |
$html .= Html::closeElement( 'a' ); |
| 471 |
|
| 472 |
return $html; |
| 473 |
} |
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
protected function getPersonalNavigation() { |
| 481 |
$skin = $this->getSkin(); |
| 482 |
$user = $skin->getUser(); |
| 483 |
$personalTools = $skin->getPersonalToolsForMakeListItem( $this->get( 'personal_urls' ) ); |
| 484 |
|
| 485 |
$html = ''; |
| 486 |
$extraTools = []; |
| 487 |
|
| 488 |
|
| 489 |
if ( isset( $personalTools['notifications-alert'] ) ) { |
| 490 |
$extraTools['notifications-alert'] = $personalTools['notifications-alert']; |
| 491 |
unset( $personalTools['notifications-alert'] ); |
| 492 |
} |
| 493 |
if ( isset( $personalTools['notifications-notice'] ) ) { |
| 494 |
$extraTools['notifications-notice'] = $personalTools['notifications-notice']; |
| 495 |
unset( $personalTools['notifications-notice'] ); |
| 496 |
} |
| 497 |
|
| 498 |
if ( $user->isRegistered() ) { |
| 499 |
$headerMsg = [ 'greystuff-loggedinas', $user->getName() ]; |
| 500 |
} else { |
| 501 |
$headerMsg = 'greystuff-notloggedin'; |
| 502 |
} |
| 503 |
|
| 504 |
$html .= Html::openElement( 'div', [ 'id' => 'p-personal-container' ] ); |
| 505 |
|
| 506 |
if ( isset( $personalTools['userpage'] ) ) { |
| 507 |
$personalTools['userpage']['links'][0]['text'] = $this->getMsg( 'greystuff-userpage' )->text(); |
| 508 |
} |
| 509 |
if ( isset( $personalTools['mytalk'] ) ) { |
| 510 |
$personalTools['mytalk']['links'][0]['text'] = $this->getMsg( 'greystuff-talkpage' )->text(); |
| 511 |
} |
| 512 |
if ( isset( $personalTools['anonuserpage'] ) ) { |
| 513 |
|
| 514 |
unset( $personalTools['anonuserpage'] ); |
| 515 |
} |
| 516 |
|
| 517 |
|
| 518 |
if ( $extraTools ) { |
| 519 |
$iconList = ''; |
| 520 |
foreach ( $extraTools as $key => $item ) { |
| 521 |
$iconList .= $skin->makeListItem( $key, $item ); |
| 522 |
} |
| 523 |
|
| 524 |
$html .= Html::rawElement( |
| 525 |
'div', |
| 526 |
[ 'id' => 'p-personal-extra', 'class' => 'p-body' ], |
| 527 |
Html::rawElement( 'ul', [], $iconList ) |
| 528 |
); |
| 529 |
} |
| 530 |
|
| 531 |
$html .= $this->getPortlet( 'personal', $personalTools, $headerMsg, |
| 532 |
[ 'body-extra-classes' => [ 'dropdown' ] ] |
| 533 |
); |
| 534 |
|
| 535 |
$html .= Html::closeElement( 'div' ); |
| 536 |
|
| 537 |
return $html; |
| 538 |
} |
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
protected function getSearch() { |
| 546 |
$skin = $this->getSkin(); |
| 547 |
$html = ''; |
| 548 |
|
| 549 |
$html .= Html::openElement( 'div', [ 'class' => 'mw-portlet', 'id' => 'p-search', 'role' => 'search' ] ); |
| 550 |
|
| 551 |
$html .= Html::rawElement( |
| 552 |
'h3', |
| 553 |
[ 'lang' => $this->get( 'userlang' ), 'dir' => $this->get( 'dir' ) ], |
| 554 |
Html::rawElement( 'label', [ 'for' => 'searchInput' ], $this->getMsg( 'search' ) ) |
| 555 |
); |
| 556 |
|
| 557 |
$html .= Html::rawElement( 'form', [ 'action' => $this->get( 'wgScript' ), 'id' => 'searchform' ], |
| 558 |
Html::rawElement( 'div', [ 'id' => 'simpleSearch' ], |
| 559 |
Html::rawElement( 'div', [ 'id' => 'searchInput-container-container' ], |
| 560 |
Html::rawElement( 'div', [ 'id' => 'searchInput-container' ], |
| 561 |
$skin->makeSearchInput( [ 'id' => 'searchInput', 'type' => 'text' ] ) |
| 562 |
) |
| 563 |
) . |
| 564 |
$skin->makeSearchButton( 'go', [ |
| 565 |
'id' => 'searchGoButton', |
| 566 |
'class' => 'searchButton', |
| 567 |
'value' => $this->getMsg( 'searcharticle' )->text() |
| 568 |
] ) . |
| 569 |
Html::hidden( 'title', $this->get( 'searchtitle' ) ) |
| 570 |
) |
| 571 |
); |
| 572 |
|
| 573 |
$html .= Html::closeElement( 'div' ); |
| 574 |
|
| 575 |
return $html; |
| 576 |
} |
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
protected function getSiteNotice() { |
| 582 |
$html = ''; |
| 583 |
|
| 584 |
if ( $this->data['sitenotice'] ) { |
| 585 |
$html = Html::rawElement( 'div', [ 'id' => 'siteNotice' ], $this->get( 'sitenotice' ) ); |
| 586 |
} |
| 587 |
|
| 588 |
return $html; |
| 589 |
} |
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
protected function getSubtitle() { |
| 598 |
$html = ''; |
| 599 |
|
| 600 |
if ( $this->data['subtitle'] || $this->data['undelete'] || $this->data['newtalk'] ) { |
| 601 |
$html .= Html::openElement( 'div', [ 'id' => 'content-top-stuff' ] ); |
| 602 |
$html .= Html::rawElement( 'div', [ |
| 603 |
'id' => 'contentSub', |
| 604 |
'lang' => $this->get( 'userlang' ), |
| 605 |
'dir' => $this->get( 'dir' ) |
| 606 |
], |
| 607 |
$this->get( 'subtitle' ) |
| 608 |
); |
| 609 |
if ( $this->data['undelete'] ) { |
| 610 |
$html .= Html::rawElement( 'div', [ 'id' => 'contentSub2' ], |
| 611 |
$this->get( 'undelete' ) |
| 612 |
); |
| 613 |
} |
| 614 |
if ( $this->data['newtalk'] ) { |
| 615 |
$html .= Html::rawElement( 'div', [ 'class' => 'usermessage' ], |
| 616 |
$this->get( 'newtalk' ) |
| 617 |
); |
| 618 |
} |
| 619 |
$html .= Html::closeElement( 'div' ); |
| 620 |
} |
| 621 |
|
| 622 |
return $html; |
| 623 |
} |
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
protected function getAfterContent() { |
| 632 |
$html = ''; |
| 633 |
|
| 634 |
if ( $this->data['catlinks'] || $this->data['dataAfterContent'] ) { |
| 635 |
$html .= Html::openElement( 'div', [ 'id' => 'content-bottom-stuff' ] ); |
| 636 |
if ( $this->data['catlinks'] ) { |
| 637 |
$html .= $this->get( 'catlinks' ) . $this->getClear(); |
| 638 |
} |
| 639 |
if ( $this->data['dataAfterContent'] ) { |
| 640 |
$html .= $this->get( 'dataAfterContent' ); |
| 641 |
} |
| 642 |
$html .= Html::closeElement( 'div' ); |
| 643 |
} |
| 644 |
|
| 645 |
return $html; |
| 646 |
} |
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
protected function getFooterBlock( $setOptions = [] ) { |
| 664 |
|
| 665 |
$options = $setOptions + [ |
| 666 |
'id' => 'footer', |
| 667 |
'class' => 'mw-footer', |
| 668 |
'order' => 'iconsfirst', |
| 669 |
'link-prefix' => 'footer', |
| 670 |
'link-style' => null |
| 671 |
]; |
| 672 |
|
| 673 |
|
| 674 |
'@phan-var array{id:string,class:string,order:string,link-prefix:string,link-style:?string} $options'; |
| 675 |
|
| 676 |
$validFooterIcons = $this->get( 'footericons' ); |
| 677 |
$validFooterLinks = $this->getFooterLinks( $options['link-style'] ); |
| 678 |
|
| 679 |
$html = ''; |
| 680 |
|
| 681 |
$html .= Html::openElement( 'div', [ |
| 682 |
'id' => $options['id'], |
| 683 |
'class' => $options['class'], |
| 684 |
'role' => 'contentinfo', |
| 685 |
'lang' => $this->get( 'userlang' ), |
| 686 |
'dir' => $this->get( 'dir' ) |
| 687 |
] ); |
| 688 |
|
| 689 |
$iconsHTML = ''; |
| 690 |
if ( count( $validFooterIcons ) > 0 ) { |
| 691 |
$skin = $this->getSkin(); |
| 692 |
$iconsHTML .= Html::openElement( 'ul', [ 'id' => "{$options['link-prefix']}-icons" ] ); |
| 693 |
foreach ( $validFooterIcons as $blockName => &$footerIcons ) { |
| 694 |
$iconsHTML .= Html::openElement( 'li', [ |
| 695 |
'id' => Sanitizer::escapeIdForAttribute( |
| 696 |
"{$options['link-prefix']}-{$blockName}ico" |
| 697 |
), |
| 698 |
'class' => 'footer-icons' |
| 699 |
] ); |
| 700 |
foreach ( $footerIcons as $footerIconKey => $icon ) { |
| 701 |
if ( !isset( $footerIcon['src'] ) ) { |
| 702 |
unset( $footerIcons[$footerIconKey] ); |
| 703 |
} |
| 704 |
$iconsHTML .= $skin->makeFooterIcon( $icon ); |
| 705 |
} |
| 706 |
$iconsHTML .= Html::closeElement( 'li' ); |
| 707 |
} |
| 708 |
$iconsHTML .= Html::closeElement( 'ul' ); |
| 709 |
} |
| 710 |
|
| 711 |
$linksHTML = ''; |
| 712 |
if ( count( $validFooterLinks ) > 0 ) { |
| 713 |
if ( $options['link-style'] === 'flat' ) { |
| 714 |
$linksHTML .= Html::openElement( 'ul', [ |
| 715 |
'id' => "{$options['link-prefix']}-list", |
| 716 |
'class' => 'footer-places' |
| 717 |
] ); |
| 718 |
foreach ( $validFooterLinks as $link ) { |
| 719 |
$linksHTML .= Html::rawElement( |
| 720 |
'li', |
| 721 |
[ 'id' => Sanitizer::escapeIdForAttribute( $link ) ], |
| 722 |
$this->get( $link ) |
| 723 |
); |
| 724 |
} |
| 725 |
$linksHTML .= Html::closeElement( 'ul' ); |
| 726 |
} else { |
| 727 |
$linksHTML .= Html::openElement( 'div', [ 'id' => "{$options['link-prefix']}-list" ] ); |
| 728 |
foreach ( $validFooterLinks as $category => $links ) { |
| 729 |
$linksHTML .= Html::openElement( 'ul', |
| 730 |
[ 'id' => Sanitizer::escapeIdForAttribute( |
| 731 |
"{$options['link-prefix']}-{$category}" |
| 732 |
) ] |
| 733 |
); |
| 734 |
foreach ( $links as $link ) { |
| 735 |
$linksHTML .= Html::rawElement( |
| 736 |
'li', |
| 737 |
[ 'id' => Sanitizer::escapeIdForAttribute( |
| 738 |
"{$options['link-prefix']}-{$category}-{$link}" |
| 739 |
) ], |
| 740 |
$this->get( $link ) |
| 741 |
); |
| 742 |
} |
| 743 |
$linksHTML .= Html::closeElement( 'ul' ); |
| 744 |
} |
| 745 |
$linksHTML .= Html::closeElement( 'div' ); |
| 746 |
} |
| 747 |
} |
| 748 |
|
| 749 |
if ( $options['order'] === 'iconsfirst' ) { |
| 750 |
$html .= $iconsHTML . $linksHTML; |
| 751 |
} else { |
| 752 |
$html .= $linksHTML . $iconsHTML; |
| 753 |
} |
| 754 |
|
| 755 |
$html .= $this->getClear() . Html::closeElement( 'div' ); |
| 756 |
|
| 757 |
return $html; |
| 758 |
} |
| 759 |
} |