WebsiteBaker 2.13.9 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
Description: Place a microGallery anywhere
<?php/* "microGallery - place Gallery anywhere" ---------------------------------------- @Author: Christian M. Stefan (Stefek) <stefek@designthings.de>*/global $MESSAGE;$output_value ="";// check if the 'folder' Parameter is set in the Dropletif (!isset($folder)): $output_value = $MESSAGE['MOD_FORM']['REQUIRED_FIELDS'].":<b>microGallery call =></b> <tt>folder={path/to/the/folder}</tt>";endif; $img_dir = WB_PATH.MEDIA_DIRECTORY.'/'.$folder.'/';$img_url = WB_URL.MEDIA_DIRECTORY.'/'.$folder.'/'; // directory exists --->if (is_dir($img_dir)): // open directory and go through the files $dir = dir($img_dir); while (FALSE !== $image_file = $dir->read()): //use jpg, gif and png files only if (!preg_match('/.+\.(jpeg|jpg|gif|png)$/', $image_file) || substr($image_file, 0, 1) == ".") continue; /** * Make Array of images for the microGallery if image files exist */ // convert filenames into Titles $img_title = str_replace(array(".png", ".jpg", ".gif", ".jpeg"), "", $image_file); $img_title = str_replace("_", " ", $img_title); if (isset($img_title) && !empty($img_title)): $link = $img_url.$image_file; $group = isset($group) ? $group : ''; //ignore $group if &group Parameter isn't set in Droplet-Call $image_array[] = "<a class='colorbox' href='".$link."' rel='lightbox[".$group."]' title='".$img_title."'>file'".$img_title."'</a>"; $linkonly[] = $link; $image_show[] = "<a class='colorbox' href='".$link."' rel='lightbox[".$group."]' title='".$img_title."'> <img src='".$link."' alt='".$img_title."' title='".$img_title."' style='width:auto; height:120px; border:0;'/></a>"; endif; endwhile; if(empty($image_show)): //no images in this directory $output_value = $MESSAGE['MEDIA']['NONE_FOUND'].': (<tt> '.$img_url.' </tt>)'; return $output_value; endif; /** * DISPLAY microGallery */ $display = (isset($display)) ? $display : 'table'; $cssclass = (isset($cssclass)) ? ' class="'.$cssclass.'"' : ''; //&cssclass=yourclass // check sorting if((isset($sort) && $display == 'table') || (isset($sort) && $display == 'all')){ if($sort=='ASC') asort($image_show); if($sort=='DESC') rsort($image_show); if($sort=='RANDOM') shuffle($image_show); } switch ($display): case 'table': //&display=table OR not-set at all $picsperrow = (isset($cols)) ? $cols : 4; // Set the amount of pics per row $output_value = "<table".$cssclass."><tr>"; for ($i=0; $i<count($image_show); $i++): if (($i > 0) && ($i % $picsperrow == 0)) $output_value .= "</tr><tr>"; $output_value .= "<td>".$image_show[$i]."</td>"; endfor; while ($i % $picsperrow > 0): $output_value .= "<td> </td>"; $i++; endwhile; $output_value .= "</tr></table>"; break; case 'all': //&display=all if(isset($sort) && $sort=='ASC') asort($image_show); if(isset($sort) && $sort=='DESC') rsort($image_show); if(isset($sort) && $sort=='RANDOM') shuffle($image_show); sort($image_show); $output_value = "<ul".$cssclass.">"; foreach ($image_show as $image){ $output_value .= '<li>'.$image.'</li>'; } $output_value .= '</ul>'; break; case 'first': //&display=first $output_value = $image_show[0]; break; case 'notfirst': //&display=notfirst array_shift($image_array); //skip first Element of Array $output_value = '<ul style="display:none">'; foreach ($image_array as $image){ $output_value .= '<li>'.$image.'</li>'; } $output_value .= '</ul>'; break; case 'firstlink': //&display=firstlink $output_value = $linkonly[0]; break; endswitch; // <-------end: if directory existselse: // directory doesn't exists ---> $output_value = $MESSAGE['MEDIA']['DIR_DOES_NOT_EXIST'].': (<tt> '.$img_url.' </tt>)';endif; return $output_value;
Comment:Use the Droplet as follows:[[microGallery?folder={path_to_image_directory}&display={first, notfirst, all, firstlink}&group={any_group_name}]]
I think the 'display:all' should be default (without extra code). Is that possible?
$images = '<ul>'; foreach ($image_show as $image){ $images .= '<li>'.$image.'</li>'; } $images .= '</ul>';
default: $images ='"&display" parameter is wrong by <tt>'.$folder.'</tt>, please correct'; endswitch;
Quote from: macsmet on April 05, 2010, 02:47:48 PMI think the 'display:all' should be default (without extra code). Is that possible?hi macsmet,just copy the code from the case "all":Code: [Select] $images = '<ul>'; foreach ($image_show as $image){ $images .= '<li>'.$image.'</li>'; } $images .= '</ul>'; replace it with the the default case:Code: [Select]default: $images ='"&display" parameter is wrong by <tt>'.$folder.'</tt>, please correct'; endswitch;then you got the "all" param as default...regards martin
else: // &all isn't set echo "'&all' isn't set"; return TRUE;endif;
else: /* &all isn't setecho "'&all' isn't set";return TRUE;*/$images = '<ul>'; foreach ($image_show as $image){ $images .= '<li>'.$image.'</li>'; } $images .= '</ul>'; return $images; endif;
I don't like the images to be listed this way. I like it more with colums and rows and will try to add that.
And is there a way to add slideshow to the ColorBox?
Make Array of images for the microGallery -----> */ if (file_exists($img_dir.$image_file)): $link = $img_url.$image_file; $group = isset($group) ? $group : ''; //ignore $group if &group Parameter isn't set in Droplet $image_array[] = "<a rel='cslide' href='".$link."' title='".$img_title."'>file'".$img_title."'</a>"; $linkonly[] = $link; $image_show[] = "<a rel='cslide' href='".$link."' title='".$img_title."'> <img src='".$link."' title='".$img_title."' style='width:auto; height:120px'/></a>"; endif;
$("a[rel='cslide1']").colorbox({ .....code for slideshow$("a[rel='cslide2']").colorbox({ .....code for slideshow
$images = '<table border="0" cellpadding="0" cellspacing="0" width="500"><tr><td width="120">'; foreach ($image_show as $image){ $images .= ''.$image.''; } $images .= '</td></tr></table>'; return $images;
// count elements in array$img_count = count($img_list);$img_total = count($img_list);//figure out how many pages are needed to display all the thumbs$page_count = ceil($img_count / ($img_rows * $img_columns));if(is_dir($WB_PATH.$gallery_path)) { // start outputting content echo '<table class="lb" cellspacing="4">' . "\n"; // Check which image to start with on the page if (isset($_GET['img_count'])) { $img_count = $_GET['img_count']; } // Set count to zero for initial view if (!isset($_GET['img_count'])) { $img_count = 0; } $row_count = 1; $col_count = 1; while($row_count <= $img_rows) { echo '<tr class="lb" >'; while ($col_count <= $img_columns) { echo '<td align="center" style="border:solid 0px #000">'; if ($img_total > $img_count){ echo '<a href="' . WB_URL . $gallery_path . $img_list[$img_count] . '" class="lb_image_link" rel="lightbox[' . $gallery_name . ']" title="' . $gallery_name . '"><img class="lb_image" src="' . WB_URL . $thumb_path . $img_list[$img_count] . '" border="0" /></a>'; } echo '</td>' . "\n"; $col_count++; $img_count++; } echo "</tr>\n"; $col_count = 1; $row_count++; } echo '</table>';
<?php/* -------------| output microGallery in table */ $picsperrow = 4; // Set the amount of pics per row $images = "<table><tr>"; for ($i=0; $i<count($image_show); $i++): if (($i > 0) && ($i % $picsperrow == 0)) $images .= "</tr><tr>"; $images .= "<td>".$image_show[$i]."</td>"; endfor; while ($i % $picsperrow > 0): $images .= "<td> </td>"; $i++; endwhile; $images .= "</tr></table>"; return $images;
<?php/* "microGallery - place Gallery anywhere" ---------------------------------------- DROPLET for use with WebsiteBaker CMS ---------------------------------------- @Author: Christian M. Stefan (Stefek) TODO: 1) check the code by pro coder 2) create massage if the folder is empty (small bug occurs if a empty dir is called) 3) making the costumization easier (needed?) 4) using of GD Library to create thumbs on the fly (needed?) 5) small documentation*/// check if the 'folder' Flag is set in the Droplet if (!isset($folder)): echo "Your droplet-call is not complete, please set 'folder={path}'"; return TRUE;endif; $img_dir = WB_PATH.MEDIA_DIRECTORY.'/'.$folder.'/';$img_url = WB_URL.MEDIA_DIRECTORY.'/'.$folder.'/'; // directory exists ---> if (is_dir($img_dir)) { // open directory and go through the files $dir = dir($img_dir); while (FALSE !== $image_file = $dir->read()): // skip index files and pointers if (preg_match("~.php~", $image_file) || substr($image_file, 0, 1) == "."): continue; endif; // convert filenames into Titles $img_title = str_replace(array(".png", ".jpg", ".gif", ".jpeg"), "", $image_file); $img_title = str_replace("_", " ", $img_title); if (!file_exists($img_dir.$image_file)) : echo 'directory empty'; return TRUE; endif; /** * Make Array of images for the microGallery -----> */ if (file_exists($img_dir.$image_file)): $link = $img_url.$image_file; $group = isset($group) ? $group : ''; //ignore $group if &group Parameter isn't set in Droplet $image_array[] = "<a class='colorbox' href='".$link."' rel='lightbox[".$group."]' title='".$img_title."'>file'".$img_title."'</a>"; $linkonly[] = $link; $image_show[] = "<a class='colorbox' href='".$link."' rel='lightbox[".$group."]' title='".$img_title."'> <img src='".$link."' title='".$img_title."' style='width:auto; height:120px'/></a>"; endif; // <!------ endwhile; } // <------- directory exists else { // directory doesn't exists ---> echo "Directory (<tt> '.$img_dir.' </tt>) doesn't exist"; return TRUE; } /*** DISPLAY microGallery*/if (isset($display)): switch ($display): case 'first': $images = $image_show[0]; break; case 'notfirst': array_shift($image_array); //skip first Element of Array $images = '<ul style="display:none">'; foreach ($image_array as $image){ $images .= '<li>'.$image.'</li>'; } $images .= '</ul>'; break; case 'all': $images = '<ul>'; foreach ($image_show as $image){ $images .= '<li>'.$image.'</li>'; } $images .= '</ul>'; break; case 'firstlink': $images = $linkonly[0]; break; default: $images ='"&display" parameter is wrong by <tt>'.$folder.'</tt>, please correct'; endswitch; return $images; else: /*-------------| output microGallery in table DEFAULT, if &display Flag isn't set*/ $picsperrow = 4; // Set the amount of pics per row $images = "<table><tr>"; for ($i=0; $i<count($image_show); $i++): if (($i > 0) && ($i % $picsperrow == 0)) $images .= "</tr><tr>"; $images .= "<td>".$image_show[$i]."</td>"; endfor; while ($i % $picsperrow > 0): $images .= "<td> </td>"; $i++; endwhile; $images .= "</tr></table>"; return $images; endif;
Anything else to adjust?