[Cpan-forum-commit] rev 319 - in trunk: . lib/CPAN/Forum/DB lib/CPAN/Forum/RM templates
svn at pti.co.il
svn at pti.co.il
Sun Aug 5 07:12:42 EEST 2007
Author: gabor
Date: 2007-08-05 07:12:42 +0300 (Sun, 05 Aug 2007)
New Revision: 319
Modified:
trunk/
trunk/lib/CPAN/Forum/DB/Tags.pm
trunk/lib/CPAN/Forum/RM/Tags.pm
trunk/templates/stats.tmpl
trunk/templates/tags.tmpl
Log:
link stats to pages showing the tags of the individual user
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4379
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
+ 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4380
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-08-05 04:12:25 UTC (rev 318)
+++ trunk/lib/CPAN/Forum/DB/Tags.pm 2007-08-05 04:12:42 UTC (rev 319)
@@ -89,7 +89,18 @@
";
return $self->_fetch_arrayref_of_hashes($sql);
}
+sub get_tags_of_user {
+ my ($self, $username) = @_;
+ my $sql = "SELECT tags.name name, COUNT(name) total
+ FROM tags, tag_cloud, users
+ WHERE tag_cloud.tag_id=tags.id AND tag_cloud.uid=users.id AND users.username=?
+ GROUP BY name
+ ORDER BY name ASC
+ ";
+ return $self->_fetch_arrayref_of_hashes($sql, $username);
+}
+
sub get_modules_with_tag {
my ($self, $tag_name) = @_;
Modified: trunk/lib/CPAN/Forum/RM/Tags.pm
===================================================================
--- trunk/lib/CPAN/Forum/RM/Tags.pm 2007-08-05 04:12:25 UTC (rev 318)
+++ trunk/lib/CPAN/Forum/RM/Tags.pm 2007-08-05 04:12:42 UTC (rev 319)
@@ -16,20 +16,35 @@
$self->log->debug("tags path='$path' value='$value'");
if ($path eq 'name' and $value) {
return $self->_list_modules_with_tag($value);
+ } elsif ($path eq 'user' and $value) {
+ my $tags = CPAN::Forum::DB::Tags->get_tags_of_user($value); # SQL
+ return $self->_list_tags($tags, {user_name => $value});
+ } else {
+ my $tags = CPAN::Forum::DB::Tags->get_all_tags(); # SQL
+ return $self->_list_tags($tags);
}
+}
+sub _list_tags {
+ my ($self, $tags, $params) = @_;
+
my $t = $self->load_tmpl("tags.tmpl",
loop_context_vars => 1,
global_vars => 1,
);
- my $tags = CPAN::Forum::DB::Tags->get_all_tags(); # SQL
+ my $tag_count = 0;
# maximize tag size to 24
foreach my $t (@$tags) {
+ #$tag_count += $t->{total};
$t->{total} = 24 if $t->{total} > 24;
}
$t->param(tags => $tags);
+ #$t->param(tag_count => $tag_count);
+ if ($params) {
+ $t->param(%$params);
+ }
return $t->output;
}
Modified: trunk/templates/stats.tmpl
===================================================================
--- trunk/templates/stats.tmpl 2007-08-05 04:12:25 UTC (rev 318)
+++ trunk/templates/stats.tmpl 2007-08-05 04:12:42 UTC (rev 319)
@@ -37,7 +37,7 @@
<p class="about_title">Top <TMPL_VAR tagging_users_cnt> taggers</p>
<table>
<TMPL_LOOP tagging_users>
- <tr><td><a href="/users/<TMPL_VAR username>"><TMPL_VAR username></a></td><td><TMPL_VAR cnt></td></tr>
+ <tr><td><a href="/tags/user/<TMPL_VAR username>"><TMPL_VAR username></a></td><td><TMPL_VAR cnt></td></tr>
</TMPL_LOOP>
</table>
</div>
Modified: trunk/templates/tags.tmpl
===================================================================
--- trunk/templates/tags.tmpl 2007-08-05 04:12:25 UTC (rev 318)
+++ trunk/templates/tags.tmpl 2007-08-05 04:12:42 UTC (rev 319)
@@ -2,6 +2,10 @@
<p id="pageTitle"><b>Tags</b></p>
<TMPL_INCLUDE NAME="navigation.tmpl">
+<TMPL_IF user_name>
+Tags of user <a href="/user/<TMPL_VAR user_name>"><TMPL_VAR user_name></a>
+</TMPL_IF>
+<!--Number of tags: <TMPL_VAR tag_count><br />-->
<div id="htmltagcloud">
<TMPL_LOOP tags>
<span class="tagcloud<TMPL_VAR total>"><a href="/tags/name/<TMPL_VAR name>"><TMPL_VAR name></a></span><TMPL_UNLESS __last__>, </TMPL_UNLESS>
More information about the Cpan-forum-commit
mailing list