* (bug 2316) Add "caption" attribute to <gallery> tag
authorRob Church <robchurch@users.mediawiki.org>
Sat, 24 Jun 2006 00:12:34 +0000 (00:12 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sat, 24 Jun 2006 00:12:34 +0000 (00:12 +0000)
* Allow setting the skin object that ImageGallery will use; needed during parse operations (the skin must come from the ParserOptions, not $wgUser)
* Prod a few skin files and increment some cache-smashers

RELEASE-NOTES
includes/Article.php
includes/ImageGallery.php
includes/Parser.php
skins/CologneBlue.php
skins/MonoBook.php
skins/common/cologneblue.css
skins/common/common.css
skins/monobook/main.css

index 2d30024..0855b57 100644 (file)
@@ -544,6 +544,9 @@ Some default configuration options have changed:
   preference.
 * Make sure '~~~' '~~~~' '~~~~~' are removed in Nickname preference.
 * Rename "ipusuccess" to "unblocked", change the format (now wiki text)
+* (bug 2316) Add "caption" attribute to <gallery> tag
+* Allow setting the skin object that ImageGallery will use; needed during parse
+  operations (the skin must come from the ParserOptions, not $wgUser)
 
 == Compatibility ==
 
index 402bced..b2f8cb0 100644 (file)
@@ -2104,6 +2104,7 @@ class Article {
                $wgOut->setRobotpolicy( 'noindex,nofollow' );
                $wgOut->addHTML( '<h2>' . htmlspecialchars( $newComment ) . "</h2>\n<hr />\n" );
 
+               #$this->updateArticle( $target->getText(), $newComment, 1, $this->mTitle->userIsWatching(), $bot );
                $this->updateArticle( $target->getText(), $newComment, 1, $this->mTitle->userIsWatching(), $bot );
 
                $wgOut->returnToMain( false );
index 4ae92d0..86927c5 100644 (file)
@@ -16,6 +16,8 @@ if ( ! defined( 'MEDIAWIKI' ) )
 class ImageGallery
 {
        var $mImages, $mShowBytes, $mShowFilename;
+       var $mCaption = false;
+       var $mSkin = false;
        
        /**
         * Is the gallery on a wiki page (i.e. not a special page)
@@ -38,6 +40,40 @@ class ImageGallery
        function setParsing( $val = true ) {
                $this->mParsing = $val;
        }
+       
+       /**
+        * Set the caption
+        * What's passed is used as HTML so don't do anything stupid
+        *
+        * @param $caption Caption
+        */
+       function setCaption( $caption ) {
+               $this->mCaption = $caption;
+       }
+
+       /**
+        * Instruct the class to use a specific skin for rendering
+        *
+        * @param $skin Skin object
+        */
+       function useSkin( &$skin ) {
+               $this->mSkin =& $skin;
+       }
+       
+       /**
+        * Return the skin that should be used
+        *
+        * @return Skin object
+        */
+       function getSkin() {
+               if( !$this->mSkin ) {
+                       global $wgUser;
+                       $skin =& $wgUser->getSkin();
+               } else {
+                       $skin =& $this->mSkin;
+               }
+               return $skin;
+       }
 
        /**
         * Add an image to the gallery.
@@ -98,11 +134,14 @@ class ImageGallery
         *
         */
        function toHTML() {
-               global $wgLang, $wgUser, $wgIgnoreImageErrors;
+               global $wgLang, $wgIgnoreImageErrors;
 
-               $sk = $wgUser->getSkin();
+               $sk =& $this->getSkin();
 
                $s = '<table class="gallery" cellspacing="0" cellpadding="0">';
+               if( $this->mCaption )
+                       $s .= '<td class="galleryheader" colspan="4"><big>' . $this->mCaption . '</big></td>';
+               
                $i = 0;
                foreach ( $this->mImages as $pair ) {
                        $img =& $pair[0];
index 530ff8b..8baaf97 100644 (file)
@@ -473,7 +473,7 @@ class Parser
                                        $output = MathRenderer::renderMath( $content );
                                        break;
                                case 'gallery':
-                                       $output = $this->renderImageGallery( $content );
+                                       $output = $this->renderImageGallery( $content, $params );
                                        break;
                                default:
                                        if( isset( $this->mTagHooks[$tagName] ) ) {
@@ -4117,13 +4117,17 @@ class Parser
         * labeled 'The number "1"' and
         * 'A tree'.
         */
-       function renderImageGallery( $text ) {
+       function renderImageGallery( $text, $params ) {
                $ig = new ImageGallery();
                $ig->setShowBytes( false );
                $ig->setShowFilename( false );
                $ig->setParsing();
-               $lines = explode( "\n", $text );
+               $ig->useSkin( $this->mOptions->getSkin() );
 
+               if( isset( $params['caption'] ) )
+                       $ig->setCaption( $this->replaceInternalLinks( $params['caption'] ) );
+               
+               $lines = explode( "\n", $text );
                foreach ( $lines as $line ) {
                        # match lines like these:
                        # Image:someimage.jpg|This is some image
index 9cb3ef3..b5f7c91 100644 (file)
@@ -18,7 +18,7 @@ if( !defined( 'MEDIAWIKI' ) )
 class SkinCologneBlue extends Skin {
 
        function getStylesheet() {
-               return "common/cologneblue.css?1";
+               return "common/cologneblue.css?2";
        }
        function getSkinName() {
                return "cologneblue";
index 67b2e38..c80700d 100644 (file)
@@ -56,7 +56,7 @@ class MonoBookTemplate extends QuickTemplate {
                <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
                <?php $this->html('headlinks') ?>
                <title><?php $this->text('pagetitle') ?></title>
-               <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?8"; /*]]>*/</style>
+               <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?9"; /*]]>*/</style>
                <link rel="stylesheet" type="text/css" <?php if(empty($this->data['printable']) ) { ?>media="print"<?php } ?> href="<?php $this->text('stylepath') ?>/common/commonPrint.css" />
                <!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css";</style><![endif]-->
                <!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css";</style><![endif]-->
index db489d3..33c12ab 100644 (file)
@@ -1,4 +1,4 @@
-@import url("common.css?1");
+@import url("common.css?2");
 
 body { margin: 0px; padding: 0px; color: black; }
 #specialform { display: inline; }
@@ -93,5 +93,4 @@ a.printable { text-decoration: underline; }
 a.stub, #quickbar a.stub { color:#772233; text-decoration:none; }
 a.new, #quickbar a.new { color: #CC2200; }
 h2, h3, h4, h5, h6 { margin-bottom: 0; }
-small { font-size: 75%; }
-
+small { font-size: 75%; }
\ No newline at end of file
index 3e51c89..09409fd 100644 (file)
@@ -378,4 +378,9 @@ table.collapsed tr.collapsable {
 
 #jump-to-nav {
   display: none;
+}
+
+table.gallery td.galleryheader {
+       text-align: center;
+       font-weight: bold;
 }
\ No newline at end of file
index 9960c8f..6373d18 100644 (file)
@@ -1222,6 +1222,11 @@ table.gallery td {
        border: solid 2px white;
 }
 
+table.gallery td.galleryheader {
+       text-align: center;
+       font-weight: bold;
+}
+
 div.gallerybox {
        margin: 2px;
        width:  150px;