From 2aed4f1f9f71e668c9c60449a12847ea171d1812 Mon Sep 17 00:00:00 2001 From: mensonge Date: Tue, 22 Jan 2008 16:16:06 +0000 Subject: [PATCH] add stats to tags relation and use them to display tags git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@21 b3834d28-1941-0410-a4f8-b48e95affb8f --- admin.php | 34 +++ alltags.php | 3 + locales/fr_FR/LC_MESSAGES/messages.mo | Bin 17152 -> 17339 bytes locales/fr_FR/LC_MESSAGES/messages.po | 332 ++++++++++---------------- locales/messages.po | 8 +- populartags.php | 2 + services/tag2tagservice.php | 81 ++++++- services/tagstatservice.php | 181 ++++++++++++++ tables.sql | 18 ++ templates/sidebar.block.linked.php | 25 +- templates/tags.tpl.php | 3 +- tests/tag2TagTest.php | 142 ++++++++++- 12 files changed, 607 insertions(+), 222 deletions(-) create mode 100644 admin.php create mode 100644 services/tagstatservice.php diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..81dde3c --- /dev/null +++ b/admin.php @@ -0,0 +1,34 @@ +updateAllStat(); + +echo "Admin script executed: OK!"; +*/ +?> diff --git a/alltags.php b/alltags.php index b784414..3805a3d 100644 --- a/alltags.php +++ b/alltags.php @@ -75,6 +75,9 @@ if (isset($userid)) { $tplVars['cat_url'] = createURL('tags', '%2$s'); } +$tplVars['sidebar_blocks'] = array('linked'); +$tplVars['userid'] = $userid; + $tplVars['subtitle'] = $pagetitle; $templateservice->loadTemplate('tags.tpl', $tplVars); diff --git a/locales/fr_FR/LC_MESSAGES/messages.mo b/locales/fr_FR/LC_MESSAGES/messages.mo index c2d6b80318302dea3f1ed230127116d0a15d6753..c068266ec7a1559d42925a94a73832707778d04e 100644 GIT binary patch delta 4211 zcmYk;3vg7`9mny1UJx)4NCF|@k;R0NLIMPc*d!&GlmwB03L$_Bf-D$~8{Ex;4U`Sx z5mBhrNEL)2g3_pIrK=F6>M%MjgVh;pX{)r>T96jUj#AnpeN4Za33-GL#?^QZ>C&n=nJ(;ROu@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IBiaxgOS6#Bb-=~>>!V_OVinPwh$eK6xjzF{HWEWr;Cg}J>^r{> zs&~}~*HYp+BA*yav?6qQh#iDq6|TL+Q%=eKh=4b2eKgLoWvBnuwj$pDPx%n#CvANS zzD`8h`gW_BM=T>^iAh8bkxmRFULlSVF~kRiu1sP&k*A}+j>5FyvF2rA!JN1;;lTq5 zt3AOU9g9M%Ydg>L`Fkh&{r&o+C;R+9U&QE9sbgj?D_l~za6#(h)0fWdm)O(iOHcLr sQ{Cr!`GftteA6Ttmz>r#_^fYoMD^)@7lOO`U+@GsWP~-TuF35DFB~SA_W%F@ diff --git a/locales/fr_FR/LC_MESSAGES/messages.po b/locales/fr_FR/LC_MESSAGES/messages.po index c3c1691..5b1e1d5 100644 --- a/locales/fr_FR/LC_MESSAGES/messages.po +++ b/locales/fr_FR/LC_MESSAGES/messages.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: Scuttle\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-01-14 11:58+0100\n" -"PO-Revision-Date: 2008-01-14 11:31+0100\n" +"POT-Creation-Date: 2008-01-22 16:54+0100\n" +"PO-Revision-Date: 2008-01-22 16:55+0100\n" "Last-Translator: BenjaminHKB \n" "Language-Team: fr-FR \n" "MIME-Version: 1.0\n" @@ -19,7 +19,8 @@ msgstr "" "X-Poedit-Country: FRANCE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: ../../../about.php:25 ../../../templates/toolbar.inc.php:23 +#: ../../../about.php:25 +#: ../../../templates/toolbar.inc.php:23 msgid "About" msgstr "À propos" @@ -27,7 +28,8 @@ msgstr "À propos" msgid "You are not allowed to delete this bookmark" msgstr "Vous ne pouvez pas supprimer ce signet." -#: ../../../ajaxDelete.php:34 ../../../edit.php:78 +#: ../../../ajaxDelete.php:34 +#: ../../../edit.php:78 msgid "Failed to delete bookmark" msgstr "Erreur dans la suppression du signet" @@ -35,31 +37,36 @@ msgstr "Erreur dans la suppression du signet" msgid "All Tags" msgstr "Tous les tags" -#: ../../../alltags.php:57 ../../../bookmarks.php:72 -#: ../../../populartags.php:58 ../../../profile.php:44 ../../../rss.php:62 -#: ../../../search.php:87 ../../../watch.php:34 ../../../watchlist.php:61 +#: ../../../alltags.php:57 +#: ../../../bookmarks.php:72 +#: ../../../populartags.php:58 +#: ../../../profile.php:44 +#: ../../../rss.php:62 +#: ../../../search.php:87 +#: ../../../watch.php:34 +#: ../../../watchlist.php:61 #, php-format msgid "User with username %s was not found" msgstr "L'utilisateur %s n'a pas été trouvé." -#: ../../../bookmarks.php:95 ../../../edit.php:44 +#: ../../../bookmarks.php:95 +#: ../../../edit.php:44 msgid "Your bookmark must have a title and an address" msgstr "Votre signet doit avoir un titre et une adresse." -#: ../../../bookmarks.php:115 ../../../edit.php:58 +#: ../../../bookmarks.php:115 +#: ../../../edit.php:58 msgid "Bookmark saved" msgstr "Signet enregistré." -#: ../../../bookmarks.php:123 ../../../import.php:99 +#: ../../../bookmarks.php:123 +#: ../../../import.php:99 #: ../../../importNetscape.php:74 -msgid "" -"There was an error saving your bookmark. Please try again or contact the " -"administrator." -msgstr "" -"Il y a eu une erreur en enregistrant ce signet. Veuillez rééssayer ou " -"contacter votre administrateur." +msgid "There was an error saving your bookmark. Please try again or contact the administrator." +msgstr "Il y a eu une erreur en enregistrant ce signet. Veuillez rééssayer ou contacter votre administrateur." -#: ../../../bookmarks.php:161 ../../../templates/toolbar.inc.php:14 +#: ../../../bookmarks.php:161 +#: ../../../templates/toolbar.inc.php:14 msgid "Add a Bookmark" msgstr "Ajouter un signet" @@ -92,7 +99,8 @@ msgstr "Vous n'êtes pas autorisé à éditer ce signet." msgid "Error while saving your bookmark" msgstr "Erreur pendant l'enregistrement de votre signet." -#: ../../../edit.php:88 ../../../templates/editprofile.tpl.php:49 +#: ../../../edit.php:88 +#: ../../../templates/editprofile.tpl.php:49 msgid "Save Changes" msgstr "Enregister les modifications" @@ -108,7 +116,8 @@ msgstr "Erreur SQL" msgid "Line" msgstr "Ligne" -#: ../../../functions.inc.php:115 ../../../templates/importDelicious.tpl.php:8 +#: ../../../functions.inc.php:115 +#: ../../../templates/importDelicious.tpl.php:8 #: ../../../templates/importNetscape.tpl.php:9 msgid "File" msgstr "Fichier" @@ -168,11 +177,13 @@ msgstr "Erreur XML: %s à la ligne %d" msgid "Import Bookmarks from del.icio.us" msgstr "Importer les signet depuis del.icio.us" -#: ../../../import.php:86 ../../../importNetscape.php:64 +#: ../../../import.php:86 +#: ../../../importNetscape.php:64 msgid "You have already submitted this bookmark." msgstr "Vous avez déjà enregistré ce signet." -#: ../../../import.php:97 ../../../importNetscape.php:72 +#: ../../../import.php:97 +#: ../../../importNetscape.php:72 #, fuzzy msgid "Bookmark imported." msgstr "Signets importés." @@ -199,18 +210,21 @@ msgstr "Conservez, partagez et taggez vos liens favoris" msgid "Recent Bookmarks" msgstr "Signets récents" -#: ../../../jsScuttle.php:22 ../../../templates/tag2tagadd.tpl.php:9 +#: ../../../jsScuttle.php:22 +#: ../../../templates/tag2tagadd.tpl.php:9 #: ../../../templates/tag2tagdelete.tpl.php:8 #: ../../../templates/tagdelete.tpl.php:6 msgid "Are you sure?" msgstr "Etes-vous sûr ?" -#: ../../../jsScuttle.php:22 ../../../templates/tag2tagdelete.tpl.php:10 +#: ../../../jsScuttle.php:22 +#: ../../../templates/tag2tagdelete.tpl.php:10 #: ../../../templates/tagdelete.tpl.php:8 msgid "Yes" msgstr "Oui" -#: ../../../jsScuttle.php:22 ../../../templates/tag2tagdelete.tpl.php:11 +#: ../../../jsScuttle.php:22 +#: ../../../templates/tag2tagdelete.tpl.php:11 #: ../../../templates/tagdelete.tpl.php:9 msgid "No" msgstr "Non" @@ -225,11 +239,10 @@ msgstr "Non Disponible" #: ../../../login.php:38 msgid "The details you have entered are incorrect. Please try again." -msgstr "" -"Les informations que vous avez entrées sont incorrectes. Veuillez " -"recommencer." +msgstr "Les informations que vous avez entrées sont incorrectes. Veuillez recommencer." -#: ../../../login.php:48 ../../../templates/login.tpl.php:26 +#: ../../../login.php:48 +#: ../../../templates/login.tpl.php:26 #: ../../../templates/toolbar.inc.php:24 msgid "Log In" msgstr "Se connecter" @@ -239,11 +252,8 @@ msgid "You must enter your username." msgstr "Vous devez entrer votre nom d'utilisateur." #: ../../../password.php:35 -msgid "" -"You must enter your e-mail address." -msgstr "" -"Vous devez saisir une E-mail." +msgid "You must enter your e-mail address." +msgstr "Vous devez saisir une E-mail." #: ../../../password.php:42 msgid "No matches found for that username." @@ -251,31 +261,20 @@ msgstr "Rien de trouvé pour ce nom d'utilisateur." #: ../../../password.php:45 #, fuzzy -msgid "" -"No matches found for that combination of username and e-mail address." -msgstr "" -"Nous n'avons rien trouvé pour cette combinaison de nom d'utilisateur et " -"d'e-mail." +msgid "No matches found for that combination of username and e-mail address." +msgstr "Nous n'avons rien trouvé pour cette combinaison de nom d'utilisateur et d'e-mail." #: ../../../password.php:53 -msgid "" -"There was an error while generating your new password. Please try again." -msgstr "" -"Il y a eu une erreur en enregistrant ce signet. Veuillez rééssayer ou " -"contacter votre administrateur." +msgid "There was an error while generating your new password. Please try again." +msgstr "Il y a eu une erreur en enregistrant ce signet. Veuillez rééssayer ou contacter votre administrateur." #: ../../../password.php:57 msgid "Your new password is:" msgstr "Votre nouveau mot de passe est:" #: ../../../password.php:57 -msgid "" -"To keep your bookmarks secure, you should change this password in your " -"profile the next time you log in." -msgstr "" -"Pour garder vos signets sûrs, vous devriez changer ce mot de passe dans " -"votre profil lors de votre prochaine authentification." +msgid "To keep your bookmarks secure, you should change this password in your profile the next time you log in." +msgstr "Pour garder vos signets sûrs, vous devriez changer ce mot de passe dans votre profil lors de votre prochaine authentification." #: ../../../password.php:60 #, php-format @@ -291,14 +290,16 @@ msgstr "Nouveau mot de passe généré et envoyé à l'adresse %s" msgid "Forgotten Password" msgstr "Mot de passe oublié" -#: ../../../populartags.php:49 ../../../templates/dynamictags.inc.php:101 +#: ../../../populartags.php:49 +#: ../../../templates/dynamictags.inc.php:101 #: ../../../templates/sidebar.block.common.php:9 #: ../../../templates/sidebar.block.popular.php:15 #: ../../../templates/sidebar.block.recent.php:25 msgid "Popular Tags" msgstr "Tags populaires" -#: ../../../profile.php:52 ../../../watchlist.php:116 +#: ../../../profile.php:52 +#: ../../../watchlist.php:116 msgid "Username was not specified" msgstr "Le nom d'utilisateur n'a pas été spécifié." @@ -306,7 +307,8 @@ msgstr "Le nom d'utilisateur n'a pas été spécifié." msgid "My Profile" msgstr "Mon Profil" -#: ../../../profile.php:60 ../../../templates/toolbar.inc.php:13 +#: ../../../profile.php:60 +#: ../../../templates/toolbar.inc.php:13 msgid "Profile" msgstr "Profil" @@ -324,8 +326,7 @@ msgstr "Adresse de courrier électronique invalide." #: ../../../profile.php:90 msgid "An error occurred while saving your changes." -msgstr "" -"Une erreur s'est produite pendant l'enregistrement de vos modifications." +msgstr "Une erreur s'est produite pendant l'enregistrement de vos modifications." #: ../../../profile.php:92 msgid "Changes saved." @@ -333,9 +334,7 @@ msgstr "Modifications enregistrées." #: ../../../register.php:33 msgid "You must enter a username, password and e-mail address." -msgstr "" -"Vous devez saisir un nom d'utilisateur, un mot de passe, un nom et " -"un e-mail" +msgstr "Vous devez saisir un nom d'utilisateur, un mot de passe, un nom et un e-mail" #: ../../../register.php:37 msgid "This username has been reserved, please make another choice." @@ -361,7 +360,8 @@ msgstr "Votre inscription a bien été prise en compte !" msgid "Registration failed. Please try again." msgstr "Enregistrement raté. Veuillez rééssayer." -#: ../../../register.php:66 ../../../templates/register.tpl.php:41 +#: ../../../register.php:66 +#: ../../../templates/register.tpl.php:41 #: ../../../templates/toolbar.inc.php:25 msgid "Register" msgstr "S'enregistrer" @@ -371,7 +371,8 @@ msgstr "S'enregistrer" msgid "Recent bookmarks posted to %s" msgstr "Signets ajoutés récemment à %s" -#: ../../../search.inc.php:13 ../../../search.inc.php:41 +#: ../../../search.inc.php:13 +#: ../../../search.inc.php:41 msgid "Search" msgstr "Chercher" @@ -395,15 +396,17 @@ msgstr "tous les signets" msgid "for" msgstr "pour" -#: ../../../search.php:58 ../../../search.php:104 +#: ../../../search.php:58 +#: ../../../search.php:104 msgid "Search Bookmarks" msgstr "Recherche de signets" #: ../../../search.php:64 msgid "Search Results" -msgstr "Résulats de recherche" +msgstr "Résultats de recherche" -#: ../../../tag2tagadd.php:31 ../../../tag2tagdelete.php:31 +#: ../../../tag2tagadd.php:31 +#: ../../../tag2tagdelete.php:31 msgid "Permission denied." msgstr "Permission non accordée." @@ -452,21 +455,22 @@ msgstr "Tag renommé" msgid "Failed to rename the tag" msgstr "Erreur dans la suppression du tag" -#: ../../../tagrename.php:57 ../../../templates/sidebar.block.tagactions.php:9 +#: ../../../tagrename.php:57 +#: ../../../templates/sidebar.block.tagactions.php:9 msgid "Rename Tag" msgid_plural "Rename Tags" msgstr[0] "Renommer le tag" msgstr[1] "TRenommer les tags" -#: ../../../tags.php:38 ../../../templates/editbookmark.tpl.php:44 +#: ../../../tags.php:38 +#: ../../../templates/editbookmark.tpl.php:44 #: ../../../templates/toolbar.inc.php:11 msgid "Tags" msgstr "Tags" #: ../../../users.php:33 -#, fuzzy msgid "Users" -msgstr "Nom d'utilisateur" +msgstr "Utilisateurs" #: ../../../watch.php:46 msgid "User removed from your watchlist" @@ -481,42 +485,28 @@ msgstr "Utilisateur ajouté à la liste des consultés." msgid "My Watchlist" msgstr "Liste des signets vus" -#: ../../../watchlist.php:105 ../../../templates/toolbar.inc.php:12 +#: ../../../watchlist.php:105 +#: ../../../templates/toolbar.inc.php:12 #, fuzzy msgid "Watchlist" msgstr "Liste des signets vus" #: ../../../templates/about.tpl.php:6 -msgid "" -"Store all your favourite links in one place, accessible " -"from anywhere." -msgstr "" -"Conservez tous vos signets au même endroit, accessibles de " -"partout. " +msgid "Store all your favourite links in one place, accessible from anywhere." +msgstr "Conservez tous vos signets au même endroit, accessibles de partout. " #: ../../../templates/about.tpl.php:7 -msgid "" -"Share your bookmarks with everyone, with friends on your " -"watchlist or just keep them private." -msgstr "" -"Partagez vos signets avec tout le monde, avec les " -"utilisateurs autorisés ou gardez-les pour vous." +msgid "Share your bookmarks with everyone, with friends on your watchlist or just keep them private." +msgstr "Partagez vos signets avec tout le monde, avec les utilisateurs autorisés ou gardez-les pour vous." #: ../../../templates/about.tpl.php:8 -msgid "" -"Tag your bookmarks with as many labels as you want, instead " -"of wrestling with folders." -msgstr "" -"Taggez vos signets avec autant de labels que vous le " -"souhaitez au lieu de les hiérarchiser avec des dossiers." +msgid "Tag your bookmarks with as many labels as you want, instead of wrestling with folders." +msgstr "Taggez vos signets avec autant de labels que vous le souhaitez au lieu de les hiérarchiser avec des dossiers." #: ../../../templates/about.tpl.php:9 #, php-format -msgid "" -"Register now to start using %s!" -msgstr "" -"Enregistrez-vous maintenant pour poster vos " -"propres signets !" +msgid "Register now to start using %s!" +msgstr "Enregistrez-vous maintenant pour poster vos propres signets sur %s !" #: ../../../templates/about.tpl.php:12 msgid "Geek Stuff" @@ -524,33 +514,16 @@ msgstr "Pour les Geeks" #: ../../../templates/about.tpl.php:14 #, php-format -msgid "" -"%s is based on an open-" -"source project licensed under the GNU General Public " -"License. This means you can host it on your own web server for free, " -"whether it is on the Internet, a private network or just your own computer." -msgstr "" -"%s est basé sur un " -"projet open-source, sous la license GNU General " -"Public License. Vous pouvez donc héberger Scuttle sur votre propre " -"serveur gratuitement, qu'il soit relié à Internet, dans un réseau privé ou " -"juste sur votre ordinateur personnel." +msgid "%s is based on an open-source project licensed under the GNU General Public License. This means you can host it on your own web server for free, whether it is on the Internet, a private network or just your own computer." +msgstr "%s est basé sur un projet open-source, sous la license GNU General Public License. Vous pouvez donc héberger Scuttle sur votre propre serveur gratuitement, qu'il soit relié à Internet, dans un réseau privé ou juste sur votre ordinateur personnel." #: ../../../templates/about.tpl.php:15 #, php-format -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." +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/bookmarks.tpl.php:17 +#: ../../../templates/tags.tpl.php:7 #: ../../../templates/users.tpl.php:8 msgid "Sort by:" msgstr "Classer par :" @@ -657,11 +630,8 @@ msgid "Comma-separated" msgstr "Séparés par des virgules" #: ../../../templates/editbookmark.tpl.php:50 -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" +msgid "Note: use \">\" to include one tag in another. e.g.: europe>france>paris" +msgstr "Note: utiliser \">\" pour inclure un tag dans un autre. ex: europe>france>paris" #: ../../../templates/editbookmark.tpl.php:53 #: ../../../templates/importDelicious.tpl.php:15 @@ -695,13 +665,8 @@ msgstr "Bookmarklet" #: ../../../templates/editbookmark.tpl.php:98 #, php-format -msgid "" -"Drag one of the following bookmarklets to your browser's bookmarks and click " -"it whenever you want to add the page you are on to %s" -msgstr "" -"Déplacez l'un des 'bookmarklet' suivants dans les marques-pages de votre " -"navigateur et cliquez dessus chaque fois que vous souhaitez ajouter un " -"signet pour la page courante dans %s " +msgid "Drag one of the following bookmarklets to your browser's bookmarks and click it whenever you want to add the page you are on to %s" +msgstr "Déplacez l'un des 'bookmarklet' suivants dans les marques-pages de votre navigateur et cliquez dessus chaque fois que vous souhaitez ajouter un signet pour la page courante dans %s " #: ../../../templates/editbookmark.tpl.php:110 #, php-format @@ -736,8 +701,10 @@ msgid "Account Details" msgstr "Détail du compte" #: ../../../templates/editprofile.tpl.php:11 -#: ../../../templates/login.tpl.php:15 ../../../templates/password.tpl.php:10 -#: ../../../templates/profile.tpl.php:7 ../../../templates/register.tpl.php:16 +#: ../../../templates/login.tpl.php:15 +#: ../../../templates/password.tpl.php:10 +#: ../../../templates/profile.tpl.php:7 +#: ../../../templates/register.tpl.php:16 msgid "Username" msgstr "Nom d'utilisateur" @@ -797,28 +764,16 @@ msgid "Instructions" msgstr "Instructions" #: ../../../templates/importDelicious.tpl.php:33 -msgid "" -"Log in to the export page at " -"del.icio.us" -msgstr "" -"Se connecter à la page d'export " -"de del.icio.us" +msgid "Log in to the export page at del.icio.us" +msgstr "Se connecter à la page d'export de del.icio.us" #: ../../../templates/importDelicious.tpl.php:34 -msgid "" -"Save the resulting XML " -"file to your computer" -msgstr "" -"Enregistrer le fichier XML " -"résultant sur votre ordinateur" +msgid "Save the resulting XML file to your computer" +msgstr "Enregistrer le fichier XML résultant sur votre ordinateur" #: ../../../templates/importDelicious.tpl.php:35 -msgid "" -"Click Browse... to find this file on your computer. The maximum " -"size the file can be is 1MB" -msgstr "" -"Cliquez sur Parcourir... pour trouver le fichier sur votre " -"ordinateur. La taille maximale du fichier ne peut excèder 1Mo" +msgid "Click Browse... to find this file on your computer. The maximum size the file can be is 1MB" +msgstr "Cliquez sur Parcourir... pour trouver le fichier sur votre ordinateur. La taille maximale du fichier ne peut excèder 1Mo" #: ../../../templates/importDelicious.tpl.php:36 #: ../../../templates/importNetscape.tpl.php:43 @@ -827,48 +782,31 @@ msgstr "Selectionnez la vision par défaut à appliquer à vos signets importés #: ../../../templates/importDelicious.tpl.php:37 #: ../../../templates/importNetscape.tpl.php:44 -msgid "" -"Click Import to start importing the bookmarks; it may take a " -"minute" -msgstr "" -"Cliquez sur Importer pour débuter l'import des signets; cette " -"opération peut prendre quelques minutes" +msgid "Click Import to start importing the bookmarks; it may take a minute" +msgstr "Cliquez sur Importer pour débuter l'import des signets; cette opération peut prendre quelques minutes" #: ../../../templates/importNetscape.tpl.php:35 msgid "Export your bookmarks from your browser to a file" msgstr "Exporter vos signets dans un fichier depuis votre navigateur" #: ../../../templates/importNetscape.tpl.php:37 -msgid "" -"Internet Explorer: File > Import and Export... > Export Favorites" -msgstr "" -"Internet Explorer: Ficher > Importer et Exporter... > Exporter " -"les favoris" +msgid "Internet Explorer: File > Import and Export... > Export Favorites" +msgstr "Internet Explorer: Ficher > Importer et Exporter... > Exporter les favoris" #: ../../../templates/importNetscape.tpl.php:38 -msgid "" -"Mozilla Firefox: Bookmarks > Manage Bookmarks... > File > " -"Export..." -msgstr "" -"Mozilla Firefox: Marques-pages > Gérer les marques-pages... > " -"Fichier > Exporter..." +msgid "Mozilla Firefox: Bookmarks > Manage Bookmarks... > File > Export..." +msgstr "Mozilla Firefox: Marques-pages > Gérer les marques-pages... > Fichier > Exporter..." #: ../../../templates/importNetscape.tpl.php:39 -msgid "" -"Netscape: Bookmarks > Manage Bookmarks... > Tools > Export..." -msgstr "" -"Netscape: Marques-pages > Gérer les marques-pages... > Outils " -"> Exporter..." +msgid "Netscape: Bookmarks > Manage Bookmarks... > Tools > Export..." +msgstr "Netscape: Marques-pages > Gérer les marques-pages... > Outils > Exporter..." #: ../../../templates/importNetscape.tpl.php:42 -msgid "" -"Click Browse... to find the saved bookmark file on your computer. " -"The maximum size the file can be is 1MB" -msgstr "" -"Cliquez sur Parcourir... pour trouver le fichier sur votre " -"ordinateur. La taille maximale du fichier ne peut excèder 1Mo" +msgid "Click Browse... to find the saved bookmark file on your computer. The maximum size the file can be is 1MB" +msgstr "Cliquez sur Parcourir... pour trouver le fichier sur votre ordinateur. La taille maximale du fichier ne peut excèder 1Mo" -#: ../../../templates/login.tpl.php:20 ../../../templates/register.tpl.php:21 +#: ../../../templates/login.tpl.php:20 +#: ../../../templates/register.tpl.php:21 msgid "Password" msgstr "Mot de passe" @@ -882,14 +820,8 @@ msgstr "Avez-vous oublié votre mot de passe ?" #: ../../../templates/password.tpl.php:5 #, php-format -msgid "" -"If you have forgotten your password, %s can generate a new one. Enter the " -"username and e-mail address of your account into the form below and we will " -"e-mail your new password to you." -msgstr "" -"Si vous avez oublié votre mot de passe, %s peut en générer un nouveau. " -"Entrez le nom d'utilisateur et l'adresse email de votre compte dans le " -"formulaire ci-dessous et nous vous enverrons un nouveau mot de passe." +msgid "If you have forgotten your password, %s can generate a new one. Enter the username and e-mail address of your account into the form below and we will e-mail your new password to you." +msgstr "Si vous avez oublié votre mot de passe, %s peut en générer un nouveau. Entrez le nom d'utilisateur et l'adresse email de votre compte dans le formulaire ci-dessous et nous vous enverrons un nouveau mot de passe." #: ../../../templates/password.tpl.php:19 msgid "Generate Password" @@ -912,21 +844,21 @@ msgstr "Consultés" #: ../../../templates/register.tpl.php:11 #, php-format -msgid "" -"Sign up here to create a free %s account. All the information requested " -"below is required" -msgstr "" -"Enregistrez-vous ici pour créer un compte gratuit %s. Toutes les " -"informations requises ci-dessous sont nécessaires." +msgid "Sign up here to create a free %s account. All the information requested below is required" +msgstr "Enregistrez-vous ici pour créer un compte gratuit %s. Toutes les informations requises ci-dessous sont nécessaires." #: ../../../templates/register.tpl.php:33 msgid "Antispam question" msgstr "Question antispam" -#: ../../../templates/sidebar.block.linked.php:63 +#: ../../../templates/sidebar.block.linked.php:72 msgid "Linked Tags" msgstr "Tags structurés" +#: ../../../templates/sidebar.block.linked.php:75 +msgid "plus" +msgstr "plus" + #: ../../../templates/sidebar.block.recent.php:15 msgid "Recent Tags" msgstr "Tags récents" @@ -954,14 +886,12 @@ msgid "Add to Watchlist" msgstr "Ajouter à la liste des consultés" #: ../../../templates/tag2tagadd.tpl.php:7 -#, fuzzy msgid "Create new link:" msgstr "Créer un nouveau lien" #: ../../../templates/tag2tagadd.tpl.php:11 -#, fuzzy msgid "Create" -msgstr "Privée" +msgstr "Créer" #: ../../../templates/tag2tagadd.tpl.php:12 #: ../../../templates/tagrename.tpl.php:25 @@ -977,16 +907,17 @@ msgid "New" msgstr "Nouvaeu" #: ../../../templates/tagrename.tpl.php:24 -#, fuzzy msgid "Rename" -msgstr "Nom d'utilisateur" +msgstr "Renommer" -#: ../../../templates/tags.tpl.php:8 ../../../templates/users.tpl.php:9 +#: ../../../templates/tags.tpl.php:8 +#: ../../../templates/users.tpl.php:9 #, fuzzy msgid "Alphabet" msgstr "Alphabet" -#: ../../../templates/tags.tpl.php:9 ../../../templates/users.tpl.php:10 +#: ../../../templates/tags.tpl.php:9 +#: ../../../templates/users.tpl.php:10 msgid "Popularity" msgstr "Popularité" @@ -1010,17 +941,16 @@ msgstr "Créé en " msgid "bookmarks" 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" #~ msgstr "Signets de %s" - #~ msgid "E-mail" #~ msgstr "E-mail" - #~ msgid "No bookmarks found" #~ msgstr "Pas de signets trouvés" + diff --git a/locales/messages.po b/locales/messages.po index f32110b..a5301eb 100644 --- a/locales/messages.po +++ b/locales/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-01-14 11:58+0100\n" +"POT-Creation-Date: 2008-01-22 16:54+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -853,10 +853,14 @@ msgstr "" msgid "Antispam question" msgstr "" -#: ../../../templates/sidebar.block.linked.php:63 +#: ../../../templates/sidebar.block.linked.php:72 msgid "Linked Tags" msgstr "" +#: ../../../templates/sidebar.block.linked.php:75 +msgid "plus" +msgstr "" + #: ../../../templates/sidebar.block.recent.php:15 msgid "Recent Tags" msgstr "" diff --git a/populartags.php b/populartags.php index daef205..6bed82d 100644 --- a/populartags.php +++ b/populartags.php @@ -76,6 +76,8 @@ if (isset($userid)) { $tplVars['cat_url'] = createURL('tags', '%2$s'); } +$tplVars['sidebar_blocks'] = array('linked'); + $tplVars['subtitle'] = $pagetitle; $templateservice->loadTemplate('tags.tpl', $tplVars); diff --git a/services/tag2tagservice.php b/services/tag2tagservice.php index 7ceb8da..14d57b3 100644 --- a/services/tag2tagservice.php +++ b/services/tag2tagservice.php @@ -28,17 +28,35 @@ class Tag2TagService { return false; } $this->db->sql_transaction('commit'); + + // Update stats + $tsts =& ServiceFactory::getServiceInstance('TagStatService'); + $tsts->updateStat($tag1, $relationType, $uId); + return true; } - function getLinkedTags($tag1, $relationType, $uId = -1) { + // Return the target linked tags. If inverseRelation is true, return the source linked tags. + function getLinkedTags($tag, $relationType, $uId = null, $inverseRelation = false) { // Set up the SQL query. - $query = "SELECT DISTINCT tag2 as 'tag' FROM `". $this->getTableName() ."`"; - $query.= " WHERE tag1 = '" .$tag1 ."'"; + if($inverseRelation) { + $queriedTag = "tag1"; + $givenTag = "tag2"; + } else { + $queriedTag = "tag2"; + $givenTag = "tag1"; + } + + $query = "SELECT DISTINCT ". $queriedTag ." as 'tag'"; + $query.= " FROM `". $this->getTableName() ."`"; + $query.= " WHERE 1=1"; + if($tag !=null) { + $query.= " AND ". $givenTag ." = '". $tag ."'"; + } if($relationType) { $query.= " AND relationType = '". $relationType ."'"; } - if($uId>0) { + if($uId != null) { $query.= " AND uId = '".$uId."'"; } @@ -88,9 +106,14 @@ class Tag2TagService { return $output; } - function getOrphewTags($relationType, $uId = 0) { - $query = "SELECT DISTINCT tag1 as tag FROM `". $this->getTableName() ."`"; - $query.= " WHERE tag1 <> ALL"; + function getOrphewTags($relationType, $uId = 0, $limit = null, $orderBy = null) { + $query = "SELECT DISTINCT tts.tag1 as tag"; + $query.= " FROM `". $this->getTableName() ."` tts"; + if($orderBy != null) { + $tsts =& ServiceFactory::getServiceInstance('TagStatService'); + $query.= ", ".$tsts->getTableName() ." tsts"; + } + $query.= " WHERE tts.tag1 <> ALL"; $query.= " (SELECT DISTINCT tag2 FROM `". $this->getTableName() ."`"; $query.= " WHERE relationType = '".$relationType."'"; if($uId > 0) { @@ -98,12 +121,41 @@ class Tag2TagService { } $query.= ")"; if($uId > 0) { - $query.= " AND uId = '".$uId."'"; + $query.= " AND tts.uId = '".$uId."'"; } - //die($query); + switch($orderBy) { + case "nb": + $query.= " AND tts.tag1 = tsts.tag1"; + $query.= " AND tsts.relationType = '".$relationType."'"; + if($uId > 0) { + $query.= " AND tsts.uId = ".$uId; + } + $query.= " ORDER BY tsts.nb DESC"; + break; + case "depth": // by nb of descendants + $query.= " AND tts.tag1 = tsts.tag1"; + $query.= " AND tsts.relationType = '".$relationType."'"; + if($uId > 0) { + $query.= " AND tsts.uId = ".$uId; + } + $query.= " ORDER BY tsts.depth DESC"; + break; + case "nbupdate": + $query.= " AND tts.tag1 = tsts.tag1"; + $query.= " AND tsts.relationType = '".$relationType."'"; + if($uId > 0) { + $query.= " AND tsts.uId = ".$uId; + } + $query.= " ORDER BY tsts.nbupdate DESC"; + break; + } - if (! ($dbresult =& $this->db->sql_query_limit($query, $limit)) ){ + if($limit != null) { + $query.= " LIMIT 0,".$limit; + } + + if (! ($dbresult =& $this->db->sql_query($query)) ){ message_die(GENERAL_ERROR, 'Could not get linked tags', '', __LINE__, __FILE__, $query, $this->db); return false; } @@ -117,7 +169,7 @@ class Tag2TagService { $query.= " AND relationType = '". $relationType ."'"; $query.= " AND uId = '".$uId."'"; - return $this->db->sql_numrows($dbresult) > 0; + return $this->db->sql_numrows($this->db->sql_query($query)) > 0; } function removeLinkedTags($tag1, $tag2, $relationType, $uId) { @@ -132,12 +184,19 @@ class Tag2TagService { return false; } + // Update stats + $tsts =& ServiceFactory::getServiceInstance('TagStatService'); + $tsts->updateStat($tag1, $relationType, $uId); + return true; } function deleteAll() { $query = 'TRUNCATE TABLE `'. $this->getTableName() .'`'; $this->db->sql_query($query); + + $tsts =& ServiceFactory::getServiceInstance('TagStatService'); + $tsts->deleteAll(); } // Properties diff --git a/services/tagstatservice.php b/services/tagstatservice.php new file mode 100644 index 0000000..fa416f4 --- /dev/null +++ b/services/tagstatservice.php @@ -0,0 +1,181 @@ +db =& $db; + $this->tablename = $GLOBALS['tableprefix'] .'tagsstats'; + } + + function getNbChildren($tag1, $relationType, $uId) { + $tts =& ServiceFactory::getServiceInstance('Tag2TagService'); + $query = "SELECT tag1, relationType, uId FROM `". $tts->getTableName() ."`"; + $query.= " WHERE tag1 = '" .$tag1 ."'"; + $query.= " AND relationType = '". $relationType ."'"; + $query.= " AND uId = '".$uId."'"; + + return $this->db->sql_numrows($this->db->sql_query($query)); + } + + function getNbDescendants($tag1, $relationType, $uId) { + $query = "SELECT nb FROM `". $this->getTableName() ."`"; + $query.= " WHERE tag1 = '" .$tag1 ."'"; + $query.= " AND relationType = '". $relationType ."'"; + $query.= " AND uId = '".$uId."'"; + + $dbresults =& $this->db->sql_query($query); + $row = $this->db->sql_fetchrow($dbresults); + if($row['nb'] == null) { + return 0; + } else { + return (int) $row['nb']; + } + } + + function getMaxDepth($tag1, $relationType, $uId) { + $query = "SELECT depth FROM `". $this->getTableName() ."`"; + $query.= " WHERE tag1 = '" .$tag1 ."'"; + $query.= " AND relationType = '". $relationType ."'"; + $query.= " AND uId = '".$uId."'"; + + $dbresults =& $this->db->sql_query($query); + $row = $this->db->sql_fetchrow($dbresults); + if($row['depth'] == null) { + return 0; + } else { + return (int) $row['depth']; + }; + } + + function getNbUpdate($tag1, $relationType, $uId) { + $query = "SELECT nbupdate FROM `". $this->getTableName() ."`"; + $query.= " WHERE tag1 = '" .$tag1 ."'"; + $query.= " AND relationType = '". $relationType ."'"; + $query.= " AND uId = '".$uId."'"; + + $dbresults =& $this->db->sql_query($query); + $row = $this->db->sql_fetchrow($dbresults); + if($row['nbupdate'] == null) { + return 0; + } else { + return (int) $row['nbupdate']; + } + } + + function existStat($tag1, $relationType, $uId) { + $query = "SELECT tag1, relationType, uId FROM `". $this->getTableName() ."`"; + $query.= " WHERE tag1 = '" .$tag1 ."'"; + $query.= " AND relationType = '". $relationType ."'"; + $query.= " AND uId = '".$uId."'"; + + return $this->db->sql_numrows($this->db->sql_query($query))>0; + } + + function createStat($tag1, $relationType, $uId) { + $query = "INSERT INTO `". $this->getTableName() ."`"; + $query.= "(tag1, relationType, uId)"; + $query.= " VALUES ('".$tag1."','".$relationType."','".$uId."')"; + $this->db->sql_query($query); + } + + function updateStat($tag1, $relationType, $uId=null, $stoplist=array()) { + if(in_array($tag1, $stoplist)) { + return false; + } + + $tts =& ServiceFactory::getServiceInstance('Tag2TagService'); + $linkedTags = $tts->getLinkedTags($tag1, $relationType, $uId); + $nbDescendants = 0; + $maxDepth = 0; + foreach($linkedTags as $linkedTag) { + $nbDescendants+= 1 + $this->getNbDescendants($linkedTag, $relationType, $uId); + $maxDepth = max($maxDepth, 1 + $this->getMaxDepth($linkedTag, $relationType, $uId)); + } + $this->setNbDescendants($tag1, $relationType, $uId, $nbDescendants); + $this->setMaxDepth($tag1, $relationType, $uId, $maxDepth); + $this->increaseNbUpdate($tag1, $relationType, $uId); + + // propagation to the precedent tags + $linkedTags = $tts->getLinkedTags($tag1, $relationType, $uId, true); + $stoplist[] = $tag1; + foreach($linkedTags as $linkedTag) { + $this->updateStat($linkedTag, $relationType, $uId, $stoplist); + } + } + + function updateAllStat() { + $tts =& ServiceFactory::getServiceInstance('Tag2TagService'); + + $query = "SELECT tag1, uId FROM `". $tts->getTableName() ."`"; + $query.= " WHERE relationType = '>'"; + +//die($query); + + if (! ($dbresult =& $this->db->sql_query($query)) ){ + message_die(GENERAL_ERROR, 'Could not update stats', '', __LINE__, __FILE__, $query, $this->db); + return false; + } + + $rowset = $this->db->sql_fetchrowset($dbresult); + foreach($rowset as $row) { + $this->updateStat($row['tag1'], '>', $row['uId']); + } + } + + function setNbDescendants($tag1, $relationType, $uId, $nb) { + if(!$this->existStat($tag1, $relationType, $uId)) { + $this->createStat($tag1, $relationType, $uId); + } + $query = "UPDATE `". $this->getTableName() ."`"; + $query.= " SET nb = ". $nb; + $query.= " WHERE tag1 = '" .$tag1 ."'"; + $query.= " AND relationType = '". $relationType ."'"; + $query.= " AND uId = '".$uId."'"; + $this->db->sql_query($query); + } + + function setMaxDepth($tag1, $relationType, $uId, $depth) { + if(!$this->existStat($tag1, $relationType, $uId)) { + $this->createStat($tag1, $relationType, $uId); + } + $query = "UPDATE `". $this->getTableName() ."`"; + $query.= " SET depth = ". $depth; + $query.= " WHERE tag1 = '" .$tag1 ."'"; + $query.= " AND relationType = '". $relationType ."'"; + $query.= " AND uId = '".$uId."'"; + $this->db->sql_query($query); + } + + function increaseNbUpdate($tag1, $relationType, $uId) { + if(!$this->existStat($tag1, $relationType, $uId)) { + $this->createStat($tag1, $relationType, $uId); + } + $query = "UPDATE `". $this->getTableName() ."`"; + $query.= " SET nbupdate = nbupdate + 1"; + $query.= " WHERE tag1 = '" .$tag1 ."'"; + $query.= " AND relationType = '". $relationType ."'"; + $query.= " AND uId = '".$uId."'"; + + //die($query); + + $this->db->sql_query($query); + } + + 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 1968507..3dd7bab 100644 --- a/tables.sql +++ b/tables.sql @@ -82,3 +82,21 @@ CREATE TABLE `sc_tags2tags` ( PRIMARY KEY (`ttId`), UNIQUE KEY `sc_tags2tags_tag1_tag2_uId` (`tag1`,`tag2`,`relationType`,`uId`) ); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `sc_tagsstats` +-- + +CREATE TABLE `sc_tagsstats` ( + `tstId` int(11) NOT NULL auto_increment, + `tag1` varchar(32) NOT NULL default '', + `relationType` varchar(32) NOT NULL default '', + `uId` int(11) NOT NULL default '0', + `nb` int(11) NOT NULL default '0', + `depth` int(11) NOT NULL default '0', + `nbupdate` int(11) NOT NULL default '0', + PRIMARY KEY (`tstId`), + UNIQUE KEY `sc_tagsstats_tag1_type_uId` (`tag1`,`relationType`,`uId`) +); diff --git a/templates/sidebar.block.linked.php b/templates/sidebar.block.linked.php index 5a891ea..7bbde81 100644 --- a/templates/sidebar.block.linked.php +++ b/templates/sidebar.block.linked.php @@ -4,11 +4,14 @@ $userservice =& ServiceFactory::getServiceInstance('UserService'); function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode =false, $precedentTag =null, $level=0, $stopList=array()) { $tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService'); + $tagstatservice =& ServiceFactory::getServiceInstance('TagStatService'); $output = ''; $output.= ''; $output.= ''; $output.= ''. str_repeat(' ', $level*2) .''; + //$output.= ' - '. $tagstatservice->getMaxDepth($tag, $linkType, $uId); + if($editingMode) { $output.= ' ('; $output.= 'add'; @@ -22,7 +25,7 @@ function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode $output.= ''; if(!in_array($tag, $stopList)) { - $linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $userid, $level); + $linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $userid); $precedentTag = $tag; $stopList[] = $tag; $level = $level + 1; @@ -33,7 +36,6 @@ function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode return $output; } - $logged_on_userid = $userservice->getCurrentUserId(); if ($logged_on_userid === false) { $logged_on_userid = NULL; @@ -43,7 +45,12 @@ $explodedTags = array(); if ($currenttag) { $explodedTags = explode('+', $currenttag); } else { - $orphewTags = $tag2tagservice->getOrphewTags('>', $userid); + if($userid != null) { + $orphewTags = $tag2tagservice->getOrphewTags('>', $userid); + } else { + $orphewTags = $tag2tagservice->getOrphewTags('>', $userid, 4, "nb"); + } + foreach($orphewTags as $orphewTag) { $explodedTags[] = $orphewTag['tag']; } @@ -60,7 +67,17 @@ if(count($explodedTags) > 0) { if ($displayLinkedZone) { ?> -

+

+getUser($userid); + echo '('.T_('plus').')'; + //} +?> +

+ +
includeTemplate('sidebar.tpl'); $this->includeTemplate($GLOBALS['bottom_include']); -?> \ No newline at end of file +?> diff --git a/tests/tag2TagTest.php b/tests/tag2TagTest.php index 3a8466f..7b84ac6 100644 --- a/tests/tag2TagTest.php +++ b/tests/tag2TagTest.php @@ -26,6 +26,8 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase $this->ts->deleteAll(); $this->tts =& ServiceFactory::getServiceInstance('Tag2TagService'); $this->tts->deleteAll(); + $this->tsts =& ServiceFactory::getServiceInstance('TagStatService'); + $this->tsts->deleteAll(); } public function testManipulateTag2TagRelations() @@ -58,9 +60,11 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase $this->assertSame('a', $orphewTags[0]['tag']); $this->assertSame('f', $orphewTags[1]['tag']); $orphewTags = $tts->getOrphewTags('>'); - $this->assertEquals(2, sizeof($orphewTags)); + $this->assertEquals(1, sizeof($orphewTags)); $this->assertSame('f', $orphewTags[0]['tag']); + $linkedTags = $tts->getLinkedTags('a', '>'); + $this->assertSame(array('b', 'c', 'd'), $linkedTags); $linkedTags = $tts->getLinkedTags('a', '>', 1); $this->assertSame(array('b', 'c'), $linkedTags); $tts->removeLinkedTags('a', 'b', '>', 1); @@ -69,8 +73,48 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase $tts->removeLinkedTags('a', 'c', '>', 1); $linkedTags = $tts->getLinkedTags('a', '>', 1); $this->assertEquals(0, sizeof($linkedTags)); - $linkedTags = $tts->getLinkedTags('a', '>'); - $this->assertSame(array('b', 'c', 'd'), $linkedTags); + } + + /* Test function that select the best tags to display? */ + public function testViewTag2TagRelations() + { + $tts = $this->tts; + + $tts->addLinkedTags('a', 'b', '>', 1); + $tts->addLinkedTags('c', 'd', '>', 1); + $tts->addLinkedTags('d', 'e', '>', 1); + $tts->addLinkedTags('f', 'g', '>', 1); + $tts->addLinkedTags('f', 'h', '>', 1); + $tts->addLinkedTags('f', 'i', '>', 1); + + $orphewTags = $tts->getOrphewTags('>', 1); + $this->assertEquals(3, sizeof($orphewTags)); + $this->assertSame('a', $orphewTags[0]['tag']); + $this->assertSame('c', $orphewTags[1]['tag']); + $this->assertSame('f', $orphewTags[2]['tag']); + + // with limit + $orphewTags = $tts->getOrphewTags('>', 1, 2); + $this->assertEquals(2, sizeof($orphewTags)); + $this->assertSame('a', $orphewTags[0]['tag']); + $this->assertSame('c', $orphewTags[1]['tag']); + + // with sorting + $orphewTags = $tts->getOrphewTags('>', 1, 2, 'nb'); // nb descendants + $this->assertEquals(2, sizeof($orphewTags)); + $this->assertSame('f', $orphewTags[0]['tag']); + $this->assertSame('c', $orphewTags[1]['tag']); + + $orphewTags = $tts->getOrphewTags('>', 1, 1, 'depth'); + $this->assertEquals(1, sizeof($orphewTags)); + $this->assertSame('c', $orphewTags[0]['tag']); + + $orphewTags = $tts->getOrphewTags('>', 1, null, 'nbupdate'); + $this->assertEquals(3, sizeof($orphewTags)); + $this->assertSame('f', $orphewTags[0]['tag']); + $this->assertSame('c', $orphewTags[1]['tag']); + $this->assertSame('a', $orphewTags[2]['tag']); + } public function testAddLinkedTagsThroughBookmarking() @@ -97,6 +141,7 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase $this->assertEquals(1, sizeof($linkedTags)); $this->assertSame('c', $linkedTags[0]['tag']); $this->assertTrue($tts->existsLinkedTags('d', 'e', '>', 1)); + $this->assertFalse($tts->existsLinkedTags('e', 'd', '>', 1)); } public function testSearchThroughLinkedTags() @@ -140,5 +185,96 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase } + public function testStatsBetweenTags() + { + $tsts = $this->tsts; + $tts = $this->tts; + + // basic functions + $this->assertFalse($tsts->existStat('a', '>', 10)); + $tsts->setNbDescendants('a', '>', 10, 2); + $this->assertSame(2, $tsts->getNbDescendants('a', '>', 10)); + $tsts->setMaxDepth('a', '>', 10, 3); + $this->assertSame(3, $tsts->getMaxDepth('a', '>', 10)); + $this->assertTrue($tsts->existStat('a', '>', 10)); + $this->assertFalse($tsts->existStat('a', '>', 20)); + $tsts->increaseNbUpdate('a', '>', 10); + $this->assertSame(1, $tsts->getNbUpdate('a', '>', 10)); + + $tsts->deleteAll(); + + // no structure + $nbC = $tsts->getNbChildren('a', '>', 1); + $nbD = $tsts->getNbDescendants('a', '>', 1); + $maxDepth = $tsts->getMaxDepth('a', '>', 1); + $this->assertSame(0, $nbC); + $this->assertSame(0, $nbD); + $this->assertSame(0, $maxDepth); + + // simple case + $tts->addLinkedTags('b', 'c', '>', 1); + $tts->addLinkedTags('a', 'd', '>', 1); + $tts->addLinkedTags('a', 'b', '>', 1); + $tts->addLinkedTags('b', 'e', '>', 1); + + $this->assertSame(3, $tsts->getNbUpdate('a', '>', '1')); + $this->assertSame(2, $tsts->getNbUpdate('b', '>', '1')); + $this->assertSame(0, $tsts->getNbUpdate('c', '>', '1')); + $this->assertSame(0, $tsts->getNbUpdate('d', '>', '1')); + $this->assertSame(0, $tsts->getNbUpdate('e', '>', '1')); + + + $nbC = $tsts->getNbChildren('a', '>', 1); + $nbD = $tsts->getNbDescendants('a', '>', 1); + $maxDepth = $tsts->getMaxDepth('a', '>', 1); + $this->assertSame(2, $nbC); + $this->assertSame(4, $nbD); + $this->assertSame(2, $maxDepth); + + $nbC = $tsts->getNbChildren('b', '>', 1); + $nbD = $tsts->getNbDescendants('b', '>', 1); + $maxDepth = $tsts->getMaxDepth('b', '>', 1); + $this->assertSame(2, $nbC); + $this->assertSame(2, $nbD); + $this->assertSame(1, $maxDepth); + + $nbC = $tsts->getNbChildren('c', '>', 1); + $nbD = $tsts->getNbDescendants('c', '>', 1); + $maxDepth = $tsts->getMaxDepth('c', '>', 1); + $this->assertSame(0, $nbC); + $this->assertSame(0, $nbD); + $this->assertSame(0, $maxDepth); + + $nbC = $tsts->getNbChildren('d', '>', 1); + $nbD = $tsts->getNbDescendants('d', '>', 1); + $maxDepth = $tsts->getMaxDepth('d', '>', 1); + $this->assertSame(0, $nbC); + $this->assertSame(0, $nbD); + $this->assertSame(0, $maxDepth); + + // deletion + $tts->removeLinkedTags('b', 'e', '>', 1); + + $nbC = $tsts->getNbChildren('b', '>', 1); + $nbD = $tsts->getNbDescendants('b', '>', 1); + $maxDepth = $tsts->getMaxDepth('b', '>', 1); + $this->assertSame(1, $nbC); + $this->assertSame(1, $nbD); + $this->assertSame(1, $maxDepth); + + $nbC = $tsts->getNbChildren('a', '>', 1); + $nbD = $tsts->getNbDescendants('a', '>', 1); + $maxDepth = $tsts->getMaxDepth('a', '>', 1); + $this->assertSame(2, $nbC); + $this->assertSame(3, $nbD); + $this->assertSame(2, $maxDepth); + + + // advanced case with fore loop + //$tts->addLinkedTags('d', 'c', '>', 1); + + // advanced case with back loop + //$tts->addLinkedTags('e', 'a', '>', 1); + } } ?>