From 484de2408fc42d8f5a25af53df159b2baa42c334 Mon Sep 17 00:00:00 2001 From: mensonge Date: Wed, 13 Feb 2008 17:34:18 +0000 Subject: new feature: collaborative description for tags and bookmarks git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@36 b3834d28-1941-0410-a4f8-b48e95affb8f --- bookmarkcommondescriptionedit.php | 65 +++++++++++ config.inc.php.example | 7 ++ locales/fr_FR/LC_MESSAGES/messages.mo | Bin 17836 -> 18380 bytes locales/fr_FR/LC_MESSAGES/messages.po | 137 +++++++++++++++-------- locales/messages.po | 130 +++++++++++++++------- scuttle.css | 7 ++ services/commondescriptionservice.php | 139 ++++++++++++++++++++++++ tables.sql | 19 ++++ tagcommondescriptionedit.php | 62 +++++++++++ templates/bookmarkcommondescriptionedit.tpl.php | 55 ++++++++++ templates/bookmarks.tpl.php | 32 +++++- templates/sidebar.block.tagactions.php | 8 +- templates/tagcommondescriptionedit.tpl.php | 48 ++++++++ templates/tags.tpl.php | 3 + tests/LAUNCH_TESTS | 7 ++ tests/commonDescriptionTest.php | 96 ++++++++++++++++ 16 files changed, 725 insertions(+), 90 deletions(-) create mode 100644 bookmarkcommondescriptionedit.php create mode 100644 services/commondescriptionservice.php create mode 100644 tagcommondescriptionedit.php create mode 100644 templates/bookmarkcommondescriptionedit.tpl.php create mode 100644 templates/tagcommondescriptionedit.tpl.php create mode 100644 tests/LAUNCH_TESTS create mode 100644 tests/commonDescriptionTest.php diff --git a/bookmarkcommondescriptionedit.php b/bookmarkcommondescriptionedit.php new file mode 100644 index 0000000..2abdf4f --- /dev/null +++ b/bookmarkcommondescriptionedit.php @@ -0,0 +1,65 @@ +getCurrentUser(); + +//permissions +if($logged_on_user == null) { + $tplVars['error'] = T_('Permission denied.'); + $templateservice->loadTemplate('error.500.tpl', $tplVars); + exit(); +} + +if ($_POST['confirm']) { + + if (strlen($hash)>0 && + $cdservice->addBookmarkDescription($_POST['hash'], stripslashes($_POST['title']), stripslashes($_POST['description']), $logged_on_user['uId'], time()) + ) { + $tplVars['msg'] = T_('Bookmark common description updated'); + header('Location: '. $_POST['referrer']); + } else { + $tplVars['error'] = T_('Failed to update the bookmark common description'); + $template = 'error.500.tpl'; + } +} elseif ($_POST['cancel']) { + $logged_on_user = $userservice->getCurrentUser(); + header('Location: '. $_POST['referrer']); +} else { + $bkm = $bookmarkservice->getBookmarkByHash($hash); + + $tplVars['subtitle'] = T_('Edit Bookmark Common Description') .': '. $bkm['bAddress']; + $tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $hash; + $tplVars['referrer'] = $_SERVER['HTTP_REFERER']; + $tplVars['hash'] = $hash; + $tplVars['description'] = $cdservice->getLastBookmarkDescription($hash); +} +$templateservice->loadTemplate($template, $tplVars); +?> diff --git a/config.inc.php.example b/config.inc.php.example index ce7bcde..4c76c9d 100644 --- a/config.inc.php.example +++ b/config.inc.php.example @@ -87,6 +87,10 @@ $dbname = 'scuttle'; # # antispamQuestion: A question to avoid spam # antispamAnswer: The answer to the question (users have to put exactly the same answer) +# +# enableCommonTagDescription : true or false +# enableCommonBookmarkDescription : true or false +# ###################################################################### $sitename = 'SemanticScuttle'; @@ -124,5 +128,8 @@ $reservedusers = array('all', 'watchlist'); $antispamQuestion = 'Put here the answer to 1 + 2 + 3'; $antispamAnswer = '6'; +$enableCommonTagDescription = true; +$enableCommonBookmarkDescription = true; + include_once('debug.inc.php'); ?> diff --git a/locales/fr_FR/LC_MESSAGES/messages.mo b/locales/fr_FR/LC_MESSAGES/messages.mo index 46db404..5f0ff25 100644 Binary files a/locales/fr_FR/LC_MESSAGES/messages.mo and b/locales/fr_FR/LC_MESSAGES/messages.mo differ diff --git a/locales/fr_FR/LC_MESSAGES/messages.po b/locales/fr_FR/LC_MESSAGES/messages.po index df79a59..a738935 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-02-05 14:06+0100\n" -"PO-Revision-Date: 2008-02-05 14:09+0100\n" +"POT-Creation-Date: 2008-02-13 18:09+0100\n" +"PO-Revision-Date: 2008-02-13 18:22+0100\n" "Last-Translator: BenjaminHKB \n" "Language-Team: fr-FR \n" "MIME-Version: 1.0\n" @@ -50,6 +50,19 @@ msgstr "Tous les tags" msgid "User with username %s was not found" msgstr "L'utilisateur %s n'a pas été trouvé." +#: ../../../bookmarkcommondescriptionedit.php:38 +msgid "Bookmark common description updated" +msgstr "Description commune du signet mise à jour." + +#: ../../../bookmarkcommondescriptionedit.php:41 +#, fuzzy +msgid "Failed to update the bookmark common description" +msgstr "Erreur dans la suppression du signet" + +#: ../../../bookmarkcommondescriptionedit.php:50 +msgid "Edit Bookmark Common Description" +msgstr "Editer la description commune du signet" + #: ../../../bookmarks.php:95 #: ../../../edit.php:44 msgid "Your bookmark must have a title and an address" @@ -435,6 +448,20 @@ msgstr "Impossible d'effacer le lien" msgid "Delete Link Between Tags" msgstr "Effacer un lien entre tags" +#: ../../../tagcommondescriptionedit.php:37 +msgid "Tag common description updated" +msgstr "Editer la description commune du tag" + +#: ../../../tagcommondescriptionedit.php:40 +#, fuzzy +msgid "Failed to update the tag common description" +msgstr "Impossible d'effacer le tag" + +#: ../../../tagcommondescriptionedit.php:47 +#: ../../../templates/sidebar.block.tagactions.php:24 +msgid "Edit Tag Common Description" +msgstr "Editer la description commune du tag" + #: ../../../tagdelete.php:31 msgid "Tag deleted" msgstr "Tag effacé" @@ -444,7 +471,7 @@ msgid "Failed to delete the tag" msgstr "Impossible d'effacer le tag" #: ../../../tagdelete.php:44 -#: ../../../templates/sidebar.block.tagactions.php:19 +#: ../../../templates/sidebar.block.tagactions.php:22 msgid "Delete Tag" msgstr "Supprimer le tag" @@ -457,7 +484,7 @@ msgid "Failed to rename the tag" msgstr "Erreur dans la suppression du tag" #: ../../../tagrename.php:57 -#: ../../../templates/sidebar.block.tagactions.php:9 +#: ../../../templates/sidebar.block.tagactions.php:11 msgid "Rename Tag" msgid_plural "Rename Tags" msgstr[0] "Renommer le tag" @@ -523,77 +550,108 @@ msgstr "%s est basé sur un msgid "%1$s supports most of the del.icio.us API. Almost all of the neat tools made for that system can be modified to work with %1$s instead. If you find a tool that won't let you change the API address, ask the creator to add this setting. You never know, they might just do it." msgstr "%1$s supporte la plupart de l'del.icio.us API." -#: ../../../templates/bookmarks.tpl.php:17 -#: ../../../templates/tags.tpl.php:7 +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:15 +#: ../../../templates/bookmarks.tpl.php:48 +#: ../../../templates/editbookmark.tpl.php:34 +msgid "Title" +msgstr "Titre" + +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:20 +#: ../../../templates/editbookmark.tpl.php:39 +#: ../../../templates/editprofile.tpl.php:44 +#: ../../../templates/profile.tpl.php:28 +#: ../../../templates/tagcommondescriptionedit.tpl.php:13 +msgid "Description" +msgstr "Description" + +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:28 +#: ../../../templates/tagcommondescriptionedit.tpl.php:21 +msgid "Last modification: " +msgstr "Dernière modification :" + +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:39 +#: ../../../templates/tagcommondescriptionedit.tpl.php:32 +msgid "Update" +msgstr "Mettre à jour" + +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:40 +#: ../../../templates/tag2tagadd.tpl.php:15 +#: ../../../templates/tagcommondescriptionedit.tpl.php:33 +#: ../../../templates/tagrename.tpl.php:25 +msgid "Cancel" +msgstr "Annuler" + +#: ../../../templates/bookmarks.tpl.php:29 +#: ../../../templates/bookmarks.tpl.php:32 +msgid "edit common description" +msgstr "éditer la description commune" + +#: ../../../templates/bookmarks.tpl.php:46 +#: ../../../templates/tags.tpl.php:10 #: ../../../templates/users.tpl.php:8 msgid "Sort by:" msgstr "Classer par :" -#: ../../../templates/bookmarks.tpl.php:18 +#: ../../../templates/bookmarks.tpl.php:47 msgid "Date" msgstr "Date" -#: ../../../templates/bookmarks.tpl.php:19 -#: ../../../templates/editbookmark.tpl.php:34 -msgid "Title" -msgstr "Titre" - -#: ../../../templates/bookmarks.tpl.php:23 +#: ../../../templates/bookmarks.tpl.php:52 msgid "URL" msgstr "URL" -#: ../../../templates/bookmarks.tpl.php:60 +#: ../../../templates/bookmarks.tpl.php:89 msgid "Edit" msgstr "Editer" -#: ../../../templates/bookmarks.tpl.php:60 +#: ../../../templates/bookmarks.tpl.php:89 msgid "Delete" msgstr "Supprimer" -#: ../../../templates/bookmarks.tpl.php:66 +#: ../../../templates/bookmarks.tpl.php:95 msgid "by" msgstr "par" -#: ../../../templates/bookmarks.tpl.php:78 +#: ../../../templates/bookmarks.tpl.php:107 #, fuzzy, php-format msgid " and %s1 other%s" msgstr " et les autres %s" -#: ../../../templates/bookmarks.tpl.php:81 +#: ../../../templates/bookmarks.tpl.php:110 #, fuzzy, php-format msgid " and %2$s%1$s others%3$s" msgstr " et les autres %s" -#: ../../../templates/bookmarks.tpl.php:90 +#: ../../../templates/bookmarks.tpl.php:119 msgid "Copy" msgstr "Copier" -#: ../../../templates/bookmarks.tpl.php:137 -#: ../../../templates/bookmarks.tpl.php:143 +#: ../../../templates/bookmarks.tpl.php:166 +#: ../../../templates/bookmarks.tpl.php:172 msgid "First" msgstr "Première" -#: ../../../templates/bookmarks.tpl.php:138 -#: ../../../templates/bookmarks.tpl.php:144 +#: ../../../templates/bookmarks.tpl.php:167 +#: ../../../templates/bookmarks.tpl.php:173 msgid "Previous" msgstr "Précédent" -#: ../../../templates/bookmarks.tpl.php:151 -#: ../../../templates/bookmarks.tpl.php:154 +#: ../../../templates/bookmarks.tpl.php:180 +#: ../../../templates/bookmarks.tpl.php:183 msgid "Next" msgstr "Suivant" -#: ../../../templates/bookmarks.tpl.php:152 -#: ../../../templates/bookmarks.tpl.php:155 +#: ../../../templates/bookmarks.tpl.php:181 +#: ../../../templates/bookmarks.tpl.php:184 msgid "Last" msgstr "Dernière" -#: ../../../templates/bookmarks.tpl.php:157 +#: ../../../templates/bookmarks.tpl.php:186 #, php-format msgid "Page %d of %d" msgstr "Page %d de %d" -#: ../../../templates/bookmarks.tpl.php:161 +#: ../../../templates/bookmarks.tpl.php:190 msgid "No bookmarks available" msgstr "Pas de signets disponibles." @@ -601,7 +659,7 @@ msgstr "Pas de signets disponibles." #: ../../../templates/sidebar.block.common.php:15 #: ../../../templates/sidebar.block.popular.php:21 #: ../../../templates/sidebar.block.recent.php:20 -#: ../../../templates/tags.tpl.php:16 +#: ../../../templates/tags.tpl.php:19 msgid "bookmark" msgid_plural "bookmarks" msgstr[0] "signet" @@ -619,12 +677,6 @@ msgstr "Adresse" msgid "Required" msgstr "Requis" -#: ../../../templates/editbookmark.tpl.php:39 -#: ../../../templates/editprofile.tpl.php:44 -#: ../../../templates/profile.tpl.php:28 -msgid "Description" -msgstr "Description" - #: ../../../templates/editbookmark.tpl.php:46 msgid "Comma-separated" msgstr "Séparés par des virgules" @@ -883,7 +935,7 @@ msgstr "Tags récents" msgid "Related Tags" msgstr "Tags en relation" -#: ../../../templates/sidebar.block.tagactions.php:14 +#: ../../../templates/sidebar.block.tagactions.php:17 #: ../../../templates/sidebar.block.watchstatus.php:17 #, fuzzy msgid "Actions" @@ -909,11 +961,6 @@ msgstr "Créer un nouveau lien" msgid "Create" msgstr "Créer" -#: ../../../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:" @@ -936,12 +983,12 @@ msgstr "Nouvaeu" msgid "Rename" msgstr "Renommer" -#: ../../../templates/tags.tpl.php:8 +#: ../../../templates/tags.tpl.php:11 #: ../../../templates/users.tpl.php:9 msgid "Alphabet" msgstr "Alphabet" -#: ../../../templates/tags.tpl.php:9 +#: ../../../templates/tags.tpl.php:12 #: ../../../templates/users.tpl.php:10 msgid "Popularity" msgstr "Popularité" @@ -968,8 +1015,6 @@ msgstr "signets" #~ msgid "edit" #~ msgstr "éditer" -#~ msgid "Failed to delete the bookmark" -#~ msgstr "Erreur dans la suppression du signet" #~ msgid "User with username %s not was not found" #~ msgstr "L'utilisateur %s n'a pas été trouvé." #~ msgid "%s Bookmarks" diff --git a/locales/messages.po b/locales/messages.po index 5b25b7b..fb8f8f5 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-02-05 14:06+0100\n" +"POT-Creation-Date: 2008-02-13 18:09+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -41,6 +41,18 @@ msgstr "" msgid "User with username %s was not found" msgstr "" +#: ../../../bookmarkcommondescriptionedit.php:38 +msgid "Bookmark common description updated" +msgstr "" + +#: ../../../bookmarkcommondescriptionedit.php:41 +msgid "Failed to update the bookmark common description" +msgstr "" + +#: ../../../bookmarkcommondescriptionedit.php:50 +msgid "Edit Bookmark Common Description" +msgstr "" + #: ../../../bookmarks.php:95 ../../../edit.php:44 msgid "Your bookmark must have a title and an address" msgstr "" @@ -411,6 +423,19 @@ msgstr "" msgid "Delete Link Between Tags" msgstr "" +#: ../../../tagcommondescriptionedit.php:37 +msgid "Tag common description updated" +msgstr "" + +#: ../../../tagcommondescriptionedit.php:40 +msgid "Failed to update the tag common description" +msgstr "" + +#: ../../../tagcommondescriptionedit.php:47 +#: ../../../templates/sidebar.block.tagactions.php:24 +msgid "Edit Tag Common Description" +msgstr "" + #: ../../../tagdelete.php:31 msgid "Tag deleted" msgstr "" @@ -420,7 +445,7 @@ msgid "Failed to delete the tag" msgstr "" #: ../../../tagdelete.php:44 -#: ../../../templates/sidebar.block.tagactions.php:19 +#: ../../../templates/sidebar.block.tagactions.php:22 msgid "Delete Tag" msgstr "" @@ -432,7 +457,8 @@ msgstr "" msgid "Failed to rename the tag" msgstr "" -#: ../../../tagrename.php:57 ../../../templates/sidebar.block.tagactions.php:9 +#: ../../../tagrename.php:57 +#: ../../../templates/sidebar.block.tagactions.php:11 msgid "Rename Tag" msgid_plural "Rename Tags" msgstr[0] "" @@ -511,76 +537,107 @@ msgid "" "the creator to add this setting. You never know, they might just do it." msgstr "" -#: ../../../templates/bookmarks.tpl.php:17 ../../../templates/tags.tpl.php:7 +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:15 +#: ../../../templates/bookmarks.tpl.php:48 +#: ../../../templates/editbookmark.tpl.php:34 +msgid "Title" +msgstr "" + +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:20 +#: ../../../templates/editbookmark.tpl.php:39 +#: ../../../templates/editprofile.tpl.php:44 +#: ../../../templates/profile.tpl.php:28 +#: ../../../templates/tagcommondescriptionedit.tpl.php:13 +msgid "Description" +msgstr "" + +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:28 +#: ../../../templates/tagcommondescriptionedit.tpl.php:21 +msgid "Last modification: " +msgstr "" + +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:39 +#: ../../../templates/tagcommondescriptionedit.tpl.php:32 +msgid "Update" +msgstr "" + +#: ../../../templates/bookmarkcommondescriptionedit.tpl.php:40 +#: ../../../templates/tag2tagadd.tpl.php:15 +#: ../../../templates/tagcommondescriptionedit.tpl.php:33 +#: ../../../templates/tagrename.tpl.php:25 +msgid "Cancel" +msgstr "" + +#: ../../../templates/bookmarks.tpl.php:29 +#: ../../../templates/bookmarks.tpl.php:32 +msgid "edit common description" +msgstr "" + +#: ../../../templates/bookmarks.tpl.php:46 ../../../templates/tags.tpl.php:10 #: ../../../templates/users.tpl.php:8 msgid "Sort by:" msgstr "" -#: ../../../templates/bookmarks.tpl.php:18 +#: ../../../templates/bookmarks.tpl.php:47 msgid "Date" msgstr "" -#: ../../../templates/bookmarks.tpl.php:19 -#: ../../../templates/editbookmark.tpl.php:34 -msgid "Title" -msgstr "" - -#: ../../../templates/bookmarks.tpl.php:23 +#: ../../../templates/bookmarks.tpl.php:52 msgid "URL" msgstr "" -#: ../../../templates/bookmarks.tpl.php:60 +#: ../../../templates/bookmarks.tpl.php:89 msgid "Edit" msgstr "" -#: ../../../templates/bookmarks.tpl.php:60 +#: ../../../templates/bookmarks.tpl.php:89 msgid "Delete" msgstr "" -#: ../../../templates/bookmarks.tpl.php:66 +#: ../../../templates/bookmarks.tpl.php:95 msgid "by" msgstr "" -#: ../../../templates/bookmarks.tpl.php:78 +#: ../../../templates/bookmarks.tpl.php:107 #, php-format msgid " and %s1 other%s" msgstr "" -#: ../../../templates/bookmarks.tpl.php:81 +#: ../../../templates/bookmarks.tpl.php:110 #, php-format msgid " and %2$s%1$s others%3$s" msgstr "" -#: ../../../templates/bookmarks.tpl.php:90 +#: ../../../templates/bookmarks.tpl.php:119 msgid "Copy" msgstr "" -#: ../../../templates/bookmarks.tpl.php:137 -#: ../../../templates/bookmarks.tpl.php:143 +#: ../../../templates/bookmarks.tpl.php:166 +#: ../../../templates/bookmarks.tpl.php:172 msgid "First" msgstr "" -#: ../../../templates/bookmarks.tpl.php:138 -#: ../../../templates/bookmarks.tpl.php:144 +#: ../../../templates/bookmarks.tpl.php:167 +#: ../../../templates/bookmarks.tpl.php:173 msgid "Previous" msgstr "" -#: ../../../templates/bookmarks.tpl.php:151 -#: ../../../templates/bookmarks.tpl.php:154 +#: ../../../templates/bookmarks.tpl.php:180 +#: ../../../templates/bookmarks.tpl.php:183 msgid "Next" msgstr "" -#: ../../../templates/bookmarks.tpl.php:152 -#: ../../../templates/bookmarks.tpl.php:155 +#: ../../../templates/bookmarks.tpl.php:181 +#: ../../../templates/bookmarks.tpl.php:184 msgid "Last" msgstr "" -#: ../../../templates/bookmarks.tpl.php:157 +#: ../../../templates/bookmarks.tpl.php:186 #, php-format msgid "Page %d of %d" msgstr "" -#: ../../../templates/bookmarks.tpl.php:161 +#: ../../../templates/bookmarks.tpl.php:190 msgid "No bookmarks available" msgstr "" @@ -588,7 +645,7 @@ msgstr "" #: ../../../templates/sidebar.block.common.php:15 #: ../../../templates/sidebar.block.popular.php:21 #: ../../../templates/sidebar.block.recent.php:20 -#: ../../../templates/tags.tpl.php:16 +#: ../../../templates/tags.tpl.php:19 msgid "bookmark" msgid_plural "bookmarks" msgstr[0] "" @@ -606,12 +663,6 @@ msgstr "" msgid "Required" msgstr "" -#: ../../../templates/editbookmark.tpl.php:39 -#: ../../../templates/editprofile.tpl.php:44 -#: ../../../templates/profile.tpl.php:28 -msgid "Description" -msgstr "" - #: ../../../templates/editbookmark.tpl.php:46 msgid "Comma-separated" msgstr "" @@ -886,7 +937,7 @@ msgstr "" msgid "Related Tags" msgstr "" -#: ../../../templates/sidebar.block.tagactions.php:14 +#: ../../../templates/sidebar.block.tagactions.php:17 #: ../../../templates/sidebar.block.watchstatus.php:17 msgid "Actions" msgstr "" @@ -911,11 +962,6 @@ msgstr "" msgid "Create" msgstr "" -#: ../../../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:" @@ -938,11 +984,11 @@ msgstr "" msgid "Rename" msgstr "" -#: ../../../templates/tags.tpl.php:8 ../../../templates/users.tpl.php:9 +#: ../../../templates/tags.tpl.php:11 ../../../templates/users.tpl.php:9 msgid "Alphabet" msgstr "" -#: ../../../templates/tags.tpl.php:9 ../../../templates/users.tpl.php:10 +#: ../../../templates/tags.tpl.php:12 ../../../templates/users.tpl.php:10 msgid "Popularity" msgstr "" diff --git a/scuttle.css b/scuttle.css index eb22bec..211e587 100644 --- a/scuttle.css +++ b/scuttle.css @@ -256,6 +256,13 @@ div#sidebar ul li { /* TAGS */ +p.commondescription { + padding-left:5px; + color: #555; + font-weight: bold; + border-left: 1px solid #CC8; +} + p.tags { line-height: 2.25em; /*margin: 2em 10%;*/ diff --git a/services/commondescriptionservice.php b/services/commondescriptionservice.php new file mode 100644 index 0000000..7e34219 --- /dev/null +++ b/services/commondescriptionservice.php @@ -0,0 +1,139 @@ +db =& $db; + $this->tablename = $GLOBALS['tableprefix'] .'commondescription'; + } + + function addTagDescription($tag, $desc, $uId, $time) { + $datetime = gmdate('Y-m-d H:i:s', $time); + $values = array('tag'=>$tag, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime); + $sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values); + + if (!($dbresult =& $this->db->sql_query($sql))) { + $this->db->sql_transaction('rollback'); + message_die(GENERAL_ERROR, 'Could not add tag description', '', __LINE__, __FILE__, $sql, $this->db); + return false; + } + + return true; + } + + function getLastTagDescription($tag) { + $query = "SELECT *"; + $query.= " FROM `". $this->getTableName() ."`"; + $query.= " WHERE tag='".$tag."'"; + $query.= " ORDER BY cdDatetime DESC"; + + if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) { + message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db); + return false; + } + + if ($row =& $this->db->sql_fetchrow($dbresult)) { + return $row; + } else { + return false; + } + } + + function getAllTagsDescription($tag) { + $query = "SELECT *"; + $query.= " FROM `". $this->getTableName() ."`"; + $query.= " WHERE tag='".$tag."'"; + $query.= " ORDER BY cdDatetime DESC"; + + if (!($dbresult = & $this->db->sql_query($query))) { + message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db); + return false; + } + + return $this->db->sql_fetchrowset($dbresult); + + } + + function getDescriptionById($cdId) { + $query = "SELECT *"; + $query.= " FROM `". $this->getTableName() ."`"; + $query.= " WHERE cdId='".$cdId."'"; + + if (!($dbresult = & $this->db->sql_query($query))) { + message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db); + return false; + } + + if ($row =& $this->db->sql_fetchrow($dbresult)) { + return $row; + } else { + return false; + } + + } + + function addBookmarkDescription($bHash, $title, $desc, $uId, $time) { + $datetime = gmdate('Y-m-d H:i:s', $time); + $values = array('bHash'=>$bHash, 'cdTitle'=>$title, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime); + $sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values); + + if (!($dbresult =& $this->db->sql_query($sql))) { + $this->db->sql_transaction('rollback'); + message_die(GENERAL_ERROR, 'Could not add bookmark description', '', __LINE__, __FILE__, $sql, $this->db); + return false; + } + return true; + } + + function getLastBookmarkDescription($bHash) { + $query = "SELECT *"; + $query.= " FROM `". $this->getTableName() ."`"; + $query.= " WHERE bHash='".$bHash."'"; + $query.= " ORDER BY cdDatetime DESC"; + + if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) { + message_die(GENERAL_ERROR, 'Could not get bookmark description', '', __LINE__, __FILE__, $query, $this->db); + return false; + } + + if ($row =& $this->db->sql_fetchrow($dbresult)) { + return $row; + } else { + return false; + } + } + + function getAllBookmarksDescription($bHash) { + $query = "SELECT *"; + $query.= " FROM `". $this->getTableName() ."`"; + $query.= " WHERE bHash='".$bHash."'"; + $query.= " ORDER BY cdDatetime DESC"; + + if (!($dbresult = & $this->db->sql_query($query))) { + message_die(GENERAL_ERROR, 'Could not get bookmark descriptions', '', __LINE__, __FILE__, $query, $this->db); + return false; + } + + return $this->db->sql_fetchrowset($dbresult); + + } + + + function deleteAll() { + $query = 'TRUNCATE TABLE `'. $this->getTableName() .'`'; + $this->db->sql_query($query); + } + + // Properties + function getTableName() { return $this->tablename; } + function setTableName($value) { $this->tablename = $value; } +} +?> diff --git a/tables.sql b/tables.sql index 3dd7bab..5adb492 100644 --- a/tables.sql +++ b/tables.sql @@ -100,3 +100,22 @@ CREATE TABLE `sc_tagsstats` ( PRIMARY KEY (`tstId`), UNIQUE KEY `sc_tagsstats_tag1_type_uId` (`tag1`,`relationType`,`uId`) ); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `sc_commondescription` +-- + +CREATE TABLE `sc_commondescription` ( + `cdId` int(11) NOT NULL auto_increment, + `uId` int(11) NOT NULL default '0', + `tag` varchar(32) NOT NULL default '', + `bHash` varchar(32) NOT NULL default '', + `cdTitle` varchar(255) NOT NULL default '', + `cdDescription` varchar(2000) default NULL, + `cdDatetime` datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (`cdId`), + UNIQUE KEY `sc_commondescription_tag_datetime` (`tag`,`cdDatetime`), + UNIQUE KEY `sc_commondescription_bookmark_datetime` (`bHash`,`cdDatetime`) +); diff --git a/tagcommondescriptionedit.php b/tagcommondescriptionedit.php new file mode 100644 index 0000000..bb167d8 --- /dev/null +++ b/tagcommondescriptionedit.php @@ -0,0 +1,62 @@ +getCurrentUser(); + +//permissions +if($logged_on_user == null) { + $tplVars['error'] = T_('Permission denied.'); + $templateservice->loadTemplate('error.500.tpl', $tplVars); + exit(); +} + +if ($_POST['confirm']) { + + if ( strlen($tag)>0 && + $cdservice->addTagDescription($tag, stripslashes($_POST['description']), $logged_on_user['uId'], time()) + ) { + $tplVars['msg'] = T_('Tag common description updated'); + header('Location: '. $_POST['referrer']); + } else { + $tplVars['error'] = T_('Failed to update the tag common description'); + $template = 'error.500.tpl'; + } +} elseif ($_POST['cancel']) { + $logged_on_user = $userservice->getCurrentUser(); + header('Location: '. $_POST['referrer']); +} else { + $tplVars['subtitle'] = T_('Edit Tag Common Description') .': '. $tag; + $tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag; + $tplVars['referrer'] = $_SERVER['HTTP_REFERER']; + $tplVars['tag'] = $tag; + $tplVars['description'] = $cdservice->getLastTagDescription($tag); +} +$templateservice->loadTemplate($template, $tplVars); +?> diff --git a/templates/bookmarkcommondescriptionedit.tpl.php b/templates/bookmarkcommondescriptionedit.tpl.php new file mode 100644 index 0000000..c1723de --- /dev/null +++ b/templates/bookmarkcommondescriptionedit.tpl.php @@ -0,0 +1,55 @@ +includeTemplate($GLOBALS['top_include']); +$userservice = & ServiceFactory :: getServiceInstance('UserService'); +list ($url, $hash) = explode('/', $_SERVER['PATH_INFO']); +?> + + +
+ + + + + + + + + + + + + + + + + + + + +
+ 0) { + echo T_('Last modification: ').$description['cdDatetime'].', '; + $lastUser = $userservice->getUser($description['uId']); + echo $lastUser['username']; + } + ?> +
+ + +
+

+ + +
+ +
+
+ +includeTemplate($GLOBALS['bottom_include']); +?> diff --git a/templates/bookmarks.tpl.php b/templates/bookmarks.tpl.php index 42015ef..13ee3a0 100644 --- a/templates/bookmarks.tpl.php +++ b/templates/bookmarks.tpl.php @@ -1,14 +1,44 @@ getCurrentUserId(); $this->includeTemplate($GLOBALS['top_include']); include('search.inc.php'); -if (count($bookmarks) > 0) { ?> + +

+ +getLastTagDescription($currenttag)) { + $description = $cdservice->getLastTagDescription($currenttag); + echo filter($description['cdDescription']); +} elseif(isset($hash) && $cdservice->getLastBookmarkDescription($hash)) { + $description = $cdservice->getLastBookmarkDescription($hash); + echo filter($description['cdTitle']). "
"; + echo filter($description['cdDescription']). "
"; +} + +if($logged_on_userid>0) { + if(isset($currenttag)) { + echo ' ('; + echo T_('edit common description').')'; + } elseif(isset($hash)) { + echo ' ('; + echo T_('edit common description').')'; + } +} +?> +

+ + + + 0) { ?> diff --git a/templates/sidebar.block.tagactions.php b/templates/sidebar.block.tagactions.php index 836c40c..a19db0b 100644 --- a/templates/sidebar.block.tagactions.php +++ b/templates/sidebar.block.tagactions.php @@ -1,5 +1,7 @@ isLoggedOn()) { $currentUser = $userservice->getCurrentUser(); $currentUsername = $currentUser[$userservice->getFieldName('username')]; @@ -9,6 +11,7 @@ if ($userservice->isLoggedOn()) { $renametext = T_ngettext('Rename Tag', 'Rename Tags', count($tags)); $renamelink = createURL('tagrename', $currenttag); $deletelink = createURL('tagdelete', $currenttag); + $commondesclink = createURL('tagcommondescriptionedit', $currenttag); ?>

@@ -18,10 +21,13 @@ if ($userservice->isLoggedOn()) {
  • + +
  • + \ No newline at end of file +?> diff --git a/templates/tagcommondescriptionedit.tpl.php b/templates/tagcommondescriptionedit.tpl.php new file mode 100644 index 0000000..6e09374 --- /dev/null +++ b/templates/tagcommondescriptionedit.tpl.php @@ -0,0 +1,48 @@ +includeTemplate($GLOBALS['top_include']); +$userservice = & ServiceFactory :: getServiceInstance('UserService'); +?> + +
    + + + + + + + + + + + + + + + +
    + 0) { + echo T_('Last modification: ').$description['cdDatetime'].', '; + $lastUser = $userservice->getUser($description['uId']); + echo $lastUser['username']; + } + ?> +
    + + +
    +

    + + +
    + +
    +
    + +includeTemplate($GLOBALS['bottom_include']); +?> diff --git a/templates/tags.tpl.php b/templates/tags.tpl.php index d5de176..d6259cc 100644 --- a/templates/tags.tpl.php +++ b/templates/tags.tpl.php @@ -1,5 +1,8 @@ includeTemplate($GLOBALS['top_include']); +?> + + 0) { ?> diff --git a/tests/LAUNCH_TESTS b/tests/LAUNCH_TESTS new file mode 100644 index 0000000..dc8bdf4 --- /dev/null +++ b/tests/LAUNCH_TESTS @@ -0,0 +1,7 @@ +You need PHPunit. + +Then + +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 diff --git a/tests/commonDescriptionTest.php b/tests/commonDescriptionTest.php new file mode 100644 index 0000000..4de4d84 --- /dev/null +++ b/tests/commonDescriptionTest.php @@ -0,0 +1,96 @@ +us =& ServiceFactory::getServiceInstance('UserService'); + $this->bs =& ServiceFactory::getServiceInstance('BookmarkService'); + $this->bs->deleteAll(); + $this->ts =& ServiceFactory::getServiceInstance('TagService'); + $this->ts->deleteAll(); + $this->tts =& ServiceFactory::getServiceInstance('Tag2TagService'); + $this->tts->deleteAll(); + $this->tsts =& ServiceFactory::getServiceInstance('TagStatService'); + $this->tsts->deleteAll(); + $this->cds =& ServiceFactory::getServiceInstance('CommonDescriptionService'); + $this->cds->deleteAll(); + } + + public function testModifyDescription() + { + $cds = $this->cds; + + $uId1 = 1; + $uId2 = 2; + $title1 = "title1"; + $title2 = "title2"; + $desc1 = "&é\"'(-è_çà)=´~#'#{{[\\\\[||`\^\^@^@}¹²¡×¿ ?./§µ%"; + $desc2 = "æâ€êþÿûîîôôöŀï'üð’‘ßä«≤»©»  ↓¿×÷¡¹²³"; + $time1 = time(); + $time2 = time()+200; + + $tagDesc1 = array('cdId'=>1, 'tag'=>'taghouse', 'cdDescription'=>$desc1, 'uId'=>$uId1,'cdDatetime'=>$time1); + $tagDesc2 = array('cdId'=>2, 'tag'=>'taghouse', 'cdDescription'=>$desc2, 'uId'=>$uId2,'cdDatetime'=>$time2); + + $cds->addTagDescription('taghouse', $desc1, $uId1, $time1); + $cds->addTagDescription('taghouse', $desc2, $uId2, $time2); + + $desc = $cds->getLastTagDescription('taghouse'); + $this->assertContains('taghouse', $desc); + $this->assertContains($desc2, $desc); + $this->assertContains(gmdate('Y-m-d H:i:s', $time2), $desc); + + $desc = $cds->getAllTagsDescription('taghouse'); + $this->assertContains($desc1, $desc[1]); + $this->assertContains(gmdate('Y-m-d H:i:s', $time1), $desc[1]); + $this->assertContains($desc2, $desc[0]); + $this->assertContains(gmdate('Y-m-d H:i:s', $time2), $desc[0]); + + $desc = $cds->getDescriptionById(1); + $this->assertContains($desc1, $desc); + + $bkDesc1 = array('cdId'=>3, 'bHash'=>'10', 'cdTitle'=>$title1, 'cdDescription'=>$desc1, 'uId'=>$uId1,'cdDatetime'=>$time1); + $bkDesc2 = array('cdId'=>4, 'bHash'=>'10', 'cdTitle'=>$title2, 'cdDescription'=>$desc2, 'uId'=>$uId2,'cdDatetime'=>$time2); + + $cds->addBookmarkDescription(10, $title1, $desc1, $uId1, $time1); + $cds->addBookmarkDescription(10, $title2, $desc2, $uId2, $time2); + + $desc = $cds->getLastBookmarkDescription(10); + $this->assertContains($title2, $desc); + $this->assertContains($desc2, $desc); + $this->assertContains(gmdate('Y-m-d H:i:s', $time2), $desc); + + $desc = $cds->getAllBookmarksDescription(10); + $this->assertContains($title1, $desc[1]); + $this->assertContains($desc1, $desc[1]); + $this->assertContains(gmdate('Y-m-d H:i:s', $time1), $desc[1]); + $this->assertContains($title2, $desc[0]); + $this->assertContains($desc2, $desc[0]); + $this->assertContains(gmdate('Y-m-d H:i:s', $time2), $desc[0]); + + $desc = $cds->getDescriptionById(3); + $this->assertContains($desc1, $desc); + + + } + +} +?> -- cgit v1.2.3-54-g00ecf