[vhffs-dev] [479] Started to use TMPL_LOOP in templates.

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


Revision: 479
Author:   beuss
Date:     2007-02-17 23:38:12 +0000 (Sat, 17 Feb 2007)

Log Message:
-----------
Started to use TMPL_LOOP in templates. Code is more readable.

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-panel/admin/cvs/list.pl
    branches/vhffs_4.1/vhffs-panel/admin/dns/list.pl
    branches/vhffs_4.1/vhffs-panel/admin/mail/list.pl
    branches/vhffs_4.1/vhffs-panel/templates/admin/cvs/part-modo.tmpl
    branches/vhffs_4.1/vhffs-panel/templates/admin/cvs/part.tmpl
    branches/vhffs_4.1/vhffs-panel/templates/admin/dns/part-modo.tmpl
    branches/vhffs_4.1/vhffs-panel/templates/admin/dns/part.tmpl
    branches/vhffs_4.1/vhffs-panel/templates/admin/mail/part-modo.tmpl
    branches/vhffs_4.1/vhffs-panel/templates/admin/mail/part.tmpl


Modified: branches/vhffs_4.1/vhffs-panel/admin/cvs/list.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/cvs/list.pl	2007-02-17 23:36:59 UTC (rev 478)
+++ branches/vhffs_4.1/vhffs-panel/admin/cvs/list.pl	2007-02-17 23:38:12 UTC (rev 479)
@@ -96,29 +96,33 @@
 
 	if( defined $cvs )
 	{
+        my $cvses;
+        my $cvshash;
+        my $send;
+        my $subtemplate;
+
+        if( $user->is_admin == 1 )  {
+            $subtemplate = new HTML::Template( filename => "$templatesdir/admin/cvs/part.tmpl" );
+            $send = gettext("Modify this CVS repository");
+        }  else  {
+            $subtemplate = new HTML::Template( filename => "$templatesdir/admin/cvs/part-modo.tmpl" );
+            $send = gettext("Show this CVS repository");
+        }
+                                                        
 		foreach $c ( @{$cvs} )
 		{
-			my $subtemplate;
-			if( $user->is_admin == 1 )  {
-				$subtemplate = new HTML::Template( filename => "$templatesdir/admin/cvs/part.tmpl" );
-			}  else  {
-				$subtemplate = new HTML::Template( filename => "$templatesdir/admin/cvs/part-modo.tmpl" );
-			}
+            $cvshash = {
+                CVSROOT => $c->get_cvsroot(),
+                GROUP => $c->get_group->get_groupname(),
+                OID => $c->get_oid(),
+                STATE => gettext( Vhffs::Functions::status_string_from_status_id( $c->get_status ) ),
+                SEND => $send
+            };
 
-			$subtemplate->param( CVSROOT => $c->get_cvsroot );
-			$subtemplate->param( GROUP => $c->get_group->get_groupname );
-			$subtemplate->param( OID => $c->get_oid );
-			$subtemplate->param( STATE => gettext( Vhffs::Functions::status_string_from_status_id( $c->get_status ) ) );
-			
-			if( $user->is_admin == 1 )  {
-				$subtemplate->param( SEND => gettext("Modify this CVS repository") );
-			}  else  {
-				$subtemplate->param( SEND => gettext("Show this CVS repository") );
-			}
-
-			$output .= $subtemplate->output;
+            push(@$cvses, $cvshash);
 		}
-		$template->param( LIST => $output );
+        $subtemplate->param(CVSES => $cvses);
+		$template->param( LIST => $subtemplate->output );
 	}
 	
 

Modified: branches/vhffs_4.1/vhffs-panel/admin/dns/list.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/dns/list.pl	2007-02-17 23:36:59 UTC (rev 478)
+++ branches/vhffs_4.1/vhffs-panel/admin/dns/list.pl	2007-02-17 23:38:12 UTC (rev 479)
@@ -94,43 +94,33 @@
 
 	if( defined $domains )
 	{
-		my $output = "";
+        my $subtemplate;
+        my $send;
+        my $dnses;
+        my $dnshash;
+        if( $user->is_admin == 1 )  {
+            $subtemplate = new HTML::Template( filename => $templatedir."/admin/dns/part.tmpl" );
+            $send = gettext("Modify this domain");
+        }  else  {
+            $subtemplate = new HTML::Template( filename => $templatedir."/admin/dns/part-modo.tmpl" );
+        }
+                                                                 
 		foreach( sort ( keys %{$domains} ) )
 		{
-			my $subtemplate;
+            $dnshash = {
+                DOMAIN => $domains->{$_}{'domain'},
+                GROUP => Vhffs::Group::get_name_by_gid( $vhffs , $domains->{$_}{'owner_gid'} ),
+                STATE => Vhffs::Functions::status_string_from_status_id($domains->{$_}{state})
+            };
 			if( $user->is_admin == 1 )  {
-				$subtemplate = new HTML::Template( filename => $templatedir."/admin/dns/part.tmpl" );
-			}  else  {
-				$subtemplate = new HTML::Template( filename => $templatedir."/admin/dns/part-modo.tmpl" );
+                $dnshash->{OID} = $domains->{$_}{'object_id'};
+                $dnshash->{SEND} = $send;
 			}
-			$subtemplate->param(  DOMAIN => $domains->{$_}{'domain'} ) if( defined $domains->{$_}{'domain'} );
-			$subtemplate->param( GROUP => Vhffs::Group::get_name_by_gid( $vhffs , $domains->{$_}{'owner_gid'} ) ) if( defined $domains->{$_}{'owner_gid'} );
 
-			if( $domains->{$_}{'state'} == Vhffs::Constants::WAITING_FOR_CREATION )
-			{
-				$subtemplate->param( STATE => gettext("Waiting for creation") );
-			}
-			elsif( $domains->{$_}{'state'} == Vhffs::Constants::ACTIVATED )
-			{
-				$subtemplate->param( STATE => gettext("Activated") );
-			}
-			elsif( $domains->{$_}{'state'} == Vhffs::Constants::TO_DELETE )
-			{
-				$subtemplate->param( STATE => gettext("Waiting for delete") );
-			}
-			elsif( $domains->{$_}{'state'} == Vhffs::Constants::WAITING_FOR_VALIDATION )
-			{
-				$subtemplate->param( STATE => gettext("Waiting for validation") );
-			}
-			
-			if( $user->is_admin == 1 )  {
-				$subtemplate->param( OID => $domains->{$_}{'object_id'} ) if( defined $domains->{$_}{'object_id'} );
-				$subtemplate->param( SEND => gettext("Modify this domain") );
-			}
-
-			$output .= $subtemplate->output;
+            push(@$dnses, $dnshash);
 		}
-		$template->param( LIST => $output );
+        $subtemplate->param(DNSES => $dnses);
+		$template->param( LIST => $subtemplate->output );
 	}
 
 

Modified: branches/vhffs_4.1/vhffs-panel/admin/mail/list.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/mail/list.pl	2007-02-17 23:36:59 UTC (rev 478)
+++ branches/vhffs_4.1/vhffs-panel/admin/mail/list.pl	2007-02-17 23:38:12 UTC (rev 479)
@@ -94,32 +94,32 @@
 
     if( defined $mails )
     {
-	my $output = "";
-	foreach( sort ( keys %{$mails} ) )
-	{
-	    my $subtemplate;
-	    if( $user->is_admin == 1 )  {
-		$subtemplate = new HTML::Template( filename => $templatedir."/admin/mail/part.tmpl" );
-	    }  else  {
-		$subtemplate = new HTML::Template( filename => $templatedir."/admin/mail/part-modo.tmpl" );
-	    }
+        my $subtemplate;
+        my $tmplmails;
+        my $mailhash;
+        my $send;
+        if( $user->is_admin == 1 )  {
+            $subtemplate = new HTML::Template( filename => $templatedir."/admin/mail/part.tmpl" );
+            $send = gettext("Modify this mail domain");
+        }  else  {
+            $subtemplate = new HTML::Template( filename => $templatedir."/admin/mail/part-modo.tmpl" );
+            $send = gettext("Show this mail domain");
+        }
 
-	    $subtemplate->param( DOMAIN => $mails->{$_}{'domain'} ) if( defined $mails->{$_}{'domain'} );
-	    $subtemplate->param( GROUP => Vhffs::Group::get_name_by_gid( $vhffs , $mails->{$_}{'owner_gid'} ) ) if( defined $mails->{$_}{'owner_gid'} );
-	    $subtemplate->param( OID => $mails->{$_}{'object_id'} ) if( defined $mails->{$_}{'object_id'} );
+    	foreach( sort ( keys %{$mails} ) )
+    	{
+            $mailhash = {
+                DOMAIN => $mails->{$_}{domain},
+                GROUP => Vhffs::Group::get_name_by_gid($vhffs, $mails->{$_}{owner_uid}),
+                OID => $mails->{$_}{object_id},
+                STATE => Vhffs::Functions::status_string_from_status_id($mails->{$_}{state}),
+                SEND => $send
+            };
 
-	    $subtemplate->param( STATE => Vhffs::Functions::status_string_from_status_id( $mails->{$_}{'state'} ) );
-	    
-	    if( $user->is_admin == 1 )  {
-		$subtemplate->param( SEND => gettext("Modify this mail domain") );
-	    }  else  {
-		$subtemplate->param( SEND => gettext("Show this mail domain") );
-	    }
-
-
-	    $output .= $subtemplate->output;
-	}
-	$template->param( LIST => $output );
+            push(@$tmplmails, $mailhash);
+    	}
+        $subtemplate->param( MAILS => $tmplmails );
+	    $template->param( LIST => $subtemplate->output );
     }
     
 

Modified: branches/vhffs_4.1/vhffs-panel/templates/admin/cvs/part-modo.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/admin/cvs/part-modo.tmpl	2007-02-17 23:36:59 UTC (rev 478)
+++ branches/vhffs_4.1/vhffs-panel/templates/admin/cvs/part-modo.tmpl	2007-02-17 23:38:12 UTC (rev 479)
@@ -1,4 +1,4 @@
-
+<TMPL_LOOP NAME="CVSES">
 <tr>
 	<td>
 		<TMPL_VAR NAME="CVSROOT">
@@ -17,4 +17,4 @@
 		</form>
 	</td>
 </tr>
-
+</TMPL_LOOP>

Modified: branches/vhffs_4.1/vhffs-panel/templates/admin/cvs/part.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/admin/cvs/part.tmpl	2007-02-17 23:36:59 UTC (rev 478)
+++ branches/vhffs_4.1/vhffs-panel/templates/admin/cvs/part.tmpl	2007-02-17 23:38:12 UTC (rev 479)
@@ -1,4 +1,4 @@
-
+<TMPL_LOOP NAME="CVSES">
 <tr>
 	<td>
 		<TMPL_VAR NAME="CVSROOT">
@@ -17,4 +17,4 @@
 		</form>
 	</td>
 </tr>
-
+</TMPL_LOOP>

Modified: branches/vhffs_4.1/vhffs-panel/templates/admin/dns/part-modo.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/admin/dns/part-modo.tmpl	2007-02-17 23:36:59 UTC (rev 478)
+++ branches/vhffs_4.1/vhffs-panel/templates/admin/dns/part-modo.tmpl	2007-02-17 23:38:12 UTC (rev 479)
@@ -1,4 +1,4 @@
-
+<TMPL_LOOP NAME="DNSES">
 <tr>
 	<td>
 		<TMPL_VAR NAME="DOMAIN">
@@ -10,3 +10,4 @@
 		<TMPL_VAR NAME="STATE"> 
 	</td>
 </tr>
+</TMPL_LOOP>

Modified: branches/vhffs_4.1/vhffs-panel/templates/admin/dns/part.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/admin/dns/part.tmpl	2007-02-17 23:36:59 UTC (rev 478)
+++ branches/vhffs_4.1/vhffs-panel/templates/admin/dns/part.tmpl	2007-02-17 23:38:12 UTC (rev 479)
@@ -1,4 +1,4 @@
-
+<TMPL_LOOP NAME="DNSES">
 <tr>
 	<td>
 		<TMPL_VAR NAME="DOMAIN">
@@ -17,4 +17,4 @@
 		</form>
 	</td>
 </tr>
-
+</TMPL_LOOP>

Modified: branches/vhffs_4.1/vhffs-panel/templates/admin/mail/part-modo.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/admin/mail/part-modo.tmpl	2007-02-17 23:36:59 UTC (rev 478)
+++ branches/vhffs_4.1/vhffs-panel/templates/admin/mail/part-modo.tmpl	2007-02-17 23:38:12 UTC (rev 479)
@@ -1,4 +1,4 @@
-
+<TMPL_LOOP NAME="MAILS">
 <tr>
 	<td>
 		<TMPL_VAR NAME="DOMAIN">
@@ -17,4 +17,4 @@
 		</form>
 	</td>
 </tr>
-
+</TMPL_LOOP>

Modified: branches/vhffs_4.1/vhffs-panel/templates/admin/mail/part.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/admin/mail/part.tmpl	2007-02-17 23:36:59 UTC (rev 478)
+++ branches/vhffs_4.1/vhffs-panel/templates/admin/mail/part.tmpl	2007-02-17 23:38:12 UTC (rev 479)
@@ -1,4 +1,4 @@
-
+<TMPL_LOOP NAME="MAILS">
 <tr>
 	<td>
 		<TMPL_VAR NAME="DOMAIN">
@@ -17,4 +17,4 @@
 		</form>
 	</td>
 </tr>
-
+</TMPL_LOOP>


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