Modified Image Gallery

From University of Washington - Ubicomp Research Page
Revision as of 01:18, 29 April 2007 by Jonathan Lester (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This change involves adding a 'nocols' (number of columns) argument to a wiki gallery. Note the patches need a bit of clean-up due to the fact that the only other wiki available for comparison (when they were made) were slighly different versions.

<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 ) {

@@ -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 ) ? '</tr>' : ; $i++; } - if( $i %4 != 0 ) { + if( $i % $this->mNumCols != 0 ) { $s .= "</tr>\n"; } $s .= '';

</diff>