diff options
Diffstat (limited to 'services')
-rw-r--r-- | services/bookmark2tagservice.php (renamed from services/tagservice.php) | 12 | ||||
-rw-r--r-- | services/bookmarkservice.php | 20 |
2 files changed, 16 insertions, 16 deletions
diff --git a/services/tagservice.php b/services/bookmark2tagservice.php index 1aba11e..148ad3a 100644 --- a/services/tagservice.php +++ b/services/bookmark2tagservice.php @@ -1,18 +1,18 @@ <?php -class TagService { +class Bookmark2TagService { var $db; var $tablename; function &getInstance(&$db) { static $instance; if (!isset($instance)) - $instance =& new TagService($db); + $instance =& new Bookmark2TagService($db); return $instance; } - function TagService(&$db) { + function Bookmark2TagService(&$db) { $this->db =& $db; - $this->tablename = $GLOBALS['tableprefix'] .'tags'; + $this->tablename = $GLOBALS['tableprefix'] .'bookmarks2tags'; } function isNotSystemTag($var) { @@ -204,7 +204,7 @@ class TagService { $userservice =& ServiceFactory::getServiceInstance('UserService'); $logged_on_user = $userservice->getCurrentUserId(); - $query = 'SELECT T.tag, COUNT(B.bId) AS bCount FROM '. $GLOBALS['tableprefix'] .'bookmarks AS B INNER JOIN '. $userservice->getTableName() .' AS U ON B.uId = U.'. $userservice->getFieldName('primary') .' INNER JOIN '. $GLOBALS['tableprefix'] .'tags AS T ON B.bId = T.bId'; + $query = 'SELECT T.tag, COUNT(B.bId) AS bCount FROM '. $GLOBALS['tableprefix'] .'bookmarks AS B INNER JOIN '. $userservice->getTableName() .' AS U ON B.uId = U.'. $userservice->getFieldName('primary') .' INNER JOIN '. $GLOBALS['tableprefix'] .'bookmarks2tags AS T ON B.bId = T.bId'; $conditions = array(); if (!is_null($userid)) { @@ -288,7 +288,7 @@ class TagService { $privacy = ' AND B.bStatus = 0 '; } - $query = 'SELECT T.tag, COUNT(T.tag) AS bCount FROM sc_bookmarks AS B LEFT JOIN sc_tags AS T ON B.bId = T.bId WHERE B.bHash = "'. $hash .'" '. $privacy .'AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC'; + $query = 'SELECT T.tag, COUNT(T.tag) AS bCount FROM '.$GLOBALS['tableprefix'].'bookmarks AS B LEFT JOIN '.$GLOBALS['tableprefix'].'bookmarks2tags AS T ON B.bId = T.bId WHERE B.bHash = "'. $hash .'" '. $privacy .'AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC'; if (!($dbresult =& $this->db->sql_query_limit($query, $limit))) { message_die(GENERAL_ERROR, 'Could not get related tags for this hash', '', __LINE__, __FILE__, $query, $this->db); diff --git a/services/bookmarkservice.php b/services/bookmarkservice.php index 54c2773..5339004 100644 --- a/services/bookmarkservice.php +++ b/services/bookmarkservice.php @@ -47,8 +47,8 @@ class BookmarkService { if ($row = & $this->db->sql_fetchrow($dbresult)) { if ($include_tags) { - $tagservice = & ServiceFactory :: getServiceInstance('TagService'); - $row['tags'] = $tagservice->getTagsForBookmark($bid); + $b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService'); + $row['tags'] = $b2tservice->getTagsForBookmark($bid); } return $row; } else { @@ -157,8 +157,8 @@ class BookmarkService { $extension = end($uriparts); unset($uriparts); - $tagservice = & ServiceFactory :: getServiceInstance('TagService'); - if (!$tagservice->attachTags($bId, $categories, $fromApi, $extension, false, $fromImport)) { + $b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService'); + if (!$b2tservice->attachTags($bId, $categories, $fromApi, $extension, false, $fromImport)) { $this->db->sql_transaction('rollback'); message_die(GENERAL_ERROR, 'Could not insert bookmark', '', __LINE__, __FILE__, $sql, $this->db); return false; @@ -204,8 +204,8 @@ class BookmarkService { $extension = end($uriparts); unset($uriparts); - $tagservice = & ServiceFactory :: getServiceInstance('TagService'); - if (!$tagservice->attachTags($bId, $categories, $fromApi, $extension)) { + $b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService'); + if (!$b2tservice->attachTags($bId, $categories, $fromApi, $extension)) { $this->db->sql_transaction('rollback'); message_die(GENERAL_ERROR, 'Could not update bookmark', '', __LINE__, __FILE__, $sql, $this->db); return false; @@ -226,7 +226,7 @@ class BookmarkService { // bookmarks; otherwise, just get the public bookmarks. // - if the $user is set and IS the logged-in user, then get all bookmarks. $userservice =& ServiceFactory::getServiceInstance('UserService'); - $tagservice =& ServiceFactory::getServiceInstance('TagService'); + $b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService'); $tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService'); $sId = $userservice->getCurrentUserId(); @@ -307,7 +307,7 @@ class BookmarkService { // Handle the parts of the query that depend on any tags that are present. $query_4 = ''; for ($i = 0; $i < $tagcount; $i ++) { - $query_2 .= ', '. $tagservice->getTableName() .' AS T'. $i; + $query_2 .= ', '. $b2tservice->getTableName() .' AS T'. $i; $query_4 .= ' AND ('; $allLinkedTags = $tag2tagservice->getAllLinkedTags($this->db->sql_escape($tags[$i]), '>', $user); @@ -331,7 +331,7 @@ class BookmarkService { // Search terms in tags as well when none given if (!count($tags)) { - $query_2 .= ' LEFT JOIN '. $tagservice->getTableName() .' AS T ON B.bId = T.bId'; + $query_2 .= ' LEFT JOIN '. $b2tservice->getTableName() .' AS T ON B.bId = T.bId'; $dotags = true; } else { $dotags = false; @@ -386,7 +386,7 @@ class BookmarkService { $bookmarks = array(); while ($row = & $this->db->sql_fetchrow($dbresult)) { - $row['tags'] = $tagservice->getTagsForBookmark(intval($row['bId'])); + $row['tags'] = $b2tservice->getTagsForBookmark(intval($row['bId'])); $bookmarks[] = $row; } return array ('bookmarks' => $bookmarks, 'total' => $total); |