[vhffs-dev] [1681] Use Template::Toolkit for panel messages. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1681
Author: beuss
Date: 2011-05-01 16:25:44 +0200 (Sun, 01 May 2011)
Log Message:
-----------
Use Template::Toolkit for panel messages.
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Panel/Main.pm
trunk/vhffs-panel/templates/Makefile.am
trunk/vhffs-public/templates/Makefile.am
Added Paths:
-----------
trunk/vhffs-panel/templates/misc/closed.tt
trunk/vhffs-public/templates/misc/
trunk/vhffs-public/templates/misc/closed.tt
Removed Paths:
-------------
trunk/vhffs-panel/templates/main/close.tmpl
Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2011-05-01 14:25:34 UTC (rev 1680)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2011-05-01 14:25:44 UTC (rev 1681)
@@ -65,16 +65,11 @@
=cut
sub check_public {
- my $panel = shift;
- my $vhffs = $panel->{vhffs};
+ my $self = shift;
+ my $vhffs = $self->{vhffs};
my $templatedir = $vhffs->get_config->get_templatedir;
if( $vhffs->get_config->get_panel->{'use_public'} ne 'yes' ) {
- my $template = new HTML::Template( filename => $templatedir.'/panel/main/close.tmpl' );
- $template->param( TEXT_CLOSE => gettext('Public area not available') );
- $template->param( TEXT_EXPLAIN => gettext('Public area is not available on this platform.') );
-
- $panel->light( $template );
- $panel->display;
+ $self->render('misc/closed.tt', undef);
exit( 0 );
}
}
@@ -266,36 +261,36 @@
sub new
{
my $class = ref($_[0]) || $_[0];
- my $this = {};
- $this->{errors} = [];
- $this->{infos} = [];
- $this->{cookies} = [];
- bless( $this, $class );
+ my $self = {};
+ $self->{errors} = [];
+ $self->{infos} = [];
+ $self->{cookies} = [];
+ bless( $self, $class );
my $cgi = new CGI;
$cgi->charset('UTF-8');
- $this->{cgi} = $cgi;
- $this->{url} = CGI::url();
+ $self->{cgi} = $cgi;
+ $self->{url} = CGI::url();
my $vhffs = init Vhffs::Main;
- $this->{vhffs} = $vhffs;
+ $self->{vhffs} = $vhffs;
unless( defined $vhffs ) {
print CGI->header( -type=>'text/html', -charset=>'utf-8' ), 'Unable to open database connection';
exit 1;
}
my $config = $vhffs->get_config;
- $this->{config} = $config;
+ $self->{config} = $config;
my $templatedir = $config->get_templatedir;
- $this->{templatedir} = $templatedir;
+ $self->{templatedir} = $templatedir;
# lang cookie
my $lang = $cgi->param('lang');
- $this->add_cookie( CGI->cookie( -name=>'language', -value=>$lang, -expires=>'+10y' ) ) if defined $lang;
+ $self->add_cookie( CGI->cookie( -name=>'language', -value=>$lang, -expires=>'+10y' ) ) if defined $lang;
$lang = CGI->cookie('language') unless defined $lang;
$lang = $vhffs->get_config->get_default_language() unless defined $lang;
$lang = 'en_US' unless defined $lang;
- $this->{lang} = $lang;
+ $self->{lang} = $lang;
setlocale(LC_ALL, $lang);
bindtextdomain('vhffs', '%localedir%');
@@ -303,41 +298,25 @@
# theme cookie
my $theme = $cgi->param('theme');
- $this->add_cookie( CGI->cookie( -name=>'theme', -value=>$theme, -expires=>'+10y' ) ) if defined $theme;
+ $self->add_cookie( CGI->cookie( -name=>'theme', -value=>$theme, -expires=>'+10y' ) ) if defined $theme;
$theme = CGI->cookie('theme') unless defined $theme;
$theme = $config->get_panel->{'default_theme'} unless defined $theme;
$theme = 'vhffs' unless( defined $theme && -f $config->get_panel->{'themesdir'}.'/'.$theme.'/main.css' );
- $this->{theme} = 'vhffs';
+ $self->{theme} = 'vhffs';
my $template = new HTML::Template( filename => $templatedir.'/panel/main/main.tmpl' );
- $this->{template} = $template;
+ $self->{template} = $template;
- if( $vhffs->is_valid() == 0 )
+ unless( $vhffs->is_valid() and $vhffs->get_config->get_panel->{'open'} eq 'yes' )
{
- my $template = new HTML::Template( filename => $templatedir.'/panel/main/close.tmpl' );
- $template->param( TEXT_CLOSE => gettext("Platform temporary closed<br/>database error") );
- $template->param( TEXT_EXPLAIN => gettext("This platform is temporary closed. Administrators are performing some maintenances tasks or system has database errors. Please come back in a few minutes to log in.") );
-
- $this->light( $template );
- $this->display;
- exit 0;
+ $self->render('misc/closed.tt', undef, 'anonymous.tt');
+ exit 0;
}
-
- if( $vhffs->get_config->get_panel->{'open'} ne 'yes' )
- {
- $template = new HTML::Template( filename => $templatedir.'/panel/main/close.tmpl' );
- $template->param( TEXT_CLOSE => gettext("Platform temporary closed.") );
- $template->param( TEXT_EXPLAIN => gettext("This platform is temporary closed. Administrators are performing some maintenances tasks. Please come back in a few minutes to log in.") );
-
- $this->light( $template );
- $this->display;
- exit 0;
- }
- $this->{is_ajax_request} = (defined $this->{cgi}->http('X-Requested-With')
- and $this->{cgi}->http('X-Requested-With') eq 'XMLHttpRequest');
+ $self->{is_ajax_request} = (defined $self->{cgi}->http('X-Requested-With')
+ and $self->{cgi}->http('X-Requested-With') eq 'XMLHttpRequest');
- return $this;
+ return $self;
}
Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am 2011-05-01 14:25:34 UTC (rev 1680)
+++ trunk/vhffs-panel/templates/Makefile.am 2011-05-01 14:25:44 UTC (rev 1681)
@@ -87,7 +87,6 @@
mail/prefs_boxes.tmpl \
mail/prefs_forwards.tmpl \
mail/prefs.tmpl \
- main/close.tmpl \
menu/context.tmpl \
menu/context-group.tmpl \
menu/context-modo.tmpl \
@@ -143,6 +142,7 @@
anonymous/login.tt \
anonymous/subscribe.tt \
layouts/anonymous.tt \
+ misc/closed.tt \
misc/errors.tt \
misc/infos.tt \
misc/languages.tt \
Deleted: trunk/vhffs-panel/templates/main/close.tmpl
===================================================================
--- trunk/vhffs-panel/templates/main/close.tmpl 2011-05-01 14:25:34 UTC (rev 1680)
+++ trunk/vhffs-panel/templates/main/close.tmpl 2011-05-01 14:25:44 UTC (rev 1681)
@@ -1,16 +0,0 @@
- <div id="chooselang">
- <TMPL_VAR ESCAPE=1 NAME="LANGS">
- </div>
-
- <div class="logo">
- </div>
-
- <div class="misc" id="misc">
-
- <h1><TMPL_VAR ESCAPE=1 NAME="TEXT_CLOSE"></h1>
- </div>
-
- <div class="explain">
-
- <TMPL_VAR ESCAPE=1 NAME="TEXT_EXPLAIN">
- </div>
Added: trunk/vhffs-panel/templates/misc/closed.tt
===================================================================
--- trunk/vhffs-panel/templates/misc/closed.tt (rev 0)
+++ trunk/vhffs-panel/templates/misc/closed.tt 2011-05-01 14:25:44 UTC (rev 1681)
@@ -0,0 +1,11 @@
+ [% INCLUDE 'misc/languages.tt' %]
+
+ <div class="logo">
+ </div>
+
+ <div class="misc" id="misc">
+ <h1>[% 'Platform temporary closed' | i18n | html %]</h1>
+ </div>
+ <div class="explain">
+ [% 'This platform is temporary closed. Administrators are performing some maintenances tasks or system encountered database error. Please come back in a few minutes to log in.' | i18n | html %]
+ </div>
Modified: trunk/vhffs-public/templates/Makefile.am
===================================================================
--- trunk/vhffs-public/templates/Makefile.am 2011-05-01 14:25:34 UTC (rev 1680)
+++ trunk/vhffs-public/templates/Makefile.am 2011-05-01 14:25:44 UTC (rev 1681)
@@ -12,6 +12,7 @@
content/usersearch-form.tt \
content/usersearch-results.tt \
layouts/public.tt \
+ misc/closed.tt \
parts/footer.tt \
parts/group-general.tt \
parts/header.tt \
Added: trunk/vhffs-public/templates/misc/closed.tt
===================================================================
--- trunk/vhffs-public/templates/misc/closed.tt (rev 0)
+++ trunk/vhffs-public/templates/misc/closed.tt 2011-05-01 14:25:44 UTC (rev 1681)
@@ -0,0 +1,2 @@
+<h1>[% 'Public area disabled' | i18n | html %]</h1>
+<p class="error">[% 'Public area is disabled on this hosting platform.' | i18n | html %]</p>