[pLog-svn] r2149 - in plugins/trunk: . galleryimages
Mark Wu
markplace at gmail.com
Wed Jun 1 03:09:10 GMT 2005
Hi Oscar:
I think it did pass two parameters without any problem....
But, we need to change the syntax in smarty ...
If only one parameter, we can write as
{$xxx->yyy(3)}
But, if the parameters are over 2 ..., we need to change it to
{$xxx->yyy('3','4') }
Do you see the single quote, that's the difference ...
I have no idea why we should put single quote there, but it works ..
Mark
> -----Original Message-----
> From: plog-svn-bounces at devel.plogworld.net
> [mailto:plog-svn-bounces at devel.plogworld.net] On Behalf Of
> oscar at devel.plogworld.net
> Sent: Wednesday, June 01, 2005 5:47 AM
> To: plog-svn at devel.plogworld.net
> Subject: [pLog-svn] r2149 - in plugins/trunk: . galleryimages
>
> Author: oscar
> Date: 2005-05-31 21:46:38 +0000 (Tue, 31 May 2005) New Revision: 2149
>
> Added:
> plugins/trunk/galleryimages/
> Modified:
> plugins/trunk/galleryimages/plugingalleryimages.class.php
> Log:
> somebody requested this plugin in the forums and I thought I
> could fix it... I almost did it, I don't know why the thing
> doesn't work when passing two parameters but I need to look
> into it. Do not include this plugin when releasing new
> packages to sf.net!
>
>
> Copied: plugins/trunk/galleryimages (from rev 2087,
> plugins/trunk/unported/galleryimages)
>
> Modified: plugins/trunk/galleryimages/plugingalleryimages.class.php
> ===================================================================
> ---
> plugins/trunk/unported/galleryimages/plugingalleryimages.cl
> ass.php 2005-05-27 19:07:42 UTC (rev 2087)
> +++ plugins/trunk/galleryimages/plugingalleryimages.class.php
> 2005-05-31 21:46:38 UTC (rev 2149)
> @@ -1,7 +1,6 @@
> <?php
>
> include_once(
> PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
> - include_once(
> PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
> include_once(
> PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
>
> /**
> @@ -14,15 +13,20 @@
> function PluginGalleryImages()
> {
> $this->author = "The pLog Team";
> - $this->desc = "This plugin offers two methods,
> one for fetching the most recently uploaded image and another
> one for retrieving a random image from our collection.
> Needless to say, this plugin only returns images and not any
> other type of resource. Only images that belong to public
> albums will be used. <br /><br />You can use the following
> snippet of template code to show the latest uploaded image in
> your templates:<br /><br /><b>{assign var=latestImage
> value=\$galleryimages->latestImage(8)}<br /><a
> href="{\$url->resourceLink(\$latestImage)}"><b
> r /><img style="border:0px;"
> src="{\$url->resourcePreviewLink(\$latestImage)}"
> alt="{\$latestImage->getDescription()}"
> /><br /></a></b> <br /><br />To show a random image
> from your collection, you can use the following snippet: <br
> /><br /><b>{assign var=randomImage
> value=\$galleryimages->randomImage(9)}<br /><a
> href="{\$url->resourceLink(\
> $randomImage)}"><br /><img
> style="border:0px;"
> src="{\$url->resourcePreviewLink(\$randomImage)}"
> alt="{\$randomImage->getDescription()}"
> /><br /></a></b></p><p>And, you can use <br /><br
> /><strong>{\$galleryimages->randomImage(8)}</strong> to
> get 1 random image from album id=8, or use <br
> /><strong>{\$galleryimages->randomImage(10,3)}</strong> to
> get the 3 random images from album id=10 </p><p>Or, you also
> can
> use</p><p><strong>{\$galleryimages->lastImage(8)}</strong>
> to get last 1 upload image from album id=8, or use <br
> /><strong>{\$galleryimages->lastImage(10,3)}</strong> to
> get last 3 upload images from album id=10 <br /><br />";
> + $this->desc = "This plugin offers two methods, one for
> + fetching the most recently uploaded image and another one for
> + retrieving a random image from our collection. Needless to
> say, this
> + plugin only returns images and not any other type of resource. Only
> + images that belong to public albums will be used. <br /><br
> />You can
> + use the following snippet of template code to show the
> latest uploaded
> + image in your templates:<br /><br /><b>{assign var=latestImage
> + value=\$galleryimages->latestImage()}<br /><a
> + href="{\$url->resourceLink(\$latestImage)}"><br
> + /><img style="border:0px;"
> + src="{\$url->resourcePreviewLink(\$latestImage)}"
> + alt="{\$latestImage->getDescription()}" /><br
> + /></a></b> <br /><br />To show a random image from your
> + collection, you can use the following snippet: <br /><br
> /><b>{assign
> + var=randomImage
> value=\$galleryimages->randomImage(9)}<br /><a
> + href="{\$url->resourceLink(\$
> randomImage)}"><br /><img
> style="border:0px;"
> src="{\$url->resourcePreviewLink(\$randomImage)}"
> alt="{\$randomImage->getDescription()}"
> /><br /></a></b></p><p>And, you can use <br /><br
> /><strong>{\$galleryimages->randomImage(8)}</strong> to
> get 1 random image from album id=8, or use <br
> /><strong>{\$galleryimages->randomImage(10,3)}</strong> to
> get the 3 random images from album id=10 </p><p>Or, you also
> can
> use</p><p><strong>{\$galleryimages->lastImage(8)}</strong>
> to get last 1 upload image from album id=8, or use <br
> /><strong>{\$galleryimages->lastImage(10,3)}</strong> to
> get last 3 upload images from album id=10 <br /><br />";
> + $this->id = "galleryimages";
> + $this->locales = Array();
>
> $this->PluginBase();
> +
> + // register an extra action that will serve the images
> +
> }
>
> /**
> * Returns the GalleryResource object of the latest
> image uploaded to the database
> */
> - function latestImage( $album_id, $maxImages = 1)
> + function latestImages( $maxImages = 1, $album_id = 0 )
> {
> $resources = new GalleryResources();
> $prefix = $resources->getPrefix(); @@ -36,12 +40,18 @@
> r.resource_type AS resource_type,
> r.file_path AS file_path,
> r.file_name AS file_name, r.metadata
> AS metadata,
> r.thumbnail_format AS thumbnail_format
> - FROM {$prefix}gallery_resources r,
> {$prefix}gallery_albums a
> - WHERE r.resource_type = 1 AND
> a.show_album = 1 AND r.album_id = {$album_id} AND a.id = {$album_id}
> - AND r.owner_id = $blogId
> - ORDER BY r.date DESC LIMIT 0, {$maxImages}";
> + FROM {$prefix}gallery_resources r";
> + if( $album_id > 0 )
> + $query .= ", {$prefix}gallery_albums a";
> +
> + $query .= " WHERE r.resource_type = 1 AND r.owner_id =
> + '".Db::qstr($blogId)."'";
> +
> + if( $album_id > 0 )
> + $query .= " AND a.show_album = 1 AND a.id =
> + '".Db::qstr($album_id)."' AND r.album_id =
> '".Db::qstr($album_id)."'";
> +
> + $query .= "ORDER BY r.date DESC LIMIT 0, {$maxImages}";
> // just to make things easier, we'll cheat a
> little here...
> -
> +
> $result = $resources->_db->Execute( $query );
>
> if( !$result )
> @@ -53,12 +63,38 @@
> }
>
> return $latestimages;
> - }
> + }
>
> /**
> + * Returns only the latest image from the givel album id
> + */
> + function latestImage( $album_id = 0 )
> + {
> + $latestImages = $this->latestImages( 1, $album_id );
> +
> + if( $latestImages )
> + return( array_pop( $latestImages ));
> + else
> + return( false );
> + }
> +
> + /**
> + * Returns exactly one random image from our collection
> + */
> + function randomImage( $album_id = 0 )
> + {
> + $randomImages = $this->randomImages( $album_id );
> +
> + if( $randomImages )
> + return( array_pop( $randomImage ));
> + else
> + return( false );
> + }
> +
> + /**
> * Returns the GalleryResource object of a random
> image from one of the public albums
> */
> - function randomImage( $album_id, $maxImages = 1 )
> + function randomImages( $maxImages = 1, $album_id = 0 )
> {
> $resources = new GalleryResources();
> $prefix = $resources->getPrefix(); @@ -69,11 +105,17 @@
> r.resource_type AS resource_type,
> r.file_path AS file_path,
> r.file_name AS file_name, r.metadata
> AS metadata,
> r.thumbnail_format AS thumbnail_format
> - FROM {$prefix}gallery_resources r,
> {$prefix}gallery_albums a
> - WHERE r.resource_type = 1 AND
> a.show_album = 1 AND r.album_id = {$album_id} AND a.id = {$album_id}
> - AND r.owner_id = $blogId
> - ORDER BY RAND() LIMIT 0, {$maxImages}";
> - // just to make things easier, we'll cheat a
> little here...
> + FROM {$prefix}gallery_resources r";
> + if( $album_id > 0 )
> + $query .= ", {$prefix}gallery_albums a";
> + $query .= " WHERE r.resource_type = 1 AND
> r.owner_id = $blogId";
> + if( $album_id > 0 ) {
> + $query .=" AND a.show_album = 1 AND
> r.album_id = '".Db::qstr($album_id)."' AND a.id =
> '".Db::qstr($album_id)."'";
> + }
> +
> + $query .=" ORDER BY RAND() LIMIT 0, {$maxImages}";
> +
> + // just to make things easier, we'll cheat a
> little here...
> $result = $resources->_db->Execute( $query );
> if( !$result )
> return false;
> @@ -87,6 +129,4 @@
> }
> }
>
> - PluginManager::registerPlugin( "galleryimages",
> "PluginGalleryImages" );
> -
> ?>
> \ No newline at end of file
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.plogworld.net
> http://devel.plogworld.net/mailman/listinfo/plog-svn
More information about the pLog-svn
mailing list