1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-19 20:21:51 +02:00

admin UI tools: add model data fields when parsing callbacks results; imagepreview/imageselector SC minor improvements

This commit is contained in:
secretr 2009-11-18 09:32:31 +00:00
parent af9235b29b
commit b7d79c5046
4 changed files with 58 additions and 17 deletions

View File

@ -1,5 +1,5 @@
// $Id: imagepreview.sc,v 1.2 2008-12-17 17:27:07 secretr Exp $
// $Id: imagepreview.sc,v 1.3 2009-11-18 09:32:31 secretr Exp $
global $e107;
list($name, $width, $height) = explode("|",$parm, 3);
@ -11,9 +11,8 @@ if(varset($width))
}
if(varset($height))
{
$height = " width: {$height};";
$height = " height: {$height};";
}
$path = (varset($_POST[$name]) && defsettrue('e_AJAX_REQUEST')) ? $e107->tp->replaceConstants($_POST[$name], 'full') : e_IMAGE_ABS."generic/blank.gif";
return "<img src='{$path}' alt=\"\" class='image-selector' style='{$width}{$height}' />";
return "<a href='{$path}' rel='external' class='e-image-preview'><img src='{$path}' alt=\"\" class='image-selector' style='{$width}{$height}' /></a>";

View File

@ -1,12 +1,12 @@
// $Id: imageselector.sc,v 1.9 2009-01-16 17:57:56 secretr Exp $
// $Id: imageselector.sc,v 1.10 2009-11-18 09:32:31 secretr Exp $
//FIXME - full rewrite, backward compatible
global $sql,$parm,$tp;
if(strstr($parm,"="))
{ // query style parms.
parse_str($parm, $tmp);
extract($tmp);
parse_str($parm, $parms);
extract($parms);
}
else
{ // comma separated parms.
@ -17,7 +17,7 @@ $paths = explode("|",$path);
if(trim($default[0])=="{")
{
$pvw_default = $tp->replaceConstants($default);
$pvw_default = $tp->replaceConstants($default, 'abs');
$path = ""; // remove the default path if a constant is used.
}
@ -92,6 +92,7 @@ if(!$pvw_default)
$pvw_default = ($default) ? $path.$default : e_IMAGE_ABS."generic/blank.gif";
}
$text .= "<div class='imgselector-container' id='{$name}_prev'>";
if(varset($click_target))
{
@ -99,11 +100,14 @@ if(varset($click_target))
$post = varset($click_postfix);
$text .= "<a href='#' onclick='addtext(\"{$pre}\"+document.getElementById(\"{$name}\").value+\"{$post}\", true);document.getElementById(\"{$name}\").selectedIndex = -1;return false;'>";
}
$text .= "<img src='{$pvw_default}' alt='' style='width:{$width};height:{$height}' />";
if(varset($click_target))
else
{
$text .= "</a>";
$text .= "<a href='{$pvw_default}' 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}' /></a>";
$text .= "</div>\n";
return "\n\n<!-- Start Image Selector [{$scaction}] -->\n\n".$text."\n\n<!-- End Image Selector [{$scaction}] -->\n\n";

View File

@ -9,9 +9,9 @@
* Administration UI handlers, admin helper functions
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/admin_handler.php,v $
* $Revision: 1.31 $
* $Date: 2009-11-18 07:16:42 $
* $Author: e107coders $
* $Revision: 1.32 $
* $Date: 2009-11-18 09:32:31 $
* $Author: secretr $
*/
if (!defined('e107_INIT')) { exit; }
@ -2112,6 +2112,26 @@ class e_admin_controller_ui extends e_admin_controller
return $default;
}
/**
*
* @param string $field
* @param string $key attribute name
* @param mixed $value default value if not set, default is null
* @return mixed FIXME
*/
public function setFieldAttr($field, $key = null, $default = null)
{
if(isset($this->fields[$field]))
{
if(null !== $key)
{
return isset($this->fields[$field][$key]) ? $this->fields[$field][$key] : $default;
}
return $this->fields[$field];
}
return $default;
}
/**
* Get fields stored as user preferences
* @return array
@ -2865,6 +2885,14 @@ class e_admin_controller_ui extends e_admin_controller
}
if($data && is_array($data))
{
// add to model data fields array if required
foreach ($data as $f => $val)
{
if($this->getFieldAttr($f, 'data'))
{
$model->setDataField($f, $this->getFieldAttr($f, 'data'));
}
}
$_posted = array_merge($_posted, $data);
}
}

View File

@ -9,9 +9,9 @@
* e107 Base Model
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
* $Revision: 1.40 $
* $Date: 2009-11-18 01:04:43 $
* $Author: e107coders $
* $Revision: 1.41 $
* $Date: 2009-11-18 09:32:31 $
* $Author: secretr $
*/
if (!defined('e107_INIT')) { exit; }
@ -140,6 +140,16 @@ class e_model
$this->_data_fields = $data_fields;
return $this;
}
/**
* Set Predefined data field
* @return e_model
*/
public function setDataField($field, $type)
{
$this->_data_fields[$field] = $type;
return $this;
}
/**
* Set name of object's field id