[vhffs-dev] [1736] No more HTML::Template in svn/prefs.pl |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1736
Author: beuss
Date: 2011-05-14 22:29:15 +0200 (Sat, 14 May 2011)
Log Message:
-----------
No more HTML::Template in svn/prefs.pl
Modified Paths:
--------------
trunk/vhffs-panel/svn/prefs.pl
trunk/vhffs-panel/templates/Makefile.am
Added Paths:
-----------
trunk/vhffs-panel/templates/svn/prefs.tt
Removed Paths:
-------------
trunk/vhffs-panel/templates/svn/prefs.tmpl
Modified: trunk/vhffs-panel/svn/prefs.pl
===================================================================
--- trunk/vhffs-panel/svn/prefs.pl 2011-05-14 20:29:08 UTC (rev 1735)
+++ trunk/vhffs-panel/svn/prefs.pl 2011-05-14 20:29:15 UTC (rev 1736)
@@ -32,7 +32,6 @@
use utf8;
use POSIX qw(locale_h);
-use HTML::Template;
use locale;
use Locale::gettext;
use CGI;
@@ -40,10 +39,7 @@
use strict;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Main;
use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
use Vhffs::Panel::Object;
use Vhffs::Services::Svn;
@@ -55,91 +51,40 @@
my $vhffs = $panel->{'vhffs'};
my $user = $panel->{'user'};
my $cgi = $panel->{'cgi'};
-my $templatedir = $panel->{'templatedir'};
my $repo_name = $cgi->param("name");
my $svn = Vhffs::Services::Svn::get_by_reponame( $vhffs , $repo_name );
my $group = Vhffs::Group::get_by_gid( $vhffs , $svn->{'owner_gid'} );
-my $template;
-unless( defined $repo_name )
-{
- $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
- $template->param( MESSAGE => gettext('CGI Error !') );
-}
-elsif( !defined $svn )
-{
- $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
- $template->param( MESSAGE => gettext('Cannot get informations on this object') );
-}
-elsif( !$user->can_view( $svn ) )
-{
- $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 $repo_name ) {
+ $panel->render('misc/message.tt', { message => gettext('CGI Error !') });
+} elsif( !defined $svn ) {
+ $panel->render('misc/message.tt', { message => gettext('Cannot get informations on this object') } );
+} elsif( !$user->can_view( $svn ) ) {
+ $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('prefs_save_submit')) {
- if(save_prefs()) {
- exit;
- }
+ save_prefs();
}
- $template = new HTML::Template( filename => $templatedir."/panel/svn/prefs.tmpl" );
-
- $panel->set_title( gettext("Admin Subversion Repository") );
-
-
- $template->param( TEXT_REPONAME => $svn->get_reponame );
- $template->param( TITLE_PUBLIC => gettext("Public") );
- $template->param( TEXT_PUBLIC => gettext("Is this a public repository ?") );
- $template->param( PUBLIC_YES => gettext("Yes") );
- $template->param( PUBLIC_NO => gettext("No") );
- $template->param( TEXT_SEND => gettext("Modify") );
- $template->param( TEXT_DELETE_CVS => gettext("Delete this repository") );
- $template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. This subversion repository will be DESTROYED.") );
- $template->param( ASK_DELETE_CVS => gettext("Are you SURE you want DELETE this subversion repository ?") );
- $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") );
-
- $template->param( VALUE_OID => $svn->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( TITLE_OPT => gettext('Options') );
- $template->param( TEXT_OPT_ML => gettext('Notify changes on mailing-list :'));
- $template->param( TEXT_OPT_ML_REMINDER => sprintf( gettext('Don\'t forget to subscribe %s to your mailing list if you are filtering posts') , $vhffs->get_config->get_service('svn')->{notify_from} ) );
- $template->param( TEXT_ML_NAME => $svn->{ml_name} );
-
- if( $svn->is_public == 1 )
- {
- $template->param( YES_SELECTED => "selected" );
- }
- else
- {
- $template->param( NO_SELECTED => "selected" );
- }
-
- my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $svn );
- $template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+ $panel->set_title( gettext("Modify Subversion repository") );
+ my $vars = {};
+ $vars->{repository} = $svn;
+ $vars->{notify_from} = $vhffs->get_config->get_service('svn')->{notify_from};
+ $panel->render( 'svn/prefs.tt', $vars );
}
-$panel->build( $template );
-$panel->display;
-
sub save_prefs {
my $public = $cgi->param('public');
my $ml_name = $cgi->param('ml_name');
if(!$user->can_modify($svn)) {
$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' ) );
- return 0;
+ return;
}
if(!defined $ml_name || !defined $public) {
$panel->add_error( gettext('CGI Error !') );
- return 0;
+ return;
}
if($public == 1 && !$svn->is_public) {
@@ -157,18 +102,16 @@
}
} else {
$panel->add_error( gettext('Mailing list address is invalid') );
- return 0;
+ return;
}
if($svn->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION) {
if($svn->commit > 0) {
my $url = '/group/view.pl?group='.$group->get_groupname.'&msg='.gettext('Modifications applied. Please wait while your repository is being updated');
- $panel->redirect($url);
- return 1;
-
+ $panel->redirect($url); # will exit()
} else {
$panel->add_error( gettext('Unable to update repository') );
- return 0;
+ return;
}
}
}
Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am 2011-05-14 20:29:08 UTC (rev 1735)
+++ trunk/vhffs-panel/templates/Makefile.am 2011-05-14 20:29:15 UTC (rev 1736)
@@ -96,7 +96,6 @@
repository/admin.tmpl \
repository/create.tmpl \
repository/prefs.tmpl \
- svn/prefs.tmpl \
svn/user_part.tmpl \
git/create.tmpl \
git/prefs.tmpl \
@@ -139,6 +138,7 @@
misc/service-index.tt \
misc/welcome.tt \
svn/create.tt \
+ svn/prefs.tt \
user/prefs.tt \
web/create.tt \
web/prefs.tt
Deleted: trunk/vhffs-panel/templates/svn/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/svn/prefs.tmpl 2011-05-14 20:29:08 UTC (rev 1735)
+++ trunk/vhffs-panel/templates/svn/prefs.tmpl 2011-05-14 20:29:15 UTC (rev 1736)
@@ -1,67 +0,0 @@
-<form method="post" action="/svn/prefs.pl" accept-charset="utf-8">
-<h2><TMPL_VAR ESCAPE=1 NAME="TITLE_PUBLIC"></h2>
- <p>
- <label for="public">
- <TMPL_VAR ESCAPE=1 NAME="TEXT_PUBLIC"> :
- </label>
- <select name="public" id="public">
- <option value="1" <TMPL_VAR ESCAPE=1 NAME="YES_SELECTED">><TMPL_VAR ESCAPE=1 NAME="PUBLIC_YES"></option>
- <option value="0" <TMPL_VAR ESCAPE=1 NAME="NO_SELECTED">><TMPL_VAR ESCAPE=1 NAME="PUBLIC_NO"></option>
- </select>
- </p>
-<h2><TMPL_VAR ESCAPE=1 NAME="TITLE_OPT"></h2>
- <p>
- <label for="option"><TMPL_VAR ESCAPE=1 NAME="TEXT_OPT_ML"></label>
- <input type="text" name="ml_name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_ML_NAME">" />
- <br/>
- <TMPL_VAR ESCAPE=1 NAME="TEXT_OPT_ML_REMINDER">
- </p>
- <p class="button">
- <input type="hidden" name="name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME">" />
- <input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_SEND">" name="prefs_save_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_CVS"></h2>
-
-<form method="post" action="delete.pl" accept-charset="utf-8">
- <fieldset class="delete">
- <legend>
- <TMPL_VAR ESCAPE=1 NAME="ASK_DELETE_CVS">:
- </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="name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME">" />
- <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/svn/prefs.tt
===================================================================
--- trunk/vhffs-panel/templates/svn/prefs.tt (rev 0)
+++ trunk/vhffs-panel/templates/svn/prefs.tt 2011-05-14 20:29:15 UTC (rev 1736)
@@ -0,0 +1,53 @@
+<form method="post" action="/svn/prefs.pl" accept-charset="utf-8">
+<h2>[% 'Public' | i18n | html %]</h2>
+ <p>
+ <label for="is-public">[% 'Is this a public repository?' | i18n | html %]</label>
+ <select name="public" id="is-public">
+ <option value="1"[% ' selected="selected"' IF repository.is_public %]>[% 'Yes' | i18n | html %]</option>
+ <option value="0"[% ' selected="selected"' UNLESS repository.is_public %]>[% 'No' | i18n | html %]</option>
+ </select>
+ </p>
+<h2>[% 'Options' | i18n | html %]</h2>
+ <p>
+ <label for="option">[% 'Notify changes on mailing-list:' | i18n | html %]</label>
+ <input type="text" name="ml_name" value="[% repository.ml_name | html %]" />
+ <br/>
+ [% 'Don\'t forget to subscribe %s to your mailing list if you are filtering posts.' | i18n | pretty_print(notify_from) %]
+ </p>
+ <p class="button">
+ <input type="hidden" name="name" value="[% repository.get_reponame %]" />
+ <input type="submit" value="[% 'Update' | i18n | html %]" name="prefs_save_submit"/>
+ </p>
+</form>
+
+[% INCLUDE 'acl/form.tt'
+ object = repository %]
+
+<h2>[% 'Delete this repository' | i18n | html %]</h2>
+
+<form method="post" action="/svn/delete.pl" accept-charset="utf-8">
+ <fieldset class="delete">
+ <legend>[% 'Are you SURE you want DELETE this subversion repository?' | i18n | html %]</legend>
+ <p class="warning">[% 'This action is non-reversible. This subversion repository will be DESTROYED.' | i18n | html %]</p>
+ <p>
+ <input type="radio" name="DELETE" id="DELETE_NO" value="0" checked="checked" />
+ <label for="DELETE_NO">
+ [% 'No, I\'m not sure, I\'d prefer to keep this repository' | i18n | html %]
+ </label>
+ </p>
+ <p>
+ <input type="radio" name="DELETE" id="DELETE_YES" value="1" />
+ <label for="DELETE_YES">
+ [% 'Yes I\'m sure of what I do' | i18n | html %]
+ </label>
+ </p>
+ </fieldset>
+
+ <p class="button" id="buttonDelete">
+ <input type="hidden" name="name" value="[% repository.get_reponame %]" />
+ <input type="submit" value="[% 'Delete' | i18n | html %]" />
+ </p>
+
+</form>
+[% INCLUDE 'admin/object/edit.tt'
+ object = repository %]