Difference between revisions of "Modified Image Gallery"

From University of Washington - Ubicomp Research Page
Jump to: navigation, search
m
 
m
 
(2 intermediate revisions by the same user not shown)
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. 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>
+
<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 @@
Line 73: Line 71:
 
                 $i = 0;
 
                 $i = 0;
 
                 foreach ( $this->mImages as $pair ) {
 
                 foreach ( $this->mImages as $pair ) {
@@ -158,7 +168,8 @@
 
                                # The image is blacklisted, just show it as a text link.
 
                                $thumbhtml = '<div style="height: 152px;">'
 
                                        . $sk->makeKnownLinkObj( $nt, htmlspecialchars( $nt->getText() ) ) . '</div>';
 
-                      } else if( !( $thumb = $img->getThumbnail( 120, 120, $wgGenerateThumbnailOnParse ) ) ) {
 
+                      }
 
+                      else if( !( $thumb = $img->getThumbnail( 120, 120, $wgGenerateThumbnailOnParse ) ) ) {
 
                                # Error generating thumbnail.
 
                                $thumbhtml = '<div style="height: 152px;">'
 
                                        . htmlspecialchars( $img->getLastError() ) . '</div>';
 
 
@@ -192,14 +203,14 @@
 
@@ -192,14 +203,14 @@
 
                         # in version 4.8.6 generated crackpot html in its absence, see:
 
                         # in version 4.8.6 generated crackpot html in its absence, see:

Latest revision as of 01:18, 29 April 2007

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>