From c4d2779171022c18c2029db34861448b7349f03f Mon Sep 17 00:00:00 2001 From: secretr Date: Fri, 5 Feb 2010 10:52:28 +0000 Subject: [PATCH] imagepreview SC improvements, converted to function; imageselector SC improvements and fixes --- e107_files/shortcode/imagepreview.php | 55 +++++++++++++++++++++++++++ e107_files/shortcode/imagepreview.sc | 24 ------------ e107_files/shortcode/imageselector.sc | 38 +++++++++++++----- 3 files changed, 84 insertions(+), 33 deletions(-) create mode 100644 e107_files/shortcode/imagepreview.php delete mode 100644 e107_files/shortcode/imagepreview.sc diff --git a/e107_files/shortcode/imagepreview.php b/e107_files/shortcode/imagepreview.php new file mode 100644 index 000000000..c27acb23b --- /dev/null +++ b/e107_files/shortcode/imagepreview.php @@ -0,0 +1,55 @@ +replaceConstants($posted, 'full'); + } + else $path = (varset($_POST[$name])/* && deftrue('e_AJAX_REQUEST')*/) ? e107::getParser()->replaceConstants($_POST[$name], 'full') : ''; + $hide = ''; + + if(!$path) + { + $path = e_IMAGE_ABS."generic/blank.gif"; + $hide = ' style="display: none;"'; + } + return "\"\""; +} \ No newline at end of file diff --git a/e107_files/shortcode/imagepreview.sc b/e107_files/shortcode/imagepreview.sc deleted file mode 100644 index c8e505c0c..000000000 --- a/e107_files/shortcode/imagepreview.sc +++ /dev/null @@ -1,24 +0,0 @@ - -// $Id: imagepreview.sc,v 1.4 2009-11-28 15:31:08 secretr Exp $ -list($name, $width, $height) = explode("|",$parm, 3); - -$name = varset($name);//avoid warnings -if(varset($width)) -{ - $width = " width: {$width};"; -} -else $width = ''; -if(varset($height)) -{ - $height = " height: {$height};"; -} -else $height = ''; -$path = (varset($_POST[$name]) && defsettrue('e_AJAX_REQUEST')) ? e107::getParser()->replaceConstants($_POST[$name], 'full') : ''; -$hide = ''; - -if(!$path) -{ - $path = e_IMAGE_ABS."generic/blank.gif"; - $hide = 'display: none;'; -} -return "\"\""; \ No newline at end of file diff --git a/e107_files/shortcode/imageselector.sc b/e107_files/shortcode/imageselector.sc index 76f91622b..b18df9d13 100644 --- a/e107_files/shortcode/imageselector.sc +++ b/e107_files/shortcode/imageselector.sc @@ -1,5 +1,5 @@ -// $Id: imageselector.sc,v 1.11 2009-11-28 15:31:08 secretr Exp $ +// $Id: imageselector.sc,v 1.12 2010-02-05 10:52:28 secretr Exp $ //FIXME - full rewrite, backward compatible global $sql,$parm,$tp; @@ -23,6 +23,7 @@ if(trim($default[0])=="{") $scaction = varsettrue($scaction, 'all'); $text = ''; +$name_id = e107::getForm()->name2id($name); //Get Select Box Only! if($scaction == 'select' || $scaction == 'all') @@ -53,7 +54,7 @@ if($scaction == 'select' || $scaction == 'all') $tabindex = varset($tabindex) ? " tabindex='{$tabindex}'" : ''; $class = varset($class) ? " class='{$class}'" : " class='tbox imgselector'"; - $text .= " + $text .= " \n"; require_once(e_HANDLER.'admin_handler.php'); @@ -90,25 +91,44 @@ if($scaction == 'select' || $scaction == 'all') $hide = ''; if(!$pvw_default) { - $pvw_default = ($default) ? $path.$default : e_IMAGE_ABS."generic/blank.gif"; - $hide = 'display: none;'; + if($default) + { + $test = pathinfo($default); + if('.' == $test['dirname']) + { + // file only, add absolute path + $path = $tp->createConstants($path, 1); + $path = $tp->replaceConstants($path, 'abs'); + $pvw_default = $path.$default; + } + else + { + // path, convert to absolute path + $pvw_default = $tp->createConstants($default, 1); + $pvw_default = $tp->replaceConstants($pvw_default, 'abs'); + } + } + else + { + $pvw_default = e_IMAGE_ABS."generic/blank.gif"; + $hide = ' style="display: none;"'; + } } - -$text .= "
"; +$text .= "
"; if(varset($click_target)) { $pre = varset($click_prefix); $post = varset($click_postfix); - $text .= ""; + $text .= ""; } else { - $text .= ""; + $text .= ""; } if(vartrue($height)) $height = "height:{$height};"; if(vartrue($width)) $width = "width:{$width}; "; -$text .= ""; +$text .= ""; $text .= "
\n";