[vhffs-dev] [1885] Unify languages handing between panel & public. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1885
Author: beuss
Date: 2011-07-25 22:58:42 +0200 (Mon, 25 Jul 2011)
Log Message:
-----------
Unify languages handing between panel & public.
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Panel/Main.pm
trunk/vhffs-api/src/Vhffs/Panel/Public.pm
trunk/vhffs-panel/templates/misc/languages.tt
trunk/vhffs-public/templates/parts/header.tt
trunk/vhffs-themes/Makefile.am
Added Paths:
-----------
trunk/vhffs-themes/light-grey/img/en_US.png
trunk/vhffs-themes/light-grey/img/es_ES.png
trunk/vhffs-themes/light-grey/img/fr_FR.png
Removed Paths:
-------------
trunk/vhffs-themes/light-grey/img/flag_en.png
trunk/vhffs-themes/light-grey/img/flag_es.png
trunk/vhffs-themes/light-grey/img/flag_fr.png
Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2011-07-23 16:32:36 UTC (rev 1884)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2011-07-25 20:58:42 UTC (rev 1885)
@@ -403,12 +403,12 @@
sub render {
- my ($self, $file, $vars, $layout) = @_;
+ my ($self, $file, $vars, $layout, $include_path) = @_;
my $conf = $self->{vhffs}->get_config;
# TODO Should be in parent class when Template::Toolkit switch is over
my $create_vars = {
- INCLUDE_PATH => $self->{templatedir}.'/panel/',
+ INCLUDE_PATH => $self->{templatedir}.(defined $include_path ? "/$include_path/" : '/panel/'),
CONSTANTS => {
object_statuses => {
WAITING_FOR_VALIDATION =>Vhffs::Constants::WAITING_FOR_VALIDATION,
@@ -483,11 +483,11 @@
$vars = {} unless(defined $vars);
- $vars->{theme} = 'vhffs'; # TODO $conf->get_panel->{default_theme} unless(defined $vars->{theme});
+ $vars->{theme} = $conf->get_panel->{default_theme} unless(defined $vars->{theme});
$vars->{panel_url} = $conf->get_panel->{url};
$vars->{title} = sprintf( gettext( '%s\'s Panel' ), $conf->get_host_name );
$vars->{page_title} = $self->{title};
- $vars->{has_public_area} = $self->is_public;
+ $vars->{public_url} = $self->{vhffs}->get_config->get_panel->{'url_public'} if($self->is_public);
if(defined $self->{cgi}->param('msg')) {
$vars->{msg} = Encode::decode_utf8($self->{cgi}->param('msg'));
}
Modified: trunk/vhffs-api/src/Vhffs/Panel/Public.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Public.pm 2011-07-23 16:32:36 UTC (rev 1884)
+++ trunk/vhffs-api/src/Vhffs/Panel/Public.pm 2011-07-25 20:58:42 UTC (rev 1885)
@@ -57,58 +57,22 @@
my ($self, $file, $vars) = @_;
my $conf = $self->{vhffs}->get_config;
- # TODO Should be in parent class when Template::Toolkit switch is over
- my $create_vars = {
- INCLUDE_PATH => $self->{templatedir}.'/public/',
- FILTERS => {
- i18n => \&gettext,
- mail => sub {
- return Vhffs::Functions::obfuscate_email($self->{vhffs}, $_[0]);
- },
- # Format filter accept only one argument
- # pretty_print can 'sprintf' anything, use it as
- # [% '%s is $%d' | pretty_print(article, price)]
- pretty_print => [sub {
- my $context = shift;
- my @args = @_;
- return sub {
- my $format = shift;
- return sprintf($format, @args);
- }
- }, 1]
- }
- };
-
-
$vars = {} unless(defined $vars);
- $vars->{theme} = $conf->get_panel->{default_theme} unless(defined $vars->{theme});
$vars->{left} = 'parts/left-menu.tt' unless(defined $vars->{left});
$vars->{right} = 'parts/tags-cloud.tt' unless(defined $vars->{right});
$vars->{top} = 'parts/top-menu.tt' unless(defined $vars->{top});
- $vars->{panel_url} = $conf->get_panel->{url};
$vars->{help_url} = $conf->get_panel->{url_help};
$vars->{users_avatar} = Vhffs::Functions::strtobool( $conf->get_panel->{'users_avatars'} );
$vars->{groups_avatar} = Vhffs::Functions::strtobool( $conf->get_panel->{'groups_avatars'} );
# Handling ajax stuff
- if($self->{is_ajax_request}) {
-
- } else {
- $create_vars->{PROCESS} = 'layouts/public.tt';
+ unless($self->{is_ajax_request}) {
$vars->{popular_tags} = Vhffs::Tag::get_most_popular_tags($self->{vhffs});
$vars->{random_tags} = Vhffs::Tag::get_random_tags($self->{vhffs});
}
- my $template = new Template($create_vars);
-
- binmode STDOUT , ':utf8';
-
- print CGI->header( -cookie=>[ @{$self->{cookies}} ], -type=>'text/html', -charset=>'utf-8' );
-
- $template->process($file, $vars)
- || die('Error while processing template: '.$template->error());
-
+ $self->SUPER::render($file, $vars, 'public.tt', 'public');
}
1;
Modified: trunk/vhffs-panel/templates/misc/languages.tt
===================================================================
--- trunk/vhffs-panel/templates/misc/languages.tt 2011-07-23 16:32:36 UTC (rev 1884)
+++ trunk/vhffs-panel/templates/misc/languages.tt 2011-07-25 20:58:42 UTC (rev 1885)
@@ -1,5 +1,5 @@
-<div id="chooselang">
+<div class="navflag">
[% FOREACH l IN languages %]
- <a href="auth.pl?lang=[% l | html %]"><img src="/themes/[% theme %]/images/[% l | html %].png" alt="[% l %]"/></a>
+ <a href="/auth.pl?lang=[% l | html %]"><img src="/themes/[% theme %]/img/[% l | html %].png" alt="[% l %]"/></a>
[% END %]
</div>
Modified: trunk/vhffs-public/templates/parts/header.tt
===================================================================
--- trunk/vhffs-public/templates/parts/header.tt 2011-07-23 16:32:36 UTC (rev 1884)
+++ trunk/vhffs-public/templates/parts/header.tt 2011-07-25 20:58:42 UTC (rev 1885)
@@ -8,9 +8,9 @@
<!-- Flag navigations -->
<div class="navflag">
- <a href="/?lang=fr_FR"><img class="img-navflag" src="/themes/[% theme %]/img/flag_fr.png" alt="[% 'French' | i18n %]" /></a>
- <a href="/?lang=es_ES"><img class="img-navflag" src="/themes/[% theme %]/img/flag_es.png" alt="[% 'Spanish' | i18n %]" /></a>
- <a href="/?lang=en_US"><img class="img-navflag" src="/themes/[% theme %]/img/flag_en.png" alt="[% 'English' | i18n %]" /></a>
+[% FOREACH l IN languages %]
+ <a href="/?lang=[% l | html %]"><img src="/themes/[% theme %]/img/[% l | html %].png" alt="[% l %]"/></a>
+[% END %]
</div>
<!-- Navigation Level 1 -->
Modified: trunk/vhffs-themes/Makefile.am
===================================================================
--- trunk/vhffs-themes/Makefile.am 2011-07-23 16:32:36 UTC (rev 1884)
+++ trunk/vhffs-themes/Makefile.am 2011-07-25 20:58:42 UTC (rev 1885)
@@ -73,9 +73,9 @@
vhffs/images/cronentry.png \
vhffs/main.css \
light-grey/main.css \
- light-grey/img/flag_en.png \
- light-grey/img/flag_es.png \
- light-grey/img/flag_fr.png \
+ light-grey/img/en_US.png \
+ light-grey/img/es_ES.png \
+ light-grey/img/fr_FR.png \
light-grey/img/background_layout_2.gif \
light-grey/img/new_tag.png \
light-grey/img/vhffs-big.png \
Copied: trunk/vhffs-themes/light-grey/img/en_US.png (from rev 1883, trunk/vhffs-themes/light-grey/img/flag_en.png)
===================================================================
(Binary files differ)
Copied: trunk/vhffs-themes/light-grey/img/es_ES.png (from rev 1883, trunk/vhffs-themes/light-grey/img/flag_es.png)
===================================================================
(Binary files differ)
Deleted: trunk/vhffs-themes/light-grey/img/flag_en.png
===================================================================
(Binary files differ)
Deleted: trunk/vhffs-themes/light-grey/img/flag_es.png
===================================================================
(Binary files differ)
Deleted: trunk/vhffs-themes/light-grey/img/flag_fr.png
===================================================================
(Binary files differ)
Copied: trunk/vhffs-themes/light-grey/img/fr_FR.png (from rev 1883, trunk/vhffs-themes/light-grey/img/flag_fr.png)
===================================================================
(Binary files differ)