[vhffs-dev] [1746] No more HTML::Template in pgsql/create.

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


Revision: 1746
Author:   beuss
Date:     2011-05-15 15:44:07 +0200 (Sun, 15 May 2011)
Log Message:
-----------
No more HTML::Template in pgsql/create.

Modified Paths:
--------------
    trunk/vhffs-panel/pgsql/create.pl
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/pgsql/create.tt

Removed Paths:
-------------
    trunk/vhffs-panel/templates/pgsql/create.tmpl

Modified: trunk/vhffs-panel/pgsql/create.pl
===================================================================
--- trunk/vhffs-panel/pgsql/create.pl	2011-05-15 13:44:00 UTC (rev 1745)
+++ trunk/vhffs-panel/pgsql/create.pl	2011-05-15 13:44:07 UTC (rev 1746)
@@ -40,12 +40,10 @@
 use Encode;
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
 use Vhffs::Group;
-use Vhffs::Main;
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Group;
+use Vhffs::Services::Pgsql;
+use Vhffs::Panel::Pgsql;
 
 my $panel = new Vhffs::Panel::Main();
 exit 0 unless $panel;
@@ -59,20 +57,16 @@
 my $group = Vhffs::Group::get_by_groupname( $vhffs , $cgi->param('group') );
 
 unless( defined $group && $user->can_modify( $group ) ) {
-	my $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this (ACL rights)' ) );
-
-	$panel->build( $template );
-	$panel->display;
-}
-else  {
+    $panel->render('misc/message.tt', { message => gettext( 'You\'re not allowed to do this (ACL rights)' ) } );
+} else {
 	my $submitted = defined($cgi->param('pgsql_submit'));
 	my $dbsuffix = '';
 	my $description = '';
 	my $dbpass = '';
+    my $vars = {};
 
 	if( $submitted ) {
-		$dbsuffix = $dbsuffix = $cgi->param('db_suffix');
+	    $dbsuffix = $cgi->param('db_suffix');
 		my $dbname = $group->get_groupname.'_'.$dbsuffix;
 		my $dbuser = $dbname;
 		$dbpass = $cgi->param('db_pass');
@@ -92,26 +86,12 @@
 		} else {
 			$panel->add_error( 'An error occured while creating the object.' );
 		}
+        $vars->{db_suffix} = $dbsuffix;
+        $vars->{description} = $description;
 	}
 
-	if( !$submitted || $panel->has_errors() ) {
-		my $template = new HTML::Template( filename => $templatedir.'/panel/pgsql/create.tmpl' );
 
-		$panel->set_title( gettext('Create a PostgreSQL database') );
-
-		$template->param( INFOS => sprintf( gettext('The database name is prefixed by your groupname followed by an underscore (%s_dbname). The database user is the database full name (%s_dbname).') , $group->get_groupname, $group->get_groupname) );
-		$template->param( GROUP_NAME => gettext("Group owning this database") );
-		$template->param( DB_PREFIX => $group->get_groupname.'_' );
-		$template->param( DB_SUFFIX => gettext("PostgreSQL database name ") );
-		$template->param( DB_SUFFIX_VALUE => $dbsuffix );
-		$template->param( DB_PASS => gettext("PostgreSQL password for this database ") );
-		# CAN'T HTML::Template RENDER A SIMPLE ARRAY?! THIS SIMPLY SUCKS!
-		$template->param( GROUP => $group->get_groupname );
-		$template->param( SEND => gettext("Send") );
-		$template->param( DESCRIPTION => gettext("Description") );
-		$template->param( DESCRIPTION_VALUE => $description );
-
-		$panel->build( $template );
-		$panel->display;
-	}
+    $panel->set_title( gettext('Create a PostgreSQL database') );
+    $vars->{group} = $group;
+    $panel->render('pgsql/create.tt', $vars);
 }

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-15 13:44:00 UTC (rev 1745)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-15 13:44:07 UTC (rev 1746)
@@ -91,7 +91,6 @@
 	misc/resubmit.tmpl \
 	mysql/create.tmpl \
 	mysql/prefs.tmpl \
-	pgsql/create.tmpl \
 	pgsql/prefs.tmpl \
 	git/create.tmpl \
 	git/prefs.tmpl \
@@ -131,6 +130,7 @@
 	misc/service-index.tt \
 	misc/welcome.tt \
 	object/delete.tt \
+	pgsql/create.tt \
 	repository/create.tt \
 	repository/prefs.tt \
 	svn/create.tt \

Deleted: trunk/vhffs-panel/templates/pgsql/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/pgsql/create.tmpl	2011-05-15 13:44:00 UTC (rev 1745)
+++ trunk/vhffs-panel/templates/pgsql/create.tmpl	2011-05-15 13:44:07 UTC (rev 1746)
@@ -1,31 +0,0 @@
-<form method="post" action="#" class="largeLabel" accept-charset="utf-8">
-    <p class="info"><TMPL_VAR ESCAPE=1 NAME="INFOS"></p>
-	<p>
-		<label>		
-			<TMPL_VAR ESCAPE=1 NAME="GROUP_NAME">: 
-		</label>
-		<TMPL_VAR ESCAPE=1 NAME="GROUP">
-	</p>
-	<p>
-        <label for="db_suffix">
-            <TMPL_VAR ESCAPE=1 NAME="DB_SUFFIX">: 
-        </label>
-		<TMPL_VAR ESCAPE=1 NAME="DB_PREFIX"><input type="text" name="db_suffix" id="db_suffix" value="<TMPL_VAR ESCAPE=1 NAME="DB_SUFFIX_VALUE">"/>
-	</p>
-	<p>
-		<label for="db_pass">
-			<TMPL_VAR ESCAPE=1 NAME="DB_PASS">: 
-		</label>
-		<input type="password" name="db_pass" id="db_pass"/>
-	</p>
-	<p>
-		<label for="description">
-			<TMPL_VAR ESCAPE=1 NAME="DESCRIPTION">:
-		</label>
-		<textarea name="description" id="description" cols="45" rows="7"><TMPL_VAR ESCAPE=1 NAME="DESCRIPTION_VALUE"></textarea>
-	</p>
-	<p class="button" id="buttonSend">
-		<input type="hidden" name="group" value="<TMPL_VAR ESCAPE=1 NAME="GROUP">" />
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="SEND">" name="pgsql_submit"/>
-	</p>
-</form>

Added: trunk/vhffs-panel/templates/pgsql/create.tt
===================================================================
--- trunk/vhffs-panel/templates/pgsql/create.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/pgsql/create.tt	2011-05-15 13:44:07 UTC (rev 1746)
@@ -0,0 +1,23 @@
+<form method="post" action="#" class="largeLabel" accept-charset="utf-8">
+    <p class="info">[% 'The database name is prefixed by your groupname followed by an underscore (%s_dbname). The database user is the database full name (%s_dbname).' | i18n | pretty_print(group.get_groupname, group.get_groupname) | html %]</p>
+	<p>
+		<label>[% 'Group owning this database:' | i18n | html %]</label>
+		[% group.get_groupname | html %]
+	</p>
+	<p>
+        <label for="db_suffix">[% 'PostgreSQL database name:' | i18n | html %]</label>
+		[% group.get_groupname | html %]_<input type="text" name="db_suffix" id="db_suffix" value="[% db_suffix | html %]"/>
+	</p>
+	<p>
+		<label for="db_pass">[% 'PostgreSQL password for this database:' | i18n | html %]</label>
+		<input type="password" name="db_pass" id="db_pass"/>
+	</p>
+	<p>
+		<label for="description">[% 'Description:' | i18n | html %]</label>
+		<textarea name="description" id="description" cols="45" rows="7">[% description | html %]</textarea>
+	</p>
+	<p class="button" id="buttonSend">
+		<input type="hidden" name="group" value="[% group.get_groupname | html %]" />
+		<input type="submit" value="[% 'Send' | i18n | html %]" name="pgsql_submit"/>
+	</p>
+</form>


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