Here is a quick patch to odf.php that adds a new function(OptVar). OptVar allows one to specify an optional variable in the template… i.e. maybe this variable is in the template, maybe it isn't.
It is a quick & dirty hack but thought others might find it useful.
--- a/library/odf.php Tue Apr 03 14:48:22 2012 -0500+++ b/library/odf.php Wed Apr 04 09:06:17 2012 -0500@@ -88,6 +88,29 @@
return $this;
}
/**
+ * Assing an optional 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+ * @return odf+ */+ public function OptVar($key, $value, $encode = true, $charset = 'ISO-8859')+ {+ if (strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']) === false) {+ // variable was NOT found in the template+ $notme="<text:line-break/>";+ $this->$notme;+ }+ else { // variable WAS found in the template+ // variable was found in the template, lets act on it+ $value = $encode ? htmlspecialchars($value) : $value;+ $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value;+ $this->vars[$this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']] = str_replace("\n", "<text:line-break/>", $value); + }+ return $this;+ }+ /**
* Assign a template variable as a picture
*
* @param string $key name of the variable within the template
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is a quick patch to odf.php that adds a new function(OptVar). OptVar allows one to specify an optional variable in the template… i.e. maybe this variable is in the template, maybe it isn't.
It is a quick & dirty hack but thought others might find it useful.
Ok, here's a better patch… fixes the Undefined error