new feature: structured tags, add synonym link
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@29 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
e740849d4c
commit
3ef7b27643
8 changed files with 177 additions and 78 deletions
Binary file not shown.
|
@ -8,8 +8,8 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Scuttle\n"
|
"Project-Id-Version: Scuttle\n"
|
||||||
"Report-Msgid-Bugs-To: \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: 2008-01-22 16:55+0100\n"
|
"PO-Revision-Date: 2008-01-28 15:54+0100\n"
|
||||||
"Last-Translator: BenjaminHKB <benjamin.huynh-kim-bang@loria.fr>\n"
|
"Last-Translator: BenjaminHKB <benjamin.huynh-kim-bang@loria.fr>\n"
|
||||||
"Language-Team: fr-FR <toony.sf@chezouam.net>\n"
|
"Language-Team: fr-FR <toony.sf@chezouam.net>\n"
|
||||||
"MIME-Version: 1.0\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"
|
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"
|
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/importDelicious.tpl.php:15
|
||||||
#: ../../../templates/importNetscape.tpl.php:16
|
#: ../../../templates/importNetscape.tpl.php:16
|
||||||
msgid "Privacy"
|
msgid "Privacy"
|
||||||
msgstr "Vision"
|
msgstr "Vision"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:56
|
#: ../../../templates/editbookmark.tpl.php:60
|
||||||
#: ../../../templates/importDelicious.tpl.php:18
|
#: ../../../templates/importDelicious.tpl.php:18
|
||||||
#: ../../../templates/importNetscape.tpl.php:19
|
#: ../../../templates/importNetscape.tpl.php:19
|
||||||
msgid "Public"
|
msgid "Public"
|
||||||
msgstr "Publique"
|
msgstr "Publique"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:57
|
#: ../../../templates/editbookmark.tpl.php:61
|
||||||
msgid "Shared with Watch List"
|
msgid "Shared with Watch List"
|
||||||
msgstr "Partagé avec liste d'accès"
|
msgstr "Partagé avec liste d'accès"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:58
|
#: ../../../templates/editbookmark.tpl.php:62
|
||||||
#: ../../../templates/importDelicious.tpl.php:20
|
#: ../../../templates/importDelicious.tpl.php:20
|
||||||
#: ../../../templates/importNetscape.tpl.php:21
|
#: ../../../templates/importNetscape.tpl.php:21
|
||||||
msgid "Private"
|
msgid "Private"
|
||||||
msgstr "Privée"
|
msgstr "Privée"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:70
|
#: ../../../templates/editbookmark.tpl.php:74
|
||||||
msgid "Delete Bookmark"
|
msgid "Delete Bookmark"
|
||||||
msgstr "Supprimer le signet"
|
msgstr "Supprimer le signet"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:97
|
#: ../../../templates/editbookmark.tpl.php:101
|
||||||
msgid "Bookmarklet"
|
msgid "Bookmarklet"
|
||||||
msgstr "Bookmarklet"
|
msgstr "Bookmarklet"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:98
|
#: ../../../templates/editbookmark.tpl.php:102
|
||||||
#, php-format
|
#, 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"
|
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 "
|
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
|
#, php-format
|
||||||
msgid "Post to %s"
|
msgid "Post to %s"
|
||||||
msgstr "Ajouter à %s"
|
msgstr "Ajouter à %s"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:111
|
#: ../../../templates/editbookmark.tpl.php:115
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "Post to %s (Pop-up)"
|
msgid "Post to %s (Pop-up)"
|
||||||
msgstr "Ajouter à %s (Pop-up)"
|
msgstr "Ajouter à %s (Pop-up)"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:115
|
#: ../../../templates/editbookmark.tpl.php:119
|
||||||
#: ../../../templates/importDelicious.tpl.php:26
|
#: ../../../templates/importDelicious.tpl.php:26
|
||||||
#: ../../../templates/importNetscape.tpl.php:27
|
#: ../../../templates/importNetscape.tpl.php:27
|
||||||
msgid "Import"
|
msgid "Import"
|
||||||
msgstr "Importer"
|
msgstr "Importer"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:117
|
#: ../../../templates/editbookmark.tpl.php:121
|
||||||
msgid "Import bookmarks from bookmark file"
|
msgid "Import bookmarks from bookmark file"
|
||||||
msgstr "Importer les signets depuis un fichier"
|
msgstr "Importer les signets depuis un fichier"
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:117
|
#: ../../../templates/editbookmark.tpl.php:121
|
||||||
msgid "Internet Explorer, Mozilla Firefox and Netscape"
|
msgid "Internet Explorer, Mozilla Firefox and Netscape"
|
||||||
msgstr "Internet Explorer, Mozilla Firefox et 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"
|
msgid "Import bookmarks from del.icio.us"
|
||||||
msgstr "Importer les signets depuis 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"
|
msgid "Antispam question"
|
||||||
msgstr "Question antispam"
|
msgstr "Question antispam"
|
||||||
|
|
||||||
#: ../../../templates/sidebar.block.linked.php:72
|
#: ../../../templates/sidebar.block.linked.php:97
|
||||||
msgid "Linked Tags"
|
msgid "Linked Tags"
|
||||||
msgstr "Tags structurés"
|
msgstr "Tags structurés"
|
||||||
|
|
||||||
#: ../../../templates/sidebar.block.linked.php:75
|
#: ../../../templates/sidebar.block.linked.php:100
|
||||||
msgid "plus"
|
msgid "plus"
|
||||||
msgstr "plus"
|
msgstr "plus"
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\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"
|
"Note: use \">\" to include one tag in another. e.g.: europe>france>paris"
|
||||||
msgstr ""
|
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/importDelicious.tpl.php:15
|
||||||
#: ../../../templates/importNetscape.tpl.php:16
|
#: ../../../templates/importNetscape.tpl.php:16
|
||||||
msgid "Privacy"
|
msgid "Privacy"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:56
|
#: ../../../templates/editbookmark.tpl.php:60
|
||||||
#: ../../../templates/importDelicious.tpl.php:18
|
#: ../../../templates/importDelicious.tpl.php:18
|
||||||
#: ../../../templates/importNetscape.tpl.php:19
|
#: ../../../templates/importNetscape.tpl.php:19
|
||||||
msgid "Public"
|
msgid "Public"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:57
|
#: ../../../templates/editbookmark.tpl.php:61
|
||||||
msgid "Shared with Watch List"
|
msgid "Shared with Watch List"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:58
|
#: ../../../templates/editbookmark.tpl.php:62
|
||||||
#: ../../../templates/importDelicious.tpl.php:20
|
#: ../../../templates/importDelicious.tpl.php:20
|
||||||
#: ../../../templates/importNetscape.tpl.php:21
|
#: ../../../templates/importNetscape.tpl.php:21
|
||||||
msgid "Private"
|
msgid "Private"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:70
|
#: ../../../templates/editbookmark.tpl.php:74
|
||||||
msgid "Delete Bookmark"
|
msgid "Delete Bookmark"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:97
|
#: ../../../templates/editbookmark.tpl.php:101
|
||||||
msgid "Bookmarklet"
|
msgid "Bookmarklet"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:98
|
#: ../../../templates/editbookmark.tpl.php:102
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"Drag one of the following bookmarklets to your browser's bookmarks and click "
|
"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"
|
"it whenever you want to add the page you are on to %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:110
|
#: ../../../templates/editbookmark.tpl.php:114
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "Post to %s"
|
msgid "Post to %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:111
|
#: ../../../templates/editbookmark.tpl.php:115
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "Post to %s (Pop-up)"
|
msgid "Post to %s (Pop-up)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:115
|
#: ../../../templates/editbookmark.tpl.php:119
|
||||||
#: ../../../templates/importDelicious.tpl.php:26
|
#: ../../../templates/importDelicious.tpl.php:26
|
||||||
#: ../../../templates/importNetscape.tpl.php:27
|
#: ../../../templates/importNetscape.tpl.php:27
|
||||||
msgid "Import"
|
msgid "Import"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:117
|
#: ../../../templates/editbookmark.tpl.php:121
|
||||||
msgid "Import bookmarks from bookmark file"
|
msgid "Import bookmarks from bookmark file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:117
|
#: ../../../templates/editbookmark.tpl.php:121
|
||||||
msgid "Internet Explorer, Mozilla Firefox and Netscape"
|
msgid "Internet Explorer, Mozilla Firefox and Netscape"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/editbookmark.tpl.php:118
|
#: ../../../templates/editbookmark.tpl.php:122
|
||||||
msgid "Import bookmarks from del.icio.us"
|
msgid "Import bookmarks from del.icio.us"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -853,11 +857,11 @@ msgstr ""
|
||||||
msgid "Antispam question"
|
msgid "Antispam question"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/sidebar.block.linked.php:72
|
#: ../../../templates/sidebar.block.linked.php:97
|
||||||
msgid "Linked Tags"
|
msgid "Linked Tags"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../../templates/sidebar.block.linked.php:75
|
#: ../../../templates/sidebar.block.linked.php:100
|
||||||
msgid "plus"
|
msgid "plus"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class Tag2TagService {
|
||||||
if($uId != null) {
|
if($uId != null) {
|
||||||
$query.= " AND uId = '".$uId."'";
|
$query.= " AND uId = '".$uId."'";
|
||||||
}
|
}
|
||||||
|
//die($query);
|
||||||
if (! ($dbresult =& $this->db->sql_query_limit($query, $limit)) ){
|
if (! ($dbresult =& $this->db->sql_query_limit($query, $limit)) ){
|
||||||
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
|
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
return false;
|
return false;
|
||||||
|
@ -69,6 +69,7 @@ class Tag2TagService {
|
||||||
$output = array();
|
$output = array();
|
||||||
foreach($rowset as $row) {
|
foreach($rowset as $row) {
|
||||||
if(!in_array($row['tag'], $stopList)) {
|
if(!in_array($row['tag'], $stopList)) {
|
||||||
|
|
||||||
$output[] = $row['tag'];
|
$output[] = $row['tag'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,19 +90,18 @@ class Tag2TagService {
|
||||||
$asFlatList = true; //we disable the tree list parameter for the moment
|
$asFlatList = true; //we disable the tree list parameter for the moment
|
||||||
|
|
||||||
if(in_array($tag1, $stopList)) {
|
if(in_array($tag1, $stopList)) {
|
||||||
return $tag1;
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$stopList2 = $stopList;
|
$stopList[] = $tag1;
|
||||||
$stopList2[] = $tag1;
|
$linkedTags = $this->getLinkedTags($tag1, $relationType, $uId, false, $stopList);
|
||||||
$linkedTags = $this->getLinkedTags($tag1, $relationType, $uId, false, $stopList2);
|
|
||||||
|
|
||||||
if($relationType != '=') {
|
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) {
|
if(count($linkedTags) == 0) {
|
||||||
return $tag1;
|
return array();
|
||||||
} else {
|
} else {
|
||||||
$output = array();
|
$output = array();
|
||||||
if($asFlatList == true) {
|
if($asFlatList == true) {
|
||||||
|
@ -110,13 +110,13 @@ class Tag2TagService {
|
||||||
$output = array('node'=>$tag1);
|
$output = array('node'=>$tag1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stopList[] = $tag1;
|
|
||||||
foreach($linkedTags as $linkedTag) {
|
foreach($linkedTags as $linkedTag) {
|
||||||
$allLinkedTags = $this->getAllLinkedTags($linkedTag, $relationType, $uId, $asFlatList, $stopList);
|
$allLinkedTags = $this->getAllLinkedTags($linkedTag, $relationType, $uId, $asFlatList, $stopList);
|
||||||
|
|
||||||
if($asFlatList == true) {
|
if($asFlatList == true) {
|
||||||
if(is_array($allLinkedTags)) {
|
|
||||||
$output[] = $linkedTag;
|
$output[] = $linkedTag;
|
||||||
|
if(is_array($allLinkedTags)) {
|
||||||
|
|
||||||
$output = array_merge($output, $allLinkedTags);
|
$output = array_merge($output, $allLinkedTags);
|
||||||
} else {
|
} else {
|
||||||
$output[] = $allLinkedTags;
|
$output[] = $allLinkedTags;
|
||||||
|
|
|
@ -86,22 +86,37 @@ class TagService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bs =& ServiceFactory::getServiceInstance('BookmarkService');
|
||||||
|
$tts =& ServiceFactory::getServiceInstance('Tag2TagService');
|
||||||
|
|
||||||
// Create links between tags
|
// Create links between tags
|
||||||
foreach($tags as $key => $tag) {
|
foreach($tags as $key => $tag) {
|
||||||
|
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 ">"
|
// case ">"
|
||||||
$pieces = explode('>', $tag);
|
$pieces = explode('>', $tag);
|
||||||
$nbPieces = count($pieces);
|
$nbPieces = count($pieces);
|
||||||
if($nbPieces > 1) {
|
if($nbPieces > 1) {
|
||||||
for($i = 0; $i < $nbPieces-1; $i++) {
|
for($i = 0; $i < $nbPieces-1; $i++) {
|
||||||
$bs =& ServiceFactory::getServiceInstance('BookmarkService');
|
|
||||||
$tts =& ServiceFactory::getServiceInstance('Tag2TagService');
|
|
||||||
|
|
||||||
$bookmark = $bs->getBookmark($bookmarkid);
|
$bookmark = $bs->getBookmark($bookmarkid);
|
||||||
$uId = $bookmark['uId'];
|
$uId = $bookmark['uId'];
|
||||||
$tts->addLinkedTags($pieces[$i], $pieces[$i+1], '>', $uId);
|
$tts->addLinkedTags($pieces[$i], $pieces[$i+1], '>', $uId);
|
||||||
}
|
}
|
||||||
$tags[$key] = $pieces[$nbPieces-1]; // Attach just the last tag to the bookmark
|
$tags[$key] = $pieces[$nbPieces-1]; // Attach just the last tag to the bookmark
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,10 @@ window.onload = function() {
|
||||||
<th></th>
|
<th></th>
|
||||||
<td align="right"><small><?php echo T_('Note: use ">" to include one tag in another. e.g.: europe>france>paris')?><small></td>
|
<td align="right"><small><?php echo T_('Note: use ">" to include one tag in another. e.g.: europe>france>paris')?><small></td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<th align="left"><?php echo T_('Privacy'); ?></th>
|
<th align="left"><?php echo T_('Privacy'); ?></th>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -3,15 +3,30 @@ $tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService');
|
||||||
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
|
||||||
function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode =false, $precedentTag =null, $level=0, $stopList=array()) {
|
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');
|
$tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService');
|
||||||
$tagstatservice =& ServiceFactory::getServiceInstance('TagStatService');
|
$tagstatservice =& ServiceFactory::getServiceInstance('TagStatService');
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
$output.= '<tr>';
|
$output.= '<tr>';
|
||||||
$output.= '<td></td>';
|
$output.= '<td></td>';
|
||||||
$output.= '<td>'. str_repeat(' ', $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(' ', $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);
|
//$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) {
|
if($editingMode) {
|
||||||
$output.= ' (';
|
$output.= ' (';
|
||||||
$output.= '<a href="'.createURL('tag2tagadd', $tag).'">add</a>';
|
$output.= '<a href="'.createURL('tag2tagadd', $tag).'">add</a>';
|
||||||
|
@ -24,16 +39,26 @@ function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode
|
||||||
$output.= '</td>';
|
$output.= '</td>';
|
||||||
$output.= '</tr>';
|
$output.= '</tr>';
|
||||||
|
|
||||||
|
$tags = array($tag);
|
||||||
|
$tags = array_merge($tags, $synonymTags);
|
||||||
|
foreach($tags as $tag) {
|
||||||
|
|
||||||
if(!in_array($tag, $stopList)) {
|
if(!in_array($tag, $stopList)) {
|
||||||
$linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $uId);
|
$linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $uId);
|
||||||
$precedentTag = $tag;
|
$precedentTag = $tag;
|
||||||
$stopList[] = $tag;
|
$stopList[] = $tag;
|
||||||
$level = $level + 1;
|
|
||||||
foreach($linkedTags as $linkedTag) {
|
foreach($linkedTags as $linkedTag) {
|
||||||
$output.= displayLinkedTags($linkedTag, $linkType, $uId, $cat_url, $user, $editingMode, $precedentTag, $level, $stopList);
|
$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 $output;
|
|
||||||
|
}
|
||||||
|
return array('output' => $output, 'stopList' => $stopList);
|
||||||
}
|
}
|
||||||
|
|
||||||
$logged_on_userid = $userservice->getCurrentUserId();
|
$logged_on_userid = $userservice->getCurrentUserId();
|
||||||
|
@ -59,7 +84,7 @@ if ($currenttag) {
|
||||||
if(count($explodedTags) > 0) {
|
if(count($explodedTags) > 0) {
|
||||||
$displayLinkedZone = false;
|
$displayLinkedZone = false;
|
||||||
foreach($explodedTags as $explodedTag) {
|
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;
|
$displayLinkedZone = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -86,8 +111,26 @@ if(count($explodedTags) > 0) {
|
||||||
} else {
|
} else {
|
||||||
$editingMode = false;
|
$editingMode = false;
|
||||||
}
|
}
|
||||||
|
$stopList = array();
|
||||||
foreach($explodedTags as $explodedTag) {
|
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>
|
</table>
|
||||||
|
|
|
@ -44,6 +44,9 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
// basic test
|
// basic test
|
||||||
|
|
||||||
|
$allLinkedTags = $tts->getAllLinkedTags('e', '>', 1, true); // as flat list
|
||||||
|
$this->assertEquals(array(), $allLinkedTags);
|
||||||
|
|
||||||
$allLinkedTags = $tts->getAllLinkedTags('d', '>', 1, true); // as flat list
|
$allLinkedTags = $tts->getAllLinkedTags('d', '>', 1, true); // as flat list
|
||||||
$this->assertEquals(array('e'), $allLinkedTags);
|
$this->assertEquals(array('e'), $allLinkedTags);
|
||||||
|
|
||||||
|
@ -125,8 +128,10 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
|
||||||
$this->assertTrue(in_array('d', $linkedTags)); // '=' is bijective
|
$this->assertTrue(in_array('d', $linkedTags)); // '=' is bijective
|
||||||
|
|
||||||
// test allLinkTags (with inference)
|
// 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
|
$allLinkedTags = $tts->getAllLinkedTags('b', '=', 1, true); // as flat list
|
||||||
$this->assertEquals(array('d', 'e', 'f'), $allLinkedTags);
|
|
||||||
$this->assertEquals(3, sizeof($allLinkedTags));
|
$this->assertEquals(3, sizeof($allLinkedTags));
|
||||||
$this->assertTrue(in_array('d', $allLinkedTags));
|
$this->assertTrue(in_array('d', $allLinkedTags));
|
||||||
$this->assertTrue(in_array('e', $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('f', $allLinkedTags));
|
||||||
$this->assertTrue(in_array('g', $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
|
// complex case: test cycle
|
||||||
$tts->addLinkedTags('g', 'a', '>', 1);
|
$tts->addLinkedTags('g', 'a', '>', 1);
|
||||||
$allLinkedTags = $tts->getAllLinkedTags('b', '>', 1, true); // as flat list
|
$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('a', $allLinkedTags));
|
||||||
$this->assertTrue(in_array('c', $allLinkedTags));
|
$this->assertTrue(in_array('c', $allLinkedTags));
|
||||||
$this->assertTrue(in_array('d', $allLinkedTags));
|
$this->assertTrue(in_array('d', $allLinkedTags));
|
||||||
$this->assertTrue(in_array('e', $allLinkedTags));
|
$this->assertTrue(in_array('e', $allLinkedTags));
|
||||||
$this->assertTrue(in_array('f', $allLinkedTags));
|
$this->assertTrue(in_array('f', $allLinkedTags));
|
||||||
$this->assertTrue(in_array('g', $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?
|
// Test function that select the best tags to display?
|
||||||
public function testViewTag2TagRelations()
|
public function testViewTag2TagRelations()
|
||||||
{
|
{
|
||||||
|
@ -207,17 +229,19 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
|
||||||
public function testAddLinkedTagsThroughBookmarking()
|
public function testAddLinkedTagsThroughBookmarking()
|
||||||
{
|
{
|
||||||
$bs = $this->bs;
|
$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);
|
$bs->addBookmark("http://google.com", "title", "description", "status", $tags, null, false, false, 1);
|
||||||
$bookmark = $bs->getBookmarkByAddress("http://google.com");
|
$bookmark = $bs->getBookmarkByAddress("http://google.com");
|
||||||
|
|
||||||
$ts = $this->ts;
|
$ts = $this->ts;
|
||||||
$savedTags = $ts->getTagsForBookmark(intval($bookmark['bId']));
|
$savedTags = $ts->getTagsForBookmark(intval($bookmark['bId']));
|
||||||
$this->assertEquals(4, sizeof($savedTags));
|
$this->assertEquals(6, sizeof($savedTags));
|
||||||
$this->assertContains('b', $savedTags);
|
$this->assertContains('b', $savedTags);
|
||||||
$this->assertContains('c', $savedTags);
|
$this->assertContains('c', $savedTags);
|
||||||
$this->assertContains('e', $savedTags);
|
$this->assertContains('e', $savedTags);
|
||||||
$this->assertContains('a', $savedTags);
|
$this->assertContains('a', $savedTags);
|
||||||
|
$this->assertContains('r', $savedTags);
|
||||||
|
$this->assertContains('s', $savedTags);
|
||||||
|
|
||||||
$tts = $this->tts;
|
$tts = $this->tts;
|
||||||
$linkedTags = $tts->getLinkedTags('a', '>', 1);
|
$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);
|
$bs->addBookmark("web1.com", "B1", "description", "status", $tags, null, false, false, 1);
|
||||||
$tags = array('bb>gg', 'ee>ff');
|
$tags = array('bb>gg', 'ee>ff');
|
||||||
$bs->addBookmark("web2.com", "B2", "description", "status", $tags, null, false, false, 1);
|
$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);
|
$bs->addBookmark("web3.com", "B3", "description", "status", $tags, null, false, false, 1);
|
||||||
|
|
||||||
// Query format:
|
// Query format:
|
||||||
|
@ -263,8 +287,13 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$results = $bs->getBookmarks(0, NULL, 1, 'ee');
|
$results = $bs->getBookmarks(0, NULL, 1, 'ee');
|
||||||
$this->assertSame(2, intval($results['total']));
|
$this->assertSame(2, intval($results['total']));
|
||||||
$this->assertSame('B2', $results['bookmarks'][0]['bTitle']);
|
$this->assertSame('B2', $results['bookmarks'][1]['bTitle']);
|
||||||
$this->assertSame('B3', $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');
|
$results = $bs->getBookmarks(0, NULL, 1, 'aa+ee');
|
||||||
$this->assertSame(1, intval($results['total']));
|
$this->assertSame(1, intval($results['total']));
|
||||||
|
@ -362,6 +391,6 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
// advanced case with back loop
|
// advanced case with back loop
|
||||||
//$tts->addLinkedTags('e', 'a', '>', 1);
|
//$tts->addLinkedTags('e', 'a', '>', 1);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue