diff --git a/include/text.php b/include/text.php index aae7393122..aa4b2c8dba 100644 --- a/include/text.php +++ b/include/text.php @@ -24,6 +24,7 @@ use Friendica\Util\Map; use Friendica\Util\Proxy as ProxyUtils; use Friendica\Core\Logger; +use Friendica\Model\FileTag; require_once "include/conversation.php"; @@ -1099,9 +1100,9 @@ function get_cats_and_terms($item) if ($cnt) { foreach ($matches as $mtch) { $categories[] = [ - 'name' => xmlify(file_tag_decode($mtch[1])), + 'name' => xmlify(FileTag::decode($mtch[1])), 'url' => "#", - 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""), + 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(FileTag::decode($mtch[1])):""), 'first' => $first, 'last' => false ]; @@ -1120,9 +1121,9 @@ function get_cats_and_terms($item) if ($cnt) { foreach ($matches as $mtch) { $folders[] = [ - 'name' => xmlify(file_tag_decode($mtch[1])), + 'name' => xmlify(FileTag::decode($mtch[1])), 'url' => "#", - 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])) : ""), + 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . xmlify(FileTag::decode($mtch[1])) : ""), 'first' => $first, 'last' => false ]; @@ -1360,199 +1361,6 @@ function item_post_type($item) { return L10n::t('post'); } -// post categories and "save to file" use the same item.file table for storage. -// We will differentiate the different uses by wrapping categories in angle brackets -// and save to file categories in square brackets. -// To do this we need to escape these characters if they appear in our tag. - -function file_tag_encode($s) { - return str_replace(['<','>','[',']'],['%3c','%3e','%5b','%5d'],$s); -} - -function file_tag_decode($s) { - return str_replace(['%3c', '%3e', '%5b', '%5d'], ['<', '>', '[', ']'], $s); -} - -function file_tag_file_query($table,$s,$type = 'file') { - - if ($type == 'file') { - $str = preg_quote('[' . str_replace('%', '%%', file_tag_encode($s)) . ']'); - } else { - $str = preg_quote('<' . str_replace('%', '%%', file_tag_encode($s)) . '>'); - } - return " AND " . (($table) ? DBA::escape($table) . '.' : '') . "file regexp '" . DBA::escape($str) . "' "; -} - -// ex. given music,video return