Commit e0dc4f50 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5358 Fixed ImageAttribute usage in templates. Added special %% string...

Fixes #5358 Fixed ImageAttribute usage in templates. Added special %% string start for template values
parent 00e560eb
......@@ -210,6 +210,10 @@ class templateHandling
*/
public static function parseString($string, array $attrs, $escapeMethod = NULL)
{
if (preg_match('/^%%/', $string)) {
/* Special case: %% at beginning of string means do not touch it. Used by binary attributes. */
return preg_replace('/^%%/', '', $string);
}
$offset = 0;
while (preg_match('/%([^%]+)%/', $string, $m, PREG_OFFSET_CAPTURE, $offset)) {
$replace = static::parseMask($m[1][0], $attrs);
......
......@@ -352,4 +352,28 @@ class ImageAttribute extends FileAttribute
$id = $this->getHtmlId();
return array($id.'_img',$id,'upload'.$id);
}
/*! \brief Fill LDAP value in the attrs array
*/
function fillLdapValue (&$attrs)
{
if ($this->isInLdap()) {
$value = $this->computeLdapValue();
if ($value !== '') {
if (isset($this->plugin) && $this->plugin->is_template) {
/* Add %% to provide template from parsing binary string */
$value = '%%'.$value;
}
$attrs[$this->getLdapName()] = $value;
} else {
$attrs[$this->getLdapName()] = array();
}
}
}
function inputValue ($value)
{
/* Remove %% that might be there in case of templating */
return preg_replace('/^%%/', '', $value);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment