mirror of
https://github.com/friendica/friendica
synced 2025-04-30 17:04:23 +02:00
Move to XML
move functions from text to xml
This commit is contained in:
parent
95a41699cf
commit
84e900d96f
2 changed files with 44 additions and 93 deletions
|
@ -462,4 +462,43 @@ class XML
|
|||
|
||||
return $first_item->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* escape text ($str) for XML transport
|
||||
* @param string $str
|
||||
* @return string Escaped text.
|
||||
*/
|
||||
public static function xmlify($str)
|
||||
{
|
||||
$buffer = htmlspecialchars($str, ENT_QUOTES, "UTF-8");
|
||||
$buffer = trim($buffer);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* undo an xmlify
|
||||
* @param string $s xml escaped text
|
||||
* @return string unescaped text
|
||||
*/
|
||||
public static function unxmlify($s)
|
||||
{
|
||||
$ret = htmlspecialchars_decode($s, ENT_QUOTES);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* apply xmlify() to all values of array $val, recursively
|
||||
* @param array $val
|
||||
* @return array
|
||||
*/
|
||||
public static function arrayXmlify($val)
|
||||
{
|
||||
if (is_bool($val)) {
|
||||
return $val?"true":"false";
|
||||
} elseif (is_array($val)) {
|
||||
return array_map('XML::arrayXmlify', $val);
|
||||
}
|
||||
return self::xmlify((string) $val);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue