1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-29 17:19:56 +02:00

Added support to {IMAGESELECTOR} for multiple paths and filtering.

This commit is contained in:
CaMer0n
2008-01-16 00:39:03 +00:00
parent e36d20162e
commit 1693bebf60

View File

@@ -1,4 +1,4 @@
// $Id: imageselector.sc,v 1.2 2007-05-28 18:49:08 e107steved Exp $ // $Id: imageselector.sc,v 1.3 2008-01-16 00:39:03 e107coders Exp $
global $sql,$parm; global $sql,$parm;
@@ -6,19 +6,25 @@ global $sql,$parm;
parse_str($parm, $tmp); parse_str($parm, $tmp);
extract($tmp); extract($tmp);
}else{ // comma separated parms. }else{ // comma separated parms.
list($name,$path,$default,$width,$height,$multiple,$label,$subdirs) = explode(",",$parm); list($name,$path,$default,$width,$height,$multiple,$label,$subdirs,$filter) = explode(",",$parm);
} }
require_once(e_HANDLER."file_class.php"); require_once(e_HANDLER."file_class.php");
$fl = new e_file; $fl = new e_file;
$paths = explode("|",$path);
// $paths = explode("|",$path);
$recurse = ($subdirs) ? $subdirs : 0; $recurse = ($subdirs) ? $subdirs : 0;
if($imagelist = $fl->get_files($path,".jpg|.gif|.png|.JPG|.GIF|.PNG", 'standard', $recurse)){ $imagelist = array();
foreach($paths as $path)
{
$imagelist += $fl->get_files($path,".jpg|.gif|.png|.JPG|.GIF|.PNG", 'standard', $recurse);
}
if($imagelist)
{
sort($imagelist); sort($imagelist);
} }
$multi = ($multiple == "TRUE" || $multiple == "1") ? "multiple='multiple' style='height:{$height}'" : "style='float:left'"; $multi = ($multiple == "TRUE" || $multiple == "1") ? "multiple='multiple' style='height:{$height}'" : "style='float:left'";
$width = ($width) ? $width : "*"; $width = ($width) ? $width : "*";
$height = ($height) ? $height : "*"; $height = ($height) ? $height : "*";
@@ -28,9 +34,12 @@ global $sql,$parm;
<option value=''>".$label."</option>\n"; <option value=''>".$label."</option>\n";
foreach($imagelist as $icon) foreach($imagelist as $icon)
{ {
$dir = str_replace($path,"",$icon['path']); $dir = str_replace($paths,"",$icon['path']);
$selected = ($default == $dir.$icon['fname']) ? " selected='selected'" : ""; $selected = ($default == $dir.$icon['fname']) ? " selected='selected'" : "";
if(!$filter || ($filter && ereg($filter,$dir.$icon['fname'])))
{
$text .= "<option value='".$dir.$icon['fname']."'".$selected.">".$dir.$icon['fname']."</option>\n"; $text .= "<option value='".$dir.$icon['fname']."'".$selected.">".$dir.$icon['fname']."</option>\n";
}
} }
$text .= "</select>"; $text .= "</select>";