use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Model\FileTag;
+use Friendica\Util\XML;
require_once "include/conversation.php";
return $word;
}
-
-/**
- * escape text ($str) for XML transport
- * @param string $str
- * @return string Escaped text.
- */
-function xmlify($str) {
- /// @TODO deprecated code found?
-/* $buffer = '';
-
- $len = mb_strlen($str);
- for ($x = 0; $x < $len; $x ++) {
- $char = mb_substr($str,$x,1);
-
- switch($char) {
-
- case "\r" :
- break;
- case "&" :
- $buffer .= '&';
- break;
- case "'" :
- $buffer .= ''';
- break;
- case "\"" :
- $buffer .= '"';
- break;
- case '<' :
- $buffer .= '<';
- break;
- case '>' :
- $buffer .= '>';
- break;
- case "\n" :
- $buffer .= "\n";
- break;
- default :
- $buffer .= $char;
- break;
- }
- }*/
- /*
- $buffer = mb_ereg_replace("&", "&", $str);
- $buffer = mb_ereg_replace("'", "'", $buffer);
- $buffer = mb_ereg_replace('"', """, $buffer);
- $buffer = mb_ereg_replace("<", "<", $buffer);
- $buffer = mb_ereg_replace(">", ">", $buffer);
- */
- $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
- */
-function unxmlify($s) {
- /// @TODO deprecated code found?
-// $ret = str_replace('&','&', $s);
-// $ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret);
- /*$ret = mb_ereg_replace('&', '&', $s);
- $ret = mb_ereg_replace(''', "'", $ret);
- $ret = mb_ereg_replace('"', '"', $ret);
- $ret = mb_ereg_replace('<', "<", $ret);
- $ret = mb_ereg_replace('>', ">", $ret);
- */
- $ret = htmlspecialchars_decode($s, ENT_QUOTES);
- return $ret;
-}
-
/**
* Loader for infinite scrolling
* @return string html for loader
if ($cnt) {
foreach ($matches as $mtch) {
$categories[] = [
- 'name' => xmlify(FileTag::decode($mtch[1])),
+ 'name' => XML::xmlify(FileTag::decode($mtch[1])),
'url' => "#",
- 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(FileTag::decode($mtch[1])):""),
+ 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . XML::xmlify(FileTag::decode($mtch[1])):""),
'first' => $first,
'last' => false
];
if ($cnt) {
foreach ($matches as $mtch) {
$folders[] = [
- 'name' => xmlify(FileTag::decode($mtch[1])),
+ 'name' => XML::xmlify(FileTag::decode($mtch[1])),
'url' => "#",
- 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . xmlify(FileTag::decode($mtch[1])) : ""),
+ 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . XML::xmlify(FileTag::decode($mtch[1])) : ""),
'first' => $first,
'last' => false
];
return $s;
}
-/**
- * apply xmlify() to all values of array $val, recursively
- * @param array $val
- * @return array
- */
-function array_xmlify($val){
- if (is_bool($val)) {
- return $val?"true":"false";
- } elseif (is_array($val)) {
- return array_map('array_xmlify', $val);
- }
- return xmlify((string) $val);
-}
-
-
/**
* transform link href and img src from relative to absolute
*
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);
+ }
}