Merge "Replace deprecated wfMsg* calls with Message class calls."
[lhc/web/wiklou.git] / includes / ImagePage.php
1 <?php
2 /**
3 * Special handling for file description pages.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 /**
24 * Class for viewing MediaWiki file description pages
25 *
26 * @ingroup Media
27 */
28 class ImagePage extends Article {
29
30 /**
31 * @var File
32 */
33 private $displayImg;
34 /**
35 * @var FileRepo
36 */
37 private $repo;
38 private $fileLoaded;
39
40 var $mExtraDescription = false;
41
42 /**
43 * @param $title Title
44 * @return WikiFilePage
45 */
46 protected function newPage( Title $title ) {
47 // Overload mPage with a file-specific page
48 return new WikiFilePage( $title );
49 }
50
51 /**
52 * Constructor from a page id
53 * @param $id Int article ID to load
54 * @return ImagePage|null
55 */
56 public static function newFromID( $id ) {
57 $t = Title::newFromID( $id );
58 # @todo FIXME: Doesn't inherit right
59 return $t == null ? null : new self( $t );
60 # return $t == null ? null : new static( $t ); // PHP 5.3
61 }
62
63 /**
64 * @param $file File:
65 * @return void
66 */
67 public function setFile( $file ) {
68 $this->mPage->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 wfRunHooks( 'ImagePageFindFile', array( $this, &$img, &$this->displayImg ) );
81 if ( !$img ) { // not set by hook?
82 $img = wfFindFile( $this->getTitle() );
83 if ( !$img ) {
84 $img = wfLocalFile( $this->getTitle() );
85 }
86 }
87 $this->mPage->setFile( $img );
88 if ( !$this->displayImg ) { // not set by hook?
89 $this->displayImg = $img;
90 }
91 $this->repo = $img->getRepo();
92 }
93
94 /**
95 * Handler for action=render
96 * Include body text only; none of the image extras
97 */
98 public function render() {
99 $this->getContext()->getOutput()->setArticleBodyOnly( true );
100 parent::view();
101 }
102
103 public function view() {
104 global $wgShowEXIF;
105
106 $out = $this->getContext()->getOutput();
107 $request = $this->getContext()->getRequest();
108 $diff = $request->getVal( 'diff' );
109 $diffOnly = $request->getBool( 'diffonly', $this->getContext()->getUser()->getOption( 'diffonly' ) );
110
111 if ( $this->getTitle()->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) ) {
112 parent::view();
113 return;
114 }
115
116 $this->loadFile();
117
118 if ( $this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected() ) {
119 if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || isset( $diff ) ) {
120 // mTitle is the same as the redirect target so ask Article
121 // to perform the redirect for us.
122 $request->setVal( 'diffonly', 'true' );
123 parent::view();
124 return;
125 } else {
126 // mTitle is not the same as the redirect target so it is
127 // probably the redirect page itself. Fake the redirect symbol
128 $out->setPageTitle( $this->getTitle()->getPrefixedText() );
129 $out->addHTML( $this->viewRedirect( Title::makeTitle( NS_FILE, $this->mPage->getFile()->getName() ),
130 /* $appendSubtitle */ true, /* $forceKnown */ true ) );
131 $this->mPage->doViewUpdates( $this->getContext()->getUser() );
132 return;
133 }
134 }
135
136 if ( $wgShowEXIF && $this->displayImg->exists() ) {
137 // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
138 $formattedMetadata = $this->displayImg->formatMetadata();
139 $showmeta = $formattedMetadata !== false;
140 } else {
141 $showmeta = false;
142 }
143
144 if ( !$diff && $this->displayImg->exists() ) {
145 $out->addHTML( $this->showTOC( $showmeta ) );
146 }
147
148 if ( !$diff ) {
149 $this->openShowImage();
150 }
151
152 # No need to display noarticletext, we use our own message, output in openShowImage()
153 if ( $this->mPage->getID() ) {
154 # NS_FILE is in the user language, but this section (the actual wikitext)
155 # should be in page content language
156 $pageLang = $this->getTitle()->getPageLanguage();
157 $out->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content',
158 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
159 'class' => 'mw-content-'.$pageLang->getDir() ) ) );
160 parent::view();
161 $out->addHTML( Xml::closeElement( 'div' ) );
162 } else {
163 # Just need to set the right headers
164 $out->setArticleFlag( true );
165 $out->setPageTitle( $this->getTitle()->getPrefixedText() );
166 $this->mPage->doViewUpdates( $this->getContext()->getUser() );
167 }
168
169 # Show shared description, if needed
170 if ( $this->mExtraDescription ) {
171 $fol = wfMessage( 'shareddescriptionfollows' );
172 if ( !$fol->isDisabled() ) {
173 $out->addWikiText( $fol->plain() );
174 }
175 $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
176 }
177
178 $this->closeShowImage();
179 $this->imageHistory();
180 // TODO: Cleanup the following
181
182 $out->addHTML( Xml::element( 'h2',
183 array( 'id' => 'filelinks' ),
184 wfMessage( 'imagelinks' )->text() ) . "\n" );
185 $this->imageDupes();
186 # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
187 # Yet we return metadata about the target. Definitely an issue in the FileRepo
188 $this->imageLinks();
189
190 # Allow extensions to add something after the image links
191 $html = '';
192 wfRunHooks( 'ImagePageAfterImageLinks', array( $this, &$html ) );
193 if ( $html ) {
194 $out->addHTML( $html );
195 }
196
197 if ( $showmeta ) {
198 $out->addHTML( Xml::element(
199 'h2',
200 array( 'id' => 'metadata' ),
201 wfMessage( 'metadata' )->text() ) . "\n" );
202 $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
203 $out->addModules( array( 'mediawiki.action.view.metadata' ) );
204 }
205
206 // Add remote Filepage.css
207 if( !$this->repo->isLocal() ) {
208 $css = $this->repo->getDescriptionStylesheetUrl();
209 if ( $css ) {
210 $out->addStyle( $css );
211 }
212 }
213 // always show the local local Filepage.css, bug 29277
214 $out->addModuleStyles( 'filepage' );
215 }
216
217 /**
218 * @return File
219 */
220 public function getDisplayedFile() {
221 $this->loadFile();
222 return $this->displayImg;
223 }
224
225 /**
226 * Create the TOC
227 *
228 * @param $metadata Boolean: whether or not to show the metadata link
229 * @return String
230 */
231 protected function showTOC( $metadata ) {
232 $r = array(
233 '<li><a href="#file">' . wfMessage( 'file-anchor-link' )->escaped() . '</a></li>',
234 '<li><a href="#filehistory">' . wfMessage( 'filehist' )->escaped() . '</a></li>',
235 '<li><a href="#filelinks">' . wfMessage( 'imagelinks' )->escaped() . '</a></li>',
236 );
237 if ( $metadata ) {
238 $r[] = '<li><a href="#metadata">' . wfMessage( 'metadata' )->escaped() . '</a></li>';
239 }
240
241 wfRunHooks( 'ImagePageShowTOC', array( $this, &$r ) );
242
243 return '<ul id="filetoc">' . implode( "\n", $r ) . '</ul>';
244 }
245
246 /**
247 * Make a table with metadata to be shown in the output page.
248 *
249 * @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
250 *
251 * @param $metadata Array: the array containing the EXIF data
252 * @return String The metadata table. This is treated as Wikitext (!)
253 */
254 protected function makeMetadataTable( $metadata ) {
255 $r = "<div class=\"mw-imagepage-section-metadata\">";
256 $r .= wfMessage( 'metadata-help' )->plain();
257 $r .= "<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
258 foreach ( $metadata as $type => $stuff ) {
259 foreach ( $stuff as $v ) {
260 # @todo FIXME: Why is this using escapeId for a class?!
261 $class = Sanitizer::escapeId( $v['id'] );
262 if ( $type == 'collapsed' ) {
263 $class .= ' collapsable';
264 }
265 $r .= "<tr class=\"$class\">\n";
266 $r .= "<th>{$v['name']}</th>\n";
267 $r .= "<td>{$v['value']}</td>\n</tr>";
268 }
269 }
270 $r .= "</table>\n</div>\n";
271 return $r;
272 }
273
274 /**
275 * Overloading Article's getContent method.
276 *
277 * Omit noarticletext if sharedupload; text will be fetched from the
278 * shared upload server if possible.
279 * @return string
280 */
281 public function getContent() {
282 $this->loadFile();
283 if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) {
284 return '';
285 }
286 return parent::getContent();
287 }
288
289 protected function openShowImage() {
290 global $wgImageLimits, $wgEnableUploads, $wgSend404Code;
291
292 $this->loadFile();
293 $out = $this->getContext()->getOutput();
294 $user = $this->getContext()->getUser();
295 $lang = $this->getContext()->getLanguage();
296 $dirmark = $lang->getDirMarkEntity();
297 $request = $this->getContext()->getRequest();
298
299 $sizeSel = intval( $user->getOption( 'imagesize' ) );
300 if ( !isset( $wgImageLimits[$sizeSel] ) ) {
301 $sizeSel = User::getDefaultOption( 'imagesize' );
302
303 // The user offset might still be incorrect, specially if
304 // $wgImageLimits got changed (see bug #8858).
305 if ( !isset( $wgImageLimits[$sizeSel] ) ) {
306 // Default to the first offset in $wgImageLimits
307 $sizeSel = 0;
308 }
309 }
310 $max = $wgImageLimits[$sizeSel];
311 $maxWidth = $max[0];
312 $maxHeight = $max[1];
313
314 if ( $this->displayImg->exists() ) {
315 # image
316 $page = $request->getIntOrNull( 'page' );
317 if ( is_null( $page ) ) {
318 $params = array();
319 $page = 1;
320 } else {
321 $params = array( 'page' => $page );
322 }
323 $width_orig = $this->displayImg->getWidth( $page );
324 $width = $width_orig;
325 $height_orig = $this->displayImg->getHeight( $page );
326 $height = $height_orig;
327
328 $longDesc = wfMessage( 'parentheses', $this->displayImg->getLongDesc() )->text();
329
330 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$out ) );
331
332 if ( $this->displayImg->allowInlineDisplay() ) {
333 # image
334
335 # "Download high res version" link below the image
336 # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
337 # We'll show a thumbnail of this image
338 if ( $width > $maxWidth || $height > $maxHeight ) {
339 # Calculate the thumbnail size.
340 # First case, the limiting factor is the width, not the height.
341 if ( $width / $height >= $maxWidth / $maxHeight ) {
342 $height = round( $height * $maxWidth / $width );
343 $width = $maxWidth;
344 # Note that $height <= $maxHeight now.
345 } else {
346 $newwidth = floor( $width * $maxHeight / $height );
347 $height = round( $height * $newwidth / $width );
348 $width = $newwidth;
349 # Note that $height <= $maxHeight now, but might not be identical
350 # because of rounding.
351 }
352 $msgbig = wfMessage( 'show-big-image' )->escaped();
353 if ( $this->displayImg->getRepo()->canTransformVia404() ) {
354 $thumbSizes = $wgImageLimits;
355 } else {
356 # Creating thumb links triggers thumbnail generation.
357 # Just generate the thumb for the current users prefs.
358 $thumbOption = $user->getOption( 'thumbsize' );
359 $thumbSizes = array( isset( $wgImageLimits[$thumbOption] )
360 ? $wgImageLimits[$thumbOption]
361 : $wgImageLimits[User::getDefaultOption( 'thumbsize' )] );
362 }
363 # Generate thumbnails or thumbnail links as needed...
364 $otherSizes = array();
365 foreach ( $thumbSizes as $size ) {
366 if ( $size[0] < $width_orig && $size[1] < $height_orig
367 && $size[0] != $width && $size[1] != $height )
368 {
369 $otherSizes[] = $this->makeSizeLink( $params, $size[0], $size[1] );
370 }
371 }
372 $msgsmall = wfMessage( 'show-big-image-preview' )->
373 rawParams( $this->makeSizeLink( $params, $width, $height ) )->
374 parse();
375 if ( count( $otherSizes ) ) {
376 $msgsmall .= ' ' .
377 Html::rawElement( 'span', array( 'class' => 'mw-filepage-other-resolutions' ),
378 wfMessage( 'show-big-image-other' )->rawParams( $lang->pipeList( $otherSizes ) )->
379 params( count( $otherSizes ) )->parse()
380 );
381 }
382 } elseif ( $width == 0 && $height == 0 ){
383 # Some sort of audio file that doesn't have dimensions
384 # Don't output a no hi res message for such a file
385 $msgsmall = '';
386 } else {
387 # Image is small enough to show full size on image page
388 $msgsmall = wfMessage( 'file-nohires' )->parse();
389 }
390
391 $params['width'] = $width;
392 $params['height'] = $height;
393 $thumbnail = $this->displayImg->transform( $params );
394
395 $showLink = true;
396 $anchorclose = Html::rawElement( 'div', array( 'class' => 'mw-filepage-resolutioninfo' ), $msgsmall );
397
398 $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
399 if ( $isMulti ) {
400 $out->addHTML( '<table class="multipageimage"><tr><td>' );
401 }
402
403 if ( $thumbnail ) {
404 $options = array(
405 'alt' => $this->displayImg->getTitle()->getPrefixedText(),
406 'file-link' => true,
407 );
408 $out->addHTML( '<div class="fullImageLink" id="file">' .
409 $thumbnail->toHtml( $options ) .
410 $anchorclose . "</div>\n" );
411 }
412
413 if ( $isMulti ) {
414 $count = $this->displayImg->pageCount();
415
416 if ( $page > 1 ) {
417 $label = $out->parse( wfMessage( 'imgmultipageprev' )->text(), false );
418 $link = Linker::linkKnown(
419 $this->getTitle(),
420 $label,
421 array(),
422 array( 'page' => $page - 1 )
423 );
424 $thumb1 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none',
425 array( 'page' => $page - 1 ) );
426 } else {
427 $thumb1 = '';
428 }
429
430 if ( $page < $count ) {
431 $label = wfMessage( 'imgmultipagenext' )->text();
432 $link = Linker::linkKnown(
433 $this->getTitle(),
434 $label,
435 array(),
436 array( 'page' => $page + 1 )
437 );
438 $thumb2 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none',
439 array( 'page' => $page + 1 ) );
440 } else {
441 $thumb2 = '';
442 }
443
444 global $wgScript;
445
446 $formParams = array(
447 'name' => 'pageselector',
448 'action' => $wgScript,
449 'onchange' => 'document.pageselector.submit();',
450 );
451 $options = array();
452 for ( $i = 1; $i <= $count; $i++ ) {
453 $options[] = Xml::option( $lang->formatNum( $i ), $i, $i == $page );
454 }
455 $select = Xml::tags( 'select',
456 array( 'id' => 'pageselector', 'name' => 'page' ),
457 implode( "\n", $options ) );
458
459 $out->addHTML(
460 '</td><td><div class="multipageimagenavbox">' .
461 Xml::openElement( 'form', $formParams ) .
462 Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
463 wfMessage( 'imgmultigoto' )->rawParams( $select )->parse() .
464 Xml::submitButton( wfMessage( 'imgmultigo' )->text() ) .
465 Xml::closeElement( 'form' ) .
466 "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
467 );
468 }
469 } else {
470 # if direct link is allowed but it's not a renderable image, show an icon.
471 if ( $this->displayImg->isSafeFile() ) {
472 $icon = $this->displayImg->iconThumb();
473
474 $out->addHTML( '<div class="fullImageLink" id="file">' .
475 $icon->toHtml( array( 'file-link' => true ) ) .
476 "</div>\n" );
477 }
478
479 $showLink = true;
480 }
481
482 if ( $showLink ) {
483 $filename = wfEscapeWikiText( $this->displayImg->getName() );
484 $linktext = $filename;
485 if ( isset( $msgbig ) ) {
486 $linktext = wfEscapeWikiText( $msgbig );
487 }
488 $medialink = "[[Media:$filename|$linktext]]";
489
490 if ( !$this->displayImg->isSafeFile() ) {
491 $warning = wfMessage( 'mediawarning' )->plain();
492 // dirmark is needed here to separate the file name, which
493 // most likely ends in Latin characters, from the description,
494 // which may begin with the file type. In RTL environment
495 // this will get messy.
496 // The dirmark, however, must not be immediately adjacent
497 // to the filename, because it can get copied with it.
498 // See bug 25277.
499 $out->addWikiText( <<<EOT
500 <div class="fullMedia"><span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span></div>
501 <div class="mediaWarning">$warning</div>
502 EOT
503 );
504 } else {
505 $out->addWikiText( <<<EOT
506 <div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
507 </div>
508 EOT
509 );
510 }
511 }
512
513 if ( !$this->displayImg->isLocal() ) {
514 $this->printSharedImageText();
515 }
516 } else {
517 # Image does not exist
518 if ( !$this->getID() ) {
519 # No article exists either
520 # Show deletion log to be consistent with normal articles
521 LogEventsList::showLogExtract(
522 $out,
523 array( 'delete', 'move' ),
524 $this->getTitle()->getPrefixedText(),
525 '',
526 array( 'lim' => 10,
527 'conds' => array( "log_action != 'revision'" ),
528 'showIfEmpty' => false,
529 'msgKey' => array( 'moveddeleted-notice' )
530 )
531 );
532 }
533
534 if ( $wgEnableUploads && $user->isAllowed( 'upload' ) ) {
535 // Only show an upload link if the user can upload
536 $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
537 $nofile = array(
538 'filepage-nofile-link',
539 $uploadTitle->getFullURL( array( 'wpDestFile' => $this->mPage->getFile()->getName() ) )
540 );
541 } else {
542 $nofile = 'filepage-nofile';
543 }
544 // Note, if there is an image description page, but
545 // no image, then this setRobotPolicy is overriden
546 // by Article::View().
547 $out->setRobotPolicy( 'noindex,nofollow' );
548 $out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
549 if ( !$this->getID() && $wgSend404Code ) {
550 // If there is no image, no shared image, and no description page,
551 // output a 404, to be consistent with articles.
552 $request->response()->header( 'HTTP/1.1 404 Not Found' );
553 }
554 }
555 $out->setFileVersion( $this->displayImg );
556 }
557
558 /**
559 * Creates an thumbnail of specified size and returns an HTML link to it
560 * @param $params array Scaler parameters
561 * @param $width int
562 * @param $height int
563 * @return string
564 */
565 private function makeSizeLink( $params, $width, $height ) {
566 $params['width'] = $width;
567 $params['height'] = $height;
568 $thumbnail = $this->displayImg->transform( $params );
569 if ( $thumbnail && !$thumbnail->isError() ) {
570 return Html::rawElement( 'a', array(
571 'href' => $thumbnail->getUrl(),
572 'class' => 'mw-thumbnail-link'
573 ), wfMessage( 'show-big-image-size' )->numParams(
574 $thumbnail->getWidth(), $thumbnail->getHeight()
575 )->parse() );
576 } else {
577 return '';
578 }
579 }
580
581 /**
582 * Show a notice that the file is from a shared repository
583 */
584 protected function printSharedImageText() {
585 $out = $this->getContext()->getOutput();
586 $this->loadFile();
587
588 $descUrl = $this->mPage->getFile()->getDescriptionUrl();
589 $descText = $this->mPage->getFile()->getDescriptionText();
590
591 /* Add canonical to head if there is no local page for this shared file */
592 if( $descUrl && $this->mPage->getID() == 0 ) {
593 $out->addLink( array( 'rel' => 'canonical', 'href' => $descUrl ) );
594 }
595
596 $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
597 $repo = $this->mPage->getFile()->getRepo()->getDisplayName();
598
599 if ( $descUrl && $descText && wfMessage( 'sharedupload-desc-here' )->plain() !== '-' ) {
600 $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
601 } elseif ( $descUrl && wfMessage( 'sharedupload-desc-there' )->plain() !== '-' ) {
602 $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) );
603 } else {
604 $out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ );
605 }
606
607 if ( $descText ) {
608 $this->mExtraDescription = $descText;
609 }
610 }
611
612 public function getUploadUrl() {
613 $this->loadFile();
614 $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
615 return $uploadTitle->getFullURL( array(
616 'wpDestFile' => $this->mPage->getFile()->getName(),
617 'wpForReUpload' => 1
618 ) );
619 }
620
621 /**
622 * Print out the various links at the bottom of the image page, e.g. reupload,
623 * external editing (and instructions link) etc.
624 */
625 protected function uploadLinksBox() {
626 global $wgEnableUploads, $wgUseExternalEditor;
627
628 if ( !$wgEnableUploads ) {
629 return;
630 }
631
632 $this->loadFile();
633 if ( !$this->mPage->getFile()->isLocal() ) {
634 return;
635 }
636
637 $out = $this->getContext()->getOutput();
638 $out->addHTML( "<br /><ul>\n" );
639
640 # "Upload a new version of this file" link
641 if ( UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) {
642 $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMessage( 'uploadnewversion-linktext' )->text() );
643 $out->addHTML( "<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
644 }
645
646 # External editing link
647 if ( $wgUseExternalEditor ) {
648 $elink = Linker::linkKnown(
649 $this->getTitle(),
650 wfMessage( 'edit-externally' )->escaped(),
651 array(),
652 array(
653 'action' => 'edit',
654 'externaledit' => 'true',
655 'mode' => 'file'
656 )
657 );
658 $out->addHTML(
659 '<li id="mw-imagepage-edit-external">' . $elink . ' <small>' .
660 wfMessage( 'edit-externally-help' )->parse() .
661 "</small></li>\n"
662 );
663 }
664
665 $out->addHTML( "</ul>\n" );
666 }
667
668 protected function closeShowImage() { } # For overloading
669
670 /**
671 * If the page we've just displayed is in the "Image" namespace,
672 * we follow it with an upload history of the image and its usage.
673 */
674 protected function imageHistory() {
675 $this->loadFile();
676 $out = $this->getContext()->getOutput();
677 $pager = new ImageHistoryPseudoPager( $this );
678 $out->addHTML( $pager->getBody() );
679 $out->preventClickjacking( $pager->getPreventClickjacking() );
680
681 $this->mPage->getFile()->resetHistory(); // free db resources
682
683 # Exist check because we don't want to show this on pages where an image
684 # doesn't exist along with the noimage message, that would suck. -ævar
685 if ( $this->mPage->getFile()->exists() ) {
686 $this->uploadLinksBox();
687 }
688 }
689
690 /**
691 * @param $target
692 * @param $limit
693 * @return ResultWrapper
694 */
695 protected function queryImageLinks( $target, $limit ) {
696 $dbr = wfGetDB( DB_SLAVE );
697
698 return $dbr->select(
699 array( 'imagelinks', 'page' ),
700 array( 'page_namespace', 'page_title', 'page_is_redirect', 'il_to' ),
701 array( 'il_to' => $target, 'il_from = page_id' ),
702 __METHOD__,
703 array( 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', )
704 );
705 }
706
707 protected function imageLinks() {
708 $limit = 100;
709
710 $out = $this->getContext()->getOutput();
711 $res = $this->queryImageLinks( $this->getTitle()->getDbKey(), $limit + 1);
712 $rows = array();
713 $redirects = array();
714 foreach ( $res as $row ) {
715 if ( $row->page_is_redirect ) {
716 $redirects[$row->page_title] = array();
717 }
718 $rows[] = $row;
719 }
720 $count = count( $rows );
721
722 $hasMore = $count > $limit;
723 if ( !$hasMore && count( $redirects ) ) {
724 $res = $this->queryImageLinks( array_keys( $redirects ),
725 $limit - count( $rows ) + 1 );
726 foreach ( $res as $row ) {
727 $redirects[$row->il_to][] = $row;
728 $count++;
729 }
730 $hasMore = ( $res->numRows() + count( $rows ) ) > $limit;
731 }
732
733 if ( $count == 0 ) {
734 $out->wrapWikiMsg(
735 Html::rawElement( 'div',
736 array( 'id' => 'mw-imagepage-nolinkstoimage' ), "\n$1\n" ),
737 'nolinkstoimage'
738 );
739 return;
740 }
741
742 $out->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
743 if ( !$hasMore ) {
744 $out->addWikiMsg( 'linkstoimage', $count );
745 } else {
746 // More links than the limit. Add a link to [[Special:Whatlinkshere]]
747 $out->addWikiMsg( 'linkstoimage-more',
748 $this->getContext()->getLanguage()->formatNum( $limit ),
749 $this->getTitle()->getPrefixedDBkey()
750 );
751 }
752
753 $out->addHTML(
754 Html::openElement( 'ul',
755 array( 'class' => 'mw-imagepage-linkstoimage' ) ) . "\n"
756 );
757 $count = 0;
758
759 // Sort the list by namespace:title
760 usort( $rows, array( $this, 'compare' ) );
761
762 // Create links for every element
763 $currentCount = 0;
764 foreach( $rows as $element ) {
765 $currentCount++;
766 if ( $currentCount > $limit ) {
767 break;
768 }
769
770 $link = Linker::linkKnown( Title::makeTitle( $element->page_namespace, $element->page_title ) );
771 if ( !isset( $redirects[$element->page_title] ) ) {
772 $liContents = $link;
773 } else {
774 $ul = "<ul class='mw-imagepage-redirectstofile'>\n";
775 foreach ( $redirects[$element->page_title] as $row ) {
776 $currentCount++;
777 if ( $currentCount > $limit ) {
778 break;
779 }
780
781 $link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
782 $ul .= Html::rawElement(
783 'li',
784 array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
785 $link2
786 ) . "\n";
787 }
788 $ul .= '</ul>';
789 $liContents = wfMessage( 'linkstoimage-redirect' )->rawParams(
790 $link, $ul )->parse();
791 }
792 $out->addHTML( Html::rawElement(
793 'li',
794 array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
795 $liContents
796 ) . "\n"
797 );
798
799 };
800 $out->addHTML( Html::closeElement( 'ul' ) . "\n" );
801 $res->free();
802
803 // Add a links to [[Special:Whatlinkshere]]
804 if ( $count > $limit ) {
805 $out->addWikiMsg( 'morelinkstoimage', $this->getTitle()->getPrefixedDBkey() );
806 }
807 $out->addHTML( Html::closeElement( 'div' ) . "\n" );
808 }
809
810 protected function imageDupes() {
811 $this->loadFile();
812 $out = $this->getContext()->getOutput();
813
814 $dupes = $this->mPage->getDuplicates();
815 if ( count( $dupes ) == 0 ) {
816 return;
817 }
818
819 $out->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
820 $out->addWikiMsg( 'duplicatesoffile',
821 $this->getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->getTitle()->getDBkey()
822 );
823 $out->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
824
825 /**
826 * @var $file File
827 */
828 foreach ( $dupes as $file ) {
829 $fromSrc = '';
830 if ( $file->isLocal() ) {
831 $link = Linker::linkKnown( $file->getTitle() );
832 } else {
833 $link = Linker::makeExternalLink( $file->getDescriptionUrl(),
834 $file->getTitle()->getPrefixedText() );
835 $fromSrc = wfMessage( 'shared-repo-from', $file->getRepo()->getDisplayName() )->text();
836 }
837 $out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
838 }
839 $out->addHTML( "</ul></div>\n" );
840 }
841
842 /**
843 * Delete the file, or an earlier version of it
844 */
845 public function delete() {
846 $file = $this->mPage->getFile();
847 if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
848 // Standard article deletion
849 parent::delete();
850 return;
851 }
852
853 $deleter = new FileDeleteForm( $file );
854 $deleter->execute();
855 }
856
857 /**
858 * Display an error with a wikitext description
859 *
860 * @param $description String
861 */
862 function showError( $description ) {
863 $out = $this->getContext()->getOutput();
864 $out->setPageTitle( wfMessage( 'internalerror' ) );
865 $out->setRobotPolicy( 'noindex,nofollow' );
866 $out->setArticleRelated( false );
867 $out->enableClientCache( false );
868 $out->addWikiText( $description );
869 }
870
871 /**
872 * Callback for usort() to do link sorts by (namespace, title)
873 * Function copied from Title::compare()
874 *
875 * @param $a object page to compare with
876 * @param $b object page to compare with
877 * @return Integer: result of string comparison, or namespace comparison
878 */
879 protected function compare( $a, $b ) {
880 if ( $a->page_namespace == $b->page_namespace ) {
881 return strcmp( $a->page_title, $b->page_title );
882 } else {
883 return $a->page_namespace - $b->page_namespace;
884 }
885 }
886 }
887
888 /**
889 * Builds the image revision log shown on image pages
890 *
891 * @ingroup Media
892 */
893 class ImageHistoryList extends ContextSource {
894
895 /**
896 * @var Title
897 */
898 protected $title;
899
900 /**
901 * @var File
902 */
903 protected $img;
904
905 /**
906 * @var ImagePage
907 */
908 protected $imagePage;
909
910 /**
911 * @var File
912 */
913 protected $current;
914
915 protected $repo, $showThumb;
916 protected $preventClickjacking = false;
917
918 /**
919 * @param ImagePage $imagePage
920 */
921 public function __construct( $imagePage ) {
922 global $wgShowArchiveThumbnails;
923 $this->current = $imagePage->getFile();
924 $this->img = $imagePage->getDisplayedFile();
925 $this->title = $imagePage->getTitle();
926 $this->imagePage = $imagePage;
927 $this->showThumb = $wgShowArchiveThumbnails && $this->img->canRender();
928 $this->setContext( $imagePage->getContext() );
929 }
930
931 /**
932 * @return ImagePage
933 */
934 public function getImagePage() {
935 return $this->imagePage;
936 }
937
938 /**
939 * @return File
940 */
941 public function getFile() {
942 return $this->img;
943 }
944
945 /**
946 * @param $navLinks string
947 * @return string
948 */
949 public function beginImageHistoryList( $navLinks = '' ) {
950 return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) . "\n"
951 . "<div id=\"mw-imagepage-section-filehistory\">\n"
952 . $this->msg( 'filehist-help' )->parseAsBlock()
953 . $navLinks . "\n"
954 . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
955 . '<tr><td></td>'
956 . ( $this->current->isLocal() && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
957 . '<th>' . $this->msg( 'filehist-datetime' )->escaped() . '</th>'
958 . ( $this->showThumb ? '<th>' . $this->msg( 'filehist-thumb' )->escaped() . '</th>' : '' )
959 . '<th>' . $this->msg( 'filehist-dimensions' )->escaped() . '</th>'
960 . '<th>' . $this->msg( 'filehist-user' )->escaped() . '</th>'
961 . '<th>' . $this->msg( 'filehist-comment' )->escaped() . '</th>'
962 . "</tr>\n";
963 }
964
965 /**
966 * @param $navLinks string
967 * @return string
968 */
969 public function endImageHistoryList( $navLinks = '' ) {
970 return "</table>\n$navLinks\n</div>\n";
971 }
972
973 /**
974 * @param $iscur
975 * @param $file File
976 * @return string
977 */
978 public function imageHistoryLine( $iscur, $file ) {
979 global $wgContLang;
980
981 $user = $this->getUser();
982 $lang = $this->getLanguage();
983 $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
984 $img = $iscur ? $file->getName() : $file->getArchiveName();
985 $userId = $file->getUser( 'id' );
986 $userText = $file->getUser( 'text' );
987 $description = $file->getDescription( File::FOR_THIS_USER, $user );
988
989 $local = $this->current->isLocal();
990 $row = $selected = '';
991
992 // Deletion link
993 if ( $local && ( $user->isAllowedAny( 'delete', 'deletedhistory' ) ) ) {
994 $row .= '<td>';
995 # Link to remove from history
996 if ( $user->isAllowed( 'delete' ) ) {
997 $q = array( 'action' => 'delete' );
998 if ( !$iscur ) {
999 $q['oldimage'] = $img;
1000 }
1001 $row .= Linker::linkKnown(
1002 $this->title,
1003 $this->msg( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' )->escaped(),
1004 array(), $q
1005 );
1006 }
1007 # Link to hide content. Don't show useless link to people who cannot hide revisions.
1008 $canHide = $user->isAllowed( 'deleterevision' );
1009 if ( $canHide || ( $user->isAllowed( 'deletedhistory' ) && $file->getVisibility() ) ) {
1010 if ( $user->isAllowed( 'delete' ) ) {
1011 $row .= '<br />';
1012 }
1013 // If file is top revision or locked from this user, don't link
1014 if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED, $user ) ) {
1015 $del = Linker::revDeleteLinkDisabled( $canHide );
1016 } else {
1017 list( $ts, ) = explode( '!', $img, 2 );
1018 $query = array(
1019 'type' => 'oldimage',
1020 'target' => $this->title->getPrefixedText(),
1021 'ids' => $ts,
1022 );
1023 $del = Linker::revDeleteLink( $query,
1024 $file->isDeleted( File::DELETED_RESTRICTED ), $canHide );
1025 }
1026 $row .= $del;
1027 }
1028 $row .= '</td>';
1029 }
1030
1031 // Reversion link/current indicator
1032 $row .= '<td>';
1033 if ( $iscur ) {
1034 $row .= $this->msg( 'filehist-current' )->escaped();
1035 } elseif ( $local && $this->title->quickUserCan( 'edit', $user )
1036 && $this->title->quickUserCan( 'upload', $user )
1037 ) {
1038 if ( $file->isDeleted( File::DELETED_FILE ) ) {
1039 $row .= $this->msg( 'filehist-revert' )->escaped();
1040 } else {
1041 $row .= Linker::linkKnown(
1042 $this->title,
1043 $this->msg( 'filehist-revert' )->escaped(),
1044 array(),
1045 array(
1046 'action' => 'revert',
1047 'oldimage' => $img,
1048 'wpEditToken' => $user->getEditToken( $img )
1049 )
1050 );
1051 }
1052 }
1053 $row .= '</td>';
1054
1055 // Date/time and image link
1056 if ( $file->getTimestamp() === $this->img->getTimestamp() ) {
1057 $selected = "class='filehistory-selected'";
1058 }
1059 $row .= "<td $selected style='white-space: nowrap;'>";
1060 if ( !$file->userCan( File::DELETED_FILE, $user ) ) {
1061 # Don't link to unviewable files
1062 $row .= '<span class="history-deleted">' . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
1063 } elseif ( $file->isDeleted( File::DELETED_FILE ) ) {
1064 if ( $local ) {
1065 $this->preventClickjacking();
1066 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
1067 # Make a link to review the image
1068 $url = Linker::linkKnown(
1069 $revdel,
1070 $lang->userTimeAndDate( $timestamp, $user ),
1071 array(),
1072 array(
1073 'target' => $this->title->getPrefixedText(),
1074 'file' => $img,
1075 'token' => $user->getEditToken( $img )
1076 )
1077 );
1078 } else {
1079 $url = $lang->userTimeAndDate( $timestamp, $user );
1080 }
1081 $row .= '<span class="history-deleted">' . $url . '</span>';
1082 } else {
1083 $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
1084 $row .= Xml::element( 'a', array( 'href' => $url ), $lang->userTimeAndDate( $timestamp, $user ) );
1085 }
1086 $row .= "</td>";
1087
1088 // Thumbnail
1089 if ( $this->showThumb ) {
1090 $row .= '<td>' . $this->getThumbForLine( $file ) . '</td>';
1091 }
1092
1093 // Image dimensions + size
1094 $row .= '<td>';
1095 $row .= htmlspecialchars( $file->getDimensionsString() );
1096 $row .= $this->msg( 'word-separator' )->plain();
1097 $row .= '<span style="white-space: nowrap;">';
1098 $row .= $this->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain();
1099 $row .= '</span>';
1100 $row .= '</td>';
1101
1102 // Uploading user
1103 $row .= '<td>';
1104 // Hide deleted usernames
1105 if ( $file->isDeleted( File::DELETED_USER ) ) {
1106 $row .= '<span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
1107 } else {
1108 if ( $local ) {
1109 $row .= Linker::userLink( $userId, $userText );
1110 $row .= $this->msg( 'word-separator' )->plain();
1111 $row .= '<span style="white-space: nowrap;">';
1112 $row .= Linker::userToolLinks( $userId, $userText );
1113 $row .= '</span>';
1114 } else {
1115 $row .= htmlspecialchars( $userText );
1116 }
1117 }
1118 $row .= '</td>';
1119
1120 // Don't show deleted descriptions
1121 if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
1122 $row .= '<td><span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span></td>';
1123 } else {
1124 $row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::formatComment( $description, $this->title ) . '</td>';
1125 }
1126
1127 $rowClass = null;
1128 wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
1129 $classAttr = $rowClass ? " class='$rowClass'" : '';
1130
1131 return "<tr{$classAttr}>{$row}</tr>\n";
1132 }
1133
1134 /**
1135 * @param $file File
1136 * @return string
1137 */
1138 protected function getThumbForLine( $file ) {
1139 $lang = $this->getLanguage();
1140 $user = $this->getUser();
1141 if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE,$user )
1142 && !$file->isDeleted( File::DELETED_FILE ) )
1143 {
1144 $params = array(
1145 'width' => '120',
1146 'height' => '120',
1147 );
1148 $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
1149
1150 $thumbnail = $file->transform( $params );
1151 $options = array(
1152 'alt' => $this->msg( 'filehist-thumbtext',
1153 $lang->userTimeAndDate( $timestamp, $user ),
1154 $lang->userDate( $timestamp, $user ),
1155 $lang->userTime( $timestamp, $user ) )->text(),
1156 'file-link' => true,
1157 );
1158
1159 if ( !$thumbnail ) {
1160 return $this->msg( 'filehist-nothumb' )->escaped();
1161 }
1162
1163 return $thumbnail->toHtml( $options );
1164 } else {
1165 return $this->msg( 'filehist-nothumb' )->escaped();
1166 }
1167 }
1168
1169 /**
1170 * @param $enable bool
1171 */
1172 protected function preventClickjacking( $enable = true ) {
1173 $this->preventClickjacking = $enable;
1174 }
1175
1176 /**
1177 * @return bool
1178 */
1179 public function getPreventClickjacking() {
1180 return $this->preventClickjacking;
1181 }
1182 }
1183
1184 class ImageHistoryPseudoPager extends ReverseChronologicalPager {
1185 protected $preventClickjacking = false;
1186
1187 /**
1188 * @var File
1189 */
1190 protected $mImg;
1191
1192 /**
1193 * @var Title
1194 */
1195 protected $mTitle;
1196
1197 /**
1198 * @param ImagePage $imagePage
1199 */
1200 function __construct( $imagePage ) {
1201 parent::__construct();
1202 $this->mImagePage = $imagePage;
1203 $this->mTitle = clone ( $imagePage->getTitle() );
1204 $this->mTitle->setFragment( '#filehistory' );
1205 $this->mImg = null;
1206 $this->mHist = array();
1207 $this->mRange = array( 0, 0 ); // display range
1208 }
1209
1210 /**
1211 * @return Title
1212 */
1213 function getTitle() {
1214 return $this->mTitle;
1215 }
1216
1217 function getQueryInfo() {
1218 return false;
1219 }
1220
1221 /**
1222 * @return string
1223 */
1224 function getIndexField() {
1225 return '';
1226 }
1227
1228 /**
1229 * @param $row object
1230 * @return string
1231 */
1232 function formatRow( $row ) {
1233 return '';
1234 }
1235
1236 /**
1237 * @return string
1238 */
1239 function getBody() {
1240 $s = '';
1241 $this->doQuery();
1242 if ( count( $this->mHist ) ) {
1243 $list = new ImageHistoryList( $this->mImagePage );
1244 # Generate prev/next links
1245 $navLink = $this->getNavigationBar();
1246 $s = $list->beginImageHistoryList( $navLink );
1247 // Skip rows there just for paging links
1248 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
1249 $file = $this->mHist[$i];
1250 $s .= $list->imageHistoryLine( !$file->isOld(), $file );
1251 }
1252 $s .= $list->endImageHistoryList( $navLink );
1253
1254 if ( $list->getPreventClickjacking() ) {
1255 $this->preventClickjacking();
1256 }
1257 }
1258 return $s;
1259 }
1260
1261 function doQuery() {
1262 if ( $this->mQueryDone ) {
1263 return;
1264 }
1265 $this->mImg = $this->mImagePage->getFile(); // ensure loading
1266 if ( !$this->mImg->exists() ) {
1267 return;
1268 }
1269 $queryLimit = $this->mLimit + 1; // limit plus extra row
1270 if ( $this->mIsBackwards ) {
1271 // Fetch the file history
1272 $this->mHist = $this->mImg->getHistory( $queryLimit, null, $this->mOffset, false );
1273 // The current rev may not meet the offset/limit
1274 $numRows = count( $this->mHist );
1275 if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
1276 $this->mHist = array_merge( array( $this->mImg ), $this->mHist );
1277 }
1278 } else {
1279 // The current rev may not meet the offset
1280 if ( !$this->mOffset || $this->mImg->getTimestamp() < $this->mOffset ) {
1281 $this->mHist[] = $this->mImg;
1282 }
1283 // Old image versions (fetch extra row for nav links)
1284 $oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
1285 // Fetch the file history
1286 $this->mHist = array_merge( $this->mHist,
1287 $this->mImg->getHistory( $oiLimit, $this->mOffset, null, false ) );
1288 }
1289 $numRows = count( $this->mHist ); // Total number of query results
1290 if ( $numRows ) {
1291 # Index value of top item in the list
1292 $firstIndex = $this->mIsBackwards ?
1293 $this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
1294 # Discard the extra result row if there is one
1295 if ( $numRows > $this->mLimit && $numRows > 1 ) {
1296 if ( $this->mIsBackwards ) {
1297 # Index value of item past the index
1298 $this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
1299 # Index value of bottom item in the list
1300 $lastIndex = $this->mHist[1]->getTimestamp();
1301 # Display range
1302 $this->mRange = array( 1, $numRows - 1 );
1303 } else {
1304 # Index value of item past the index
1305 $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
1306 # Index value of bottom item in the list
1307 $lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
1308 # Display range
1309 $this->mRange = array( 0, $numRows - 2 );
1310 }
1311 } else {
1312 # Setting indexes to an empty string means that they will be
1313 # omitted if they would otherwise appear in URLs. It just so
1314 # happens that this is the right thing to do in the standard
1315 # UI, in all the relevant cases.
1316 $this->mPastTheEndIndex = '';
1317 # Index value of bottom item in the list
1318 $lastIndex = $this->mIsBackwards ?
1319 $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
1320 # Display range
1321 $this->mRange = array( 0, $numRows - 1 );
1322 }
1323 } else {
1324 $firstIndex = '';
1325 $lastIndex = '';
1326 $this->mPastTheEndIndex = '';
1327 }
1328 if ( $this->mIsBackwards ) {
1329 $this->mIsFirst = ( $numRows < $queryLimit );
1330 $this->mIsLast = ( $this->mOffset == '' );
1331 $this->mLastShown = $firstIndex;
1332 $this->mFirstShown = $lastIndex;
1333 } else {
1334 $this->mIsFirst = ( $this->mOffset == '' );
1335 $this->mIsLast = ( $numRows < $queryLimit );
1336 $this->mLastShown = $lastIndex;
1337 $this->mFirstShown = $firstIndex;
1338 }
1339 $this->mQueryDone = true;
1340 }
1341
1342 /**
1343 * @param $enable bool
1344 */
1345 protected function preventClickjacking( $enable = true ) {
1346 $this->preventClickjacking = $enable;
1347 }
1348
1349 /**
1350 * @return bool
1351 */
1352 public function getPreventClickjacking() {
1353 return $this->preventClickjacking;
1354 }
1355
1356 }