From b7d79c504649fa01b0cc9cf84bcb34db4da7f96b Mon Sep 17 00:00:00 2001 From: secretr Date: Wed, 18 Nov 2009 09:32:31 +0000 Subject: [PATCH] admin UI tools: add model data fields when parsing callbacks results; imagepreview/imageselector SC minor improvements --- e107_files/shortcode/imagepreview.sc | 7 +++--- e107_files/shortcode/imageselector.sc | 18 ++++++++------ e107_handlers/admin_handler.php | 34 ++++++++++++++++++++++++--- e107_handlers/model_class.php | 16 ++++++++++--- 4 files changed, 58 insertions(+), 17 deletions(-) diff --git a/e107_files/shortcode/imagepreview.sc b/e107_files/shortcode/imagepreview.sc index 452f988bd..2a479efb8 100644 --- a/e107_files/shortcode/imagepreview.sc +++ b/e107_files/shortcode/imagepreview.sc @@ -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 "\"\""; +return "\"\""; diff --git a/e107_files/shortcode/imageselector.sc b/e107_files/shortcode/imageselector.sc index 1fa3e289b..4a1de2b9b 100644 --- a/e107_files/shortcode/imageselector.sc +++ b/e107_files/shortcode/imageselector.sc @@ -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 .= "
"; if(varset($click_target)) { @@ -99,11 +100,14 @@ if(varset($click_target)) $post = varset($click_postfix); $text .= ""; } -$text .= ""; -if(varset($click_target)) +else { - $text .= ""; + $text .= ""; } +if(vartrue($height)) $height = "height:{$height}"; +if(vartrue($width)) $width = "width:{$width}; "; +$text .= ""; + $text .= "
\n"; return "\n\n\n\n".$text."\n\n\n\n"; \ No newline at end of file diff --git a/e107_handlers/admin_handler.php b/e107_handlers/admin_handler.php index 101fbead1..bbc8e3316 100644 --- a/e107_handlers/admin_handler.php +++ b/e107_handlers/admin_handler.php @@ -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); } } diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index 55dbee47d..1a2832aae 100644 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -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