mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-24 22:21:34 +01:00
some more js pseudo functions and docu
This commit is contained in:
parent
4796812a17
commit
21465c8c93
@ -1761,16 +1761,21 @@ foreach($sess as $key => $val)
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve javascript pseudo functions:
|
||||
* Resolve javascript pseudo functions in onclick or onchange:
|
||||
* - egw::link('$l','$p') calls $egw->link($l,$p)
|
||||
* - form::name('name') returns expanded name/id taking into account the name at that point of the template hierashy
|
||||
* - form::name('name') returns expanded name/id taking into account the name at that point of the template hierarchy
|
||||
* - egw::lang('Message ...') translate the message
|
||||
* - confirm('message') translates 'message' and adds a '?' if not present
|
||||
* - window.open() replaces it with egw_openWindowCentered2()
|
||||
* - xajax_doXMLHTTP('etemplate. replace ajax calls in widgets with special handler not requiring etemplate run rights
|
||||
*
|
||||
* @param string $on onclick, onchange, ... action
|
||||
* @param string $cname name-prefix / name-space
|
||||
* @return string
|
||||
*/
|
||||
function js_pseudo_funcs($on,$cname)
|
||||
{
|
||||
if (strpos($on,'::') !== false) // avoid the expensive regular expresions, for performance reasons
|
||||
{
|
||||
if (preg_match("/egw::link\\('([^']+)','(.+?)'\\)/",$on,$matches)) // the ? alters the expression to shortest match
|
||||
{ // this way we can correctly parse ' in the 2. argument
|
||||
@ -1785,13 +1790,18 @@ foreach($sess as $key => $val)
|
||||
$on = str_replace($matches[0],$matches[1],$on);
|
||||
}
|
||||
|
||||
if (preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/',$on,$matches)) {
|
||||
if (preg_match('/egw::lang\(["\']{1}(.*)["\']{1}\)/',$on,$matches)) {
|
||||
$str = lang($matches[1]);
|
||||
$on = str_replace($matches[0],'\''.addslashes($str).'\'',$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
|
||||
$on = str_replace($matches[0],'confirm(\''.addslashes($question).'\')',$on);
|
||||
//$on = preg_replace('/confirm\(["\']{1}(.*)["\']{1}\)/','confirm(\''.addslashes($question).'\')',$on);
|
||||
}
|
||||
|
||||
if (preg_match("/window.open\('(.*)','(.*)','dependent=yes,width=(.*),height=(.*),scrollbars=yes,status=(.*)'\)/",$on,$matches)) {
|
||||
if (strpos($on,'window.open(') !== false && preg_match("/window.open\('(.*)','(.*)','dependent=yes,width=(.*),height=(.*),scrollbars=yes,status=(.*)'\)/",$on,$matches)) {
|
||||
$on = str_replace($matches[0], "egw_openWindowCentered2('{$matches[1]}', '{$matches[2]}', '{$matches[3]}', '{$matches[4]}', '{$matches[5]}')", $on);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user