summaryrefslogtreecommitdiff
path: root/classes/feeditem/common.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/feeditem/common.php')
-rwxr-xr-xclasses/feeditem/common.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/classes/feeditem/common.php b/classes/feeditem/common.php
index 3193ed273..f208f4a48 100755
--- a/classes/feeditem/common.php
+++ b/classes/feeditem/common.php
@@ -162,4 +162,35 @@ abstract class FeedItem_Common extends FeedItem {
}
}
+ static function normalize_categories($cats) {
+
+ $tmp = [];
+
+ foreach ($cats as $rawcat) {
+ $tmp = array_merge($tmp, explode(",", $rawcat));
+ }
+
+ $tmp = array_map(function($srccat) {
+ $cat = clean(trim(mb_strtolower($srccat)));
+
+ // we don't support numeric tags
+ if (is_numeric($cat))
+ $cat = 't:' . $cat;
+
+ $cat = preg_replace('/[,\'\"]/', "", $cat);
+
+ if (DB_TYPE == "mysql") {
+ $cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat);
+ }
+
+ if (mb_strlen($cat) > 250)
+ $cat = mb_substr($cat, 0, 250);
+
+ return $cat;
+ }, $tmp);
+
+ asort($tmp);
+
+ return array_unique($tmp);
+ }
}