*/
public static function convertDefinitionToXML($name, $definition) {
$xmlFile = '<?xml version="1.0" encoding="utf-8" ?>' . "\n\n<CaseType>\n";
- $xmlFile .= "<name>{$name}</name>\n";
+ $xmlFile .= "<name>" . self::encodeXmlString($name) . "</name>\n";
if (array_key_exists('forkable', $definition)) {
$xmlFile .= "<forkable>" . ((int) $definition['forkable']) . "</forkable>\n";
foreach ($definition['activityTypes'] as $values) {
$xmlFile .= "<ActivityType>\n";
foreach ($values as $key => $value) {
- $xmlFile .= "<{$key}>{$value}</{$key}>\n";
+ $xmlFile .= "<{$key}>" . self::encodeXmlString($value) . "</{$key}>\n";
}
$xmlFile .= "</ActivityType>\n";
}
foreach ($setVal as $values) {
$xmlFile .= "<ActivityType>\n";
foreach ($values as $key => $value) {
- $xmlFile .= "<{$key}>{$value}</{$key}>\n";
+ $xmlFile .= "<{$key}>" . self::encodeXmlString($value) . "</{$key}>\n";
}
$xmlFile .= "</ActivityType>\n";
}
break;
default:
- $xmlFile .= "<{$index}>{$setVal}</{$index}>\n";
+ $xmlFile .= "<{$index}>" . self::encodeXmlString($setVal) . "</{$index}>\n";
}
}
foreach ($definition['caseRoles'] as $values) {
$xmlFile .= "<RelationshipType>\n";
foreach ($values as $key => $value) {
- $xmlFile .= "<{$key}>{$value}</{$key}>\n";
+ $xmlFile .= "<{$key}>" . self::encodeXmlString($value) . "</{$key}>\n";
}
$xmlFile .= "</RelationshipType>\n";
}
return $xmlFile;
}
+ /**
+ * Ugh. This shouldn't exist. Use a real XML-encoder.
+ *
+ * Escape a string for use in XML.
+ *
+ * @param string $str
+ * A string which should outputted to XML.
+ * @return string
+ * @deprecated
+ */
+ protected static function encodeXmlString($str) {
+ // PHP 5.4: return htmlspecialchars($str, ENT_XML1, 'UTF-8')
+ return htmlspecialchars($str);
+ }
+
/**
* Get the case definition either from db or read from xml file.
*