]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
fix interface: make easier the management of tag links
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Tue, 5 Feb 2008 13:30:33 +0000 (13:30 +0000)
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Tue, 5 Feb 2008 13:30:33 +0000 (13:30 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@33 b3834d28-1941-0410-a4f8-b48e95affb8f

locales/fr_FR/LC_MESSAGES/messages.mo
locales/fr_FR/LC_MESSAGES/messages.po
locales/messages.po
services/tag2tagservice.php
tag2tagadd.php
tag2tagdelete.php
templates/sidebar.block.linked.php
templates/tag2tagadd.tpl.php
templates/tag2tagdelete.tpl.php
tests/tag2TagTest.php

index 17bc6b02a0b36fc6fb9e5f6407c36cd2bfa3f7ba..46db404aa4c1a60dc572640649a665639c28d720 100644 (file)
Binary files a/locales/fr_FR/LC_MESSAGES/messages.mo and b/locales/fr_FR/LC_MESSAGES/messages.mo differ
index 3ee3fe963e309d6abf9a76b669a94eee4ebae85a..df79a59ad76f27437285d1898547dd5f78048285 100644 (file)
@@ -8,9 +8,9 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Scuttle\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-02-01 17:37+0100\n"
-"PO-Revision-Date: 2008-02-01 17:39+0100\n"
-"Last-Translator: Éric DANÉ <ericdane@free.fr>\n"
+"POT-Creation-Date: 2008-02-05 14:06+0100\n"
+"PO-Revision-Date: 2008-02-05 14:09+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"
 "Content-Type: text/plain; charset=utf-8\n"
@@ -212,20 +212,20 @@ msgid "Recent Bookmarks"
 msgstr "Signets récents"
 
 #: ../../../jsScuttle.php:22
-#: ../../../templates/tag2tagadd.tpl.php:9
-#: ../../../templates/tag2tagdelete.tpl.php:8
+#: ../../../templates/tag2tagadd.tpl.php:12
+#: ../../../templates/tag2tagdelete.tpl.php:13
 #: ../../../templates/tagdelete.tpl.php:6
 msgid "Are you sure?"
 msgstr "Etes-vous sûr ?"
 
 #: ../../../jsScuttle.php:22
-#: ../../../templates/tag2tagdelete.tpl.php:10
+#: ../../../templates/tag2tagdelete.tpl.php:15
 #: ../../../templates/tagdelete.tpl.php:8
 msgid "Yes"
 msgstr "Oui"
 
 #: ../../../jsScuttle.php:22
-#: ../../../templates/tag2tagdelete.tpl.php:11
+#: ../../../templates/tag2tagdelete.tpl.php:16
 #: ../../../templates/tagdelete.tpl.php:9
 msgid "No"
 msgstr "Non"
@@ -411,27 +411,27 @@ msgstr "Résultats de recherche"
 msgid "Permission denied."
 msgstr "Permission non accordée."
 
-#: ../../../tag2tagadd.php:42
+#: ../../../tag2tagadd.php:44
 msgid "Tag link created"
 msgstr "Lien entre tags créé."
 
-#: ../../../tag2tagadd.php:45
+#: ../../../tag2tagadd.php:47
 msgid "Failed to create the link"
 msgstr "Impossible de créer le lien"
 
-#: ../../../tag2tagadd.php:54
+#: ../../../tag2tagadd.php:58
 msgid "Add Tag Link"
 msgstr "Ajout d'un lien entre tags"
 
-#: ../../../tag2tagdelete.php:40
+#: ../../../tag2tagdelete.php:43
 msgid "Tag link deleted"
 msgstr "Effacement d'un lien entre tags"
 
-#: ../../../tag2tagdelete.php:43
+#: ../../../tag2tagdelete.php:46
 msgid "Failed to delete the link"
 msgstr "Impossible d'effacer le lien"
 
-#: ../../../tag2tagdelete.php:53
+#: ../../../tag2tagdelete.php:58
 msgid "Delete Link Between Tags"
 msgstr "Effacer un lien entre tags"
 
@@ -855,14 +855,26 @@ 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:97
+#: ../../../templates/sidebar.block.linked.php:35
+msgid "Synonyms:"
+msgstr "Synonymes :"
+
+#: ../../../templates/sidebar.block.linked.php:96
 msgid "Linked Tags"
 msgstr "Tags structurés"
 
-#: ../../../templates/sidebar.block.linked.php:100
+#: ../../../templates/sidebar.block.linked.php:99
 msgid "plus"
 msgstr "plus"
 
+#: ../../../templates/sidebar.block.linked.php:116
+msgid "Add new link"
+msgstr "Créer un lien"
+
+#: ../../../templates/sidebar.block.linked.php:117
+msgid "Delete link"
+msgstr "Supprimer un lien"
+
 #: ../../../templates/sidebar.block.recent.php:15
 msgid "Recent Tags"
 msgstr "Tags récents"
@@ -889,19 +901,29 @@ msgstr "Enlever de la liste des consultés"
 msgid "Add to Watchlist"
 msgstr "Ajouter à la liste des consultés"
 
-#: ../../../templates/tag2tagadd.tpl.php:7
+#: ../../../templates/tag2tagadd.tpl.php:6
 msgid "Create new link:"
 msgstr "Créer un nouveau lien"
 
-#: ../../../templates/tag2tagadd.tpl.php:11
+#: ../../../templates/tag2tagadd.tpl.php:14
 msgid "Create"
 msgstr "Créer"
 
-#: ../../../templates/tag2tagadd.tpl.php:12
+#: ../../../templates/tag2tagadd.tpl.php:15
 #: ../../../templates/tagrename.tpl.php:25
 msgid "Cancel"
 msgstr "Annuler"
 
+#: ../../../templates/tag2tagadd.tpl.php:26
+#: ../../../templates/tag2tagdelete.tpl.php:27
+msgid "Existing links:"
+msgstr "Liens existants :"
+
+#: ../../../templates/tag2tagadd.tpl.php:44
+#: ../../../templates/tag2tagdelete.tpl.php:45
+msgid "No links"
+msgstr "Pas de liens"
+
 #: ../../../templates/tagrename.tpl.php:12
 msgid "Old"
 msgstr "Ancien"
index 5fc2607b8e700d7e20b0c2773f1f5cadee9e7496..5b25b7bf8717b15f8cbf04e2e5b94e0c9f569e4d 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-02-01 17:37+0100\n"
+"POT-Creation-Date: 2008-02-05 14:06+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"
@@ -193,18 +193,18 @@ msgstr ""
 msgid "Recent Bookmarks"
 msgstr ""
 
-#: ../../../jsScuttle.php:22 ../../../templates/tag2tagadd.tpl.php:9
-#: ../../../templates/tag2tagdelete.tpl.php:8
+#: ../../../jsScuttle.php:22 ../../../templates/tag2tagadd.tpl.php:12
+#: ../../../templates/tag2tagdelete.tpl.php:13
 #: ../../../templates/tagdelete.tpl.php:6
 msgid "Are you sure?"
 msgstr ""
 
-#: ../../../jsScuttle.php:22 ../../../templates/tag2tagdelete.tpl.php:10
+#: ../../../jsScuttle.php:22 ../../../templates/tag2tagdelete.tpl.php:15
 #: ../../../templates/tagdelete.tpl.php:8
 msgid "Yes"
 msgstr ""
 
-#: ../../../jsScuttle.php:22 ../../../templates/tag2tagdelete.tpl.php:11
+#: ../../../jsScuttle.php:22 ../../../templates/tag2tagdelete.tpl.php:16
 #: ../../../templates/tagdelete.tpl.php:9
 msgid "No"
 msgstr ""
@@ -387,27 +387,27 @@ msgstr ""
 msgid "Permission denied."
 msgstr ""
 
-#: ../../../tag2tagadd.php:42
+#: ../../../tag2tagadd.php:44
 msgid "Tag link created"
 msgstr ""
 
-#: ../../../tag2tagadd.php:45
+#: ../../../tag2tagadd.php:47
 msgid "Failed to create the link"
 msgstr ""
 
-#: ../../../tag2tagadd.php:54
+#: ../../../tag2tagadd.php:58
 msgid "Add Tag Link"
 msgstr ""
 
-#: ../../../tag2tagdelete.php:40
+#: ../../../tag2tagdelete.php:43
 msgid "Tag link deleted"
 msgstr ""
 
-#: ../../../tag2tagdelete.php:43
+#: ../../../tag2tagdelete.php:46
 msgid "Failed to delete the link"
 msgstr ""
 
-#: ../../../tag2tagdelete.php:53
+#: ../../../tag2tagdelete.php:58
 msgid "Delete Link Between Tags"
 msgstr ""
 
@@ -858,14 +858,26 @@ msgstr ""
 msgid "Antispam question"
 msgstr ""
 
-#: ../../../templates/sidebar.block.linked.php:97
+#: ../../../templates/sidebar.block.linked.php:35
+msgid "Synonyms:"
+msgstr ""
+
+#: ../../../templates/sidebar.block.linked.php:96
 msgid "Linked Tags"
 msgstr ""
 
-#: ../../../templates/sidebar.block.linked.php:100
+#: ../../../templates/sidebar.block.linked.php:99
 msgid "plus"
 msgstr ""
 
+#: ../../../templates/sidebar.block.linked.php:116
+msgid "Add new link"
+msgstr ""
+
+#: ../../../templates/sidebar.block.linked.php:117
+msgid "Delete link"
+msgstr ""
+
 #: ../../../templates/sidebar.block.recent.php:15
 msgid "Recent Tags"
 msgstr ""
@@ -891,19 +903,29 @@ msgstr ""
 msgid "Add to Watchlist"
 msgstr ""
 
-#: ../../../templates/tag2tagadd.tpl.php:7
+#: ../../../templates/tag2tagadd.tpl.php:6
 msgid "Create new link:"
 msgstr ""
 
-#: ../../../templates/tag2tagadd.tpl.php:11
+#: ../../../templates/tag2tagadd.tpl.php:14
 msgid "Create"
 msgstr ""
 
-#: ../../../templates/tag2tagadd.tpl.php:12
+#: ../../../templates/tag2tagadd.tpl.php:15
 #: ../../../templates/tagrename.tpl.php:25
 msgid "Cancel"
 msgstr ""
 
+#: ../../../templates/tag2tagadd.tpl.php:26
+#: ../../../templates/tag2tagdelete.tpl.php:27
+msgid "Existing links:"
+msgstr ""
+
+#: ../../../templates/tag2tagadd.tpl.php:44
+#: ../../../templates/tag2tagdelete.tpl.php:45
+msgid "No links"
+msgstr ""
+
 #: ../../../templates/tagrename.tpl.php:12
 msgid "Old"
 msgstr ""
index d37ab8bd7f2087727760533ad7739a8734046870..1c6392eda7d20c3a4a2cfb9284f6632e7aad6759 100644 (file)
@@ -16,7 +16,8 @@ class Tag2TagService {
     }
 
     function addLinkedTags($tag1, $tag2, $relationType, $uId) {
-       if($tag1 == $tag2) {
+       if($tag1 == $tag2 || strlen($tag1) == 0 || strlen($tag2) == 0
+               || ($relationType != ">" && $relationType != "=")) {
                return false;
        }
        $values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> $relationType, 'uId'=> $uId);
@@ -196,7 +197,21 @@ class Tag2TagService {
         return $this->db->sql_numrows($this->db->sql_query($query)) > 0;
     }
 
+    function getLinks($uId) {
+       $query = "SELECT tag1, tag2, relationType, uId FROM `". $this->getTableName() ."`";
+       $query.= " WHERE 1=1";
+       if($uId > 0) {
+           $query.= " AND uId = '".$uId."'";
+       }
+
+        return $this->db->sql_fetchrowset($this->db->sql_query($query));
+    }
+
     function removeLinkedTags($tag1, $tag2, $relationType, $uId) {
+       if($tag1 == $tag2 || strlen($tag1) == 0 || strlen($tag2) == 0
+               || ($relationType != ">" && $relationType != "=")) {
+               return false;
+       }
        $query = 'DELETE FROM '. $this->getTableName();
        $query.= ' WHERE tag1 = "'. $tag1 .'"';
        $query.= ' AND tag2 = "'. $tag2 .'"';
index 83af1d6a85a954f017e24034b113ff9026f576c6..bc13b16deaba054075729b53c6c7b20ea5ad6f70 100644 (file)
@@ -34,11 +34,13 @@ if($logged_on_user == null) {
 }
 
 
-list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
+list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
 
 if ($_POST['confirm']) {
-    $newTag = $_POST['newTag'];
-    if ($tag2tagservice->addLinkedTags($tag, $newTag, '>', $userservice->getCurrentUserId())) {
+    $tag1 = $_POST['tag1'];
+    $linkType = $_POST['linkType'];
+    $tag2 = $_POST['tag2'];
+    if ($tag2tagservice->addLinkedTags($tag1, $tag2, $linkType, $userservice->getCurrentUserId())) {
         $tplVars['msg'] = T_('Tag link created');
         header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
     } else {
@@ -50,9 +52,11 @@ if ($_POST['confirm']) {
     header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
 }
 
-$tplVars['tag']                = $tag;
-$tplVars['subtitle']    = T_('Add Tag Link') .': '. $tag;
-$tplVars['formaction']  = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
+$tplVars['links']      = $tag2tagservice->getLinks($userservice->getCurrentUserId());
+
+$tplVars['tag1']               = $tag1;
+$tplVars['subtitle']    = T_('Add Tag Link') .': '. $tag1;
+$tplVars['formaction']  = $_SERVER['SCRIPT_NAME'] .'/'. $tag1;
 $tplVars['referrer']    = $_SERVER['HTTP_REFERER'];
 $templateservice->loadTemplate('tag2tagadd.tpl', $tplVars);
 ?>
index f79445606ef1a395eb4580f2c23bf2111b47bcb9..7f1ac8fc2c5d63f99d6e18ddb9b890ac68af1e27 100644 (file)
@@ -36,7 +36,10 @@ if($logged_on_user == null) {
 list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
 
 if ($_POST['confirm']) {
-    if ($tag2tagservice->removeLinkedTags($_POST['tag1'], $_POST['tag2'], '>', $userservice->getCurrentUserId())) {
+    $tag = $_POST['tag1'];
+    $linkType = $_POST['linkType'];
+    $newTag = $_POST['tag2'];
+    if ($tag2tagservice->removeLinkedTags($_POST['tag1'], $_POST['tag2'], $linkType, $userservice->getCurrentUserId())) {
         $tplVars['msg'] = T_('Tag link deleted');
         header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
     } else {
@@ -48,6 +51,8 @@ if ($_POST['confirm']) {
     header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
 }
 
+$tplVars['links']      = $tag2tagservice->getLinks($userservice->getCurrentUserId());
+
 $tplVars['tag1']       = $tag1;
 $tplVars['tag2']       = $tag2;
 $tplVars['subtitle']    = T_('Delete Link Between Tags') .': '. $tag1.' > '.$tag2;
index 401d0d7b46b98ed467604d67b7a93027a20027ee..164327297c71411e889b471315405871f09c3bda 100644 (file)
@@ -23,8 +23,16 @@ function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode
     $synonymTags = $tag2tagservice->getAllLinkedTags($tag, '=', $uId);
     $synonymTags = is_array($synonymTags)?$synonymTags:array($synonymTags);
     sort($synonymTags);
+    $synonymList = '';
     foreach($synonymTags as $synonymTag) {
-       $output.= ", ".$synonymTag;
+       //$output.= ", ".$synonymTag;
+       $synonymList.= $synonymTag.' ';
+    }
+    if(count($synonymTags)>0) {
+        $output.= ', '.$synonymTags[0];
+    }
+    if(count($synonymTags)>1) {
+        $output.= '<span title="'.T_('Synonyms:').' '.$synonymList.'">, etc</span>';
     }
 
     if($editingMode) {
@@ -81,15 +89,6 @@ if ($currenttag) {
     }
 }
 
-if(count($explodedTags) > 0) {
-    $displayLinkedZone = false;
-    foreach($explodedTags as $explodedTag) {
-       if($tag2tagservice->getLinkedTags($explodedTag, '>', $userid) || $tag2tagservice->getLinkedTags($explodedTag, '>', $userid, true) || $tag2tagservice->getLinkedTags($explodedTag, '=', $userid)) {
-           $displayLinkedZone = true;    
-           break;
-       }
-    }
-    if ($displayLinkedZone) {
 ?>
 
 <h2>
@@ -111,6 +110,14 @@ if(count($explodedTags) > 0) {
        } else {
            $editingMode = false;
        }
+
+       if($editingMode) {
+           echo '<tr><td></td><td>';
+           echo ' (<a href="'. createURL('tag2tagadd','') .'" rel="tag">'.T_('Add new link').'</a>) ';
+           echo ' (<a href="'. createURL('tag2tagdelete','') .'" rel="tag">'.T_('Delete link').'</a>)';
+           echo '</td></tr>';
+       }
+
        $stopList = array();
        foreach($explodedTags as $explodedTag) {
            if(!in_array($explodedTag, $stopList)) {
@@ -135,8 +142,3 @@ if(count($explodedTags) > 0) {
     ?>
     </table>
 </div>
-
-<?php
-    }
-}
-?>
index 109eea73498d0a74463235f842997397a0f5bcf2..cb86a37c88172dcdc080c0a1354bdd198267be23 100644 (file)
@@ -3,9 +3,12 @@ $this->includeTemplate($GLOBALS['top_include']);
 ?>
 
 <form action="<?= $formaction ?>" method="post">
-<input type="hidden" name="tag" value="<?php echo $tag ?>" />
 <p><?php echo T_('Create new link:')?></p>
-<p><?php echo $tag ?> > <input type="text" name="newTag" /></p>
+<p>
+<input type="text" name="tag1" value="<?php echo $tag1 ?>"/>
+<input type="text" name="linkType" value=">" size="1" maxlength="1"/>
+<input type="text" name="tag2" />
+</p>
 <!--p><?php echo T_('Are you sure?'); ?></p-->
 <p>
     <input type="submit" name="confirm" value="<?php echo T_('Create'); ?>" />
@@ -19,5 +22,27 @@ $this->includeTemplate($GLOBALS['top_include']);
 </form>
 
 <?php
+if(count($links)>0) {
+echo T_("Existing links:");
+foreach($links as $link) {
+    echo '<span style="white-space:nowrap;margin-left:25px;">';
+    if($link['tag1'] == $tag1 || $link['tag1'] == $tag2) {
+       $textTag1 = '<b>'.$tag1.'</b>';
+    } else {
+       $textTag1 = $link['tag1'];
+    }
+    if($link['tag2'] == $tag1 || $link['tag2'] == $tag2) {
+       $textTag2 = '<b>'.$tag2.'</b>';
+    } else {
+       $textTag2 = $link['tag2'];
+    }
+
+    echo $textTag1.' '.$link['relationType'].' '.$textTag2;
+    echo "</span> ";
+}
+} else {
+    echo T_('No links');
+}
+
 $this->includeTemplate($GLOBALS['bottom_include']); 
 ?>
index 9a276d1c48a882e54143960f46d092a8b79d34cf..2f0715be6c005aeded2c9b393e421b43b002b667 100644 (file)
@@ -3,8 +3,13 @@ $this->includeTemplate($GLOBALS['top_include']);
 ?>
 
 <form action="<?= $formaction ?>" method="post">
-<input type="hidden" name="tag1" value="<?php echo $tag1 ?>" />
-<input type="hidden" name="tag2" value="<?php echo $tag2 ?>" />
+<!--input type="hidden" name="tag1" value="<?php echo $tag1 ?>" />
+<input type="hidden" name="tag2" value="<?php echo $tag2 ?>" /-->
+<p>
+<input type="text" name="tag1" value="<?php echo $tag1 ?>"/>
+<input type="text" name="linkType" value=">" size="1" maxlength="1"/>
+<input type="text" name="tag2" value="<?php echo $tag2 ?>"/>
+</p>
 <p><?php echo T_('Are you sure?'); ?></p>
 <p>
     <input type="submit" name="confirm" value="<?php echo T_('Yes'); ?>" />
@@ -18,5 +23,27 @@ $this->includeTemplate($GLOBALS['top_include']);
 </form>
 
 <?php
+if(count($links)>0) {
+echo T_("Existing links:");
+foreach($links as $link) {
+    echo '<span style="white-space:nowrap;margin-left:25px;">';
+    if($link['tag1'] == $tag1 || $link['tag1'] == $tag2) {
+       $textTag1 = '<b>'.$tag1.'</b>';
+    } else {
+       $textTag1 = $link['tag1'];
+    }
+    if($link['tag2'] == $tag1 || $link['tag2'] == $tag2) {
+       $textTag2 = '<b>'.$tag2.'</b>';
+    } else {
+       $textTag2 = $link['tag2'];
+    }
+
+    echo $textTag1.' '.$link['relationType'].' '.$textTag2;
+    echo "</span> ";
+}
+} else {
+    echo T_('No links');
+}
+
 $this->includeTemplate($GLOBALS['bottom_include']); 
 ?>
index 9a72eb8da84d3e29ddcc81c02248ed54636b9620..4154c6f86b51b809fb2c67651620cb83818378da 100644 (file)
@@ -44,6 +44,8 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
 
        // basic test
 
+       $links = $tts->getLinks(1);
+
        $allLinkedTags = $tts->getAllLinkedTags('e', '>', 1, true); // as flat list
        $this->assertEquals(array(), $allLinkedTags);