From 60a65bb560034a156f934d9b13b1f32197eecd88 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 5 Mar 2008 18:38:46 +0000 Subject: [PATCH] Added an id tag to templates, contact and infolog widget New js_pseudo_function to fetch the styles of a template: template::styles('template.name') --- etemplate/inc/class.contact_widget.inc.php | 4 +++- etemplate/inc/class.uietemplate.inc.php | 15 +++++++++++---- infolog/inc/class.infolog_widget.inc.php | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/etemplate/inc/class.contact_widget.inc.php b/etemplate/inc/class.contact_widget.inc.php index e2e669cd41..2e28b7edb9 100644 --- a/etemplate/inc/class.contact_widget.inc.php +++ b/etemplate/inc/class.contact_widget.inc.php @@ -80,7 +80,7 @@ class contact_widget function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) { //echo "

contact_widget::pre_process('$name','$value',".print_r($cell,true).",...)

\n"; - switch($cell['type']) + switch($type = $cell['type']) { case 'contact-fields': $GLOBALS['egw']->translation->add_app('addressbook'); @@ -158,6 +158,8 @@ class contact_widget } break; } + $cell['id'] = ($cell['id'] ? $cell['id'] : $cell['name'])."[$type]"; + return True; // extra label ok } } diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php index 89e5b2eaf2..fc8df5393b 100644 --- a/etemplate/inc/class.uietemplate.inc.php +++ b/etemplate/inc/class.uietemplate.inc.php @@ -615,8 +615,8 @@ foreach($sess as $key => $val) } // make the content availible as class-var for extensions $this->content =& $content; - - $html = "\n\n\n\n"; + + $html = "\n\n\n
name\">\n\n"; if (!$GLOBALS['egw_info']['etemplate']['styles_included'][$this->name]) { $GLOBALS['egw_info']['etemplate']['styles_included'][$this->name] = True; @@ -631,7 +631,7 @@ foreach($sess as $key => $val) $child['align'], ),'class,align')) : $h; } - return $html."\n\n"; + return $html."\n
\n\n\n"; } /** @@ -1118,7 +1118,7 @@ foreach($sess as $key => $val) if ($value != '' && $style && strpos($style,'b')!==false) $value = $this->html->bold($value); if ($value != '' && $style && strpos($style,'i')!==false) $value = $this->html->italic($value); // if the label has a name, use it as id in a span, to allow addressing it via javascript - $html .= ($name ? '' : '').$value.($name ? '' : ''); + $html .= ($name ? '' : '').$value.($name ? '' : ''); if ($help) { $class = array( @@ -1860,6 +1860,13 @@ foreach($sess as $key => $val) $str = lang($matches[1]); $on = str_replace($matches[0],'\''.addslashes($str).'\'',$on); } + + // inserts the styles of a named template + if (preg_match('/template::styles\(["\']{1}(.*)["\']{1}\)/U',$on,$matches)) + { + $tpl = $matches[1] == $this->name ? $this : new etemplate($matches[1]); + $on = str_replace($matches[0],"''",$on); + } } if (strpos($on,'confirm(') !== false && preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/',$on,$matches)) { $question = lang($matches[1]).(substr($matches[1],-1) != '?' ? '?' : ''); // add ? if not there, saves extra phrase diff --git a/infolog/inc/class.infolog_widget.inc.php b/infolog/inc/class.infolog_widget.inc.php index c0ac4f6888..4cbb44f7ab 100644 --- a/infolog/inc/class.infolog_widget.inc.php +++ b/infolog/inc/class.infolog_widget.inc.php @@ -200,6 +200,8 @@ class infolog_widget } break; } + $cell['id'] = ($cell['id'] ? $cell['id'] : $cell['name'])."[$type]"; + return True; // extra label ok }