From a1c714bdb875645124ca44a3d4bab7e40b6a0aa8 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 24 Feb 2010 22:20:26 +1100 Subject: [PATCH] Fix template engine rending attributes with multiselect configured --- lib/Attribute.php | 4 ++++ lib/AttributeFactory.php | 1 + lib/PageRender.php | 5 ++++- lib/TemplateRender.php | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Attribute.php b/lib/Attribute.php index c4e489a..d355aa8 100644 --- a/lib/Attribute.php +++ b/lib/Attribute.php @@ -477,6 +477,10 @@ class Attribute { $this->readonly = true; } + public function isMultiple() { + return false; + } + public function isVisible() { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); diff --git a/lib/AttributeFactory.php b/lib/AttributeFactory.php index 82403db..a928c29 100644 --- a/lib/AttributeFactory.php +++ b/lib/AttributeFactory.php @@ -85,6 +85,7 @@ class AttributeFactory { case 'password': return $this->newPasswordAttribute($name,$values,$server_id,$source); + case 'multiselect': case 'select': return $this->newSelectionAttribute($name,$values,$server_id,$source); diff --git a/lib/PageRender.php b/lib/PageRender.php index 44b6873..eab1fe9 100644 --- a/lib/PageRender.php +++ b/lib/PageRender.php @@ -1011,6 +1011,9 @@ class PageRender extends Visitor { $vals = $attribute->getValues(); $j = 0; + if (! $vals && ! is_array($vals = $attribute->getDefault())) + $vals = array($attribute->getDefault()); + if (($attribute->getSize() > 0) && ($attribute->getSize() < $attribute->getOptionCount())) { printf(' %s', + printf(' %s', htmlspecialchars($attribute->getName()),$j++, htmlspecialchars($attribute->getName()),$val, $attribute->needJS('focus') ? sprintf('onFocus="focus_%s(this);" ',$attribute->getName()) : '', diff --git a/lib/TemplateRender.php b/lib/TemplateRender.php index 18ed07f..7323a1c 100644 --- a/lib/TemplateRender.php +++ b/lib/TemplateRender.php @@ -2042,6 +2042,9 @@ function fillRec(id,value) { protected function drawValueAttribute($attribute,$i) { if (DEBUGTMP) printf('%s
',__METHOD__); + if ($attribute->isMultiple() && $i > 0) + return; + $val = $attribute->getValue($i); if ($attribute->isVisible()) {