aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-03-11 20:19:56 -0700
committerfriendica <info@friendica.com>2012-03-11 20:19:56 -0700
commit93058af4fcfa0c1dbe8398271c60513dea16338c (patch)
treec8f863d19bee59fb858c6daccde93ea567666fd0 /include/text.php
parent18ef942f6213c43fdef98caad4b42f7015eca20c (diff)
downloadvolse-hubzilla-93058af4fcfa0c1dbe8398271c60513dea16338c.tar.gz
volse-hubzilla-93058af4fcfa0c1dbe8398271c60513dea16338c.tar.bz2
volse-hubzilla-93058af4fcfa0c1dbe8398271c60513dea16338c.zip
backend for "save to file" feature
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index 5ad0154d7..08b2b8487 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1235,4 +1235,23 @@ function item_post_type($item) {
return 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(array('<','>','[',']'),array('%3c','%3e','%5b','%5d'),$s);
+}
+
+function file_tag_decode($s) {
+ return str_replace(array('%3c','%3e','%5b','%5d'),array('<','>','[',']'),$s);
+}
+
+function file_tag_file_query($table,$s,$type = 'file') {
+ if($type == 'file')
+ $str = preg_quote( '[' . file_tag_encode($s) . ']' );
+ else
+ $str = preg_quote( '<' . file_tag_encode($s) . '>' );
+ return " AND " . (($table) ? dbesc($table) . '.' : '') . "file regexp '" . dbesc($str) . "' ";
+} \ No newline at end of file