fix interface: make easier the management of tag links

git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@33 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
mensonge 2008-02-05 13:30:33 +00:00
parent 67b4663c9a
commit 73e20c2ff5
10 changed files with 185 additions and 61 deletions

View 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"

View 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 ""

View 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 .'"';

View 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);
?>

View 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;

View 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
}
}
?>

View 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']);
?>

View 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']);
?>

View 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);