Add subtitution inside header and fotter document
This commit is contained in:
parent
2f7be8d2c2
commit
629ef78dc8
@ -511,6 +511,7 @@ class doc_generic_project_odt extends ModelePDFProjects
|
|||||||
else // Text
|
else // Text
|
||||||
{
|
{
|
||||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||||
|
$odfHandler->setVarsHeadFooter($key, $value, true, 'UTF-8');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(OdfException $e)
|
catch(OdfException $e)
|
||||||
|
|||||||
@ -127,6 +127,33 @@ class Odf
|
|||||||
$this->vars[$tag] = str_replace("\n", "<text:line-break/>", $value);
|
$this->vars[$tag] = str_replace("\n", "<text:line-break/>", $value);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assing a template variable
|
||||||
|
*
|
||||||
|
* @param string $key name of the variable within the template
|
||||||
|
* @param string $value replacement value
|
||||||
|
* @param bool $encode if true, special XML characters are encoded
|
||||||
|
* @throws OdfException
|
||||||
|
* @return odf
|
||||||
|
*/
|
||||||
|
public function setVarsHeadFooter($key, $value, $encode = true, $charset = 'ISO-8859')
|
||||||
|
{
|
||||||
|
$tag = $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT'];
|
||||||
|
// TODO Warning string may be:
|
||||||
|
// <text:span text:style-name="T13">{</text:span><text:span text:style-name="T12">aaa</text:span><text:span text:style-name="T13">}</text:span>
|
||||||
|
// instead of {aaa} so we should enhance this function.
|
||||||
|
//print $key.'-'.$value.'-'.strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']).'<br>';
|
||||||
|
if (strpos($this->stylesXml, $tag) === false && strpos($this->stylesXml , $tag) === false) {
|
||||||
|
//if (strpos($this->contentXml, '">'. $key . '</text;span>') === false) {
|
||||||
|
throw new OdfException("var $key not found in the document");
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
$value = $encode ? htmlspecialchars($value) : $value;
|
||||||
|
$value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value;
|
||||||
|
$this->vars[$tag] = str_replace("\n", "<text:line-break/>", $value);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluating php codes inside the ODT and output the buffer (print, echo) inplace of the code
|
* Evaluating php codes inside the ODT and output the buffer (print, echo) inplace of the code
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user