forked from extern/egroupware
Fix merge replace placeholders causes huge performance issue. Additionally, fixes the extra $ sign shown up in replaced placeholders.
This commit is contained in:
parent
74746a14ef
commit
2943b678bd
@ -258,9 +258,7 @@ abstract class Merge
|
|||||||
case 'jpegphoto': // returning a link might make more sense then the binary photo
|
case 'jpegphoto': // returning a link might make more sense then the binary photo
|
||||||
if ($contact['photo'])
|
if ($contact['photo'])
|
||||||
{
|
{
|
||||||
$value = ($GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ?
|
$value = Api\Framework::getUrl(Api\Framework::link('/index.php',$contact['photo']));
|
||||||
($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : '').
|
|
||||||
$GLOBALS['egw']->link('/index.php',$contact['photo']);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'tel_prefer':
|
case 'tel_prefer':
|
||||||
@ -380,14 +378,14 @@ abstract class Merge
|
|||||||
protected function get_all_links($app, $id, $prefix, &$content)
|
protected function get_all_links($app, $id, $prefix, &$content)
|
||||||
{
|
{
|
||||||
$array = array();
|
$array = array();
|
||||||
$pattern = '@\$(links_attachments|links|attachments|link)\/?(title|href|link)?\/?([a-z]*)\$@';
|
$pattern = '@\$\$(links_attachments|links|attachments|link)\/?(title|href|link)?\/?([a-z]*)\$\$@';
|
||||||
static $link_cache=null;
|
static $link_cache=null;
|
||||||
$matches = null;
|
$matches = null;
|
||||||
if(preg_match_all($pattern, $content, $matches))
|
if(preg_match_all($pattern, $content, $matches))
|
||||||
{
|
{
|
||||||
foreach($matches[0] as $i => $placeholder)
|
foreach($matches[0] as $i => $placeholder)
|
||||||
{
|
{
|
||||||
$placeholder = substr($placeholder, 1, -1);
|
$placeholder = substr($placeholder, 2, -2);
|
||||||
if($link_cache[$id][$placeholder])
|
if($link_cache[$id][$placeholder])
|
||||||
{
|
{
|
||||||
$array[$placeholder] = $link_cache[$id][$placeholder];
|
$array[$placeholder] = $link_cache[$id][$placeholder];
|
||||||
@ -416,27 +414,22 @@ abstract class Merge
|
|||||||
// Prepend site
|
// Prepend site
|
||||||
if ($link[0] == '/') $link = Api\Framework::getUrl($link);
|
if ($link[0] == '/') $link = Api\Framework::getUrl($link);
|
||||||
|
|
||||||
$array[($prefix?$prefix.'/':'').$placeholder] = Api\Html::a_href(Api\Html::htmlspecialchars($title), $link);
|
$array['$$'.($prefix?$prefix.'/':'').$placeholder.'$$'] = Api\Html::a_href(Api\Html::htmlspecialchars($title), $link);
|
||||||
break;
|
break;
|
||||||
case 'links':
|
case 'links':
|
||||||
$link_app = $matches[3][$i] ? $matches[3][$i] : '!'.Api\Link::VFS_APPNAME;
|
$link_app = $matches[3][$i] ? $matches[3][$i] : '!'.Api\Link::VFS_APPNAME;
|
||||||
$array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, $link_app, array(),$matches[2][$i]);
|
$array['$$'.($prefix?$prefix.'/':'').$placeholder.'$$'] = $this->get_links($app, $id, $link_app, array(),$matches[2][$i]);
|
||||||
break;
|
break;
|
||||||
case 'attachments':
|
case 'attachments':
|
||||||
$array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, Api\Link::VFS_APPNAME,array(),$matches[2][$i]);
|
$array['$$'.($prefix?$prefix.'/':'').$placeholder.'$$'] = $this->get_links($app, $id, Api\Link::VFS_APPNAME,array(),$matches[2][$i]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, $matches[3][$i], array(), $matches[2][$i]);
|
$array['$$'.($prefix?$prefix.'/':'').$placeholder.'$$'] = $this->get_links($app, $id, $matches[3][$i], array(), $matches[2][$i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$link_cache[$id][$placeholder] = $array[$placeholder];
|
$link_cache[$id][$placeholder] = $array[$placeholder];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Need to set each app, to make sure placeholders are removed
|
|
||||||
foreach(array_keys($GLOBALS['egw_info']['user']['apps']) as $_app)
|
|
||||||
{
|
|
||||||
$array[($prefix?$prefix.'/':'')."links/$app"] = $this->get_links($app,$id,$_app);
|
|
||||||
}
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user