# this file is used if you configure your scuttle for nice urls
# (see $cleanurls in config.inc.php)
-Options +FollowSymlinks
-# AcceptPathInfo On
-RewriteEngine On
-RewriteBase /
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule ^([^/]+)/?(.*) $1.php/$2 [L]
+#Options +FollowSymlinks
+#RewriteEngine On
+#RewriteBase /
+#RewriteCond %{REQUEST_FILENAME} !-f
+#RewriteCond %{REQUEST_FILENAME} !-d
+#RewriteRule ^([^/]+)/?(.*) $1.php/$2 [L]
# If you have Scuttle in subdirectories e.g. http://www.example.com/myscuttle/links/
# then you need to comment the precedent line and remove comment of the following one
# (replace "myscuttle/links/" with your subdirectories name)
#RewriteRule ^([^/]+)/?(.*) myscuttle/links/$1.php/$2 [L]
+
+####
+
+# Rewrite clean URLs onto real files
+<IfModule mod_rewrite.c>
+Options +FollowSymlinks
+RewriteEngine On
+RewriteBase /
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond %{REQUEST_FILENAME}.php -f
+RewriteRule ^([^/]+)/?(.*) $1.php?query=$2 [L,QSA]
+</IfModule>
require_once('header.inc.php');
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
+$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
$userid = NULL;
}
-$tags =& $tagservice->getTags($userid);
-$tplVars['tags'] =& $tagservice->tagCloud($tags, 5, 90, 225, getSortOrder());
+$tags =& $b2tservice->getTags($userid);
+$tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder());
$tplVars['user'] = $user;
if (isset($userid)) {
require_once('httpauth.inc.php');
require_once('../header.inc.php');
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
+$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
// Get the tags relevant to the passed-in variables.
-$tags =& $tagservice->getTags($userservice->getCurrentUserId());
+$tags =& $b2tservice->getTags($userservice->getCurrentUserId());
// Set up the XML file and output all the tags.
header('Content-Type: text/xml');
echo "\t<tag count=\"". $row['bCount'] .'" tag="'. filter(convertTag($row['tag'], 'out'), 'xml') ."\" />\r\n";
}
echo "</tags>";
-?>
\ No newline at end of file
+?>
require_once('httpauth.inc.php');
require_once('../header.inc.php');
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
+$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
// Get the tag info.
$renamed = false;
} else {
// Rename the tag.
- $result = $tagservice->renameTag($userservice->getCurrentUserId(), $old, $new, true);
+ $result = $b2tservice->renameTag($userservice->getCurrentUserId(), $old, $new, true);
$renamed = $result;
}
require_once('header.inc.php');
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
-$tagservice = & ServiceFactory :: getServiceInstance('TagService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService');
$cdservice = & ServiceFactory :: getServiceInstance('CommonDescriptionService');
}
$root = 'http://'. $_SERVER['HTTP_HOST'] . $root;
}
-
-// Error codes
-define('GENERAL_MESSAGE', 200);
-define('GENERAL_ERROR', 202);
-define('CRITICAL_MESSAGE', 203);
-define('CRITICAL_ERROR', 204);
?>
require_once('header.inc.php');
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
+$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
$userid = NULL;
}
-$tags = $tagservice->getPopularTags($userid, 150, $logged_on_userid);
-$tplVars['tags'] =& $tagservice->tagCloud($tags, 5, 90, 225, getSortOrder('alphabet_asc'));
+$tags = $b2tservice->getPopularTags($userid, 150, $logged_on_userid);
+$tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder('alphabet_asc'));
$tplVars['user'] = $user;
if (isset($userid)) {
<?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) {
$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)) {
$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);
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 {
$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;
$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;
// 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();
// 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);
// 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;
$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);
-- Semantice Scuttle - Tables creation SQL script
-- ! Dont forget to change table names according to $tableprefix defined in config.inc.php !
+
--
-- Table structure for table `sc_bookmarks`
--
--
CREATE TABLE `sc_tags` (
+ `tId` int(11) NOT NULL auto_increment,
+ `tag` varchar(32) NOT NULL default '',
+ `uId` int(11) NOT NULL default '0',
+ `tDescription` varchar(255) default NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `sc_tags_tag_uId` (`tag`, `uId`)
+);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `sc_bookmarks2tags`
+--
+
+CREATE TABLE `sc_bookmarks2tags` (
`id` int(11) NOT NULL auto_increment,
`bId` int(11) NOT NULL default '0',
`tag` varchar(32) NOT NULL default '',
PRIMARY KEY (`id`),
- UNIQUE KEY `sc_tags_tag_bId` (`tag`,`bId`),
- KEY `sc_tags_bId` (`bId`)
+ UNIQUE KEY `sc_bookmarks2tags_tag_bId` (`tag`,`bId`),
+ KEY `sc_bookmarks2tags_bId` (`bId`)
);
-- --------------------------------------------------------
***************************************************************************/
require_once('header.inc.php');
-$tagservice = & ServiceFactory :: getServiceInstance('TagService');
+$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService');
$cdservice = & ServiceFactory :: getServiceInstance('CommonDescriptionService');
***************************************************************************/
require_once('header.inc.php');
-$tagservice = & ServiceFactory :: getServiceInstance('TagService');
+$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService');
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
if ($_POST['confirm']) {
- if ($tagservice->deleteTag($logged_on_user['uId'], $tag)) {
+ if ($b2tservice->deleteTag($logged_on_user['uId'], $tag)) {
$tplVars['msg'] = T_('Tag deleted');
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
} else {
***************************************************************************/
require_once('header.inc.php');
-$tagservice = & ServiceFactory :: getServiceInstance('TagService');
+$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2tagService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService');
if (
!is_null($old) &&
!is_null($new) &&
- $tagservice->renameTag($userservice->getCurrentUserId(), $old, $new) &&
+ $b2tservice->renameTag($userservice->getCurrentUserId(), $old, $new) &&
$tag2tagservice->renameTag($userservice->getCurrentUserId(), $old, $new)
) {
$tplVars['msg'] = T_('Tag renamed');
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
-$tagservice = & ServiceFactory :: getServiceInstance('TagService');
+$b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService');
$userservice = & ServiceFactory :: getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
-$userPopularTags =& $tagservice->getPopularTags($logged_on_userid, 25, $logged_on_userid);
-$userPopularTagsCloud =& $tagservice->tagCloud($userPopularTags, 5, 90, 175);
+$userPopularTags =& $b2tservice->getPopularTags($logged_on_userid, 25, $logged_on_userid);
+$userPopularTagsCloud =& $b2tservice->tagCloud($userPopularTags, 5, 90, 175);
$userPopularTagsCount = count($userPopularTags);
if ($userPopularTagsCount > 0) {
<?php
}
-?>
\ No newline at end of file
+?>
<?php
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
-$commonTags =& $tagservice->getRelatedTagsByHash($hash);
-$commonTags =& $tagservice->tagCloud($commonTags, 5, 90, 225, 'alphabet_asc');
+$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
+$commonTags =& $b2tservice->getRelatedTagsByHash($hash);
+$commonTags =& $b2tservice->tagCloud($commonTags, 5, 90, 225, 'alphabet_asc');
if ($commonTags && count($commonTags) > 0) {
?>
<?php
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
+$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
$logged_on_userid = NULL;
}
-$popularTags =& $tagservice->getPopularTags($userid, $popCount, $logged_on_userid);
-$popularTags =& $tagservice->tagCloud($popularTags, 5, 90, 225, 'alphabet_asc');
+$popularTags =& $b2tservice->getPopularTags($userid, $popCount, $logged_on_userid);
+$popularTags =& $b2tservice->tagCloud($popularTags, 5, 90, 225, 'alphabet_asc');
if ($popularTags && count($popularTags) > 0) {
?>
<?php
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
+$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
$logged_on_userid = NULL;
}
-$recentTags = $tagservice->getPopularTags($userid, $popCount, $logged_on_userid, $GLOBALS['defaultRecentDays']);
-$recentTags =& $tagservice->tagCloud($recentTags, 5, 90, 225, 'alphabet_asc');
+$recentTags = $b2tservice->getPopularTags($userid, $popCount, $logged_on_userid, $GLOBALS['defaultRecentDays']);
+$recentTags =& $b2tservice->tagCloud($recentTags, 5, 90, 225, 'alphabet_asc');
if ($recentTags && count($recentTags) > 0) {
?>
<?php
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
+$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
$cat_url = createURL('tags', '%2$s');
}
if ($currenttag) {
- $relatedTags = $tagservice->getRelatedTags($currenttag, $userid, $logged_on_userid);
+ $relatedTags = $b2tservice->getRelatedTags($currenttag, $userid, $logged_on_userid);
if (sizeof($relatedTags) > 0) {
?>
<?php
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
$searchhistoryservice =& ServiceFactory::getServiceInstance('SearchHistoryService');
<?php
$userservice =& ServiceFactory::getServiceInstance('UserService');
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
if ($userservice->isLoggedOn()) {
$currentUser = $userservice->getCurrentUser();
<?php
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
To launch the tests, put in a console situated in the root of the SEMANTICSCUTTLE project (where is the SEMANTICSCUTTLE config file):
-phpunit BookmarksTest ./tests/bookmarksTest.php ; phpunit CommonDescriptionTest tests/commonDescriptionTest.php ; phpunit Tag2TagTest tests/tag2TagTest.php ; phpunit SearchTest tests/searchTest.php
+phpunit BookmarksTest ./tests/bookmarksTest.php ; phpunit CommonDescriptionTest tests/commonDescriptionTest.php ; phpunit Tag2TagTest tests/tag2TagTest.php ; phpunit SearchTest tests/searchTest.php ; phpunit TagsTest tests/tagsTest.php
$this->us =& ServiceFactory::getServiceInstance('UserService');
$this->bs =& ServiceFactory::getServiceInstance('BookmarkService');
$this->bs->deleteAll();
- $this->ts =& ServiceFactory::getServiceInstance('TagService');
- $this->ts->deleteAll();
+ $this->b2ts=& ServiceFactory::getServiceInstance('Bookmark2TagService');
+ $this->b2ts->deleteAll();
$this->tts =& ServiceFactory::getServiceInstance('Tag2TagService');
$this->tts->deleteAll();
$this->tsts =& ServiceFactory::getServiceInstance('TagStatService');
{
protected $us;
protected $bs;
- protected $ts;
+ protected $b2ts;
protected $tts;
protected $tsts;
protected $cds;
$this->us =& ServiceFactory::getServiceInstance('UserService');
$this->bs =& ServiceFactory::getServiceInstance('BookmarkService');
$this->bs->deleteAll();
- $this->ts =& ServiceFactory::getServiceInstance('TagService');
- $this->ts->deleteAll();
+ $this->b2ts =& ServiceFactory::getServiceInstance('Bookmark2TagService');
+ $this->b2ts->deleteAll();
$this->tts =& ServiceFactory::getServiceInstance('Tag2TagService');
$this->tts->deleteAll();
$this->tsts =& ServiceFactory::getServiceInstance('TagStatService');
{
protected $us;
protected $bs;
- protected $ts;
+ protected $b2ts;
protected $tts;
protected $shs;
$this->us =& ServiceFactory::getServiceInstance('UserService');
$this->bs =& ServiceFactory::getServiceInstance('BookmarkService');
$this->bs->deleteAll();
- $this->ts =& ServiceFactory::getServiceInstance('TagService');
- $this->ts->deleteAll();
+ $this->b2ts =& ServiceFactory::getServiceInstance('Bookmark2TagService');
+ $this->b2ts->deleteAll();
$this->tts =& ServiceFactory::getServiceInstance('Tag2TagService');
$this->tts->deleteAll();
$this->tsts =& ServiceFactory::getServiceInstance('TagStatService');
{
protected $us;
protected $bs;
- protected $ts;
+ protected $b2ts;
protected $tts;
protected function setUp()
$this->us =& ServiceFactory::getServiceInstance('UserService');
$this->bs =& ServiceFactory::getServiceInstance('BookmarkService');
$this->bs->deleteAll();
- $this->ts =& ServiceFactory::getServiceInstance('TagService');
- $this->ts->deleteAll();
+ $this->b2ts =& ServiceFactory::getServiceInstance('Bookmark2TagService');
+ $this->b2ts->deleteAll();
$this->tts =& ServiceFactory::getServiceInstance('Tag2TagService');
$this->tts->deleteAll();
$this->tsts =& ServiceFactory::getServiceInstance('TagStatService');
$bs->addBookmark("http://google.com", "title", "description", "status", $tags, null, false, false, 1);
$bookmark = $bs->getBookmarkByAddress("http://google.com");
- $ts = $this->ts;
- $savedTags = $ts->getTagsForBookmark(intval($bookmark['bId']));
+ $b2ts = $this->b2ts;
+ $savedTags = $b2ts->getTagsForBookmark(intval($bookmark['bId']));
$this->assertEquals(6, sizeof($savedTags));
$this->assertContains('b', $savedTags);
$this->assertContains('c', $savedTags);
public function testRenameFunction()
{
$tts = $this->tts;
- $ts = $this->ts;
+ $b2ts = $this->b2ts;
$bs = $this->bs;
$tsts = $this->tsts;
$bookmarks =& $bs->getBookmarks(0, 1, NULL, NULL, NULL, getSortOrder(), NULL, 0, $dtend);
$this->assertEquals(1, $bookmarks['total']);
- $ts->renameTag(1, 'tag1', 'newtag1');
- $tags1 = $ts->getTagsForBookmark(1);
+ $b2ts->renameTag(1, 'tag1', 'newtag1');
+ $tags1 = $b2ts->getTagsForBookmark(1);
$this->assertSame(array('newtag1', 'tag11', 'tag111'), $tags1);
- $tags1 = $ts->getTagsForBookmark(2);
+ $tags1 = $b2ts->getTagsForBookmark(2);
$this->assertSame(array('tag2', 'tag22', 'tag222'), $tags1); //should not be changed
=== From version 0.88 to 0.89 ===
- Backup you database
- Make a copy from your SemanticScuttle Web directory
-- Upgrade your database : add the following table (adapt its name prefix to your convenience) executin the following SQL commands:
+- Upgrade your database :
+
+
+* change the table called 'sc_tags' into 'sc_bookmarks2tags' by executing the following SQL commands (after changing 'yourdatabasename' and adapting its name prefix 'sc_' to your convenience):
+
+ RENAME TABLE `yourdatabasename`.`sc_tags` TO `yourdatabasename`.`sc_bookmarks2tags` ;
+
+
+* add the following table (adapt its name prefix to your convenience) executing the following SQL commands:
CREATE TABLE `sc_searchhistory` (
`shId` int(11) NOT NULL auto_increment,