| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
use MediaWiki\Html\Html; |
| 22 |
use MediaWiki\Language\LanguageCode; |
| 23 |
use MediaWiki\Linker\Linker; |
| 24 |
use MediaWiki\MainConfigNames; |
| 25 |
use MediaWiki\MediaWikiServices; |
| 26 |
use MediaWiki\Request\WebRequest; |
| 27 |
use MediaWiki\SpecialPage\SpecialPage; |
| 28 |
use MediaWiki\Title\Title; |
| 29 |
use MediaWiki\Title\TitleArrayFromResult; |
| 30 |
use MediaWiki\Xml\Xml; |
| 31 |
use Wikimedia\Rdbms\IResultWrapper; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
class ImagePage extends Article { |
| 40 |
use MediaFileTrait; |
| 41 |
|
| 42 |
|
| 43 |
private $displayImg; |
| 44 |
|
| 45 |
|
| 46 |
private $repo; |
| 47 |
|
| 48 |
|
| 49 |
private $fileLoaded; |
| 50 |
|
| 51 |
|
| 52 |
protected $mExtraDescription = false; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
protected function newPage( Title $title ) { |
| 59 |
|
| 60 |
return new WikiFilePage( $title ); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
public function setFile( $file ) { |
| 68 |
$this->getPage()->setFile( $file ); |
| 69 |
$this->displayImg = $file; |
| 70 |
$this->fileLoaded = true; |
| 71 |
} |
| 72 |
|
| 73 |
protected function loadFile() { |
| 74 |
if ( $this->fileLoaded ) { |
| 75 |
return; |
| 76 |
} |
| 77 |
$this->fileLoaded = true; |
| 78 |
|
| 79 |
$this->displayImg = $img = false; |
| 80 |
|
| 81 |
$this->getHookRunner()->onImagePageFindFile( $this, $img, $this->displayImg ); |
| 82 |
if ( !$img ) { |
| 83 |
$services = MediaWikiServices::getInstance(); |
| 84 |
$img = $services->getRepoGroup()->findFile( $this->getTitle() ); |
| 85 |
if ( !$img ) { |
| 86 |
$img = $services->getRepoGroup()->getLocalRepo()->newFile( $this->getTitle() ); |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
$this->getPage()->setFile( $img ); |
| 91 |
if ( !$this->displayImg ) { |
| 92 |
|
| 93 |
$this->displayImg = $img; |
| 94 |
} |
| 95 |
$this->repo = $img->getRepo(); |
| 96 |
} |
| 97 |
|
| 98 |
public function view() { |
| 99 |
$context = $this->getContext(); |
| 100 |
$showEXIF = $context->getConfig()->get( MainConfigNames::ShowEXIF ); |
| 101 |
|
| 102 |
|
| 103 |
if ( $this->viewIsRenderAction ) { |
| 104 |
parent::view(); |
| 105 |
return; |
| 106 |
} |
| 107 |
|
| 108 |
$out = $context->getOutput(); |
| 109 |
$request = $context->getRequest(); |
| 110 |
$diff = $request->getVal( 'diff' ); |
| 111 |
|
| 112 |
if ( $this->getTitle()->getNamespace() !== NS_FILE || ( $diff !== null && $this->isDiffOnlyView() ) ) { |
| 113 |
parent::view(); |
| 114 |
return; |
| 115 |
} |
| 116 |
|
| 117 |
$this->loadFile(); |
| 118 |
|
| 119 |
if ( |
| 120 |
$this->getTitle()->getNamespace() === NS_FILE |
| 121 |
&& $this->getFile()->getRedirected() |
| 122 |
) { |
| 123 |
if ( |
| 124 |
$this->getTitle()->getDBkey() == $this->getFile()->getName() |
| 125 |
|| $diff !== null |
| 126 |
) { |
| 127 |
$request->setVal( 'diffonly', 'true' ); |
| 128 |
} |
| 129 |
|
| 130 |
parent::view(); |
| 131 |
return; |
| 132 |
} |
| 133 |
|
| 134 |
if ( $showEXIF && $this->displayImg->exists() ) { |
| 135 |
|
| 136 |
$formattedMetadata = $this->displayImg->formatMetadata( $this->getContext() ); |
| 137 |
} else { |
| 138 |
$formattedMetadata = false; |
| 139 |
} |
| 140 |
|
| 141 |
if ( !$diff && $this->displayImg->exists() ) { |
| 142 |
$out->addHTML( $this->showTOC( (bool)$formattedMetadata ) ); |
| 143 |
} |
| 144 |
|
| 145 |
if ( !$diff ) { |
| 146 |
$this->openShowImage(); |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
if ( $this->getPage()->getId() ) { |
| 151 |
$out->addHTML( Html::openElement( 'div', [ 'id' => 'mw-imagepage-content' ] ) ); |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
parent::view(); |
| 156 |
$out->addHTML( Html::closeElement( 'div' ) ); |
| 157 |
} else { |
| 158 |
|
| 159 |
$out->setArticleFlag( true ); |
| 160 |
$out->setPageTitle( $this->getTitle()->getPrefixedText() ); |
| 161 |
$this->getPage()->doViewUpdates( |
| 162 |
$context->getAuthority(), |
| 163 |
$this->getOldID() |
| 164 |
); |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
if ( $this->mExtraDescription ) { |
| 169 |
$fol = $context->msg( 'shareddescriptionfollows' ); |
| 170 |
if ( !$fol->isDisabled() ) { |
| 171 |
$out->addWikiTextAsInterface( $fol->plain() ); |
| 172 |
} |
| 173 |
$out->addHTML( |
| 174 |
Html::rawElement( |
| 175 |
'div', |
| 176 |
[ 'id' => 'shared-image-desc' ], |
| 177 |
$this->mExtraDescription |
| 178 |
) . "\n" |
| 179 |
); |
| 180 |
} |
| 181 |
|
| 182 |
$this->closeShowImage(); |
| 183 |
$this->imageHistory(); |
| 184 |
|
| 185 |
|
| 186 |
$out->addHTML( Xml::element( 'h2', |
| 187 |
[ 'id' => 'filelinks' ], |
| 188 |
$context->msg( 'imagelinks' )->text() ) . "\n" ); |
| 189 |
$this->imageDupes(); |
| 190 |
|
| 191 |
|
| 192 |
$this->imageLinks(); |
| 193 |
|
| 194 |
|
| 195 |
$html = ''; |
| 196 |
$this->getHookRunner()->onImagePageAfterImageLinks( $this, $html ); |
| 197 |
if ( $html ) { |
| 198 |
$out->addHTML( $html ); |
| 199 |
} |
| 200 |
|
| 201 |
if ( $formattedMetadata ) { |
| 202 |
$out->addHTML( Xml::element( |
| 203 |
'h2', |
| 204 |
[ 'id' => 'metadata' ], |
| 205 |
$context->msg( 'metadata' )->text() ) . "\n" ); |
| 206 |
$out->wrapWikiTextAsInterface( |
| 207 |
'mw-imagepage-section-metadata', |
| 208 |
$this->makeMetadataTable( $formattedMetadata ) |
| 209 |
); |
| 210 |
$out->addModules( [ 'mediawiki.action.view.metadata' ] ); |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
if ( !$this->repo->isLocal() ) { |
| 215 |
$css = $this->repo->getDescriptionStylesheetUrl(); |
| 216 |
if ( $css ) { |
| 217 |
$out->addStyle( $css ); |
| 218 |
} |
| 219 |
} |
| 220 |
|
| 221 |
$out->addModuleStyles( [ |
| 222 |
'mediawiki.action.view.filepage', |
| 223 |
] ); |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
public function getDisplayedFile() { |
| 230 |
$this->loadFile(); |
| 231 |
return $this->displayImg; |
| 232 |
} |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
protected function showTOC( $metadata ) { |
| 241 |
$r = [ |
| 242 |
Html::rawElement( |
| 243 |
'li', |
| 244 |
[], |
| 245 |
Html::rawElement( |
| 246 |
'a', |
| 247 |
[ 'href' => '#file' ], |
| 248 |
$this->getContext()->msg( 'file-anchor-link' )->escaped() |
| 249 |
) |
| 250 |
), |
| 251 |
Html::rawElement( |
| 252 |
'li', |
| 253 |
[], |
| 254 |
Html::rawElement( |
| 255 |
'a', |
| 256 |
[ 'href' => '#filehistory' ], |
| 257 |
$this->getContext()->msg( 'filehist' )->escaped() |
| 258 |
) |
| 259 |
), |
| 260 |
Html::rawElement( |
| 261 |
'li', |
| 262 |
[], |
| 263 |
Html::rawElement( |
| 264 |
'a', |
| 265 |
[ 'href' => '#filelinks' ], |
| 266 |
$this->getContext()->msg( 'imagelinks' )->escaped() |
| 267 |
) |
| 268 |
), |
| 269 |
]; |
| 270 |
|
| 271 |
$this->getHookRunner()->onImagePageShowTOC( $this, $r ); |
| 272 |
|
| 273 |
if ( $metadata ) { |
| 274 |
$r[] = Html::rawElement( |
| 275 |
'li', |
| 276 |
[], |
| 277 |
Html::rawElement( |
| 278 |
'a', |
| 279 |
[ 'href' => '#metadata' ], |
| 280 |
$this->getContext()->msg( 'metadata' )->escaped() |
| 281 |
) |
| 282 |
); |
| 283 |
} |
| 284 |
|
| 285 |
return Html::rawElement( 'ul', [ |
| 286 |
'id' => 'filetoc', |
| 287 |
'role' => 'navigation' |
| 288 |
], implode( "\n", $r ) ); |
| 289 |
} |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
protected function makeMetadataTable( $metadata ) { |
| 300 |
$r = $this->getContext()->msg( 'metadata-help' )->plain(); |
| 301 |
|
| 302 |
|
| 303 |
$r .= "<table id=\"mw_metadata\" class=\"mw_metadata collapsed\">\n"; |
| 304 |
foreach ( $metadata as $type => $stuff ) { |
| 305 |
foreach ( $stuff as $v ) { |
| 306 |
$class = str_replace( ' ', '_', $v['id'] ); |
| 307 |
if ( $type === 'collapsed' ) { |
| 308 |
$class .= ' mw-metadata-collapsible'; |
| 309 |
} |
| 310 |
$r .= Html::rawElement( 'tr', |
| 311 |
[ 'class' => $class ], |
| 312 |
Html::rawElement( 'th', [], $v['name'] ) |
| 313 |
. Html::rawElement( 'td', [], $v['value'] ) |
| 314 |
); |
| 315 |
} |
| 316 |
} |
| 317 |
$r .= "</table>\n"; |
| 318 |
return $r; |
| 319 |
} |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
private function getLanguageForRendering( WebRequest $request, File $file ) { |
| 330 |
$handler = $file->getHandler(); |
| 331 |
if ( !$handler ) { |
| 332 |
return null; |
| 333 |
} |
| 334 |
|
| 335 |
$requestLanguage = $request->getVal( 'lang' ); |
| 336 |
if ( $requestLanguage === null ) { |
| 337 |
|
| 338 |
|
| 339 |
$services = MediaWikiServices::getInstance(); |
| 340 |
$variantLangCode = $services->getLanguageConverterFactory() |
| 341 |
->getLanguageConverter( $services->getContentLanguage() ) |
| 342 |
->getPreferredVariant(); |
| 343 |
$requestLanguage = LanguageCode::bcp47( $variantLangCode ); |
| 344 |
} |
| 345 |
if ( $handler->validateParam( 'lang', $requestLanguage ) ) { |
| 346 |
return $file->getMatchedLanguage( $requestLanguage ); |
| 347 |
} |
| 348 |
|
| 349 |
return $handler->getDefaultRenderLanguage( $file ); |
| 350 |
} |
| 351 |
|
| 352 |
protected function openShowImage() { |
| 353 |
$context = $this->getContext(); |
| 354 |
$mainConfig = $context->getConfig(); |
| 355 |
$enableUploads = $mainConfig->get( MainConfigNames::EnableUploads ); |
| 356 |
$send404Code = $mainConfig->get( MainConfigNames::Send404Code ); |
| 357 |
$svgMaxSize = $mainConfig->get( MainConfigNames::SVGMaxSize ); |
| 358 |
$enableLegacyMediaDOM = $mainConfig->get( MainConfigNames::ParserEnableLegacyMediaDOM ); |
| 359 |
$this->loadFile(); |
| 360 |
$out = $context->getOutput(); |
| 361 |
$user = $context->getUser(); |
| 362 |
$lang = $context->getLanguage(); |
| 363 |
$sitedir = MediaWikiServices::getInstance()->getContentLanguage()->getDir(); |
| 364 |
$request = $context->getRequest(); |
| 365 |
|
| 366 |
if ( $this->displayImg->exists() ) { |
| 367 |
[ $maxWidth, $maxHeight ] = $this->getImageLimitsFromOption( $user, 'imagesize' ); |
| 368 |
|
| 369 |
|
| 370 |
$page = $request->getIntOrNull( 'page' ); |
| 371 |
if ( $page === null ) { |
| 372 |
$params = []; |
| 373 |
$page = 1; |
| 374 |
} else { |
| 375 |
$params = [ 'page' => $page ]; |
| 376 |
} |
| 377 |
|
| 378 |
$renderLang = $this->getLanguageForRendering( $request, $this->displayImg ); |
| 379 |
if ( $renderLang !== null ) { |
| 380 |
$params['lang'] = $renderLang; |
| 381 |
} |
| 382 |
|
| 383 |
$width_orig = $this->displayImg->getWidth( $page ); |
| 384 |
$width = $width_orig; |
| 385 |
$height_orig = $this->displayImg->getHeight( $page ); |
| 386 |
$height = $height_orig; |
| 387 |
|
| 388 |
$filename = wfEscapeWikiText( $this->displayImg->getName() ); |
| 389 |
$linktext = $filename; |
| 390 |
|
| 391 |
$this->getHookRunner()->onImageOpenShowImageInlineBefore( $this, $out ); |
| 392 |
|
| 393 |
if ( $this->displayImg->allowInlineDisplay() ) { |
| 394 |
if ( |
| 395 |
$this->displayImg->isVectorized() && |
| 396 |
$mainConfig->get( MainConfigNames::SVGNativeRendering ) === true |
| 397 |
) { |
| 398 |
|
| 399 |
$msgsmall = ''; |
| 400 |
} elseif ( $width > $maxWidth || |
| 401 |
$height > $maxHeight || |
| 402 |
$this->displayImg->isVectorized() |
| 403 |
) { |
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
[ $width, $height ] = $this->displayImg->getDisplayWidthHeight( |
| 409 |
$maxWidth, $maxHeight, $page |
| 410 |
); |
| 411 |
$linktext = $context->msg( 'show-big-image' )->escaped(); |
| 412 |
|
| 413 |
$thumbSizes = $this->getThumbSizes( $width_orig, $height_orig ); |
| 414 |
|
| 415 |
$otherSizes = []; |
| 416 |
foreach ( $thumbSizes as $size ) { |
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig ) |
| 426 |
|| ( $this->displayImg->isVectorized() |
| 427 |
&& max( $size[0], $size[1] ) <= $svgMaxSize ) |
| 428 |
) |
| 429 |
&& $size[0] != $width && $size[1] != $height |
| 430 |
&& $size[0] != $maxWidth && $size[1] != $maxHeight |
| 431 |
) { |
| 432 |
$sizeLink = $this->makeSizeLink( $params, $size[0], $size[1] ); |
| 433 |
if ( $sizeLink ) { |
| 434 |
$otherSizes[] = $sizeLink; |
| 435 |
} |
| 436 |
} |
| 437 |
} |
| 438 |
$otherSizes = array_unique( $otherSizes ); |
| 439 |
|
| 440 |
$sizeLinkBigImagePreview = $this->makeSizeLink( $params, $width, $height ); |
| 441 |
$msgsmall = $this->getThumbPrevText( $params, $sizeLinkBigImagePreview ); |
| 442 |
if ( count( $otherSizes ) ) { |
| 443 |
$msgsmall .= ' ' . |
| 444 |
Html::rawElement( |
| 445 |
'span', |
| 446 |
[ 'class' => 'mw-filepage-other-resolutions' ], |
| 447 |
$context->msg( 'show-big-image-other' ) |
| 448 |
->rawParams( $lang->pipeList( $otherSizes ) ) |
| 449 |
->params( count( $otherSizes ) ) |
| 450 |
->parse() |
| 451 |
); |
| 452 |
} |
| 453 |
} elseif ( $width == 0 && $height == 0 ) { |
| 454 |
|
| 455 |
|
| 456 |
$msgsmall = ''; |
| 457 |
} else { |
| 458 |
|
| 459 |
$msgsmall = $this->getContext()->msg( 'file-nohires' )->parse(); |
| 460 |
} |
| 461 |
|
| 462 |
$params['width'] = $width; |
| 463 |
$params['height'] = $height; |
| 464 |
$params['isFilePageThumb'] = true; |
| 465 |
|
| 466 |
|
| 467 |
$params['imagePageParams'] = $request->getQueryValuesOnly(); |
| 468 |
$thumbnail = $this->displayImg->transform( $params ); |
| 469 |
Linker::processResponsiveImages( $this->displayImg, $thumbnail, $params ); |
| 470 |
|
| 471 |
$anchorclose = Html::rawElement( |
| 472 |
'div', |
| 473 |
[ 'class' => 'mw-filepage-resolutioninfo' ], |
| 474 |
$msgsmall |
| 475 |
); |
| 476 |
|
| 477 |
$isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1; |
| 478 |
if ( $isMulti ) { |
| 479 |
$out->addModules( 'mediawiki.page.image.pagination' ); |
| 480 |
|
| 481 |
$out->addHTML( '<div class="mw-filepage-multipage multipageimage">' ); |
| 482 |
} |
| 483 |
|
| 484 |
if ( $thumbnail ) { |
| 485 |
$options = [ |
| 486 |
'alt' => $this->displayImg->getTitle()->getPrefixedText(), |
| 487 |
'file-link' => true, |
| 488 |
]; |
| 489 |
$out->addHTML( |
| 490 |
Html::rawElement( |
| 491 |
'div', |
| 492 |
[ 'class' => 'fullImageLink', 'id' => 'file' ], |
| 493 |
$thumbnail->toHtml( $options ) . $anchorclose |
| 494 |
) . "\n" |
| 495 |
); |
| 496 |
} |
| 497 |
|
| 498 |
if ( $isMulti ) { |
| 499 |
$linkPrev = $linkNext = ''; |
| 500 |
$count = $this->displayImg->pageCount(); |
| 501 |
if ( !$enableLegacyMediaDOM ) { |
| 502 |
$out->addModules( 'mediawiki.page.media' ); |
| 503 |
} |
| 504 |
|
| 505 |
if ( $page > 1 ) { |
| 506 |
$label = $context->msg( 'imgmultipageprev' )->text(); |
| 507 |
|
| 508 |
|
| 509 |
$linkPrev = $this->linkRenderer->makeKnownLink( |
| 510 |
$this->getTitle(), |
| 511 |
$label, |
| 512 |
[], |
| 513 |
[ 'page' => $page - 1 ] |
| 514 |
); |
| 515 |
$thumbPrevPage = Linker::makeThumbLinkObj( |
| 516 |
$this->getTitle(), |
| 517 |
$this->displayImg, |
| 518 |
$linkPrev, |
| 519 |
$label, |
| 520 |
'none', |
| 521 |
[ 'page' => $page - 1, 'isFilePageThumb' => true ] |
| 522 |
); |
| 523 |
} else { |
| 524 |
$thumbPrevPage = ''; |
| 525 |
} |
| 526 |
|
| 527 |
if ( $page < $count ) { |
| 528 |
$label = $context->msg( 'imgmultipagenext' )->text(); |
| 529 |
$linkNext = $this->linkRenderer->makeKnownLink( |
| 530 |
$this->getTitle(), |
| 531 |
$label, |
| 532 |
[], |
| 533 |
[ 'page' => $page + 1 ] |
| 534 |
); |
| 535 |
$thumbNextPage = Linker::makeThumbLinkObj( |
| 536 |
$this->getTitle(), |
| 537 |
$this->displayImg, |
| 538 |
$linkNext, |
| 539 |
$label, |
| 540 |
'none', |
| 541 |
[ 'page' => $page + 1, 'isFilePageThumb' => true ] |
| 542 |
); |
| 543 |
} else { |
| 544 |
$thumbNextPage = ''; |
| 545 |
} |
| 546 |
|
| 547 |
$script = $mainConfig->get( MainConfigNames::Script ); |
| 548 |
|
| 549 |
$formParams = [ |
| 550 |
'name' => 'pageselector', |
| 551 |
'action' => $script, |
| 552 |
]; |
| 553 |
$options = []; |
| 554 |
for ( $i = 1; $i <= $count; $i++ ) { |
| 555 |
$options[] = Xml::option( $lang->formatNum( $i ), (string)$i, $i == $page ); |
| 556 |
} |
| 557 |
$select = Xml::tags( 'select', |
| 558 |
[ 'id' => 'pageselector', 'name' => 'page' ], |
| 559 |
implode( "\n", $options ) ); |
| 560 |
|
| 561 |
|
| 562 |
$out->addHTML( |
| 563 |
'<div class="mw-filepage-multipage-navigation multipageimagenavbox">' . |
| 564 |
$linkPrev . |
| 565 |
Html::rawElement( 'form', $formParams, |
| 566 |
Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . |
| 567 |
$context->msg( 'imgmultigoto' )->rawParams( $select )->parse() . |
| 568 |
$context->msg( 'word-separator' )->escaped() . |
| 569 |
Xml::submitButton( $context->msg( 'imgmultigo' )->text() ) |
| 570 |
) . |
| 571 |
"$thumbPrevPage\n$thumbNextPage\n$linkNext</div></div>" |
| 572 |
); |
| 573 |
} |
| 574 |
} elseif ( $this->displayImg->isSafeFile() ) { |
| 575 |
|
| 576 |
$icon = $this->displayImg->iconThumb(); |
| 577 |
|
| 578 |
$out->addHTML( |
| 579 |
Html::rawElement( |
| 580 |
'div', |
| 581 |
[ 'class' => 'fullImageLink', 'id' => 'file' ], |
| 582 |
$icon->toHtml( [ 'file-link' => true ] ) |
| 583 |
) . "\n" |
| 584 |
); |
| 585 |
} |
| 586 |
|
| 587 |
$longDesc = $context->msg( 'parentheses', $this->displayImg->getLongDesc() )->text(); |
| 588 |
|
| 589 |
$handler = $this->displayImg->getHandler(); |
| 590 |
|
| 591 |
|
| 592 |
if ( $handler ) { |
| 593 |
$warningConfig = $handler->getWarningConfig( $this->displayImg ); |
| 594 |
|
| 595 |
if ( $warningConfig !== null ) { |
| 596 |
|
| 597 |
|
| 598 |
$output = $context->getOutput(); |
| 599 |
$output->addJsConfigVars( 'wgFileWarning', $warningConfig ); |
| 600 |
$output->addModules( $warningConfig['module'] ); |
| 601 |
$output->addModules( 'mediawiki.filewarning' ); |
| 602 |
} |
| 603 |
} |
| 604 |
|
| 605 |
$medialink = "[[Media:$filename|$linktext]]"; |
| 606 |
|
| 607 |
if ( !$this->displayImg->isSafeFile() ) { |
| 608 |
$warning = $context->msg( 'mediawarning' )->plain(); |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
$out->wrapWikiTextAsInterface( 'fullMedia', <<<EOT |
| 614 |
<bdi dir="$sitedir"><span class="dangerousLink">$medialink</span></bdi> <span class="fileInfo">$longDesc</span> |
| 615 |
EOT |
| 616 |
); |
| 617 |
|
| 618 |
$out->wrapWikiTextAsInterface( 'mediaWarning', $warning ); |
| 619 |
} else { |
| 620 |
$out->wrapWikiTextAsInterface( 'fullMedia', <<<EOT |
| 621 |
<bdi dir="$sitedir">$medialink</bdi> <span class="fileInfo">$longDesc</span> |
| 622 |
EOT |
| 623 |
); |
| 624 |
} |
| 625 |
|
| 626 |
$renderLangOptions = $this->displayImg->getAvailableLanguages(); |
| 627 |
if ( count( $renderLangOptions ) >= 1 ) { |
| 628 |
$out->addHTML( $this->doRenderLangOpt( $renderLangOptions, $renderLang ) ); |
| 629 |
} |
| 630 |
|
| 631 |
|
| 632 |
if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) { |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
$ext = $this->displayImg->getExtension(); |
| 639 |
$noAnimMesg = wfMessageFallback( |
| 640 |
'file-no-thumb-animation-' . $ext, |
| 641 |
'file-no-thumb-animation' |
| 642 |
)->setContext( $context )->plain(); |
| 643 |
|
| 644 |
$out->wrapWikiTextAsInterface( 'mw-noanimatethumb', $noAnimMesg ); |
| 645 |
} |
| 646 |
|
| 647 |
if ( !$this->displayImg->isLocal() ) { |
| 648 |
$this->printSharedImageText(); |
| 649 |
} |
| 650 |
} else { |
| 651 |
|
| 652 |
if ( !$this->getPage()->getId() ) { |
| 653 |
$dbr = $this->dbProvider->getReplicaDatabase(); |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
LogEventsList::showLogExtract( |
| 658 |
$out, |
| 659 |
[ 'delete', 'move', 'protect', 'merge' ], |
| 660 |
$this->getTitle()->getPrefixedText(), |
| 661 |
'', |
| 662 |
[ 'lim' => 10, |
| 663 |
'conds' => [ $dbr->expr( 'log_action', '!=', 'revision' ) ], |
| 664 |
'showIfEmpty' => false, |
| 665 |
'msgKey' => [ 'moveddeleted-notice' ] |
| 666 |
] |
| 667 |
); |
| 668 |
} |
| 669 |
|
| 670 |
if ( $enableUploads && |
| 671 |
$context->getAuthority()->isAllowed( 'upload' ) |
| 672 |
) { |
| 673 |
|
| 674 |
$uploadTitle = SpecialPage::getTitleFor( 'Upload' ); |
| 675 |
$nofile = [ |
| 676 |
'filepage-nofile-link', |
| 677 |
$uploadTitle->getFullURL( [ |
| 678 |
'wpDestFile' => $this->getFile()->getName() |
| 679 |
] ) |
| 680 |
]; |
| 681 |
} else { |
| 682 |
$nofile = 'filepage-nofile'; |
| 683 |
} |
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
$out->setRobotPolicy( 'noindex,nofollow' ); |
| 688 |
$out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile ); |
| 689 |
if ( !$this->getPage()->getId() && $send404Code ) { |
| 690 |
|
| 691 |
|
| 692 |
$request->response()->statusHeader( 404 ); |
| 693 |
} |
| 694 |
} |
| 695 |
$out->setFileVersion( $this->displayImg ); |
| 696 |
} |
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
protected function getThumbPrevText( $params, $sizeLinkBigImagePreview ) { |
| 706 |
if ( $sizeLinkBigImagePreview ) { |
| 707 |
|
| 708 |
$previewTypeDiffers = false; |
| 709 |
$origExt = $thumbExt = $this->displayImg->getExtension(); |
| 710 |
if ( $this->displayImg->getHandler() ) { |
| 711 |
$origMime = $this->displayImg->getMimeType(); |
| 712 |
$typeParams = $params; |
| 713 |
$this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams ); |
| 714 |
[ $thumbExt, $thumbMime ] = $this->displayImg->getHandler()->getThumbType( |
| 715 |
$origExt, $origMime, $typeParams ); |
| 716 |
if ( $thumbMime !== $origMime ) { |
| 717 |
$previewTypeDiffers = true; |
| 718 |
} |
| 719 |
} |
| 720 |
if ( $previewTypeDiffers ) { |
| 721 |
return $this->getContext()->msg( 'show-big-image-preview-differ' )-> |
| 722 |
rawParams( $sizeLinkBigImagePreview )-> |
| 723 |
params( strtoupper( $origExt ) )-> |
| 724 |
params( strtoupper( $thumbExt ) )-> |
| 725 |
parse(); |
| 726 |
} else { |
| 727 |
return $this->getContext()->msg( 'show-big-image-preview' )-> |
| 728 |
rawParams( $sizeLinkBigImagePreview )-> |
| 729 |
parse(); |
| 730 |
} |
| 731 |
} else { |
| 732 |
return ''; |
| 733 |
} |
| 734 |
} |
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
protected function makeSizeLink( $params, $width, $height ) { |
| 744 |
$params['width'] = $width; |
| 745 |
$params['height'] = $height; |
| 746 |
$thumbnail = $this->displayImg->transform( $params ); |
| 747 |
if ( $thumbnail && !$thumbnail->isError() ) { |
| 748 |
return Html::rawElement( 'a', [ |
| 749 |
'href' => $thumbnail->getUrl(), |
| 750 |
'class' => 'mw-thumbnail-link' |
| 751 |
], $this->getContext()->msg( 'show-big-image-size' )->numParams( |
| 752 |
$thumbnail->getWidth(), $thumbnail->getHeight() |
| 753 |
)->parse() ); |
| 754 |
} else { |
| 755 |
return ''; |
| 756 |
} |
| 757 |
} |
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
protected function printSharedImageText() { |
| 763 |
$out = $this->getContext()->getOutput(); |
| 764 |
$this->loadFile(); |
| 765 |
|
| 766 |
$descUrl = $this->getFile()->getDescriptionUrl(); |
| 767 |
$descText = $this->getFile()->getDescriptionText( $this->getContext()->getLanguage() ); |
| 768 |
|
| 769 |
|
| 770 |
if ( $descUrl && !$this->getPage()->getId() ) { |
| 771 |
$out->setCanonicalUrl( $descUrl ); |
| 772 |
} |
| 773 |
|
| 774 |
$wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n"; |
| 775 |
$repo = $this->getFile()->getRepo()->getDisplayName(); |
| 776 |
|
| 777 |
if ( $descUrl && |
| 778 |
$descText && |
| 779 |
!$this->getContext()->msg( 'sharedupload-desc-here' )->isDisabled() |
| 780 |
) { |
| 781 |
$out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-here', $repo, $descUrl ] ); |
| 782 |
} elseif ( $descUrl && |
| 783 |
!$this->getContext()->msg( 'sharedupload-desc-there' )->isDisabled() |
| 784 |
) { |
| 785 |
$out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-there', $repo, $descUrl ] ); |
| 786 |
} else { |
| 787 |
$out->wrapWikiMsg( $wrap, [ 'sharedupload', $repo ], '' ); |
| 788 |
} |
| 789 |
|
| 790 |
if ( $descText ) { |
| 791 |
$this->mExtraDescription = $descText; |
| 792 |
} |
| 793 |
} |
| 794 |
|
| 795 |
public function getUploadUrl() { |
| 796 |
$this->loadFile(); |
| 797 |
$uploadTitle = SpecialPage::getTitleFor( 'Upload' ); |
| 798 |
return $uploadTitle->getFullURL( [ |
| 799 |
'wpDestFile' => $this->getFile()->getName(), |
| 800 |
'wpForReUpload' => 1 |
| 801 |
] ); |
| 802 |
} |
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
protected function uploadLinksBox() { |
| 808 |
if ( !$this->getContext()->getConfig()->get( MainConfigNames::EnableUploads ) ) { |
| 809 |
return; |
| 810 |
} |
| 811 |
|
| 812 |
$this->loadFile(); |
| 813 |
if ( !$this->getFile()->isLocal() ) { |
| 814 |
return; |
| 815 |
} |
| 816 |
|
| 817 |
$canUpload = $this->getContext()->getAuthority() |
| 818 |
->probablyCan( 'upload', $this->getTitle() ); |
| 819 |
if ( $canUpload && UploadBase::userCanReUpload( |
| 820 |
$this->getContext()->getAuthority(), |
| 821 |
$this->getFile() ) |
| 822 |
) { |
| 823 |
|
| 824 |
$ulink = $this->linkRenderer->makeExternalLink( |
| 825 |
$this->getUploadUrl(), |
| 826 |
$this->getContext()->msg( 'uploadnewversion-linktext' ), |
| 827 |
$this->getTitle() |
| 828 |
); |
| 829 |
$attrs = [ 'class' => 'plainlinks', 'id' => 'mw-imagepage-reupload-link' ]; |
| 830 |
$linkPara = Html::rawElement( 'p', $attrs, $ulink ); |
| 831 |
} else { |
| 832 |
|
| 833 |
$attrs = [ 'id' => 'mw-imagepage-upload-disallowed' ]; |
| 834 |
$msg = $this->getContext()->msg( 'upload-disallowed-here' )->text(); |
| 835 |
$linkPara = Html::element( 'p', $attrs, $msg ); |
| 836 |
} |
| 837 |
|
| 838 |
$uploadLinks = Html::rawElement( 'div', [ 'class' => 'mw-imagepage-upload-links' ], $linkPara ); |
| 839 |
$this->getContext()->getOutput()->addHTML( $uploadLinks ); |
| 840 |
} |
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
protected function closeShowImage() { |
| 846 |
} |
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
protected function imageHistory() { |
| 853 |
$this->loadFile(); |
| 854 |
$out = $this->getContext()->getOutput(); |
| 855 |
$pager = new ImageHistoryPseudoPager( |
| 856 |
$this, |
| 857 |
MediaWikiServices::getInstance()->getLinkBatchFactory() |
| 858 |
); |
| 859 |
$out->addHTML( $pager->getBody() ); |
| 860 |
$out->getMetadata()->setPreventClickjacking( $pager->getPreventClickjacking() ); |
| 861 |
|
| 862 |
$this->getFile()->resetHistory(); |
| 863 |
|
| 864 |
|
| 865 |
r |
| 866 |
if ( $this->getFile()->exists() ) { |
| 867 |
$this->uploadLinksBox(); |
| 868 |
} |
| 869 |
} |
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
protected function queryImageLinks( $target, $limit ) { |
| 877 |
return $this->dbProvider->getReplicaDatabase()->newSelectQueryBuilder() |
| 878 |
->select( [ 'page_namespace', 'page_title', 'il_to' ] ) |
| 879 |
->from( 'imagelinks' ) |
| 880 |
->join( 'page', null, 'il_from = page_id' ) |
| 881 |
->where( [ 'il_to' => $target ] ) |
| 882 |
->orderBy( 'il_from' ) |
| 883 |
->limit( $limit + 1 ) |
| 884 |
->caller( __METHOD__ )->fetchResultSet(); |
| 885 |
} |
| 886 |
|
| 887 |
protected function imageLinks() { |
| 888 |
$limit = 100; |
| 889 |
|
| 890 |
$out = $this->getContext()->getOutput(); |
| 891 |
|
| 892 |
$rows = []; |
| 893 |
$redirects = []; |
| 894 |
foreach ( $this->getTitle()->getRedirectsHere( NS_FILE ) as $redir ) { |
| 895 |
$redirects[$redir->getDBkey()] = []; |
| 896 |
$rows[] = (object)[ |
| 897 |
'page_namespace' => NS_FILE, |
| 898 |
'page_title' => $redir->getDBkey(), |
| 899 |
]; |
| 900 |
} |
| 901 |
|
| 902 |
$res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit + 1 ); |
| 903 |
foreach ( $res as $row ) { |
| 904 |
$rows[] = $row; |
| 905 |
} |
| 906 |
$count = count( $rows ); |
| 907 |
|
| 908 |
$hasMore = $count > $limit; |
| 909 |
if ( !$hasMore && count( $redirects ) ) { |
| 910 |
$res = $this->queryImageLinks( array_keys( $redirects ), |
| 911 |
$limit - count( $rows ) + 1 ); |
| 912 |
foreach ( $res as $row ) { |
| 913 |
$redirects[$row->il_to][] = $row; |
| 914 |
$count++; |
| 915 |
} |
| 916 |
$hasMore = ( $res->numRows() + count( $rows ) ) > $limit; |
| 917 |
} |
| 918 |
|
| 919 |
if ( $count == 0 ) { |
| 920 |
$out->wrapWikiMsg( |
| 921 |
Html::rawElement( 'div', |
| 922 |
[ 'id' => 'mw-imagepage-nolinkstoimage' ], "\n$1\n" ), |
| 923 |
'nolinkstoimage' |
| 924 |
); |
| 925 |
return; |
| 926 |
} |
| 927 |
|
| 928 |
$out->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" ); |
| 929 |
if ( !$hasMore ) { |
| 930 |
$out->addWikiMsg( 'linkstoimage', $count ); |
| 931 |
} else { |
| 932 |
|
| 933 |
$out->addWikiMsg( 'linkstoimage-more', |
| 934 |
$this->getContext()->getLanguage()->formatNum( $limit ), |
| 935 |
$this->getTitle()->getPrefixedDBkey() |
| 936 |
); |
| 937 |
} |
| 938 |
|
| 939 |
$out->addHTML( |
| 940 |
Html::openElement( 'ul', |
| 941 |
[ 'class' => 'mw-imagepage-linkstoimage' ] ) . "\n" |
| 942 |
); |
| 943 |
|
| 944 |
usort( $rows, [ $this, 'compare' ] ); |
| 945 |
|
| 946 |
|
| 947 |
$currentCount = 0; |
| 948 |
foreach ( $rows as $element ) { |
| 949 |
$currentCount++; |
| 950 |
if ( $currentCount > $limit ) { |
| 951 |
break; |
| 952 |
} |
| 953 |
|
| 954 |
$link = $this->linkRenderer->makeKnownLink( |
| 955 |
Title::makeTitle( $element->page_namespace, $element->page_title ), |
| 956 |
null, |
| 957 |
[], |
| 958 |
|
| 959 |
[ 'redirect' => isset( $redirects[$element->page_title] ) ? 'no' : null ] |
| 960 |
); |
| 961 |
if ( !isset( $redirects[$element->page_title] ) ) { |
| 962 |
|
| 963 |
$liContents = $link; |
| 964 |
} elseif ( count( $redirects[$element->page_title] ) === 0 ) { |
| 965 |
|
| 966 |
$liContents = $this->getContext()->msg( 'linkstoimage-redirect' ) |
| 967 |
->rawParams( $link, '' ) |
| 968 |
->parse(); |
| 969 |
} else { |
| 970 |
|
| 971 |
$li = ''; |
| 972 |
foreach ( $redirects[$element->page_title] as $row ) { |
| 973 |
$currentCount++; |
| 974 |
if ( $currentCount > $limit ) { |
| 975 |
break; |
| 976 |
} |
| 977 |
|
| 978 |
$link2 = $this->linkRenderer->makeKnownLink( |
| 979 |
Title::makeTitle( $row->page_namespace, $row->page_title ) ); |
| 980 |
$li .= Html::rawElement( |
| 981 |
'li', |
| 982 |
[ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ], |
| 983 |
$link2 |
| 984 |
) . "\n"; |
| 985 |
} |
| 986 |
|
| 987 |
$ul = Html::rawElement( |
| 988 |
'ul', |
| 989 |
[ 'class' => 'mw-imagepage-redirectstofile' ], |
| 990 |
$li |
| 991 |
) . "\n"; |
| 992 |
$liContents = $this->getContext()->msg( 'linkstoimage-redirect' )->rawParams( |
| 993 |
$link, $ul )->parse(); |
| 994 |
} |
| 995 |
$out->addHTML( Html::rawElement( |
| 996 |
'li', |
| 997 |
[ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ], |
| 998 |
$liContents |
| 999 |
) . "\n" |
| 1000 |
); |
| 1001 |
|
| 1002 |
} |
| 1003 |
$out->addHTML( Html::closeElement( 'ul' ) . "\n" ); |
| 1004 |
$res->free(); |
| 1005 |
|
| 1006 |
|
| 1007 |
if ( $currentCount > $limit ) { |
| 1008 |
$out->addWikiMsg( 'morelinkstoimage', $this->getTitle()->getPrefixedDBkey() ); |
| 1009 |
} |
| 1010 |
$out->addHTML( Html::closeElement( 'div' ) . "\n" ); |
| 1011 |
} |
| 1012 |
|
| 1013 |
protected function imageDupes() { |
| 1014 |
$this->loadFile(); |
| 1015 |
$out = $this->getContext()->getOutput(); |
| 1016 |
|
| 1017 |
$dupes = $this->getPage()->getDuplicates(); |
| 1018 |
if ( count( $dupes ) == 0 ) { |
| 1019 |
return; |
| 1020 |
} |
| 1021 |
|
| 1022 |
$out->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" ); |
| 1023 |
$out->addWikiMsg( 'duplicatesoffile', |
| 1024 |
$this->getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->getTitle()->getDBkey() |
| 1025 |
); |
| 1026 |
$out->addHTML( "<ul class='mw-imagepage-duplicates'>\n" ); |
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
foreach ( $dupes as $file ) { |
| 1032 |
$fromSrc = ''; |
| 1033 |
if ( $file->isLocal() ) { |
| 1034 |
$link = $this->linkRenderer->makeKnownLink( $file->getTitle() ); |
| 1035 |
} else { |
| 1036 |
$link = $this->linkRenderer->makeExternalLink( |
| 1037 |
$file->getDescriptionUrl(), |
| 1038 |
$file->getTitle()->getPrefixedText(), |
| 1039 |
$this->getTitle() |
| 1040 |
); |
| 1041 |
$fromSrc = $this->getContext()->msg( |
| 1042 |
'shared-repo-from', |
| 1043 |
$file->getRepo()->getDisplayName() |
| 1044 |
)->escaped(); |
| 1045 |
} |
| 1046 |
$out->addHTML( "<li>{$link} {$fromSrc}</li>\n" ); |
| 1047 |
} |
| 1048 |
$out->addHTML( "</ul></div>\n" ); |
| 1049 |
} |
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
public function showError( $description ) { |
| 1057 |
$out = $this->getContext()->getOutput(); |
| 1058 |
$out->setPageTitleMsg( $this->getContext()->msg( 'internalerror' ) ); |
| 1059 |
$out->setRobotPolicy( 'noindex,nofollow' ); |
| 1060 |
$out->setArticleRelated( false ); |
| 1061 |
$out->disableClientCache(); |
| 1062 |
$out->addWikiTextAsInterface( $description ); |
| 1063 |
} |
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
protected function compare( $a, $b ) { |
| 1074 |
return $a->page_namespace <=> $b->page_namespace |
| 1075 |
?: strcmp( $a->page_title, $b->page_title ); |
| 1076 |
} |
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
protected function doRenderLangOpt( array $langChoices, $renderLang ) { |
| 1087 |
$context = $this->getContext(); |
| 1088 |
$script = $context->getConfig()->get( MainConfigNames::Script ); |
| 1089 |
$opts = ''; |
| 1090 |
|
| 1091 |
$matchedRenderLang = $renderLang === null ? null : $this->displayImg->getMatchedLanguage( $renderLang ); |
| 1092 |
|
| 1093 |
foreach ( $langChoices as $lang ) { |
| 1094 |
$opts .= $this->createXmlOptionStringForLanguage( |
| 1095 |
$lang, |
| 1096 |
$matchedRenderLang === $lang |
| 1097 |
); |
| 1098 |
} |
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
$opts .= "\n" . |
| 1103 |
Xml::option( |
| 1104 |
$context->msg( 'img-lang-default' )->text(), |
| 1105 |
'und', |
| 1106 |
$matchedRenderLang === null || $matchedRenderLang === 'und' |
| 1107 |
); |
| 1108 |
|
| 1109 |
$select = Html::rawElement( |
| 1110 |
'select', |
| 1111 |
[ 'id' => 'mw-imglangselector', 'name' => 'lang' ], |
| 1112 |
$opts |
| 1113 |
); |
| 1114 |
$submit = Xml::submitButton( $context->msg( 'img-lang-go' )->text() ); |
| 1115 |
|
| 1116 |
$formContents = $context->msg( 'img-lang-info' ) |
| 1117 |
->rawParams( $select, $submit ) |
| 1118 |
->parse(); |
| 1119 |
$formContents .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ); |
| 1120 |
|
| 1121 |
$langSelectLine = Html::rawElement( 'div', [ 'id' => 'mw-imglangselector-line' ], |
| 1122 |
Html::rawElement( 'form', [ 'action' => $script ], $formContents ) |
| 1123 |
); |
| 1124 |
return $langSelectLine; |
| 1125 |
} |
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
private function createXmlOptionStringForLanguage( $lang, $selected ) { |
| 1133 |
|
| 1134 |
|
| 1135 |
$name = MediaWikiServices::getInstance() |
| 1136 |
->getLanguageNameUtils() |
| 1137 |
->getLanguageName( $lang, $this->getContext()->getLanguage()->getCode() ); |
| 1138 |
if ( $name !== '' ) { |
| 1139 |
$display = $this->getContext()->msg( 'img-lang-opt', $lang, $name )->text(); |
| 1140 |
} else { |
| 1141 |
$display = $lang; |
| 1142 |
} |
| 1143 |
return "\n" . |
| 1144 |
Xml::option( |
| 1145 |
$display, |
| 1146 |
$lang, |
| 1147 |
$selected |
| 1148 |
); |
| 1149 |
} |
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
protected function getThumbSizes( $origWidth, $origHeight ) { |
| 1161 |
$context = $this->getContext(); |
| 1162 |
$imageLimits = $context->getConfig()->get( MainConfigNames::ImageLimits ); |
| 1163 |
if ( $this->displayImg->getRepo()->canTransformVia404() ) { |
| 1164 |
$thumbSizes = $imageLimits; |
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
$thumbSizes[] = [ $origWidth, $origHeight ]; |
| 1172 |
} else { |
| 1173 |
|
| 1174 |
|
| 1175 |
$thumbSizes = [ |
| 1176 |
$this->getImageLimitsFromOption( $context->getUser(), 'thumbsize' ) |
| 1177 |
]; |
| 1178 |
if ( !$this->displayImg->mustRender() ) { |
| 1179 |
|
| 1180 |
|
| 1181 |
$thumbSizes[] = [ $origWidth, $origHeight ]; |
| 1182 |
} |
| 1183 |
} |
| 1184 |
return $thumbSizes; |
| 1185 |
} |
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
public function getFile(): File { |
| 1192 |
return $this->getPage()->getFile(); |
| 1193 |
} |
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
public function isLocal() { |
| 1200 |
return $this->getPage()->isLocal(); |
| 1201 |
} |
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
public function getDuplicates() { |
| 1208 |
return $this->getPage()->getDuplicates(); |
| 1209 |
} |
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
public function getForeignCategories() { |
| 1216 |
return $this->getPage()->getForeignCategories(); |
| 1217 |
} |
| 1218 |
|
| 1219 |
} |