aboutsummaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Service
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-23 17:13:16 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-23 17:13:16 +0000
commit68c01cda10ef49b05fffb6e323fa2d34ba5dd2f4 (patch)
tree5aabcd77449786df7629f351e2f2816284f99cd5 /src/SemanticScuttle/Service
parent3df99a0aec0b926464449e8ca33c808c63d903df (diff)
downloadsemanticscuttle-68c01cda10ef49b05fffb6e323fa2d34ba5dd2f4.tar.gz
semanticscuttle-68c01cda10ef49b05fffb6e323fa2d34ba5dd2f4.tar.bz2
rename ServiceFactory::getServiceInstance() to get() - much easier to write
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@396 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src/SemanticScuttle/Service')
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php20
-rw-r--r--src/SemanticScuttle/Service/Bookmark2Tag.php20
-rw-r--r--src/SemanticScuttle/Service/Factory.php2
-rw-r--r--src/SemanticScuttle/Service/Tag2Tag.php16
-rw-r--r--src/SemanticScuttle/Service/TagCache.php14
-rw-r--r--src/SemanticScuttle/Service/TagStat.php6
-rw-r--r--src/SemanticScuttle/Service/User.php14
7 files changed, 46 insertions, 46 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index 6075a0d..c920d65 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -27,7 +27,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_Service
function _getbookmark($fieldname, $value, $all = false) {
if (!$all) {
- $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User');
+ $userservice = SemanticScuttle_Service_Factory :: get('User');
$sId = $userservice->getCurrentUserId();
$range = ' AND uId = '. $sId;
} else {
@@ -61,7 +61,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_Service
if ($row = & $this->db->sql_fetchrow($dbresult)) {
if ($include_tags) {
- $b2tservice = SemanticScuttle_Service_Factory :: getServiceInstance('Bookmark2Tag');
+ $b2tservice = SemanticScuttle_Service_Factory :: get('Bookmark2Tag');
$row['tags'] = $b2tservice->getTagsForBookmark($bid);
}
$output = $row;
@@ -128,7 +128,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_Service
return false;
}
- $userservice = SemanticScuttle_Service_Factory::getServiceInstance('User');
+ $userservice = SemanticScuttle_Service_Factory::get('User');
$user = $userservice->getCurrentUser();
//user has to be either admin, or owner
@@ -170,7 +170,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_Service
// Note that date is expected to be a string that's interpretable by strtotime().
function addBookmark($address, $title, $description, $privateNote, $status, $categories, $date = NULL, $fromApi = false, $fromImport = false, $sId = -1) {
if($sId == -1) {
- $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User');
+ $userservice = SemanticScuttle_Service_Factory :: get('User');
$sId = $userservice->getCurrentUserId();
}
@@ -214,7 +214,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_Service
$extension = end($uriparts);
unset($uriparts);
- $b2tservice = SemanticScuttle_Service_Factory :: getServiceInstance('Bookmark2Tag');
+ $b2tservice = SemanticScuttle_Service_Factory :: get('Bookmark2Tag');
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);
@@ -270,7 +270,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_Service
$extension = end($uriparts);
unset($uriparts);
- $b2tservice = SemanticScuttle_Service_Factory :: getServiceInstance('Bookmark2Tag');
+ $b2tservice = SemanticScuttle_Service_Factory :: get('Bookmark2Tag');
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);
@@ -292,9 +292,9 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_Service
// bookmarks; otherwise, just get the public bookmarks.
// - if the $user is set and IS the logged-in user, then get all bookmarks.
- $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
- $b2tservice =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark2Tag');
- $tag2tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag2Tag');
+ $userservice =SemanticScuttle_Service_Factory::get('User');
+ $b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
+ $tag2tagservice =SemanticScuttle_Service_Factory::get('Tag2Tag');
$sId = $userservice->getCurrentUserId();
if ($userservice->isLoggedOn()) {
@@ -506,7 +506,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_Service
return false;
}
- $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User');
+ $userservice = SemanticScuttle_Service_Factory :: get('User');
$sId = $userservice->getCurrentUserId();
if ($userservice->isLoggedOn()) {
diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php
index bd3f3af..07d75b9 100644
--- a/src/SemanticScuttle/Service/Bookmark2Tag.php
+++ b/src/SemanticScuttle/Service/Bookmark2Tag.php
@@ -53,7 +53,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_Service
}
}
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tags = $tagservice->normalize($tags);
@@ -104,8 +104,8 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_Service
}
}
- $bs =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark');
- $tts =SemanticScuttle_Service_Factory::getServiceInstance('Tag2Tag');
+ $bs =SemanticScuttle_Service_Factory::get('Bookmark');
+ $tts =SemanticScuttle_Service_Factory::get('Tag2Tag');
// Create links between tags
foreach($tags as $key => $tag) {
@@ -161,7 +161,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_Service
}
function deleteTag($uId, $tag) {
- $bs =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark');
+ $bs =SemanticScuttle_Service_Factory::get('Bookmark');
$query = 'DELETE FROM '. $this->getTableName();
$query.= ' USING '. $this->getTableName() .', '. $bs->getTableName();
@@ -235,7 +235,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_Service
}
function &getTags($userid = NULL) {
- $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
+ $userservice =SemanticScuttle_Service_Factory::get('User');
$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'] .'bookmarks2tags AS T ON B.bId = T.bId';
@@ -310,7 +310,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_Service
// Returns the most popular tags used for a particular bookmark hash
function &getRelatedTagsByHash($hash, $limit = 20) {
- $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User');
+ $userservice = SemanticScuttle_Service_Factory :: get('User');
$sId = $userservice->getCurrentUserId();
// Logged in
if ($userservice->isLoggedOn()) {
@@ -340,7 +340,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_Service
function &getAdminTags($limit = 30, $logged_on_user = NULL, $days = NULL) {
// look for admin ids
- $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User');
+ $userservice = SemanticScuttle_Service_Factory :: get('User');
$adminIds = $userservice->getAdminIds();
// ask for their tags
@@ -349,7 +349,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_Service
function &getContactTags($user, $limit = 30, $logged_on_user = NULL, $days = NULL) {
// look for contact ids
- $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User');
+ $userservice = SemanticScuttle_Service_Factory :: get('User');
$contacts = $userservice->getWatchlist($user);
// add the user (to show him/her also his/her tags)
@@ -417,8 +417,8 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_Service
}
function renameTag($userid, $old, $new, $fromApi = false) {
- $bookmarkservice =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark');
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
if (is_null($userid) || is_null($old) || is_null($new))
return false;
diff --git a/src/SemanticScuttle/Service/Factory.php b/src/SemanticScuttle/Service/Factory.php
index 92747d7..0ea9009 100644
--- a/src/SemanticScuttle/Service/Factory.php
+++ b/src/SemanticScuttle/Service/Factory.php
@@ -62,7 +62,7 @@ class SemanticScuttle_Service_Factory
*
* @return SemanticScuttle_Service Service object
*/
- public static function getServiceInstance($name)
+ public static function get($name)
{
self::loadDb();
self::loadService($name);
diff --git a/src/SemanticScuttle/Service/Tag2Tag.php b/src/SemanticScuttle/Service/Tag2Tag.php
index b209d60..d283b57 100644
--- a/src/SemanticScuttle/Service/Tag2Tag.php
+++ b/src/SemanticScuttle/Service/Tag2Tag.php
@@ -27,7 +27,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_Service
}
function addLinkedTags($tag1, $tag2, $relationType, $uId) {
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tag1 = $tagservice->normalize($tag1);
$tag2 = $tagservice->normalize($tag2);
@@ -57,7 +57,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_Service
// Return linked tags just for admin users
function getAdminLinkedTags($tag, $relationType, $inverseRelation = false, $stopList = array()) {
// look for admin ids
- $userservice = SemanticScuttle_Service_Factory :: getServiceInstance('User');
+ $userservice = SemanticScuttle_Service_Factory :: get('User');
$adminIds = $userservice->getAdminIds();
//ask for their linked tags
@@ -130,7 +130,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_Service
}
// try to find data in cache
- $tcs = SemanticScuttle_Service_Factory::getServiceInstance('TagCache');
+ $tcs = SemanticScuttle_Service_Factory::get('TagCache');
if(count($stopList) == 0) {
$activatedCache = true;
} else {
@@ -188,7 +188,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_Service
$query = "SELECT DISTINCT tts.tag1 as tag";
$query.= " FROM `". $this->getTableName() ."` tts";
if($orderBy != null) {
- $tsts =SemanticScuttle_Service_Factory::getServiceInstance('TagStat');
+ $tsts =SemanticScuttle_Service_Factory::get('TagStat');
$query.= ", ".$tsts->getTableName() ." tsts";
}
$query.= " WHERE tts.tag1 <> ALL";
@@ -339,7 +339,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_Service
}
function renameTag($uId, $oldName, $newName) {
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$newName = $tagservice->normalize($newName);
$query = 'UPDATE `'. $this->getTableName() .'`';
@@ -366,10 +366,10 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_Service
}
function update($tag1, $tag2, $relationType, $uId) {
- $tsts =SemanticScuttle_Service_Factory::getServiceInstance('TagStat');
+ $tsts =SemanticScuttle_Service_Factory::get('TagStat');
$tsts->updateStat($tag1, $relationType, $uId);
- $tcs = SemanticScuttle_Service_Factory::getServiceInstance('TagCache');
+ $tcs = SemanticScuttle_Service_Factory::get('TagCache');
$tcs->deleteByUser($uId);
}
@@ -377,7 +377,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_Service
$query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
$this->db->sql_query($query);
- $tsts =SemanticScuttle_Service_Factory::getServiceInstance('TagStat');
+ $tsts =SemanticScuttle_Service_Factory::get('TagStat');
$tsts->deleteAll();
}
diff --git a/src/SemanticScuttle/Service/TagCache.php b/src/SemanticScuttle/Service/TagCache.php
index 30f9ebd..95f3ea8 100644
--- a/src/SemanticScuttle/Service/TagCache.php
+++ b/src/SemanticScuttle/Service/TagCache.php
@@ -37,7 +37,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_Service
}
function getChildren($tag1, $uId) {
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tag1 = $tagservice->normalize($tag1);
if($tag1 == '') return false;
@@ -66,7 +66,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_Service
}
function addChild($tag1, $tag2, $uId) {
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tag1 = $tagservice->normalize($tag1);
$tag2 = $tagservice->normalize($tag2);
@@ -110,7 +110,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_Service
}
function existsChild($tag1, $tag2, $uId) {
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tag1 = $tagservice->normalize($tag1);
$tag2 = $tagservice->normalize($tag2);
@@ -214,7 +214,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_Service
}
function _isSynonymKey($tag1, $uId) {
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tag1 = $tagservice->normalize($tag1);
$query = "SELECT tag1 FROM `". $this->getTableName() ."`";
@@ -226,7 +226,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_Service
}
function _isSynonymValue($tag2, $uId) {
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tag2 = $tagservice->normalize($tag2);
$query = "SELECT tag2 FROM `". $this->getTableName() ."`";
@@ -250,7 +250,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_Service
}
function _getSynonymKey($tag2, $uId) {
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tag2 = $tagservice->normalize($tag2);
if($this->_isSynonymKey($tag2)) return $tag2;
@@ -279,7 +279,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_Service
* $tagExcepted allows to hide a value.
*/
function _getSynonymValues($tag1, $uId, $tagExcepted = NULL) {
- $tagservice =SemanticScuttle_Service_Factory::getServiceInstance('Tag');
+ $tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tag1 = $tagservice->normalize($tag1);
$tagExcepted = $tagservice->normalize($tagExcepted);
diff --git a/src/SemanticScuttle/Service/TagStat.php b/src/SemanticScuttle/Service/TagStat.php
index c54dcb7..1bb7b05 100644
--- a/src/SemanticScuttle/Service/TagStat.php
+++ b/src/SemanticScuttle/Service/TagStat.php
@@ -27,7 +27,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_Service
}
function getNbChildren($tag1, $relationType, $uId) {
- $tts =SemanticScuttle_Service_Factory::getServiceInstance('Tag2Tag');
+ $tts =SemanticScuttle_Service_Factory::get('Tag2Tag');
$query = "SELECT tag1, relationType, uId FROM `". $tts->getTableName() ."`";
$query.= " WHERE tag1 = '" .$tag1 ."'";
$query.= " AND relationType = '". $relationType ."'";
@@ -102,7 +102,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_Service
return false;
}
- $tts =SemanticScuttle_Service_Factory::getServiceInstance('Tag2Tag');
+ $tts =SemanticScuttle_Service_Factory::get('Tag2Tag');
$linkedTags = $tts->getLinkedTags($tag1, $relationType, $uId);
$nbDescendants = 0;
$maxDepth = 0;
@@ -123,7 +123,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_Service
}
function updateAllStat() {
- $tts =SemanticScuttle_Service_Factory::getServiceInstance('Tag2Tag');
+ $tts =SemanticScuttle_Service_Factory::get('Tag2Tag');
$query = "SELECT tag1, uId FROM `". $tts->getTableName() ."`";
$query.= " WHERE relationType = '>'";
diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php
index 22076fe..49951d1 100644
--- a/src/SemanticScuttle/Service/User.php
+++ b/src/SemanticScuttle/Service/User.php
@@ -612,7 +612,7 @@ class User {
function getName() {
// Look for value only if not already set
if(!isset($this->name)) {
- $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
+ $userservice =SemanticScuttle_Service_Factory::get('User');
$user = $userservice->getUser($this->id);
$this->name = $user['name'];
}
@@ -622,7 +622,7 @@ class User {
function getEmail() {
// Look for value only if not already set
if(!isset($this->email)) {
- $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
+ $userservice =SemanticScuttle_Service_Factory::get('User');
$user = $userservice->getUser($this->id);
$this->email = $user['email'];
}
@@ -632,7 +632,7 @@ class User {
function getHomepage() {
// Look for value only if not already set
if(!isset($this->homepage)) {
- $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
+ $userservice =SemanticScuttle_Service_Factory::get('User');
$user = $userservice->getUser($this->id);
$this->homepage = $user['homepage'];
}
@@ -642,7 +642,7 @@ class User {
function getContent() {
// Look for value only if not already set
if(!isset($this->content)) {
- $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
+ $userservice =SemanticScuttle_Service_Factory::get('User');
$user = $userservice->getUser($this->id);
$this->content = $user['uContent'];
}
@@ -652,7 +652,7 @@ class User {
function getDatetime() {
// Look for value only if not already set
if(!isset($this->content)) {
- $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
+ $userservice =SemanticScuttle_Service_Factory::get('User');
$user = $userservice->getUser($this->id);
$this->datetime = $user['uDatetime'];
}
@@ -662,14 +662,14 @@ class User {
function isAdmin() {
// Look for value only if not already set
if(!isset($this->isAdmin)) {
- $userservice =SemanticScuttle_Service_Factory::getServiceInstance('User');
+ $userservice =SemanticScuttle_Service_Factory::get('User');
$this->isAdmin = $userservice->isAdmin($this->id);
}
return $this->isAdmin;
}
function getNbBookmarks($range = 'public') {
- $bookmarkservice =SemanticScuttle_Service_Factory::getServiceInstance('Bookmark');
+ $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
return $bookmarkservice->countBookmarks($this->getId(), $range);
}
}