merged master
[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
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::linkKnown(
418 $this->getTitle(),
419 $label,
420 array(),
421 array( 'page' => $page - 1 )
422 );
423 $thumb1 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none',
424 array( 'page' => $page - 1 ) );
425 } else {
426 $thumb1 = '';
427 }
428
429 if ( $page < $count ) {
430 $label = wfMsg( 'imgmultipagenext' );
431 $link = Linker::linkKnown(
432 $this->getTitle(),
433 $label,
434 array(),
435 array( 'page' => $page + 1 )
436 );
437 $thumb2 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none',
438 array( 'page' => $page + 1 ) );
439 } else {
440 $thumb2 = '';
441 }
442
443 global $wgScript;
444
445 $formParams = array(
446 'name' => 'pageselector',
447 'action' => $wgScript,
448 'onchange' => 'document.pageselector.submit();',
449 );
450 $options = array();
451 for ( $i = 1; $i <= $count; $i++ ) {
452 $options[] = Xml::option( $lang->formatNum( $i ), $i, $i == $page );
453 }
454 $select = Xml::tags( 'select',
455 array( 'id' => 'pageselector', 'name' => 'page' ),
456 implode( "\n", $options ) );
457
458 $out->addHTML(
459 '</td><td><div class="multipageimagenavbox">' .
460 Xml::openElement( 'form', $formParams ) .
461 Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
462 wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
463 Xml::submitButton( wfMsg( 'imgmultigo' ) ) .
464 Xml::closeElement( 'form' ) .
465 "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
466 );
467 }
468 } else {
469 # if direct link is allowed but it's not a renderable image, show an icon.
470 if ( $this->displayImg->isSafeFile() ) {
471 $icon = $this->displayImg->iconThumb();
472
473 $out->addHTML( '<div class="fullImageLink" id="file">' .
474 $icon->toHtml( array( 'file-link' => true ) ) .
475 "</div>\n" );
476 }
477
478 $showLink = true;
479 }
480
481 if ( $showLink ) {
482 $filename = wfEscapeWikiText( $this->displayImg->getName() );
483 $linktext = $filename;
484 if ( isset( $msgbig ) ) {
485 $linktext = wfEscapeWikiText( $msgbig );
486 }
487 $medialink = "[[Media:$filename|$linktext]]";
488
489 if ( !$this->displayImg->isSafeFile() ) {
490 $warning = wfMsgNoTrans( 'mediawarning' );
491 // dirmark is needed here to separate the file name, which
492 // most likely ends in Latin characters, from the description,
493 // which may begin with the file type. In RTL environment
494 // this will get messy.
495 // The dirmark, however, must not be immediately adjacent
496 // to the filename, because it can get copied with it.
497 // See bug 25277.
498 $out->addWikiText( <<<EOT
499 <div class="fullMedia"><span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span></div>
500 <div class="mediaWarning">$warning</div>
501 EOT
502 );
503 } else {
504 $out->addWikiText( <<<EOT
505 <div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
506 </div>
507 EOT
508 );
509 }
510 }
511
512 if ( !$this->displayImg->isLocal() ) {
513 $this->printSharedImageText();
514 }
515 } else {
516 # Image does not exist
517 if ( !$this->getID() ) {
518 # No article exists either
519 # Show deletion log to be consistent with normal articles
520 LogEventsList::showLogExtract(
521 $out,
522 array( 'delete', 'move' ),
523 $this->getTitle()->getPrefixedText(),
524 '',
525 array( 'lim' => 10,
526 'conds' => array( "log_action != 'revision'" ),
527 'showIfEmpty' => false,
528 'msgKey' => array( 'moveddeleted-notice' )
529 )
530 );
531 }
532
533 if ( $wgEnableUploads && $user->isAllowed( 'upload' ) ) {
534 // Only show an upload link if the user can upload
535 $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
536 $nofile = array(
537 'filepage-nofile-link',
538 $uploadTitle->getFullURL( array( 'wpDestFile' => $this->mPage->getFile()->getName() ) )
539 );
540 } else {
541 $nofile = 'filepage-nofile';
542 }
543 // Note, if there is an image description page, but
544 // no image, then this setRobotPolicy is overriden
545 // by Article::View().
546 $out->setRobotPolicy( 'noindex,nofollow' );
547 $out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
548 if ( !$this->getID() && $wgSend404Code ) {
549 // If there is no image, no shared image, and no description page,
550 // output a 404, to be consistent with articles.
551 $request->response()->header( 'HTTP/1.1 404 Not Found' );
552 }
553 }
554 $out->setFileVersion( $this->displayImg );
555 }
556
557 /**
558 * Creates an thumbnail of specified size and returns an HTML link to it
559 * @param $params array Scaler parameters
560 * @param $width int
561 * @param $height int
562 * @return string
563 */
564 private function makeSizeLink( $params, $width, $height ) {
565 $params['width'] = $width;
566 $params['height'] = $height;
567 $thumbnail = $this->displayImg->transform( $params );
568 if ( $thumbnail && !$thumbnail->isError() ) {
569 return Html::rawElement( 'a', array(
570 'href' => $thumbnail->getUrl(),
571 'class' => 'mw-thumbnail-link'
572 ), wfMessage( 'show-big-image-size' )->numParams(
573 $thumbnail->getWidth(), $thumbnail->getHeight()
574 )->parse() );
575 } else {
576 return '';
577 }
578 }
579
580 /**
581 * Show a notice that the file is from a shared repository
582 */
583 protected function printSharedImageText() {
584 $out = $this->getContext()->getOutput();
585 $this->loadFile();
586
587 $descUrl = $this->mPage->getFile()->getDescriptionUrl();
588 $descText = $this->mPage->getFile()->getDescriptionText();
589
590 /* Add canonical to head if there is no local page for this shared file */
591 if( $descUrl && $this->mPage->getID() == 0 ) {
592 $out->addLink( array( 'rel' => 'canonical', 'href' => $descUrl ) );
593 }
594
595 $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
596 $repo = $this->mPage->getFile()->getRepo()->getDisplayName();
597
598 if ( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-' ) {
599 $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
600 } elseif ( $descUrl && wfMsgNoTrans( 'sharedupload-desc-there' ) !== '-' ) {
601 $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) );
602 } else {
603 $out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ );
604 }
605
606 if ( $descText ) {
607 $this->mExtraDescription = $descText;
608 }
609 }
610
611 public function getUploadUrl() {
612 $this->loadFile();
613 $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
614 return $uploadTitle->getFullURL( array(
615 'wpDestFile' => $this->mPage->getFile()->getName(),
616 'wpForReUpload' => 1
617 ) );
618 }
619
620 /**
621 * Print out the various links at the bottom of the image page, e.g. reupload,
622 * external editing (and instructions link) etc.
623 */
624 protected function uploadLinksBox() {
625 global $wgEnableUploads, $wgUseExternalEditor;
626
627 if ( !$wgEnableUploads ) {
628 return;
629 }
630
631 $this->loadFile();
632 if ( !$this->mPage->getFile()->isLocal() ) {
633 return;
634 }
635
636 $out = $this->getContext()->getOutput();
637 $out->addHTML( "<br /><ul>\n" );
638
639 # "Upload a new version of this file" link
640 if ( UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) {
641 $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
642 $out->addHTML( "<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
643 }
644
645 # External editing link
646 if ( $wgUseExternalEditor ) {
647 $elink = Linker::linkKnown(
648 $this->getTitle(),
649 wfMsgHtml( 'edit-externally' ),
650 array(),
651 array(
652 'action' => 'edit',
653 'externaledit' => 'true',
654 'mode' => 'file'
655 )
656 );
657 $out->addHTML(
658 '<li id="mw-imagepage-edit-external">' . $elink . ' <small>' .
659 wfMsgExt( 'edit-externally-help', array( 'parseinline' ) ) .
660 "</small></li>\n"
661 );
662 }
663
664 $out->addHTML( "</ul>\n" );
665 }
666
667 protected function closeShowImage() { } # For overloading
668
669 /**
670 * If the page we've just displayed is in the "Image" namespace,
671 * we follow it with an upload history of the image and its usage.
672 */
673 protected function imageHistory() {
674 $this->loadFile();
675 $out = $this->getContext()->getOutput();
676 $pager = new ImageHistoryPseudoPager( $this );
677 $out->addHTML( $pager->getBody() );
678 $out->preventClickjacking( $pager->getPreventClickjacking() );
679
680 $this->mPage->getFile()->resetHistory(); // free db resources
681
682 # Exist check because we don't want to show this on pages where an image
683 # doesn't exist along with the noimage message, that would suck. -ævar
684 if ( $this->mPage->getFile()->exists() ) {
685 $this->uploadLinksBox();
686 }
687 }
688
689 /**
690 * @param $target
691 * @param $limit
692 * @return ResultWrapper
693 */
694 protected function queryImageLinks( $target, $limit ) {
695 $dbr = wfGetDB( DB_SLAVE );
696
697 return $dbr->select(
698 array( 'imagelinks', 'page' ),
699 array( 'page_namespace', 'page_title', 'page_is_redirect', 'il_to' ),
700 array( 'il_to' => $target, 'il_from = page_id' ),
701 __METHOD__,
702 array( 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', )
703 );
704 }
705
706 protected function imageLinks() {
707 $limit = 100;
708
709 $out = $this->getContext()->getOutput();
710 $res = $this->queryImageLinks( $this->getTitle()->getDbKey(), $limit + 1);
711 $rows = array();
712 $redirects = array();
713 foreach ( $res as $row ) {
714 if ( $row->page_is_redirect ) {
715 $redirects[$row->page_title] = array();
716 }
717 $rows[] = $row;
718 }
719 $count = count( $rows );
720
721 $hasMore = $count > $limit;
722 if ( !$hasMore && count( $redirects ) ) {
723 $res = $this->queryImageLinks( array_keys( $redirects ),
724 $limit - count( $rows ) + 1 );
725 foreach ( $res as $row ) {
726 $redirects[$row->il_to][] = $row;
727 $count++;
728 }
729 $hasMore = ( $res->numRows() + count( $rows ) ) > $limit;
730 }
731
732 if ( $count == 0 ) {
733 $out->wrapWikiMsg(
734 Html::rawElement( 'div',
735 array( 'id' => 'mw-imagepage-nolinkstoimage' ), "\n$1\n" ),
736 'nolinkstoimage'
737 );
738 return;
739 }
740
741 $out->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
742 if ( !$hasMore ) {
743 $out->addWikiMsg( 'linkstoimage', $count );
744 } else {
745 // More links than the limit. Add a link to [[Special:Whatlinkshere]]
746 $out->addWikiMsg( 'linkstoimage-more',
747 $this->getContext()->getLanguage()->formatNum( $limit ),
748 $this->getTitle()->getPrefixedDBkey()
749 );
750 }
751
752 $out->addHTML(
753 Html::openElement( 'ul',
754 array( 'class' => 'mw-imagepage-linkstoimage' ) ) . "\n"
755 );
756 $count = 0;
757
758 // Sort the list by namespace:title
759 usort( $rows, array( $this, 'compare' ) );
760
761 // Create links for every element
762 $currentCount = 0;
763 foreach( $rows as $element ) {
764 $currentCount++;
765 if ( $currentCount > $limit ) {
766 break;
767 }
768
769 $link = Linker::linkKnown( Title::makeTitle( $element->page_namespace, $element->page_title ) );
770 if ( !isset( $redirects[$element->page_title] ) ) {
771 $liContents = $link;
772 } else {
773 $ul = "<ul class='mw-imagepage-redirectstofile'>\n";
774 foreach ( $redirects[$element->page_title] as $row ) {
775 $currentCount++;
776 if ( $currentCount > $limit ) {
777 break;
778 }
779
780 $link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
781 $ul .= Html::rawElement(
782 'li',
783 array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
784 $link2
785 ) . "\n";
786 }
787 $ul .= '</ul>';
788 $liContents = wfMessage( 'linkstoimage-redirect' )->rawParams(
789 $link, $ul )->parse();
790 }
791 $out->addHTML( Html::rawElement(
792 'li',
793 array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
794 $liContents
795 ) . "\n"
796 );
797
798 };
799 $out->addHTML( Html::closeElement( 'ul' ) . "\n" );
800 $res->free();
801
802 // Add a links to [[Special:Whatlinkshere]]
803 if ( $count > $limit ) {
804 $out->addWikiMsg( 'morelinkstoimage', $this->getTitle()->getPrefixedDBkey() );
805 }
806 $out->addHTML( Html::closeElement( 'div' ) . "\n" );
807 }
808
809 protected function imageDupes() {
810 $this->loadFile();
811 $out = $this->getContext()->getOutput();
812
813 $dupes = $this->mPage->getDuplicates();
814 if ( count( $dupes ) == 0 ) {
815 return;
816 }
817
818 $out->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
819 $out->addWikiMsg( 'duplicatesoffile',
820 $this->getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->getTitle()->getDBkey()
821 );
822 $out->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
823
824 /**
825 * @var $file File
826 */
827 foreach ( $dupes as $file ) {
828 $fromSrc = '';
829 if ( $file->isLocal() ) {
830 $link = Linker::linkKnown( $file->getTitle() );
831 } else {
832 $link = Linker::makeExternalLink( $file->getDescriptionUrl(),
833 $file->getTitle()->getPrefixedText() );
834 $fromSrc = wfMsg( 'shared-repo-from', $file->getRepo()->getDisplayName() );
835 }
836 $out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
837 }
838 $out->addHTML( "</ul></div>\n" );
839 }
840
841 /**
842 * Delete the file, or an earlier version of it
843 */
844 public function delete() {
845 $file = $this->mPage->getFile();
846 if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
847 // Standard article deletion
848 parent::delete();
849 return;
850 }
851
852 $deleter = new FileDeleteForm( $file );
853 $deleter->execute();
854 }
855
856 /**
857 * Display an error with a wikitext description
858 *
859 * @param $description String
860 */
861 function showError( $description ) {
862 $out = $this->getContext()->getOutput();
863 $out->setPageTitle( wfMessage( 'internalerror' ) );
864 $out->setRobotPolicy( 'noindex,nofollow' );
865 $out->setArticleRelated( false );
866 $out->enableClientCache( false );
867 $out->addWikiText( $description );
868 }
869
870 /**
871 * Callback for usort() to do link sorts by (namespace, title)
872 * Function copied from Title::compare()
873 *
874 * @param $a object page to compare with
875 * @param $b object page to compare with
876 * @return Integer: result of string comparison, or namespace comparison
877 */
878 protected function compare( $a, $b ) {
879 if ( $a->page_namespace == $b->page_namespace ) {
880 return strcmp( $a->page_title, $b->page_title );
881 } else {
882 return $a->page_namespace - $b->page_namespace;
883 }
884 }
885 }
886
887 /**
888 * Builds the image revision log shown on image pages
889 *
890 * @ingroup Media
891 */
892 class ImageHistoryList extends ContextSource {
893
894 /**
895 * @var Title
896 */
897 protected $title;
898
899 /**
900 * @var File
901 */
902 protected $img;
903
904 /**
905 * @var ImagePage
906 */
907 protected $imagePage;
908
909 /**
910 * @var File
911 */
912 protected $current;
913
914 protected $repo, $showThumb;
915 protected $preventClickjacking = false;
916
917 /**
918 * @param ImagePage $imagePage
919 */
920 public function __construct( $imagePage ) {
921 global $wgShowArchiveThumbnails;
922 $this->current = $imagePage->getFile();
923 $this->img = $imagePage->getDisplayedFile();
924 $this->title = $imagePage->getTitle();
925 $this->imagePage = $imagePage;
926 $this->showThumb = $wgShowArchiveThumbnails && $this->img->canRender();
927 $this->setContext( $imagePage->getContext() );
928 }
929
930 /**
931 * @return ImagePage
932 */
933 public function getImagePage() {
934 return $this->imagePage;
935 }
936
937 /**
938 * @return File
939 */
940 public function getFile() {
941 return $this->img;
942 }
943
944 /**
945 * @param $navLinks string
946 * @return string
947 */
948 public function beginImageHistoryList( $navLinks = '' ) {
949 return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) . "\n"
950 . "<div id=\"mw-imagepage-section-filehistory\">\n"
951 . $this->msg( 'filehist-help' )->parseAsBlock()
952 . $navLinks . "\n"
953 . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
954 . '<tr><td></td>'
955 . ( $this->current->isLocal() && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
956 . '<th>' . $this->msg( 'filehist-datetime' )->escaped() . '</th>'
957 . ( $this->showThumb ? '<th>' . $this->msg( 'filehist-thumb' )->escaped() . '</th>' : '' )
958 . '<th>' . $this->msg( 'filehist-dimensions' )->escaped() . '</th>'
959 . '<th>' . $this->msg( 'filehist-user' )->escaped() . '</th>'
960 . '<th>' . $this->msg( 'filehist-comment' )->escaped() . '</th>'
961 . "</tr>\n";
962 }
963
964 /**
965 * @param $navLinks string
966 * @return string
967 */
968 public function endImageHistoryList( $navLinks = '' ) {
969 return "</table>\n$navLinks\n</div>\n";
970 }
971
972 /**
973 * @param $iscur
974 * @param $file File
975 * @return string
976 */
977 public function imageHistoryLine( $iscur, $file ) {
978 global $wgContLang;
979
980 $user = $this->getUser();
981 $lang = $this->getLanguage();
982 $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
983 $img = $iscur ? $file->getName() : $file->getArchiveName();
984 $userId = $file->getUser( 'id' );
985 $userText = $file->getUser( 'text' );
986 $description = $file->getDescription( File::FOR_THIS_USER, $user );
987
988 $local = $this->current->isLocal();
989 $row = $selected = '';
990
991 // Deletion link
992 if ( $local && ( $user->isAllowedAny( 'delete', 'deletedhistory' ) ) ) {
993 $row .= '<td>';
994 # Link to remove from history
995 if ( $user->isAllowed( 'delete' ) ) {
996 $q = array( 'action' => 'delete' );
997 if ( !$iscur ) {
998 $q['oldimage'] = $img;
999 }
1000 $row .= Linker::linkKnown(
1001 $this->title,
1002 $this->msg( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' )->escaped(),
1003 array(), $q
1004 );
1005 }
1006 # Link to hide content. Don't show useless link to people who cannot hide revisions.
1007 $canHide = $user->isAllowed( 'deleterevision' );
1008 if ( $canHide || ( $user->isAllowed( 'deletedhistory' ) && $file->getVisibility() ) ) {
1009 if ( $user->isAllowed( 'delete' ) ) {
1010 $row .= '<br />';
1011 }
1012 // If file is top revision or locked from this user, don't link
1013 if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED, $user ) ) {
1014 $del = Linker::revDeleteLinkDisabled( $canHide );
1015 } else {
1016 list( $ts, ) = explode( '!', $img, 2 );
1017 $query = array(
1018 'type' => 'oldimage',
1019 'target' => $this->title->getPrefixedText(),
1020 'ids' => $ts,
1021 );
1022 $del = Linker::revDeleteLink( $query,
1023 $file->isDeleted( File::DELETED_RESTRICTED ), $canHide );
1024 }
1025 $row .= $del;
1026 }
1027 $row .= '</td>';
1028 }
1029
1030 // Reversion link/current indicator
1031 $row .= '<td>';
1032 if ( $iscur ) {
1033 $row .= $this->msg( 'filehist-current' )->escaped();
1034 } elseif ( $local && $this->title->quickUserCan( 'edit', $user )
1035 && $this->title->quickUserCan( 'upload', $user )
1036 ) {
1037 if ( $file->isDeleted( File::DELETED_FILE ) ) {
1038 $row .= $this->msg( 'filehist-revert' )->escaped();
1039 } else {
1040 $row .= Linker::linkKnown(
1041 $this->title,
1042 $this->msg( 'filehist-revert' )->escaped(),
1043 array(),
1044 array(
1045 'action' => 'revert',
1046 'oldimage' => $img,
1047 'wpEditToken' => $user->getEditToken( $img )
1048 )
1049 );
1050 }
1051 }
1052 $row .= '</td>';
1053
1054 // Date/time and image link
1055 if ( $file->getTimestamp() === $this->img->getTimestamp() ) {
1056 $selected = "class='filehistory-selected'";
1057 }
1058 $row .= "<td $selected style='white-space: nowrap;'>";
1059 if ( !$file->userCan( File::DELETED_FILE, $user ) ) {
1060 # Don't link to unviewable files
1061 $row .= '<span class="history-deleted">' . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
1062 } elseif ( $file->isDeleted( File::DELETED_FILE ) ) {
1063 if ( $local ) {
1064 $this->preventClickjacking();
1065 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
1066 # Make a link to review the image
1067 $url = Linker::linkKnown(
1068 $revdel,
1069 $lang->userTimeAndDate( $timestamp, $user ),
1070 array(),
1071 array(
1072 'target' => $this->title->getPrefixedText(),
1073 'file' => $img,
1074 'token' => $user->getEditToken( $img )
1075 )
1076 );
1077 } else {
1078 $url = $lang->userTimeAndDate( $timestamp, $user );
1079 }
1080 $row .= '<span class="history-deleted">' . $url . '</span>';
1081 } else {
1082 $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
1083 $row .= Xml::element( 'a', array( 'href' => $url ), $lang->userTimeAndDate( $timestamp, $user ) );
1084 }
1085 $row .= "</td>";
1086
1087 // Thumbnail
1088 if ( $this->showThumb ) {
1089 $row .= '<td>' . $this->getThumbForLine( $file ) . '</td>';
1090 }
1091
1092 // Image dimensions + size
1093 $row .= '<td>';
1094 $row .= htmlspecialchars( $file->getDimensionsString() );
1095 $row .= $this->msg( 'word-separator' )->plain();
1096 $row .= '<span style="white-space: nowrap;">';
1097 $row .= $this->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain();
1098 $row .= '</span>';
1099 $row .= '</td>';
1100
1101 // Uploading user
1102 $row .= '<td>';
1103 // Hide deleted usernames
1104 if ( $file->isDeleted( File::DELETED_USER ) ) {
1105 $row .= '<span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
1106 } else {
1107 if ( $local ) {
1108 $row .= Linker::userLink( $userId, $userText );
1109 $row .= $this->msg( 'word-separator' )->plain();
1110 $row .= '<span style="white-space: nowrap;">';
1111 $row .= Linker::userToolLinks( $userId, $userText );
1112 $row .= '</span>';
1113 } else {
1114 $row .= htmlspecialchars( $userText );
1115 }
1116 }
1117 $row .= '</td>';
1118
1119 // Don't show deleted descriptions
1120 if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
1121 $row .= '<td><span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span></td>';
1122 } else {
1123 $row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::formatComment( $description, $this->title ) . '</td>';
1124 }
1125
1126 $rowClass = null;
1127 wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
1128 $classAttr = $rowClass ? " class='$rowClass'" : '';
1129
1130 return "<tr{$classAttr}>{$row}</tr>\n";
1131 }
1132
1133 /**
1134 * @param $file File
1135 * @return string
1136 */
1137 protected function getThumbForLine( $file ) {
1138 $lang = $this->getLanguage();
1139 $user = $this->getUser();
1140 if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE,$user )
1141 && !$file->isDeleted( File::DELETED_FILE ) )
1142 {
1143 $params = array(
1144 'width' => '120',
1145 'height' => '120',
1146 );
1147 $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
1148
1149 $thumbnail = $file->transform( $params );
1150 $options = array(
1151 'alt' => $this->msg( 'filehist-thumbtext',
1152 $lang->userTimeAndDate( $timestamp, $user ),
1153 $lang->userDate( $timestamp, $user ),
1154 $lang->userTime( $timestamp, $user ) )->text(),
1155 'file-link' => true,
1156 );
1157
1158 if ( !$thumbnail ) {
1159 return $this->msg( 'filehist-nothumb' )->escaped();
1160 }
1161
1162 return $thumbnail->toHtml( $options );
1163 } else {
1164 return $this->msg( 'filehist-nothumb' )->escaped();
1165 }
1166 }
1167
1168 /**
1169 * @param $enable bool
1170 */
1171 protected function preventClickjacking( $enable = true ) {
1172 $this->preventClickjacking = $enable;
1173 }
1174
1175 /**
1176 * @return bool
1177 */
1178 public function getPreventClickjacking() {
1179 return $this->preventClickjacking;
1180 }
1181 }
1182
1183 class ImageHistoryPseudoPager extends ReverseChronologicalPager {
1184 protected $preventClickjacking = false;
1185
1186 /**
1187 * @var File
1188 */
1189 protected $mImg;
1190
1191 /**
1192 * @var Title
1193 */
1194 protected $mTitle;
1195
1196 /**
1197 * @param ImagePage $imagePage
1198 */
1199 function __construct( $imagePage ) {
1200 parent::__construct();
1201 $this->mImagePage = $imagePage;
1202 $this->mTitle = clone ( $imagePage->getTitle() );
1203 $this->mTitle->setFragment( '#filehistory' );
1204 $this->mImg = null;
1205 $this->mHist = array();
1206 $this->mRange = array( 0, 0 ); // display range
1207 }
1208
1209 /**
1210 * @return Title
1211 */
1212 function getTitle() {
1213 return $this->mTitle;
1214 }
1215
1216 function getQueryInfo() {
1217 return false;
1218 }
1219
1220 /**
1221 * @return string
1222 */
1223 function getIndexField() {
1224 return '';
1225 }
1226
1227 /**
1228 * @param $row object
1229 * @return string
1230 */
1231 function formatRow( $row ) {
1232 return '';
1233 }
1234
1235 /**
1236 * @return string
1237 */
1238 function getBody() {
1239 $s = '';
1240 $this->doQuery();
1241 if ( count( $this->mHist ) ) {
1242 $list = new ImageHistoryList( $this->mImagePage );
1243 # Generate prev/next links
1244 $navLink = $this->getNavigationBar();
1245 $s = $list->beginImageHistoryList( $navLink );
1246 // Skip rows there just for paging links
1247 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
1248 $file = $this->mHist[$i];
1249 $s .= $list->imageHistoryLine( !$file->isOld(), $file );
1250 }
1251 $s .= $list->endImageHistoryList( $navLink );
1252
1253 if ( $list->getPreventClickjacking() ) {
1254 $this->preventClickjacking();
1255 }
1256 }
1257 return $s;
1258 }
1259
1260 function doQuery() {
1261 if ( $this->mQueryDone ) {
1262 return;
1263 }
1264 $this->mImg = $this->mImagePage->getFile(); // ensure loading
1265 if ( !$this->mImg->exists() ) {
1266 return;
1267 }
1268 $queryLimit = $this->mLimit + 1; // limit plus extra row
1269 if ( $this->mIsBackwards ) {
1270 // Fetch the file history
1271 $this->mHist = $this->mImg->getHistory( $queryLimit, null, $this->mOffset, false );
1272 // The current rev may not meet the offset/limit
1273 $numRows = count( $this->mHist );
1274 if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
1275 $this->mHist = array_merge( array( $this->mImg ), $this->mHist );
1276 }
1277 } else {
1278 // The current rev may not meet the offset
1279 if ( !$this->mOffset || $this->mImg->getTimestamp() < $this->mOffset ) {
1280 $this->mHist[] = $this->mImg;
1281 }
1282 // Old image versions (fetch extra row for nav links)
1283 $oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
1284 // Fetch the file history
1285 $this->mHist = array_merge( $this->mHist,
1286 $this->mImg->getHistory( $oiLimit, $this->mOffset, null, false ) );
1287 }
1288 $numRows = count( $this->mHist ); // Total number of query results
1289 if ( $numRows ) {
1290 # Index value of top item in the list
1291 $firstIndex = $this->mIsBackwards ?
1292 $this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
1293 # Discard the extra result row if there is one
1294 if ( $numRows > $this->mLimit && $numRows > 1 ) {
1295 if ( $this->mIsBackwards ) {
1296 # Index value of item past the index
1297 $this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
1298 # Index value of bottom item in the list
1299 $lastIndex = $this->mHist[1]->getTimestamp();
1300 # Display range
1301 $this->mRange = array( 1, $numRows - 1 );
1302 } else {
1303 # Index value of item past the index
1304 $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
1305 # Index value of bottom item in the list
1306 $lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
1307 # Display range
1308 $this->mRange = array( 0, $numRows - 2 );
1309 }
1310 } else {
1311 # Setting indexes to an empty string means that they will be
1312 # omitted if they would otherwise appear in URLs. It just so
1313 # happens that this is the right thing to do in the standard
1314 # UI, in all the relevant cases.
1315 $this->mPastTheEndIndex = '';
1316 # Index value of bottom item in the list
1317 $lastIndex = $this->mIsBackwards ?
1318 $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
1319 # Display range
1320 $this->mRange = array( 0, $numRows - 1 );
1321 }
1322 } else {
1323 $firstIndex = '';
1324 $lastIndex = '';
1325 $this->mPastTheEndIndex = '';
1326 }
1327 if ( $this->mIsBackwards ) {
1328 $this->mIsFirst = ( $numRows < $queryLimit );
1329 $this->mIsLast = ( $this->mOffset == '' );
1330 $this->mLastShown = $firstIndex;
1331 $this->mFirstShown = $lastIndex;
1332 } else {
1333 $this->mIsFirst = ( $this->mOffset == '' );
1334 $this->mIsLast = ( $numRows < $queryLimit );
1335 $this->mLastShown = $lastIndex;
1336 $this->mFirstShown = $firstIndex;
1337 }
1338 $this->mQueryDone = true;
1339 }
1340
1341 /**
1342 * @param $enable bool
1343 */
1344 protected function preventClickjacking( $enable = true ) {
1345 $this->preventClickjacking = $enable;
1346 }
1347
1348 /**
1349 * @return bool
1350 */
1351 public function getPreventClickjacking() {
1352 return $this->preventClickjacking;
1353 }
1354
1355 }