From: <nat...@us...> - 2013-06-11 18:59:41
|
Author: nathangray Date: Tue Jun 11 20:59:34 2013 New Revision: 42743 URL: http://svn.stylite.de/viewvc/egroupware?rev=42743&view=rev Log: Better fix for tabs not being validated - handle it at the top level Modified: trunk/etemplate/inc/class.etemplate_widget.inc.php trunk/etemplate/inc/class.etemplate_widget_tabbox.inc.php Modified: trunk/etemplate/inc/class.etemplate_widget.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/etemplate/inc/class.etemplate_widget.inc.php?rev=42743&r1=42742&r2=42743&view=diff ============================================================================== --- trunk/etemplate/inc/class.etemplate_widget.inc.php (original) +++ trunk/etemplate/inc/class.etemplate_widget.inc.php Tue Jun 11 20:59:34 2013 @@ -277,6 +277,11 @@ $class_name = 'etemplate_widget'; } } + + if(!$xml) + { + $xml = "<$type id='$id'/>"; + } //error_log(__METHOD__."('$type', ..., '$id') using $class_name"); // currently only overlays can contain templates, other widgets can only reference to templates via id @@ -380,6 +385,19 @@ } foreach($this->children as $child) { + // If type has something that can be expanded, we need to expand it so the correct method is run + if(strpos($child->attrs['type'], '@') !== false || strpos($child->attrs['type'], '$') !== false) + { + $type = self::expand_name($child->attrs['type'],$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); + $id = self::expand_name($child->id,$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); + $attrs = $child->attrs; + unset($attrs['type']); + $expanded_child = self::factory($type, false,$id); + $expanded_child->id = $id; + $expanded_child->type = $type; + $expanded_child->attrs = $attrs + array('type' => $type); + $child = $expanded_child; + } $child->run($method_name, $params, $respect_disabled); } } @@ -791,6 +809,7 @@ public function &setElementAttribute($name,$attr,$val) { $ref =& self::$request->modifications[$name][$attr]; + $this->attrs[$attr] = $val; if (!is_null($val)) $ref = $val; //error_log(__METHOD__."('$name', '$attr', ".array2string($val).')'); Modified: trunk/etemplate/inc/class.etemplate_widget_tabbox.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/etemplate/inc/class.etemplate_widget_tabbox.inc.php?rev=42743&r1=42742&r2=42743&view=diff ============================================================================== --- trunk/etemplate/inc/class.etemplate_widget_tabbox.inc.php (original) +++ trunk/etemplate/inc/class.etemplate_widget_tabbox.inc.php Tue Jun 11 20:59:34 2013 @@ -14,8 +14,35 @@ /** * eTemplate Tabs widget stacks multiple sub-templates and lets you switch between them */ -class etemplate_widget_tabbox extends etemplate_widget_box +class etemplate_widget_tabbox extends etemplate_widget { + /** + * Fill additional tabs + * + * @param string $cname + */ + public function beforeSendToClient($cname) + { + if($this->attrs['tabs']) + { + $this->children[1]->children = array(); + foreach($this->attrs['tabs'] as $tab) + { + if($tab['id']) + { + $template= clone etemplate_widget_template::instance($tab['template']); + $template->attrs['content'] = $tab['id']; + $this->children[1]->children[] = $template; + unset($template); + /* This doesn't work for some reason + $tab_valid =& self::get_array($validated, $tab['id'], true); + $tab_valid = $content[$tab['id']]; + */ + } + } + } + } + /** * Validate input - just pass through, tabs doesn't care * @@ -41,16 +68,19 @@ } // Make sure additional tabs are processed + $this->children[1]->children = array(); foreach($this->attrs['tabs'] as $tab) { if($tab['id'] && $content[$tab['id']]) { + $template= clone etemplate_widget_template::instance($tab['template']); + $template->attrs['content'] = $tab['id']; + $this->children[1]->children[] = $template; + unset($template); /* This doesn't work for some reason - $template = etemplate_widget_template::instance($tab['template']); - $template->run('validate', array($tab['id'], $expand, $content, &$validated), true); - */ $tab_valid =& self::get_array($validated, $tab['id'], true); $tab_valid = $content[$tab['id']]; + */ } } $valid = $value; |