Modified Image Gallery: Difference between revisions

From University of Washington - Ubicomp Research Page
Jump to navigationJump to search
mNo edit summary
 
mNo edit summary
Line 1: Line 1:
This change involves adding a 'nocols' (number of columns) argument to a wiki gallery:
This change involves adding a 'nocols' (number of columns) argument to a wiki gallery:


<diff>
<diff>--- ../../oldWiki/includes/Parser.php    2006-10-13 17:06:32.000000000 -0700
--- ../../oldWiki/includes/Parser.php    2006-10-13 17:06:32.000000000 -0700
+++ ./Parser.php        2007-03-08 21:54:50.000000000 -0800
+++ ./Parser.php        2007-03-08 21:54:50.000000000 -0800
@@ -4221,6 +4059,9 @@
@@ -4221,6 +4059,9 @@
Line 16: Line 15:
</diff>
</diff>


<diff>
<diff>--- ../../oldWiki/includes/ImageGallery.php      2006-10-13 17:06:35.000000000 -0700
--- ../../oldWiki/includes/ImageGallery.php      2006-10-13 17:06:35.000000000 -0700
+++ ./ImageGallery.php  2007-03-14 14:51:18.000000000 -0700
+++ ./ImageGallery.php  2007-03-14 14:51:18.000000000 -0700
@@ -18,6 +18,7 @@
@@ -18,6 +18,7 @@

Revision as of 01:17, 29 April 2007

This change involves adding a 'nocols' (number of columns) argument to a wiki gallery:

<diff>--- ../../oldWiki/includes/Parser.php 2006-10-13 17:06:32.000000000 -0700 +++ ./Parser.php 2007-03-08 21:54:50.000000000 -0800 @@ -4221,6 +4059,9 @@

               if( isset( $params['caption'] ) )
                       $ig->setCaption( $params['caption'] );

+ if( isset( $params['nocols'] ) ) + $ig->setNumcols( $params['nocols'] ); +

               $lines = explode( "\n", $text );
               foreach ( $lines as $line ) {
                       # match lines like these:

</diff>

<diff>--- ../../oldWiki/includes/ImageGallery.php 2006-10-13 17:06:35.000000000 -0700 +++ ./ImageGallery.php 2007-03-14 14:51:18.000000000 -0700 @@ -18,6 +18,7 @@

       var $mImages, $mShowBytes, $mShowFilename;
       var $mCaption = false;
       var $mSkin = false;

+ var $mNumCols = 4;

       /**
        * Is the gallery on a wiki page (i.e. not a special page)

@@ -50,12 +51,22 @@

               $this->mCaption = $caption;
       }

+ /** + * Set the number of columns + * @param $caption Caption + $this->mNumCols = ord($nocols) - ord('0'); + */ + function setNumcols( $nocols ) { + sscanf( $nocols, "%d", $this->mNumCols ); + } + +

       /**
        * Instruct the class to use a specific skin for rendering
        *
        * @param $skin Skin object
        */

- function useSkin( $skin ) { + function useSkin( &$skin ) {

               $this->mSkin =& $skin;
       }

@@ -82,7 +93,6 @@

        */
       function add( $image, $html= ) {
               $this->mImages[] = array( &$image, $html );

- wfDebug( "ImageGallery::add " . $image->getName() . "\n" );

       }

       /**

@@ -136,11 +146,11 @@

       function toHTML() {
               global $wgLang, $wgIgnoreImageErrors, $wgGenerateThumbnailOnParse;

- $sk = $this->getSkin(); + $sk =& $this->getSkin();

$s = '

'; if( $this->mCaption ) - $s .= ''; + $s .= '';
               $i = 0;
               foreach ( $this->mImages as $pair ) {

@@ -158,7 +168,8 @@

                               # The image is blacklisted, just show it as a text link.
$thumbhtml = '
' . $sk->makeKnownLinkObj( $nt, htmlspecialchars( $nt->getText() ) ) . '
';

- } else if( !( $thumb = $img->getThumbnail( 120, 120, $wgGenerateThumbnailOnParse ) ) ) { + } + else if( !( $thumb = $img->getThumbnail( 120, 120, $wgGenerateThumbnailOnParse ) ) ) {

                               # Error generating thumbnail.
$thumbhtml = '
' . htmlspecialchars( $img->getLastError() ) . '
';

@@ -192,14 +203,14 @@

                       # in version 4.8.6 generated crackpot html in its absence, see:
                       # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar

- $s .= ($i%4==0) ? '' : ; + $s .= ( $i % $this->mNumCols == 0 ) ? '' : ; $s .= '\n"; - $s .= ($i%4==3) ? '' : ; + $s .= ( $i % $this->mNumCols == $this->mNumCols-1 ) ? '' : ; $i++; } - if( $i %4 != 0 ) { + if( $i % $this->mNumCols != 0 ) { $s .= "\n"; } $s .= '

';

</diff>