[vhffs-dev] [1242] Here we go! tag search is operational

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1242
Author:   beuss
Date:     2008-07-30 00:11:26 +0200 (Wed, 30 Jul 2008)

Log Message:
-----------
Here we go! tag search is operational

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Makefile.am
    trunk/vhffs-public/Makefile.am
    trunk/vhffs-public/templates/index.tmpl

Added Paths:
-----------
    trunk/vhffs-api/src/Vhffs/Panel/Tag.pm
    trunk/vhffs-public/tagsearch.pl


Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am	2008-07-28 14:59:11 UTC (rev 1241)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am	2008-07-29 22:11:26 UTC (rev 1242)
@@ -35,6 +35,7 @@
 	Panel/Pgsql.pm \
 	Panel/Repository.pm \
 	Panel/Svn.pm \
+	Panel/Tag.pm \
 	Panel/Git.pm \
 	Panel/User.pm \
 	Panel/Web.pm \

Added: trunk/vhffs-api/src/Vhffs/Panel/Tag.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Tag.pm	                        (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Panel/Tag.pm	2008-07-29 22:11:26 UTC (rev 1242)
@@ -0,0 +1,74 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+package Vhffs::Panel::Tag;
+
+use DBI;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use Vhffs::User;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Group;
+
+=head1 NAME
+
+Vhffs::Panel::Tag - Handle tags information in the panel.
+
+=head1 METHODS
+
+=cut
+
+sub get_groups {
+    my ($main, $tag_id, $start, $count) = @_;
+
+
+	my $select =  'SELECT g.gid, g.groupname, g.realname, o.description ';
+	my $restriction=	'FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id=g.object_id '.
+		'INNER JOIN vhffs_object_tag ot ON ot.object_id = o.object_id '.
+		'INNER JOIN vhffs_tag t ON t.tag_id = ot.tag_id '.
+		'WHERE o.state = ? AND ot.tag_id = ?';
+    my @params;
+    push @params, Vhffs::Constants::ACTIVATED;
+    push @params, $tag_id;
+
+    return Vhffs::Panel::Commons::fetch_slice_and_count($main, $select, $restriction, 
+        ' ORDER BY g.groupname', $start, $count, \@params, \&Vhffs::Panel::Group::fetch_groups_and_users);
+}
+
+1;

Modified: trunk/vhffs-public/Makefile.am
===================================================================
--- trunk/vhffs-public/Makefile.am	2008-07-28 14:59:11 UTC (rev 1241)
+++ trunk/vhffs-public/Makefile.am	2008-07-29 22:11:26 UTC (rev 1242)
@@ -11,6 +11,7 @@
 	index.pl \
 	lastgroups.pl \
 	lastusers.pl \
+	tagsearch.pl \
 	user.pl \
 	usersearch.pl \
 	websitesearch.pl \

Added: trunk/vhffs-public/tagsearch.pl
===================================================================
--- trunk/vhffs-public/tagsearch.pl	                        (rev 0)
+++ trunk/vhffs-public/tagsearch.pl	2008-07-29 22:11:26 UTC (rev 1242)
@@ -0,0 +1,84 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+use POSIX qw(locale_h);
+use locale;
+use Locale::gettext;
+use CGI;
+use Encode;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Commons;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Tag;
+use Vhffs::Panel::Template;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+
+my $vhffs = $panel->{'vhffs'};
+my $templatedir = $panel->{'templatedir'};
+my $cgi = $panel->{'cgi'};
+
+$panel->check_public();
+
+my $template = new Vhffs::Panel::Template( filename => $templatedir.'/public/groupslist.tmpl', die_on_bad_params => 0 );
+my $tag = $cgi->param('tag');
+my $page = $cgi->param('page');
+my $per_page_count = 5;
+$page = 1 unless(defined $page && int($page) > 0);
+$panel->redirect('/') unless(defined $tag && int($tag) > 0);
+
+my $result = Vhffs::Panel::Tag::get_groups(
+    $vhffs,
+    int($tag),
+    ($page -1) * $per_page_count,
+    $per_page_count
+);
+
+$template->param( URL_PANEL => $vhffs->get_config->get_panel->{'url'} );
+
+if($result->{total_count} == 0) {
+    $template->param( TEXT_TITLE => gettext('No group found') );
+} else {
+    Vhffs::Panel::Commons::paginate($template, $page, $result->{total_count}, $per_page_count,
+        { tag => $tag });
+    $template->param( USE_AVATAR => $panel->use_groups_avatars );
+    $template->param( TEXT_TITLE => sprintf( gettext('%d group(s) found'), $result->{total_count} ) );
+    $template->param( GROUPS => $result->{data} );
+}
+
+$panel->light( $template );
+$panel->display;
+

Modified: trunk/vhffs-public/templates/index.tmpl
===================================================================
--- trunk/vhffs-public/templates/index.tmpl	2008-07-28 14:59:11 UTC (rev 1241)
+++ trunk/vhffs-public/templates/index.tmpl	2008-07-29 22:11:26 UTC (rev 1242)
@@ -39,7 +39,7 @@
 	<h3><TMPL_I18N KEY="Most popular tags"></h3>
 	<TMPL_LOOP NAME="TOP_TAGS">
 		<span class="tag-<TMPL_VAR NAME="WEIGHT">">
-			<a href="#"> <span title="<TMPL_VAR ESCAPE=1 NAME="CATEGORY_DESCRIPTION">"><TMPL_VAR NAME="CATEGORY_LABEL"></span>::<span title="<TMPL_VAR ESCAPE=1 NAME="TAG_DESCRIPTION">"><TMPL_VAR NAME="TAG_LABEL"></span></a>
+			<a href="/tagsearch.pl?tag=<TMPL_VAR NAME="TAG_ID">"> <span title="<TMPL_VAR ESCAPE=1 NAME="CATEGORY_DESCRIPTION">"><TMPL_VAR NAME="CATEGORY_LABEL"></span>::<span title="<TMPL_VAR ESCAPE=1 NAME="TAG_DESCRIPTION">"><TMPL_VAR NAME="TAG_LABEL"></span></a>
 		</span>
 	</TMPL_LOOP>
 	</TMPL_IF>
@@ -47,7 +47,7 @@
 	<h3><TMPL_I18N KEY="Random tags"></h3>
 	<TMPL_LOOP NAME="RANDOM_TAGS">
 		<span class="tag-<TMPL_VAR NAME="WEIGHT">">
-			<a href="#" ><span title="<TMPL_VAR ESCAPE=1 NAME="CATEGORY_DESCRIPTION">"><TMPL_VAR NAME="CATEGORY_LABEL"></span>::<span title="<TMPL_VAR ESCAPE=1 NAME="TAG_DESCRIPTION">"><TMPL_VAR NAME="TAG_LABEL"></span></a>
+			<a href="/tagsearch.pl?tag=<TMPL_VAR NAME="TAG_ID">" ><span title="<TMPL_VAR ESCAPE=1 NAME="CATEGORY_DESCRIPTION">"><TMPL_VAR NAME="CATEGORY_LABEL"></span>::<span title="<TMPL_VAR ESCAPE=1 NAME="TAG_DESCRIPTION">"><TMPL_VAR NAME="TAG_LABEL"></span></a>
 		</span>
 	</TMPL_LOOP>
 	</TMPL_IF>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/