[ADD-ON] galleries WIP
this is a WIP Gallery addon, maybe will turn into a mod,
i have added below the first part of the script with comments,
and a link to download package with all file needed.
UPDATE: 16/07/2008
Thank you Vasile for advise with latest fix.
<?php
/**
* Easy Galleries Script ::
* @ Moshe Gil Lemberger
* July 09 2008 ::
* email: mymgl@yahoo.com
* website: http://www.cms-zen.com
* FIX: code updated 16/07/08
* thank you vasile for advise
* http://moriscanet.blogspot.com/
*/
// TAG TO CALL THE GALLERY
easyGal('gallery-dir','your-galleries-root-path','y','ibox');
// easyGal function
function easyGal( $gsef, $groot='', $rel='', $styl='' ) {
global $errors;
//////////////////////////////////
# $gsef => name for gallery directory
$galName = $gsef.'/';
# $tumbs => name for tumbs directory
$tumbs = 'tumbs/';
# $larg => name for pictures source directory
$larg = 'larg/';
# $groot => name for ROOT galleries directory [ contain all galleries ] , relation to document location
//// 16/07/08 FIX: galleries_root closing slash was added to code.
//// NOTE: No need for the closing slash in function parameter,
//// just the name for your galleries_root.
//// end FIX 16/07/08.
$galleries_root = $groot!='' ? $groot.'/' : "galleries_root/";
# $rel => Set this for PREV - NEXT link option ( 'y' or empty )
$rel = $rel!='y' ? 'lightbox' : 'lightbox['.$gsef.']';
$gallery=$galleries_root.$galName;
$tumbdir=$gallery.$tumbs;
$largdir=$gallery.$larg;
if (is_dir($tumbdir)) {
$fd = opendir($tumbdir);
$images = array();
while (($part = @readdir($fd)) == true) {
clearstatcache();
if ( eregi("(gif|jpg|png|jpeg)$",$part) ) {
$images[] = $part;
}
}
# here we echo the javascript and css for the gallery
echo '
<script type="text/javascript" src="js/mootools.js"></script>
<script type="text/javascript" src="js/slimbox.js"></script>
<link rel="stylesheet" href="css/slimbox.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/ibox.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/egfx.js"></script>
';
# end js
$so=sizeof($images);
for ($x=0; $x<$so; $x++) {
$imgName=$images[$x];
$tumbsrc = $tumbdir.$imgName;
$imgsrc= $largdir.$imgName;
$title=$imgName;
$title=eregi_replace("(-|_)",' ',$title);
list($width,$height)=getimagesize($imgsrc);
echo '<div class="'.$styl.'">';
echo '<a href="'.$imgsrc.'" rel="'.$rel.'" title="'.$title.'">';
echo '<img src="'.$tumbsrc.'" alt="'.$title.'" />';
echo '</a>';
echo '<p><span>'.$title.'</span><br/>';
echo $width .' X '. $height;
echo '</p>';
echo '</div>';
}
} else {
$errors[] = $tumbdir.' is not a directory';
return false;
}
}
//////
?> <?php
/*
USE:
copy files in css, js directories to your server ( corresponding dir )
include this script ( will work on any php page or cms )
- make ROOT directory for all your galleries,
# ( Preset in the function as "galleries_root/" )
# can be set as option in function parameters.
# can be set different root for any call to the script.
- inside the ROOT,
for each gallery you need a directory.
# this will be used as the first parameter in function call.
inside, make 2 sub directories,
1 to hold the tumbs and 1 to hold the larg pictures,
#( Preset in the function as 'tumbs/' and 'larg/' ).
# can be set as option in function parameters.
call the function where ever you want to display the gallery.
easyGal( 'GALLERY DIR NAME' , 'ROOT GALLERIES DIR' , ENTER 'y' OR LEAVE EMPTY , 'THE TUMB DIV STYLE/S (i use tag ibox )' )
for include within the text area of article, use:
[MOD] Function use in articles (snews1.6) by philmoz. location: http://snewscms.com/forum/index.php?topic=4583.0
*/
?>
09.07.2008. 15:31









Write a comment
* = required field