[Cpan-forum-commit] rev 241 - in trunk: . lib/CPAN/Forum/DB lib/CPAN/Forum/RM templates

svn at pti.co.il svn at pti.co.il
Wed Jul 4 00:04:08 IDT 2007


Author: gabor
Date: 2007-07-04 00:04:08 +0300 (Wed, 04 Jul 2007)
New Revision: 241

Added:
   trunk/templates/modules_with_tags.tmpl
Modified:
   trunk/
   trunk/lib/CPAN/Forum/DB/Tags.pm
   trunk/lib/CPAN/Forum/RM/Tags.pm
   trunk/templates/tags.tmpl
Log:
list all the modules with a given tag



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4100
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
   + 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4101
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752

Modified: trunk/lib/CPAN/Forum/DB/Tags.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Tags.pm	2007-07-03 21:03:35 UTC (rev 240)
+++ trunk/lib/CPAN/Forum/DB/Tags.pm	2007-07-03 21:04:08 UTC (rev 241)
@@ -115,7 +115,23 @@
     return \@tags;
 }
 
+sub get_modules_with_tag {
+    my ($self, $tag_name) = @_;
 
+    my $sql = "SELECT groups.name
+               FROM groups, tags, tag_cloud
+               WHERE groups.id=tag_cloud.group_id AND tag_cloud.tag_id=tags.id AND tags.name=?";
+    my $dbh = CPAN::Forum::DBI::db_Main();
+    my $sth = $dbh->prepare($sql);
+    $sth->execute($tag_name);
+    my @res;
+    while (my $hr = $sth->fetchrow_hashref) {
+        push @res, $hr;
+    }
+    return \@res;
+}
+
+
 =head1 Design
 
 Every person can put any tage on any module

Modified: trunk/lib/CPAN/Forum/RM/Tags.pm
===================================================================
--- trunk/lib/CPAN/Forum/RM/Tags.pm	2007-07-03 21:03:35 UTC (rev 240)
+++ trunk/lib/CPAN/Forum/RM/Tags.pm	2007-07-03 21:04:08 UTC (rev 241)
@@ -5,6 +5,14 @@
 sub tags {
     my ($self) = @_;
 
+    my $path = ${$self->param("path_parameters")}[0] || '';
+    my $value = ${$self->param("path_parameters")}[1] || '';
+    $self->log->debug("tags path='$path' value='$value'");
+    if ($path eq 'name' and $value) {
+        return $self->_list_modules_with_tag($value);
+    }
+     
+
     my $t = $self->load_tmpl("tags.tmpl",
         loop_context_vars => 1,
         global_vars => 1,
@@ -14,6 +22,20 @@
     return $t->output; 
 }
 
+sub _list_modules_with_tag {
+    my ($self, $value) = @_;
+
+    my $t = $self->load_tmpl("modules_with_tags.tmpl",
+        loop_context_vars => 1,
+        global_vars => 1,
+    );
+    my $modules = CPAN::Forum::DB::Tags->get_modules_with_tag($value);
+    $t->param(tag => $value);
+    $t->param(modules => $modules);
+    return $t->output; 
+    
+}
+
 1;
 
 

Added: trunk/templates/modules_with_tags.tmpl
===================================================================
--- trunk/templates/modules_with_tags.tmpl	                        (rev 0)
+++ trunk/templates/modules_with_tags.tmpl	2007-07-03 21:04:08 UTC (rev 241)
@@ -0,0 +1,10 @@
+<TMPL_INCLUDE NAME="head.tmpl">
+<p id="pageTitle"><b>Modules with tag <TMPL_VAR tag></b></p>
+<TMPL_INCLUDE NAME="navigation.tmpl">
+<TMPL_INCLUDE NAME="links.tmpl">
+
+<TMPL_LOOP modules>
+<a href="/dist/<TMPL_VAR name>"><TMPL_VAR name></a> <TMPL_VAR cnt><br />
+</TMPL_LOOP>
+
+<TMPL_INCLUDE NAME="footer.tmpl">

Modified: trunk/templates/tags.tmpl
===================================================================
--- trunk/templates/tags.tmpl	2007-07-03 21:03:35 UTC (rev 240)
+++ trunk/templates/tags.tmpl	2007-07-03 21:04:08 UTC (rev 241)
@@ -1,7 +1,6 @@
 <TMPL_INCLUDE NAME="head.tmpl">
 <p id="pageTitle"><b>Tags</b></p>
 <TMPL_INCLUDE NAME="navigation.tmpl">
-<TMPL_INCLUDE NAME="search_form.tmpl">
 <TMPL_INCLUDE NAME="links.tmpl">
 
 <TMPL_LOOP tags>



More information about the Cpan-forum-commit mailing list