[vhffs-dev] [1807] No more HTML::Template in git/list

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


Revision: 1807
Author:   beuss
Date:     2011-05-25 08:11:42 +0200 (Wed, 25 May 2011)
Log Message:
-----------
No more HTML::Template in git/list

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Git.pm
    trunk/vhffs-panel/admin/git/list.pl
    trunk/vhffs-panel/templates/Makefile.am

Removed Paths:
-------------
    trunk/vhffs-panel/templates/admin/git/part.tmpl

Modified: trunk/vhffs-api/src/Vhffs/Panel/Git.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Git.pm	2011-05-24 06:13:28 UTC (rev 1806)
+++ trunk/vhffs-api/src/Vhffs/Panel/Git.pm	2011-05-25 06:11:42 UTC (rev 1807)
@@ -95,28 +95,22 @@
 sub search {
     my ($main, $name) = @_;
 
-    my $sql;
     my @params;
-    my $gits = [];
+    my $sql = 'SELECT git.reponame as label, g.groupname as owner_group, o.state, u.username as owner_user '.
+        'FROM vhffs_git git '.
+        'INNER JOIN vhffs_object o ON (o.object_id = git.object_id) '.
+        'INNER JOIN vhffs_groups g ON (g.gid = o.owner_gid) '.
+        'INNER JOIN vhffs_users u ON (u.uid = o.owner_uid) ';
 
     if( defined $name ) {
-        $sql = 'SELECT s.reponame AS gitroot, g.groupname, o.state FROM vhffs_git s INNER JOIN vhffs_object o ON o.object_id=s.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE s.reponame LIKE ?';
+        $sql .= 'WHERE git.reponame LIKE ? ';
         push(@params, '%'.lc($name).'%');
-    } else {
-        $sql = 'SELECT s.reponame AS gitroot, g.groupname, o.state FROM vhffs_git s INNER JOIN vhffs_object o ON o.object_id=s.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid';
     }
 
-    my $dbh = $main->get_db_object();
-    my $sth = $dbh->prepare($sql) or return undef;
+    $sql .= 'ORDER BY git.reponame';
 
-    return undef unless($sth->execute(@params));
-
-    while(my $s = $sth->fetchrow_hashref('NAME_lc')) {
-        $s->{state} = Vhffs::Functions::status_string_from_status_id($s->{state});
-        push(@$gits, $s);
-    }
-
-    return $gits;
+    my $dbh = $main->get_db_object();
+    return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 

Modified: trunk/vhffs-panel/admin/git/list.pl
===================================================================
--- trunk/vhffs-panel/admin/git/list.pl	2011-05-24 06:13:28 UTC (rev 1806)
+++ trunk/vhffs-panel/admin/git/list.pl	2011-05-25 06:11:42 UTC (rev 1807)
@@ -32,7 +32,6 @@
 
 use strict;
 use utf8;
-use HTML::Template;
 use Locale::gettext;
 
 use lib '%VHFFS_LIB_DIR%';
@@ -45,47 +44,18 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $user = $panel->{'user'};
 my $cgi = $panel->{'cgi'};
-my $templatedir = $panel->{'templatedir'};
-my $template;
+my $name = $cgi->param('NAME');
+my $vars = {
+    type => 'git'
+};
 
-if( ($user->is_moderator != 1 ) && ( $user->is_admin != 1 ) )
-{
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext('You are not allowed to see it') );
+if( defined( $name ) ) {
+    $vars->{list_title} = sprintf( gettext('Search result for git repository %s'), $name );
+} else {
+    $vars->{list_title} = gettext('All git repositories list');
 }
-else
-{
-	$template = new HTML::Template( filename => $templatedir.'/panel/admin/misc/list.tmpl' );
-	my $name = $cgi->param('NAME');
 
-	if( defined( $name ) )
-	{
-		$template->param( TITLE => gettext('Search result for git repository').': '.$name );
-	}
-	else
-	{
-		$template->param( TITLE => gettext('All git repositories lists') );
-	}
-
-	$template->param(TEXT_TITLE1 => gettext('GIT root'));
-	$template->param(TEXT_TITLE2 => gettext('Group'));
-	$template->param(TEXT_TITLE3 => gettext('State'));
-
-	my $repos = Vhffs::Panel::Git::search( $vhffs, $name );
-	if( defined $repos )
-	{
-		my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/admin/git/part.tmpl', global_vars => 1 );
-		if( $user->is_admin == 1 )  {
-			$subtemplate->param( ACTION => gettext('Modify') );
-		}  else  {
-			$subtemplate->param( ACTION => gettext('Show') );
-		}
-		$subtemplate->param( GITREPOS => $repos);
-		$template->param( LIST => $subtemplate->output );
-	}
-}
-
-$panel->build( $template );
-$panel->display;
+$vars->{label_title} = gettext('GIT root');
+$vars->{list} = Vhffs::Panel::Git::search( $vhffs, $name );
+$panel->render('admin/misc/list.tt', $vars);

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-24 06:13:28 UTC (rev 1806)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-25 06:11:42 UTC (rev 1807)
@@ -40,7 +40,6 @@
 	admin/tag/category/list.tmpl \
 	admin/tag/request/details.tmpl \
 	admin/tag/request/list.tmpl \
-	admin/git/part.tmpl \
 	admin/git/search.tmpl \
 	admin/mercurial/search.tmpl \
 	admin/user/part.tmpl \

Deleted: trunk/vhffs-panel/templates/admin/git/part.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/git/part.tmpl	2011-05-24 06:13:28 UTC (rev 1806)
+++ trunk/vhffs-panel/templates/admin/git/part.tmpl	2011-05-25 06:11:42 UTC (rev 1807)
@@ -1,16 +0,0 @@
-<TMPL_LOOP NAME="GITREPOS">
-<tr>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="GITROOT">
-	</td>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="GROUPNAME"> 
-	</td>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="STATE"> 
-	</td>
-	<td>
-		<a href="/git/prefs.pl?admin_menu=1&amp;name=<TMPL_VAR ESCAPE=1 NAME="GITROOT">"><TMPL_VAR ESCAPE=1 NAME="ACTION"></a>
-	</td>
-</tr>
-</TMPL_LOOP>


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