X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImagePage.php;h=55e63baffe8912536f4e7e8bd98d48c1b8a94b41;hb=06adafb3d506a347cc7cffbe50a3c15dc8368912;hp=a9070dae043ea1ec45f8a85822e15a69cfb03391;hpb=d4c4ed8bfeaca6c009b4335344e5045b64465c4c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImagePage.php b/includes/ImagePage.php index a9070dae04..55e63baffe 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -13,45 +13,34 @@ class ImagePage extends Article { /* private */ var $img; // Image object /* private */ var $displayImg; /* private */ var $repo; - /* private */ var $time; /* private */ var $fileLoaded; var $mExtraDescription = false; var $dupes; - function __construct( $title, $time = null ) { + function __construct( $title ) { parent::__construct( $title ); - - global $wgRequest; - $time = is_null($time) ? $wgRequest->getVal( 'filetimestamp' ) : $time; - $time = $time ? $time : false; // be clear about type - $this->time = $time; $this->dupes = null; $this->repo = null; } - + protected function loadFile() { if ( $this->fileLoaded ) { return true; } - $this->displayImg = wfFindFile( $this->mTitle, $this->time ); - # If none found, and no time given, use a valid local placeholder - if ( !$this->displayImg && !$this->time ) { - $this->displayImg = wfLocalFile( $this->mTitle ); - $this->img = $this->displayImg; - # If none found, and time given, try current - } else if ( !$this->displayImg && $this->time ) { - $this->displayImg = wfFindFile( $this->mTitle ); - # If none found, use a valid local placeholder - if( !$this->displayImg ) { - $this->displayImg = wfLocalFile( $this->mTitle ); // fallback to current + $this->fileLoaded = true; + + $this->displayImg = $this->img = false; + wfRunHooks( 'ImagePageFindFile', array( $this, &$this->img, &$this->displayImg ) ); + if ( !$this->img ) { + $this->img = wfFindFile( $this->mTitle ); + if ( !$this->img ) { + $this->img = wfLocalFile( $this->mTitle ); } - $this->img = $this->displayImg; - # If found, set $this->img. This will be the same if no time given - } else { - $this->img = $this->time ? wfFindFile( $this->mTitle ) : $this->displayImg; + } + if ( !$this->displayImg ) { + $this->displayImg = $this->img; } $this->repo = $this->img->getRepo(); - $this->fileLoaded = true; } /** @@ -552,10 +541,11 @@ EOT function checkSharedConflictCallback( $repo ) { $this->loadFile(); $dupfile = $repo->newFile( $this->img->getTitle() ); - if( $dupfile->exists() ) { + if( $dupfile && $dupfile->exists() ) { $this->dupFile = $dupfile; + return $dupfile->exists(); } - return $dupfile->exists(); + return false; } function getUploadUrl() { @@ -608,13 +598,11 @@ EOT */ function imageHistory() { - global $wgUser, $wgOut, $wgUseExternalEditor; - - $sk = $wgUser->getSkin(); + global $wgOut, $wgUseExternalEditor; $this->loadFile(); if ( $this->img->exists() ) { - $list = new ImageHistoryList( $sk, $this->img, $this->displayImg ); + $list = new ImageHistoryList( $this ); $file = $this->img; $dims = $file->getDimensionsString(); $s = $list->beginImageHistoryList(); @@ -656,9 +644,12 @@ EOT ); if ( 0 == $dbr->numRows( $res ) ) { + $wgOut->addHTML( "