mirror of
https://github.com/e107inc/e107.git
synced 2025-01-19 05:28:10 +01:00
imagepreview SC improvements, converted to function; imageselector SC improvements and fixes
This commit is contained in:
parent
836317f87e
commit
c4d2779171
55
e107_files/shortcode/imagepreview.php
Normal file
55
e107_files/shortcode/imagepreview.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
// $Id: imagepreview.php,v 1.1 2010-02-05 10:52:27 secretr Exp $
|
||||
|
||||
function imagepreview_shortcode($parm)
|
||||
{
|
||||
list($name, $width, $height) = explode("|",$parm, 3);
|
||||
|
||||
$name = rawurldecode(varset($name));//avoid warnings
|
||||
if(varset($width))
|
||||
{
|
||||
$width = " width: {$width};";
|
||||
}
|
||||
else $width = '';
|
||||
if(varset($height))
|
||||
{
|
||||
$height = " height: {$height};";
|
||||
}
|
||||
else $height = '';
|
||||
|
||||
// array support
|
||||
if(strpos($name, '[')) //can't be first string
|
||||
{
|
||||
$matches = array();
|
||||
$search = $name;
|
||||
|
||||
$tmp = explode('[', $name, 2);
|
||||
$name = $tmp[0]; unset($tmp);
|
||||
|
||||
$path = '';
|
||||
|
||||
if(isset($_POST[$name]) && is_array($_POST[$name]) && preg_match_all('#\[([\w]*)\]#', $search, $matches, PREG_PATTERN_ORDER))
|
||||
{
|
||||
$posted = $_POST[$name];
|
||||
foreach ($matches[1] as $varname)
|
||||
{
|
||||
if(!isset($posted[$varname]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
$posted = $posted[$varname];
|
||||
}
|
||||
}
|
||||
if($posted && is_string($posted))
|
||||
$path = e107::getParser()->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 "<a href='{$path}' rel='external' class='e-image-preview'{$hide}><img src='{$path}' alt=\"\" class='image-selector' style='{$width}{$height}' /></a>";
|
||||
}
|
@ -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 "<a href='{$path}' rel='external' class='e-image-preview'><img src='{$path}' alt=\"\" class='image-selector' style='{$width}{$height}{$hide}' /></a>";
|
@ -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 .= "<select{$multi}{$tabindex}{$class} name='{$name}' id='{$name}' onchange=\"replaceSC('imagepreview={$name}|{$width}|{$height}',this.form,'{$name}_prev'); \">
|
||||
$text .= "<select{$multi}{$tabindex}{$class} name='{$name}' id='{$name_id}' onchange=\"replaceSC('imagepreview={$name}|{$width}|{$height}',this.form,'{$name_id}_prev'); \">
|
||||
<option value=''>".$label."</option>\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 .= "<div class='imgselector-container' id='{$name}_prev'>";
|
||||
$text .= "<div class='imgselector-container' id='{$name_id}_prev'>";
|
||||
if(varset($click_target))
|
||||
{
|
||||
$pre = varset($click_prefix);
|
||||
$post = varset($click_postfix);
|
||||
$text .= "<a href='#' onclick='addtext(\"{$pre}\"+document.getElementById(\"{$name}\").value+\"{$post}\", true);document.getElementById(\"{$name}\").selectedIndex = -1;return false;'>";
|
||||
$text .= "<a href='#'{$hide} onclick='addtext(\"{$pre}\"+document.getElementById(\"{$name_id}\").value+\"{$post}\", true);document.getElementById(\"{$name_id}\").selectedIndex = -1;return false;'>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= "<a href='{$pvw_default}' rel='external' class='e-image-preview'>";
|
||||
$text .= "<a href='{$pvw_default}'{$hide} rel='external' class='e-image-preview'>";
|
||||
}
|
||||
if(vartrue($height)) $height = "height:{$height};";
|
||||
if(vartrue($width)) $width = "width:{$width}; ";
|
||||
$text .= "<img src='{$pvw_default}' alt='' style='{$width}{$height}{$hide}' /></a>";
|
||||
$text .= "<img src='{$pvw_default}' alt='' style='{$width}{$height}' /></a>";
|
||||
|
||||
$text .= "</div>\n";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user