Do not assume that the current working dir is phase3/config
[lhc/web/wiklou.git] / includes / ImagePage.php
index 1bfbdc9..6676ea8 100644 (file)
@@ -22,7 +22,11 @@ class ImagePage extends Article {
                $this->dupes = null;
                $this->repo = null;
        }
-       
+
+       /**
+        * @param  $file File:
+        * @return void
+        */
        public function setFile( $file ) {
                $this->displayImg = $file;
                $this->img = $file;
@@ -143,13 +147,9 @@ class ImagePage extends Article {
                        $wgOut->addHTML( $html );
 
                if ( $showmeta ) {
-                       $expand = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-expand' ) ) );
-                       $collapse = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-collapse' ) ) );
                        $wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" );
                        $wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
                        $wgOut->addModules( array( 'mediawiki.legacy.metadata' ) );
-                       $wgOut->addHTML(
-                               "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
                }
                
                $css = $this->repo->getDescriptionStylesheetUrl();
@@ -290,7 +290,7 @@ class ImagePage extends Article {
                if ( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) {
                        return '';
                }
-               return Article::getContent();
+               return parent::getContent();
        }
 
        protected function openShowImage() {
@@ -299,7 +299,6 @@ class ImagePage extends Article {
 
                $this->loadFile();
 
-               $full_url  = $this->displayImg->getURL();
                $sizeSel = intval( $wgUser->getOption( 'imagesize' ) );
                if ( !isset( $wgImageLimits[$sizeSel] ) ) {
                        $sizeSel = User::getDefaultOption( 'imagesize' );
@@ -331,8 +330,6 @@ class ImagePage extends Article {
                        $height_orig = $this->displayImg->getHeight( $page );
                        $height = $height_orig;
 
-                       $showLink = false;
-                       $linkAttribs = array( 'href' => $full_url );
                        $longDesc = $this->displayImg->getLongDesc();
 
                        wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) );
@@ -442,7 +439,7 @@ class ImagePage extends Article {
                                        $wgOut->addHTML(
                                                '</td><td><div class="multipageimagenavbox">' .
                                                Xml::openElement( 'form', $formParams ) .
-                                               Xml::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
+                                               Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
                                                wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
                                                Xml::submitButton( wfMsg( 'imgmultigo' ) ) .
                                                Xml::closeElement( 'form' ) .
@@ -520,6 +517,11 @@ EOT
                $descUrl = $this->img->getDescriptionUrl();
                $descText = $this->img->getDescriptionText();
 
+               /* Add canonical to head if there is no local page for this shared file */
+               if( $descUrl && $this->getID() == 0 ) {
+                       $wgOut->addLink( array( 'rel' => 'canonical', 'href' => $descUrl ) );
+               }
+
                $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
                $repo = $this->img->getRepo()->getDisplayName();
 
@@ -644,7 +646,7 @@ EOT
                $sk = $wgUser->getSkin();
                $count = 0;
                $elements = array();
-               while ( $s = $res->fetchObject() ) {
+               foreach ( $res as $s ) {
                        $count++;
                        if ( $count <= $limit ) {
                                // We have not yet reached the extra one that tells us there is more to fetch
@@ -1006,6 +1008,7 @@ class ImageHistoryList {
                }
                $row .= '</td>';
 
+               $rowClass = null;
                wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
                $classAttr = $rowClass ? " class='$rowClass'" : "";