From 73be040a7af289f40ba95950ad57d64f8434b3a1 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sat, 24 Jun 2006 00:12:34 +0000 Subject: [PATCH] * (bug 2316) Add "caption" attribute to tag * 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 | 3 +++ includes/Article.php | 1 + includes/ImageGallery.php | 43 ++++++++++++++++++++++++++++++++++-- includes/Parser.php | 10 ++++++--- skins/CologneBlue.php | 2 +- skins/MonoBook.php | 2 +- skins/common/cologneblue.css | 5 ++--- skins/common/common.css | 5 +++++ skins/monobook/main.css | 5 +++++ 9 files changed, 66 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2d300241a7..0855b574b2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 tag +* Allow setting the skin object that ImageGallery will use; needed during parse + operations (the skin must come from the ParserOptions, not $wgUser) == Compatibility == diff --git a/includes/Article.php b/includes/Article.php index 402bceddc4..b2f8cb0856 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -2104,6 +2104,7 @@ class Article { $wgOut->setRobotpolicy( 'noindex,nofollow' ); $wgOut->addHTML( '

' . htmlspecialchars( $newComment ) . "

\n
\n" ); + #$this->updateArticle( $target->getText(), $newComment, 1, $this->mTitle->userIsWatching(), $bot ); $this->updateArticle( $target->getText(), $newComment, 1, $this->mTitle->userIsWatching(), $bot ); $wgOut->returnToMain( false ); diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 4ae92d0e3f..86927c5b0e 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -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 = ''; + if( $this->mCaption ) + $s .= ''; + $i = 0; foreach ( $this->mImages as $pair ) { $img =& $pair[0]; diff --git a/includes/Parser.php b/includes/Parser.php index 530ff8b9bd..8baaf97e89 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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 diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index 9cb3ef32dd..b5f7c91772 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -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"; diff --git a/skins/MonoBook.php b/skins/MonoBook.php index 67b2e38209..c80700d005 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -56,7 +56,7 @@ class MonoBookTemplate extends QuickTemplate { html('headlinks') ?> <?php $this->text('pagetitle') ?> - + data['printable']) ) { ?>media="print" href="text('stylepath') ?>/common/commonPrint.css" /> diff --git a/skins/common/cologneblue.css b/skins/common/cologneblue.css index db489d3689..33c12abb48 100644 --- a/skins/common/cologneblue.css +++ b/skins/common/cologneblue.css @@ -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 diff --git a/skins/common/common.css b/skins/common/common.css index 3e51c89797..09409fd6fa 100644 --- a/skins/common/common.css +++ b/skins/common/common.css @@ -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 diff --git a/skins/monobook/main.css b/skins/monobook/main.css index 9960c8f8cb..6373d18fd1 100644 --- a/skins/monobook/main.css +++ b/skins/monobook/main.css @@ -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; -- 2.20.1