X-Git-Url: https://projects.mako.cc/source/scuttle/blobdiff_plain/bce919af7b49bbd06223f79b8c37a53a3d263ff0..c7f63c8b9b12efd7b3c10b9f80cda06eaf32068f:/services/tagservice.php diff --git a/services/tagservice.php b/services/tagservice.php index 6bfbf15..9c6c75f 100644 --- a/services/tagservice.php +++ b/services/tagservice.php @@ -1,26 +1,24 @@ db =& $db; - $this->tablename = $GLOBALS['tableprefix'] .'tags'; + function &getInstance(&$db) { + static $instance; + if (!isset($instance)) { + $instance = new TagService($db); } + return $instance; + } - function isNotSystemTag($var) { - if (utf8_substr($var, 0, 7) == 'system:') - return false; - else - return true; - } + function TagService(&$db) { + $this->db =& $db; + $this->tablename = $GLOBALS['tableprefix'] .'tags'; + } + + function isNotSystemTag($var) { + return !(utf8_substr($var, 0, 7) == 'system:'); + } function attachTags($bookmarkid, $tags, $fromApi = false, $extension = NULL, $replace = true, $fromImport = false) { // Make sure that categories is an array of trimmed strings, and that if the categories are @@ -45,7 +43,7 @@ class TagService { for ($i = 0; $i < $tags_count; $i++) { $tags[$i] = trim(strtolower($tags[$i])); if ($fromApi) { - include_once(dirname(__FILE__) .'/../functions.inc.php'); + include_once dirname(__FILE__) .'/../functions.inc.php'; $tags[$i] = convertTag($tags[$i], 'in'); } } @@ -64,7 +62,7 @@ class TagService { // Media and file types if (!is_null($extension)) { - include_once(dirname(__FILE__) .'/../functions.inc.php'); + include_once dirname(__FILE__) .'/../functions.inc.php'; if ($keys = multi_array_search($extension, $GLOBALS['filetypes'])) { $tags[] = 'system:filetype:'. $extension; $tags[] = 'system:media:'. array_shift($keys); @@ -350,7 +348,7 @@ class TagService { } if ($sortOrder == 'alphabet_asc') { - usort($output, create_function('$a,$b','return strcasecmp(utf8_deaccent($a["tag"]), utf8_deaccent($b["tag"]));')); + usort($output, create_function('$a,$b','return strcmp(utf8_strtolower($a["tag"]), utf8_strtolower($b["tag"]));')); } return $output; @@ -360,4 +358,3 @@ class TagService { function getTableName() { return $this->tablename; } function setTableName($value) { $this->tablename = $value; } } -?> \ No newline at end of file