[vhffs-dev] [1748] No more HTML::Template in pgsql/prefs.pl

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


Revision: 1748
Author:   beuss
Date:     2011-05-15 16:54:25 +0200 (Sun, 15 May 2011)
Log Message:
-----------
No more HTML::Template in pgsql/prefs.pl

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

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

Removed Paths:
-------------
    trunk/vhffs-panel/pgsql/delete.pl
    trunk/vhffs-panel/templates/pgsql/prefs.tmpl

Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am	2011-05-15 14:54:18 UTC (rev 1747)
+++ trunk/vhffs-panel/Makefile.am	2011-05-15 14:54:25 UTC (rev 1748)
@@ -901,7 +901,6 @@
 	object/resubmit.pl \
 	object/quickdelete.pl \
 	pgsql/create.pl \
-	pgsql/delete.pl \
 	pgsql/index.pl \
 	pgsql/prefs.pl \
 	repository/create.pl \

Deleted: trunk/vhffs-panel/pgsql/delete.pl
===================================================================
--- trunk/vhffs-panel/pgsql/delete.pl	2011-05-15 14:54:18 UTC (rev 1747)
+++ trunk/vhffs-panel/pgsql/delete.pl	2011-05-15 14:54:25 UTC (rev 1748)
@@ -1,106 +0,0 @@
-#!%PERL% -w
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-
-use utf8;
-use POSIX qw(locale_h);
-use HTML::Template;
-use locale;
-use Locale::gettext;
-use CGI;
-use CGI::Session;
-use strict;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Main;
-use Vhffs::Group;
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Group;
-use Vhffs::Services::Pgsql;
-
-my $panel = new Vhffs::Panel::Main();
-exit 0 unless $panel;
-my $session = $panel->get_session;
-exit 0 unless $session;
-
-my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
-my $user = $panel->{'user'};
-my $cgi = $panel->{'cgi'};
-my $message;
-my $owner = $cgi->param("PROJECT_OWNER");
-my $sure = $cgi->param("DELETE");
-
-my $dbname = $cgi->param("DBNAME");
-
-my $pgsql = Vhffs::Services::Pgsql::get_by_dbname( $vhffs , $dbname );
-
-my $templatedir = $vhffs->get_config->get_templatedir;
-
-if ( ! defined( $pgsql ) )
-{
-    $message = gettext("This DB doesn't exist in VHFFS database");
-}
-elsif( !$user->can_delete( $pgsql ) )
-{
-	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
-}
-elsif( ! defined $sure )
-{
-	$message = gettext("CGI Error !");
-}
-elsif( $sure == 0 )
-{
-	$message = gettext( "Database will NOT be deleted !" );
-}
-else
-{
-	$pgsql->set_status( Vhffs::Constants::TO_DELETE );
-
-	if( $pgsql->commit < 0 )
-	{
-		$message = gettext( "This database cannot be deleted" );
-	}
-	else
-	{
-		$message = gettext( "Database will be DELETE" );
-	}
-}
-
-
-my $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-$template->param( MESSAGE => $message );
-
-$panel->set_refresh_url( "/pgsql/prefs.pl?name=$dbname" );
-$panel->build( $template );
-$panel->display;

Modified: trunk/vhffs-panel/pgsql/prefs.pl
===================================================================
--- trunk/vhffs-panel/pgsql/prefs.pl	2011-05-15 14:54:18 UTC (rev 1747)
+++ trunk/vhffs-panel/pgsql/prefs.pl	2011-05-15 14:54:25 UTC (rev 1748)
@@ -39,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::Pgsql;
 
 my $panel = new Vhffs::Panel::Main();
@@ -65,52 +60,21 @@
 my $template;
 
 unless( defined $pgsql ) {
-	my $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'Cannot get informations on this object') );
+    $panel->render('misc/message.tt', { message => gettext( 'Cannot get informations on this object') });
 } elsif( !$user->can_view( $pgsql ) ) {
-	$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' ) );	
+    $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'))) {
-        # save_prefs issues a redirect on success
-        if(&save_prefs()) {
-            #exit;
-        }
+        save_prefs();
     }
 
-	$template = new Vhffs::Panel::Template( filename => $templatedir."/panel/pgsql/prefs.tmpl" );
-
+    my $vars = {
+        db => $pgsql
+    };
 	$panel->set_title( gettext("PostgreSQL Administration") );
-
-	$template->param( TEXT_DBNAME => gettext("Name of the database") );
-	$template->param( VALUE_DBNAME => $pgsql->get_dbname );
-
-	$template->param( TEXT_DBUSER => gettext("Username for this database") );
-	$template->param( VALUE_DBUSER => $pgsql->get_dbusername );
-
-	$template->param( TEXT_DBPASS => gettext("Password for this database") );
-
-    $template->param( VALUE_OID => $pgsql->get_oid );
-	$template->param( TEXT_ACL_ADMIN => "Admin Rights on this object (ACL)" );
-	$template->param( EXPLAIN_ADMIN_ACL => "You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it." );
-	$template->param( ADMIN_ACL => "Ok, go to ACL admin" );
-
-	$template->param( TEXT_SEND => gettext("Modify") );
-	$template->param( TEXT_DELETE_PGSQL => gettext("Delete this PostgreSQL database") );
-	$template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. This PostgreSQL database will be DESTROYED.") );
-	$template->param( ASK_DELETE_PGSQL => gettext("Are you SURE you want DELETE this PostgreSQL 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, $pgsql );
-	$template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+    $panel->render('pgsql/prefs.tt', $vars);
 }
 
-$panel->build( $template );
-$panel->display;
-
-
 sub save_prefs {
     if(!$user->can_modify($pgsql)) {
         $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/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-15 14:54:18 UTC (rev 1747)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-15 14:54:25 UTC (rev 1748)
@@ -91,7 +91,6 @@
 	misc/resubmit.tmpl \
 	mysql/create.tmpl \
 	mysql/prefs.tmpl \
-	pgsql/prefs.tmpl \
 	git/create.tmpl \
 	git/prefs.tmpl \
 	mercurial/create.tmpl \
@@ -131,6 +130,7 @@
 	misc/welcome.tt \
 	object/delete.tt \
 	pgsql/create.tt \
+	pgsql/prefs.tt \
 	repository/create.tt \
 	repository/prefs.tt \
 	svn/create.tt \

Deleted: trunk/vhffs-panel/templates/pgsql/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/pgsql/prefs.tmpl	2011-05-15 14:54:18 UTC (rev 1747)
+++ trunk/vhffs-panel/templates/pgsql/prefs.tmpl	2011-05-15 14:54:25 UTC (rev 1748)
@@ -1,71 +0,0 @@
-<form method="post" action="/pgsql/prefs.pl" accept-charset="utf-8">
-	<p>
-		<label>
-			<TMPL_VAR ESCAPE=1 NAME="TEXT_DBNAME"> :
-		</label>
-		<TMPL_VAR ESCAPE=1 NAME="VALUE_DBNAME">
-	</p>
-	<p>
-		<label>
-			<TMPL_VAR ESCAPE=1 NAME="TEXT_DBUSER"> :
-		</label>
-		<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="hidden" name="name" value="<TMPL_VAR ESCAPE=1 NAME="value_dbname">"/>
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_SEND">" name="save_prefs_submit"/>
-	</p>
-</form>
-
-<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_PGSQL"></h2>
-
-<form method="post" action="delete.pl" accept-charset="utf-8">
-	<fieldset class="delete">
-		<legend>
-			<TMPL_VAR ESCAPE=1 NAME="ASK_DELETE_PGSQL">:
-		</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">

Added: trunk/vhffs-panel/templates/pgsql/prefs.tt
===================================================================
--- trunk/vhffs-panel/templates/pgsql/prefs.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/pgsql/prefs.tt	2011-05-15 14:54:25 UTC (rev 1748)
@@ -0,0 +1,31 @@
+<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/