summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-01-28 14:55:07 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-01-28 14:55:07 +0000
commit3ef7b27643328861ab47bc1cfd8596bc747b5a09 (patch)
tree22ad2cd5d4742e9472ef3ea0d56af733a6bddf5b
parente740849d4c37dca5634e0ac39ffb6dfdb2aedf1e (diff)
downloadsemanticscuttle-3ef7b27643328861ab47bc1cfd8596bc747b5a09.tar.gz
semanticscuttle-3ef7b27643328861ab47bc1cfd8596bc747b5a09.tar.bz2
new feature: structured tags, add synonym link
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@29 b3834d28-1941-0410-a4f8-b48e95affb8f
-rw-r--r--locales/fr_FR/LC_MESSAGES/messages.mobin17339 -> 17488 bytes
-rw-r--r--locales/fr_FR/LC_MESSAGES/messages.po38
-rw-r--r--locales/messages.po36
-rw-r--r--services/tag2tagservice.php18
-rw-r--r--services/tagservice.php43
-rw-r--r--templates/editbookmark.tpl.php4
-rw-r--r--templates/sidebar.block.linked.php69
-rw-r--r--tests/tag2TagTest.php47
8 files changed, 177 insertions, 78 deletions
diff --git a/locales/fr_FR/LC_MESSAGES/messages.mo b/locales/fr_FR/LC_MESSAGES/messages.mo
index c068266..c075f59 100644
--- a/locales/fr_FR/LC_MESSAGES/messages.mo
+++ b/locales/fr_FR/LC_MESSAGES/messages.mo
Binary files differ
diff --git a/locales/fr_FR/LC_MESSAGES/messages.po b/locales/fr_FR/LC_MESSAGES/messages.po
index 5b1e1d5..a7b6171 100644
--- a/locales/fr_FR/LC_MESSAGES/messages.po
+++ b/locales/fr_FR/LC_MESSAGES/messages.po
@@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Scuttle\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-01-22 16:54+0100\n"
-"PO-Revision-Date: 2008-01-22 16:55+0100\n"
+"POT-Creation-Date: 2008-01-28 15:37+0100\n"
+"PO-Revision-Date: 2008-01-28 15:54+0100\n"
"Last-Translator: BenjaminHKB <benjamin.huynh-kim-bang@loria.fr>\n"
"Language-Team: fr-FR <toony.sf@chezouam.net>\n"
"MIME-Version: 1.0\n"
@@ -633,66 +633,70 @@ msgstr "Séparés par des virgules"
msgid "Note: use \">\" to include one tag in another. e.g.: europe>france>paris"
msgstr "Note: utiliser \">\" pour inclure un tag dans un autre. ex: europe>france>paris"
-#: ../../../templates/editbookmark.tpl.php:53
+#: ../../../templates/editbookmark.tpl.php:54
+msgid "Note: use \"=\" to make synonym two tags. e.g.: france=frenchcountry"
+msgstr "Note : utiliser \"=\" pour rendre deux tags synonymes ex: europe=eu"
+
+#: ../../../templates/editbookmark.tpl.php:57
#: ../../../templates/importDelicious.tpl.php:15
#: ../../../templates/importNetscape.tpl.php:16
msgid "Privacy"
msgstr "Vision"
-#: ../../../templates/editbookmark.tpl.php:56
+#: ../../../templates/editbookmark.tpl.php:60
#: ../../../templates/importDelicious.tpl.php:18
#: ../../../templates/importNetscape.tpl.php:19
msgid "Public"
msgstr "Publique"
-#: ../../../templates/editbookmark.tpl.php:57
+#: ../../../templates/editbookmark.tpl.php:61
msgid "Shared with Watch List"
msgstr "Partagé avec liste d'accès"
-#: ../../../templates/editbookmark.tpl.php:58
+#: ../../../templates/editbookmark.tpl.php:62
#: ../../../templates/importDelicious.tpl.php:20
#: ../../../templates/importNetscape.tpl.php:21
msgid "Private"
msgstr "Privée"
-#: ../../../templates/editbookmark.tpl.php:70
+#: ../../../templates/editbookmark.tpl.php:74
msgid "Delete Bookmark"
msgstr "Supprimer le signet"
-#: ../../../templates/editbookmark.tpl.php:97
+#: ../../../templates/editbookmark.tpl.php:101
msgid "Bookmarklet"
msgstr "Bookmarklet"
-#: ../../../templates/editbookmark.tpl.php:98
+#: ../../../templates/editbookmark.tpl.php:102
#, php-format
msgid "Drag one of the following bookmarklets to your browser's bookmarks and click it whenever you want to add the page you are on to %s"
msgstr "Déplacez l'un des 'bookmarklet' suivants dans les marques-pages de votre navigateur et cliquez dessus chaque fois que vous souhaitez ajouter un signet pour la page courante dans %s "
-#: ../../../templates/editbookmark.tpl.php:110
+#: ../../../templates/editbookmark.tpl.php:114
#, php-format
msgid "Post to %s"
msgstr "Ajouter à %s"
-#: ../../../templates/editbookmark.tpl.php:111
+#: ../../../templates/editbookmark.tpl.php:115
#, php-format
msgid "Post to %s (Pop-up)"
msgstr "Ajouter à %s (Pop-up)"
-#: ../../../templates/editbookmark.tpl.php:115
+#: ../../../templates/editbookmark.tpl.php:119
#: ../../../templates/importDelicious.tpl.php:26
#: ../../../templates/importNetscape.tpl.php:27
msgid "Import"
msgstr "Importer"
-#: ../../../templates/editbookmark.tpl.php:117
+#: ../../../templates/editbookmark.tpl.php:121
msgid "Import bookmarks from bookmark file"
msgstr "Importer les signets depuis un fichier"
-#: ../../../templates/editbookmark.tpl.php:117
+#: ../../../templates/editbookmark.tpl.php:121
msgid "Internet Explorer, Mozilla Firefox and Netscape"
msgstr "Internet Explorer, Mozilla Firefox et Netscape"
-#: ../../../templates/editbookmark.tpl.php:118
+#: ../../../templates/editbookmark.tpl.php:122
msgid "Import bookmarks from del.icio.us"
msgstr "Importer les signets depuis del.icio.us"
@@ -851,11 +855,11 @@ msgstr "Enregistrez-vous ici pour créer un compte gratuit %s. Toutes les inform
msgid "Antispam question"
msgstr "Question antispam"
-#: ../../../templates/sidebar.block.linked.php:72
+#: ../../../templates/sidebar.block.linked.php:97
msgid "Linked Tags"
msgstr "Tags structurés"
-#: ../../../templates/sidebar.block.linked.php:75
+#: ../../../templates/sidebar.block.linked.php:100
msgid "plus"
msgstr "plus"
diff --git a/locales/messages.po b/locales/messages.po
index a5301eb..acd7574 100644
--- a/locales/messages.po
+++ b/locales/messages.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-01-22 16:54+0100\n"
+"POT-Creation-Date: 2008-01-28 15:37+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -620,68 +620,72 @@ msgid ""
"Note: use \">\" to include one tag in another. e.g.: europe>france>paris"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:53
+#: ../../../templates/editbookmark.tpl.php:54
+msgid "Note: use \"=\" to make synonym two tags. e.g.: france=frenchcountry"
+msgstr ""
+
+#: ../../../templates/editbookmark.tpl.php:57
#: ../../../templates/importDelicious.tpl.php:15
#: ../../../templates/importNetscape.tpl.php:16
msgid "Privacy"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:56
+#: ../../../templates/editbookmark.tpl.php:60
#: ../../../templates/importDelicious.tpl.php:18
#: ../../../templates/importNetscape.tpl.php:19
msgid "Public"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:57
+#: ../../../templates/editbookmark.tpl.php:61
msgid "Shared with Watch List"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:58
+#: ../../../templates/editbookmark.tpl.php:62
#: ../../../templates/importDelicious.tpl.php:20
#: ../../../templates/importNetscape.tpl.php:21
msgid "Private"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:70
+#: ../../../templates/editbookmark.tpl.php:74
msgid "Delete Bookmark"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:97
+#: ../../../templates/editbookmark.tpl.php:101
msgid "Bookmarklet"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:98
+#: ../../../templates/editbookmark.tpl.php:102
#, php-format
msgid ""
"Drag one of the following bookmarklets to your browser's bookmarks and click "
"it whenever you want to add the page you are on to %s"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:110
+#: ../../../templates/editbookmark.tpl.php:114
#, php-format
msgid "Post to %s"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:111
+#: ../../../templates/editbookmark.tpl.php:115
#, php-format
msgid "Post to %s (Pop-up)"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:115
+#: ../../../templates/editbookmark.tpl.php:119
#: ../../../templates/importDelicious.tpl.php:26
#: ../../../templates/importNetscape.tpl.php:27
msgid "Import"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:117
+#: ../../../templates/editbookmark.tpl.php:121
msgid "Import bookmarks from bookmark file"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:117
+#: ../../../templates/editbookmark.tpl.php:121
msgid "Internet Explorer, Mozilla Firefox and Netscape"
msgstr ""
-#: ../../../templates/editbookmark.tpl.php:118
+#: ../../../templates/editbookmark.tpl.php:122
msgid "Import bookmarks from del.icio.us"
msgstr ""
@@ -853,11 +857,11 @@ msgstr ""
msgid "Antispam question"
msgstr ""
-#: ../../../templates/sidebar.block.linked.php:72
+#: ../../../templates/sidebar.block.linked.php:97
msgid "Linked Tags"
msgstr ""
-#: ../../../templates/sidebar.block.linked.php:75
+#: ../../../templates/sidebar.block.linked.php:100
msgid "plus"
msgstr ""
diff --git a/services/tag2tagservice.php b/services/tag2tagservice.php
index f46ef7c..d37ab8b 100644
--- a/services/tag2tagservice.php
+++ b/services/tag2tagservice.php
@@ -59,7 +59,7 @@ class Tag2TagService {
if($uId != null) {
$query.= " AND uId = '".$uId."'";
}
-
+//die($query);
if (! ($dbresult =& $this->db->sql_query_limit($query, $limit)) ){
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
return false;
@@ -69,6 +69,7 @@ class Tag2TagService {
$output = array();
foreach($rowset as $row) {
if(!in_array($row['tag'], $stopList)) {
+
$output[] = $row['tag'];
}
}
@@ -89,19 +90,18 @@ class Tag2TagService {
$asFlatList = true; //we disable the tree list parameter for the moment
if(in_array($tag1, $stopList)) {
- return $tag1;
+ return array();
}
- $stopList2 = $stopList;
- $stopList2[] = $tag1;
- $linkedTags = $this->getLinkedTags($tag1, $relationType, $uId, false, $stopList2);
+ $stopList[] = $tag1;
+ $linkedTags = $this->getLinkedTags($tag1, $relationType, $uId, false, $stopList);
if($relationType != '=') {
- $linkedTags = array_merge($linkedTags, $this->getLinkedTags($tag1, '=', $uId, false, $stopList2));
+ $linkedTags = array_merge($linkedTags, $this->getLinkedTags($tag1, '=', $uId, false, $stopList));
}
if(count($linkedTags) == 0) {
- return $tag1;
+ return array();
} else {
$output = array();
if($asFlatList == true) {
@@ -110,13 +110,13 @@ class Tag2TagService {
$output = array('node'=>$tag1);
}
- $stopList[] = $tag1;
foreach($linkedTags as $linkedTag) {
$allLinkedTags = $this->getAllLinkedTags($linkedTag, $relationType, $uId, $asFlatList, $stopList);
if($asFlatList == true) {
+ $output[] = $linkedTag;
if(is_array($allLinkedTags)) {
- $output[] = $linkedTag;
+
$output = array_merge($output, $allLinkedTags);
} else {
$output[] = $allLinkedTags;
diff --git a/services/tagservice.php b/services/tagservice.php
index 509e575..bbf3574 100644
--- a/services/tagservice.php
+++ b/services/tagservice.php
@@ -86,22 +86,37 @@ class TagService {
}
}
+ $bs =& ServiceFactory::getServiceInstance('BookmarkService');
+ $tts =& ServiceFactory::getServiceInstance('Tag2TagService');
+
// Create links between tags
foreach($tags as $key => $tag) {
- // case ">"
- $pieces = explode('>', $tag);
- $nbPieces = count($pieces);
- if($nbPieces > 1) {
- for($i = 0; $i < $nbPieces-1; $i++) {
- $bs =& ServiceFactory::getServiceInstance('BookmarkService');
- $tts =& ServiceFactory::getServiceInstance('Tag2TagService');
-
- $bookmark = $bs->getBookmark($bookmarkid);
- $uId = $bookmark['uId'];
- $tts->addLinkedTags($pieces[$i], $pieces[$i+1], '>', $uId);
- }
- $tags[$key] = $pieces[$nbPieces-1]; // Attach just the last tag to the bookmark
- }
+ if(strpos($tag, '=')) {
+ // case "="
+ $pieces = explode('=', $tag);
+ $nbPieces = count($pieces);
+ if($nbPieces > 1) {
+ for($i = 0; $i < $nbPieces-1; $i++) {
+ $bookmark = $bs->getBookmark($bookmarkid);
+ $uId = $bookmark['uId'];
+ $tts->addLinkedTags($pieces[$i], $pieces[$i+1], '=', $uId);
+ }
+ $tags[$key] = $pieces[0]; // Attach just the last tag to the bookmark
+ }
+ } else {
+ // case ">"
+ $pieces = explode('>', $tag);
+ $nbPieces = count($pieces);
+ if($nbPieces > 1) {
+ for($i = 0; $i < $nbPieces-1; $i++) {
+ $bookmark = $bs->getBookmark($bookmarkid);
+ $uId = $bookmark['uId'];
+ $tts->addLinkedTags($pieces[$i], $pieces[$i+1], '>', $uId);
+ }
+ $tags[$key] = $pieces[$nbPieces-1]; // Attach just the last tag to the bookmark
+ }
+ }
+
}
diff --git a/templates/editbookmark.tpl.php b/templates/editbookmark.tpl.php
index f707668..3101431 100644
--- a/templates/editbookmark.tpl.php
+++ b/templates/editbookmark.tpl.php
@@ -50,6 +50,10 @@ window.onload = function() {
<td align="right"><small><?php echo T_('Note: use ">" to include one tag in another. e.g.: europe>france>paris')?><small></td>
</tr>
<tr>
+ <th></th>
+ <td align="right"><small><?php echo T_('Note: use "=" to make synonym two tags. e.g.: france=frenchcountry')?><small></td>
+</tr>
+<tr>
<th align="left"><?php echo T_('Privacy'); ?></th>
<td>
<select name="status">
diff --git a/templates/sidebar.block.linked.php b/templates/sidebar.block.linked.php
index 24ca7e6..74516ae 100644
--- a/templates/sidebar.block.linked.php
+++ b/templates/sidebar.block.linked.php
@@ -3,15 +3,30 @@ $tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService');
function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode =false, $precedentTag =null, $level=0, $stopList=array()) {
+
+ if(in_array($tag, $stopList)) {
+ return array('output' => '', 'stoplist' => $stopList);
+ }
+
$tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService');
$tagstatservice =& ServiceFactory::getServiceInstance('TagStatService');
$output = '';
$output.= '<tr>';
$output.= '<td></td>';
- $output.= '<td>'. str_repeat('&nbsp;', $level*2) .'<a href="'. sprintf($cat_url, filter($user, 'url'), filter($tag, 'url')) .'" rel="tag">'. filter($tag) .'</a>';
+ $output.= '<td>';
+ $output.= $level == 0?'<b>':'';
+ $output.= str_repeat('&nbsp;', $level*2) .'<a href="'. sprintf($cat_url, filter($user, 'url'), filter($tag, 'url')) .'" rel="tag">'. filter($tag) .'</a>';
+ $output.= $level == 1?'</b>':'';
//$output.= ' - '. $tagstatservice->getMaxDepth($tag, $linkType, $uId);
+ $synonymTags = $tag2tagservice->getAllLinkedTags($tag, '=', $uId);
+ $synonymTags = is_array($synonymTags)?$synonymTags:array($synonymTags);
+ sort($synonymTags);
+ foreach($synonymTags as $synonymTag) {
+ $output.= ", ".$synonymTag;
+ }
+
if($editingMode) {
$output.= ' (';
$output.= '<a href="'.createURL('tag2tagadd', $tag).'">add</a>';
@@ -24,16 +39,26 @@ function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode
$output.= '</td>';
$output.= '</tr>';
- if(!in_array($tag, $stopList)) {
- $linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $uId);
- $precedentTag = $tag;
- $stopList[] = $tag;
- $level = $level + 1;
- foreach($linkedTags as $linkedTag) {
- $output.= displayLinkedTags($linkedTag, $linkType, $uId, $cat_url, $user, $editingMode, $precedentTag, $level, $stopList);
- }
- }
- return $output;
+ $tags = array($tag);
+ $tags = array_merge($tags, $synonymTags);
+ foreach($tags as $tag) {
+
+ if(!in_array($tag, $stopList)) {
+ $linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $uId);
+ $precedentTag = $tag;
+ $stopList[] = $tag;
+ foreach($linkedTags as $linkedTag) {
+ $displayLinkedTags = displayLinkedTags($linkedTag, $linkType, $uId, $cat_url, $user, $editingMode, $precedentTag, $level + 1, $stopList);
+ $output.= $displayLinkedTags['output'];
+ }
+ if(is_array($displayLinkedTags['stopList'])) {
+ $stopList = array_merge($stopList, $displayLinkedTags['stopList']);
+ $stopList = array_unique($stopList);
+ }
+ }
+
+ }
+ return array('output' => $output, 'stopList' => $stopList);
}
$logged_on_userid = $userservice->getCurrentUserId();
@@ -59,7 +84,7 @@ if ($currenttag) {
if(count($explodedTags) > 0) {
$displayLinkedZone = false;
foreach($explodedTags as $explodedTag) {
- if($tag2tagservice->getLinkedTags($explodedTag, '>', $userid)) {
+ if($tag2tagservice->getLinkedTags($explodedTag, '>', $userid) || $tag2tagservice->getLinkedTags($explodedTag, '>', $userid, true) || $tag2tagservice->getLinkedTags($explodedTag, '=', $userid)) {
$displayLinkedZone = true;
break;
}
@@ -86,8 +111,26 @@ if(count($explodedTags) > 0) {
} else {
$editingMode = false;
}
+ $stopList = array();
foreach($explodedTags as $explodedTag) {
- echo displayLinkedTags($explodedTag, '>', $userid, $cat_url, $user, $editingMode);
+ if(!in_array($explodedTag, $stopList)) {
+ // fathers tag
+ $fatherTags = $tag2tagservice->getLinkedTags($explodedTag, '>', $userid, true);
+ if(count($fatherTags)>0) {
+ foreach($fatherTags as $fatherTag) {
+ echo '<tr><td>';
+ echo '<a href="'. sprintf($cat_url, filter($user, 'url'), filter($fatherTag, 'url')) .'" rel="tag">('. filter($fatherTag) .')</a>';
+ echo '</td></tr>';
+ }
+ }
+
+ $displayLinkedTags = displayLinkedTags($explodedTag, '>', $userid, $cat_url, $user, $editingMode, null, 0);
+ echo $displayLinkedTags['output'];
+ if(is_array($displayLinkedTags['stopList'])) {
+ $stopList = array_merge($stopList, $displayLinkedTags['stopList']);
+ }
+ }
+
}
?>
</table>
diff --git a/tests/tag2TagTest.php b/tests/tag2TagTest.php
index 83e7dbc..9a72eb8 100644
--- a/tests/tag2TagTest.php
+++ b/tests/tag2TagTest.php
@@ -44,6 +44,9 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
// basic test
+ $allLinkedTags = $tts->getAllLinkedTags('e', '>', 1, true); // as flat list
+ $this->assertEquals(array(), $allLinkedTags);
+
$allLinkedTags = $tts->getAllLinkedTags('d', '>', 1, true); // as flat list
$this->assertEquals(array('e'), $allLinkedTags);
@@ -125,8 +128,10 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
$this->assertTrue(in_array('d', $linkedTags)); // '=' is bijective
// test allLinkTags (with inference)
+ $allLinkedTags = $tts->getAllLinkedTags('a', '=', 1, true); // as flat list
+ $this->assertEquals(0, sizeof($allLinkedTags));
+
$allLinkedTags = $tts->getAllLinkedTags('b', '=', 1, true); // as flat list
- $this->assertEquals(array('d', 'e', 'f'), $allLinkedTags);
$this->assertEquals(3, sizeof($allLinkedTags));
$this->assertTrue(in_array('d', $allLinkedTags));
$this->assertTrue(in_array('e', $allLinkedTags));
@@ -149,19 +154,36 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
$this->assertTrue(in_array('f', $allLinkedTags));
$this->assertTrue(in_array('g', $allLinkedTags));
+ $tts->addLinkedTags('g', 'h', '>', 1);
+ $tts->addLinkedTags('i', 'h', '=', 1);
+ $tts->addLinkedTags('j', 'f', '>', 1);
+
+ $allLinkedTags = $tts->getAllLinkedTags('j', '>', 1, true); // as flat list
+ $this->assertEquals(8, sizeof($allLinkedTags));
+ $this->assertTrue(in_array('b', $allLinkedTags));
+ $this->assertTrue(in_array('c', $allLinkedTags));
+ $this->assertTrue(in_array('d', $allLinkedTags));
+ $this->assertTrue(in_array('e', $allLinkedTags));
+ $this->assertTrue(in_array('f', $allLinkedTags));
+ $this->assertTrue(in_array('g', $allLinkedTags));
+ $this->assertTrue(in_array('h', $allLinkedTags));
+ $this->assertTrue(in_array('i', $allLinkedTags));
+
// complex case: test cycle
$tts->addLinkedTags('g', 'a', '>', 1);
$allLinkedTags = $tts->getAllLinkedTags('b', '>', 1, true); // as flat list
- $this->assertEquals(6, sizeof($allLinkedTags));
+ $this->assertEquals(8, sizeof($allLinkedTags));
$this->assertTrue(in_array('a', $allLinkedTags));
$this->assertTrue(in_array('c', $allLinkedTags));
$this->assertTrue(in_array('d', $allLinkedTags));
$this->assertTrue(in_array('e', $allLinkedTags));
$this->assertTrue(in_array('f', $allLinkedTags));
$this->assertTrue(in_array('g', $allLinkedTags));
+ $this->assertTrue(in_array('h', $allLinkedTags));
+ $this->assertTrue(in_array('i', $allLinkedTags));
}
-/*
+
// Test function that select the best tags to display?
public function testViewTag2TagRelations()
{
@@ -207,17 +229,19 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
public function testAddLinkedTagsThroughBookmarking()
{
$bs = $this->bs;
- $tags = array('a>b', 'b>c', 'a>d>e', 'a>a', 'a');
+ $tags = array('a>b', 'b>c', 'a>d>e', 'a>a', 'a', 'r=s', 's=t=u');
$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']));
- $this->assertEquals(4, sizeof($savedTags));
+ $this->assertEquals(6, sizeof($savedTags));
$this->assertContains('b', $savedTags);
$this->assertContains('c', $savedTags);
$this->assertContains('e', $savedTags);
$this->assertContains('a', $savedTags);
+ $this->assertContains('r', $savedTags);
+ $this->assertContains('s', $savedTags);
$tts = $this->tts;
$linkedTags = $tts->getLinkedTags('a', '>', 1);
@@ -240,7 +264,7 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
$bs->addBookmark("web1.com", "B1", "description", "status", $tags, null, false, false, 1);
$tags = array('bb>gg', 'ee>ff');
$bs->addBookmark("web2.com", "B2", "description", "status", $tags, null, false, false, 1);
- $tags = array('ee');
+ $tags = array('ee=ii');
$bs->addBookmark("web3.com", "B3", "description", "status", $tags, null, false, false, 1);
// Query format:
@@ -263,8 +287,13 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
$results = $bs->getBookmarks(0, NULL, 1, 'ee');
$this->assertSame(2, intval($results['total']));
- $this->assertSame('B2', $results['bookmarks'][0]['bTitle']);
- $this->assertSame('B3', $results['bookmarks'][1]['bTitle']);
+ $this->assertSame('B2', $results['bookmarks'][1]['bTitle']);
+ $this->assertSame('B3', $results['bookmarks'][0]['bTitle']);
+
+ $results = $bs->getBookmarks(0, NULL, 1, 'ii');
+ $this->assertSame(2, intval($results['total']));
+ $this->assertSame('B2', $results['bookmarks'][1]['bTitle']);
+ $this->assertSame('B3', $results['bookmarks'][0]['bTitle']);
$results = $bs->getBookmarks(0, NULL, 1, 'aa+ee');
$this->assertSame(1, intval($results['total']));
@@ -362,6 +391,6 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
// advanced case with back loop
//$tts->addLinkedTags('e', 'a', '>', 1);
- }*/
+ }
}
?>