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')
This commit is contained in:
Ralf Becker 2008-03-05 18:38:46 +00:00
parent 2bb4fd1df1
commit 60a65bb560
3 changed files with 16 additions and 5 deletions

View File

@ -80,7 +80,7 @@ class contact_widget
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
{
//echo "<p>contact_widget::pre_process('$name','$value',".print_r($cell,true).",...)</p>\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
}
}

View File

@ -616,7 +616,7 @@ foreach($sess as $key => $val)
// make the content availible as class-var for extensions
$this->content =& $content;
$html = "\n\n<!-- BEGIN eTemplate $this->name -->\n\n";
$html = "\n\n<!-- BEGIN eTemplate $this->name -->\n<div id=\"$this->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."<!-- END eTemplate $this->name -->\n\n";
return $html."\n</div>\n<!-- END eTemplate $this->name -->\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 ? '<span id="'.$name.'">' : '').$value.($name ? '</span>' : '');
$html .= ($name ? '<span id="'.($cell['id']?$cell['id']:$name).'">' : '').$value.($name ? '</span>' : '');
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],"'<style>".str_replace(array("\n","\r"),'',$tpl->style)."</style>'",$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

View File

@ -200,6 +200,8 @@ class infolog_widget
}
break;
}
$cell['id'] = ($cell['id'] ? $cell['id'] : $cell['name'])."[$type]";
return True; // extra label ok
}