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