[vhffs-dev] [1754] Use common template for databases preferences.

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


Revision: 1754
Author:   beuss
Date:     2011-05-16 08:14:55 +0200 (Mon, 16 May 2011)
Log Message:
-----------
Use common template for databases preferences.

BUT as usual: "No more HTML::Template in mysql/prefs.pl"

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

Added Paths:
-----------
    trunk/vhffs-panel/templates/database/
    trunk/vhffs-panel/templates/database/prefs.tt

Removed Paths:
-------------
    trunk/vhffs-panel/templates/mysql/prefs.tmpl
    trunk/vhffs-panel/templates/pgsql/prefs.tt

Modified: trunk/vhffs-panel/mysql/prefs.pl
===================================================================
--- trunk/vhffs-panel/mysql/prefs.pl	2011-05-16 06:14:47 UTC (rev 1753)
+++ trunk/vhffs-panel/mysql/prefs.pl	2011-05-16 06:14:55 UTC (rev 1754)
@@ -32,7 +32,6 @@
 
 use utf8;
 use POSIX qw(locale_h);
-use HTML::Template;
 use locale;
 use Locale::gettext;
 use CGI;
@@ -40,13 +39,8 @@
 use strict;
 
 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::Object;
-use Vhffs::Panel::Template;
 use Vhffs::Services::Mysql;
 
 my $panel = new Vhffs::Panel::Main();
@@ -66,63 +60,25 @@
 my $template;
 
 
-unless( defined $dbname )
-{
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'CGI Error !' ) );
-}
-elsif( ! defined($mysql) )
-{
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext('Cannot get informations on this object') );
-}
-elsif( !$user->can_view( $mysql ) )
-{
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
-}
-else
-{
-
+unless( defined $dbname ) {
+    $panel->render('misc/message.tt', { message => gettext( 'CGI Error !' ) } );
+} elsif( ! defined($mysql) ) {
+    $panel->render('misc/message.tt', { message => gettext('Cannot get informations on this object') } );
+} elsif( !$user->can_view( $mysql ) ) {
+    $panel->render('misc/message.tt', { message => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) } );
+} else {
     if(defined($cgi->param('save_prefs_submit'))) {
-        if(save_prefs()) {
-        # If successful, save_prefs issues a redirect.
-            exit;
-        }
+        save_prefs();
     }
-	$template = new Vhffs::Panel::Template( filename => $templatedir."/panel/mysql/prefs.tmpl" );
+    my $vars = {
+        db => $mysql,
+        type => 'mysql'
+    };
 
 	$panel->set_title( gettext("MySQL Administration") );
-
-	$template->param( TEXT_DBNAME => gettext("Name of the database") );
-	$template->param( VALUE_DBNAME => $mysql->get_dbname );
-
-	$template->param( TEXT_DBUSER => gettext("Username for this database") );
-	$template->param( VALUE_DBUSER => $mysql->get_dbname );
-
-	$template->param( TEXT_DBPASS => gettext("Password for this database") );
-	#$template->param( VALUE_DBPASS => $mysql->get_dbpassword );
-
-	$template->param( VALUE_OID => $mysql->get_oid );
-	$template->param( TEXT_ACL_ADMIN => gettext("Admin Rights on this object (ACL)") );
-	$template->param( EXPLAIN_ADMIN_ACL => gettext("You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it.") );
-	$template->param( ADMIN_ACL => gettext("Ok, go to ACL admin") );
-
-	$template->param( TEXT_SEND => gettext("Modify") );
-	$template->param( TEXT_DELETE_MYSQL => gettext("Delete this database") );
-	$template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. This MySQL database will be DESTROYED.") );
-	$template->param( ASK_DELETE_MYSQL => gettext("Are you SURE you want DELETE this MySQL database ?") );
-	$template->param( YES => gettext("Yes I'm sure of what I do") );
-	$template->param( NO => gettext("No, I'm not sure, I prefer to keep this project.") );
-	$template->param( TEXT_DELETE => gettext("Delete") );
-
-	my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $mysql );
-	$template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+    $panel->render('database/prefs.tt', $vars);
 }
 
-$panel->build( $template );
-$panel->display;
-
 sub save_prefs {
     if(!$user->can_modify($mysql)) {
         $panel->add_error( gettext('You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights') );

Modified: trunk/vhffs-panel/pgsql/prefs.pl
===================================================================
--- trunk/vhffs-panel/pgsql/prefs.pl	2011-05-16 06:14:47 UTC (rev 1753)
+++ trunk/vhffs-panel/pgsql/prefs.pl	2011-05-16 06:14:55 UTC (rev 1754)
@@ -69,10 +69,11 @@
     }
 
     my $vars = {
-        db => $pgsql
+        db => $pgsql,
+        type => 'pgsql'
     };
 	$panel->set_title( gettext("PostgreSQL Administration") );
-    $panel->render('pgsql/prefs.tt', $vars);
+    $panel->render('database/prefs.tt', $vars);
 }
 
 sub save_prefs {

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-16 06:14:47 UTC (rev 1753)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-16 06:14:55 UTC (rev 1754)
@@ -88,7 +88,6 @@
 	misc/infos.tmpl \
 	misc/service_index.tmpl \
 	misc/simplemsg.tmpl \
-	mysql/prefs.tmpl \
 	git/create.tmpl \
 	git/prefs.tmpl \
 	mercurial/create.tmpl \
@@ -105,6 +104,7 @@
 	anonymous/lost-password.tt \
 	anonymous/lost-password-ack.tt \
 	anonymous/subscribe.tt \
+	database/prefs.tt \
 	group/create.tt \
 	group/index.tt \
 	group/info.tt \
@@ -130,7 +130,6 @@
 	object/delete.tt \
 	object/resubmit.tt \
 	pgsql/create.tt \
-	pgsql/prefs.tt \
 	repository/create.tt \
 	repository/prefs.tt \
 	svn/create.tt \

Copied: trunk/vhffs-panel/templates/database/prefs.tt (from rev 1753, trunk/vhffs-panel/templates/pgsql/prefs.tt)
===================================================================
--- trunk/vhffs-panel/templates/database/prefs.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/database/prefs.tt	2011-05-16 06:14:55 UTC (rev 1754)
@@ -0,0 +1,30 @@
+<form method="post" action="/[% type | html %]/prefs.pl" accept-charset="utf-8">
+	<p>
+		<label>[% 'Name of the database:' | i18n | html %]</label>
+		[% db.get_dbname | html %]
+	</p>
+	<p>
+		<label>[% 'Username for this database:' | i18n | html %]</label>
+        [% db.get_dbusername | html %]
+	</p>
+    <p class="info">[% 'Warning, password change isn\'t immediate, you\'ve to check periodically to see if it\'s done' | i18n | html %]</p>
+	<p>
+		<label for="newpassword">[% 'Password for this database:' | i18n | html %]</label>
+		<input type="password" name="newpassword" id="newpassword" value=""/>
+	</p>
+	<p class="button">
+        <input type="hidden" name="name" value="[% db.get_dbname | html %]"/>
+		<input type="submit" value="[% 'Update' | i18n | html %]" name="save_prefs_submit"/>
+	</p>
+</form>
+
+[% INCLUDE 'acl/form.tt' 
+    object = db %]
+
+[% INCLUDE 'object/delete.tt'
+    oid = db.get_oid %]
+
+[% IF current_user.is_admin %]
+    [% INCLUDE 'admin/object/edit.tt' 
+        object = db %]
+[% END %]

Deleted: trunk/vhffs-panel/templates/mysql/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/mysql/prefs.tmpl	2011-05-16 06:14:47 UTC (rev 1753)
+++ trunk/vhffs-panel/templates/mysql/prefs.tmpl	2011-05-16 06:14:55 UTC (rev 1754)
@@ -1,75 +0,0 @@
-<fieldset>
-<legend><TMPL_I18N KEY="Options"></legend>
-<form method="post" action="/mysql/prefs.pl" accept-charset="utf-8">
-	<p>
-		<label for="name">
-			<TMPL_VAR ESCAPE=1 NAME="TEXT_DBNAME"> :
-		</label>
-		<TMPL_VAR ESCAPE=1 NAME="VALUE_DBNAME">
-		<input type="hidden" name="name" id="name" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_DBNAME">"/>
-	</p>
-	<p>
-		<label for="DBUSER">
-			<TMPL_VAR ESCAPE=1 NAME="TEXT_DBUSER"> :
-		</label>
-		<TMPL_VAR ESCAPE=1 NAME="VALUE_DBUSER">
-		<input type="hidden" name="DBUSER" id="DBUSER" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_DBUSER">"/>
-	</p>
-	<p class="info">
-        <TMPL_I18N KEY="Warning, password change isn't immediate, you've to check periodically to see if it's done">
-	</p>
-	<p>
-		<label for="newpassword">
-			<TMPL_VAR ESCAPE=1 NAME="TEXT_DBPASS"> :
-		</label>
-		<input type="password" name="newpassword" id="newpassword" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_DBPASS">"/>
-	</p>
-	<p class="button">
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_SEND">" name="save_prefs_submit"/>
-	</p>
-</form>
-</fieldset>
-
-<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_ADMIN"></h2>
-		
-<form method="post" action="../acl/view.pl" accept-charset="utf-8">
-	<p><TMPL_VAR ESCAPE=1 NAME="EXPLAIN_ADMIN_ACL"></p>
-
-	<input type="hidden" name="target_oid" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_OID">" />
-	<p class="button" id="buttonAclAdmin">
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="ADMIN_ACL">" />
-	</p>
-</form>
-
-
-<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE_MYSQL"></h2>
-
-<form method="post" action="delete.pl" accept-charset="utf-8">
-	<fieldset class="delete">
-		<legend>
-			<TMPL_VAR ESCAPE=1 NAME="ASK_DELETE_MYSQL">:
-		</legend>
-
-		<p class="warning"><TMPL_VAR ESCAPE=1 NAME="TEXT_BEFORE_DELETE"></p>
-		<p>
-			<input type="radio" name="DELETE" id="DELETE_NO"  value="0" checked="checked" />
-			<label for="DELETE_NO">
-				<TMPL_VAR ESCAPE=1 NAME="NO">
-			</label>
-		</p>
-		<p>
-			<input type="radio" name="DELETE" id="DELETE_YES" value="1" />
-			<label for="DELETE_YES">
-				<TMPL_VAR ESCAPE=1 NAME="YES">
-			</label>
-		</p>
-	</fieldset>
-	
-	<p class="button" id="buttonDelete">
-		<input type="hidden" name="DBNAME" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_DBNAME">" />
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE">" />
-	</p>
-				
-</form>
-
-<TMPL_VAR ESCAPE=0 NAME="ADMIN_PART">

Deleted: trunk/vhffs-panel/templates/pgsql/prefs.tt
===================================================================
--- trunk/vhffs-panel/templates/pgsql/prefs.tt	2011-05-16 06:14:47 UTC (rev 1753)
+++ trunk/vhffs-panel/templates/pgsql/prefs.tt	2011-05-16 06:14:55 UTC (rev 1754)
@@ -1,31 +0,0 @@
-<form method="post" action="/pgsql/prefs.pl" accept-charset="utf-8">
-	<p>
-		<label>[% 'Name of the database:' | i18n | html %]</label>
-		[% db.get_dbname | html %]
-	</p>
-	<p>
-		<label>[% 'Username for this database:' | i18n | html %]</label>
-        [% db.get_dbusername | html %]
-	</p>
-    <p class="info">[% 'Warning, password change isn\'t immediate, you\'ve to check periodically to see if it\'s done' | i18n | html %]</p>
-	<p>
-		<label for="newpassword">[% 'Password for this database:' | i18n | html %]</label>
-		<input type="password" name="newpassword" id="newpassword" value=""/>
-	</p>
-	<p class="button">
-        <input type="hidden" name="name" value="[% db.get_dbname | html %]"/>
-		<input type="submit" value="[% 'Update' | i18n | html %]" name="save_prefs_submit"/>
-	</p>
-</form>
-
-[% INCLUDE 'acl/form.tt' 
-    object = db %]
-
-[% INCLUDE 'object/delete.tt'
-    type = 'pgsql'
-    oid = db.get_oid %]
-
-[% IF current_user.is_admin %]
-    [% INCLUDE 'admin/object/edit.tt' 
-        object = db %]
-[% END %]


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