1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

IN PROGRESS - Task EONE-10: thumb support added to imagepreview/imageselector shortcodes

This commit is contained in:
secretr
2010-03-10 11:06:41 +00:00
parent e18b650bea
commit c2e6caf631
3 changed files with 32 additions and 24 deletions

View File

@@ -1,37 +1,37 @@
<?php
<?php
// $Id$
function imagepreview_shortcode($parm)
{
list($name, $width, $height) = explode("|",$parm, 3);
list($name, $width, $height, $nothumb) = explode("|",$parm, 4);
$name = rawurldecode(varset($name));//avoid warnings
if(varset($width))
{
$width = " width: {$width};";
$width = intval($width);
}
else $width = '';
else $width = 0;
if(varset($height))
{
$height = " height: {$height};";
$height = intval($height);
}
else $height = '';
else $height = 0;
// array support
if(strpos($name, '[')) //can't be first string
{
$matches = array();
$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)
foreach ($matches[1] as $varname)
{
if(!isset($posted[$varname]))
{
@@ -40,16 +40,21 @@ function imagepreview_shortcode($parm)
$posted = $posted[$varname];
}
}
if($posted && is_string($posted))
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)
if(!$path)
{
$path = e_IMAGE_ABS."generic/blank.gif";
$path = '#';
$thpath = 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>";
else
{
$thpath = !varset($nothumb) ? e107::getParser()->thumbUrl($path, 'w='.$width.'h='.$height, true) : $path;
}
return "<a href='{$path}' rel='external' class='e-image-preview'{$hide}><img src='{$thpath}' alt=\"\" class='image-selector' /></a>";
}

View File

@@ -1,7 +1,9 @@
// $Id$
//FIXME - full rewrite, backward compatible
global $sql,$parm,$tp;
$sql = e107::getDb();
$tp = e107::getParser();
if(strstr($parm,"="))
{ // query style parms.
@@ -120,15 +122,16 @@ if(varset($click_target))
{
$pre = varset($click_prefix);
$post = varset($click_postfix);
$text .= "<a href='#'{$hide} onclick='addtext(\"{$pre}\"+document.getElementById(\"{$name_id}\").value+\"{$post}\", true);document.getElementById(\"{$name_id}\").selectedIndex = -1;return false;'>";
$text .= "<a href='#'{$hide} title='Select' onclick='addtext(\"{$pre}\"+document.getElementById(\"{$name_id}\").value+\"{$post}\", true);document.getElementById(\"{$name_id}\").selectedIndex = -1;return false;'>";
}
else
{
$text .= "<a href='{$pvw_default}'{$hide} rel='external' class='e-image-preview'>";
$text .= "<a href='{$pvw_default}'{$hide} rel='external' title='Preview {$pvw_default}' 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}' /></a>";
if(vartrue($height)) $height = intval($height);
if(vartrue($width)) $width = intval($width);
$thpath = isset($parms['nothumb']) ? $pvw_default : $tp->thumbUrl($pvw_default, 'w='.$width.'h='.$height, true);
$text .= "<img src='{$thpath}' alt='$pvw_default' class='image-selector' /></a>";
$text .= "</div>\n";

View File

@@ -177,7 +177,7 @@ class e_form
$parms .= "&multiple=FALSE";
$parms .= "&label=-- ".$label." --";
$parms .= "&subdirs=".varset($sc_parameters['subdirs'], 1);
$parms .= '&width='.vartrue($sc_parameters['width'], 150).'px';
$parms .= '&width='.vartrue($sc_parameters['width'], 150);
if(vartrue($sc_parameters['height'])) $parms .= '&height='.$sc_parameters['height'].'px';
//$parms .= "&tabindex=".$this->getNext();
//$parms .= "&click_target=data";