[vhffs-dev] [1818] No more HTML::Template in broadcast/view

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


Revision: 1818
Author:   beuss
Date:     2011-05-26 14:21:16 +0200 (Thu, 26 May 2011)
Log Message:
-----------
No more HTML::Template in broadcast/view

Modified Paths:
--------------
    trunk/vhffs-panel/admin/broadcast/view.pl
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/admin/broadcast/view.tt

Removed Paths:
-------------
    trunk/vhffs-panel/templates/admin/misc/broadcast_view.tmpl

Modified: trunk/vhffs-panel/admin/broadcast/view.pl
===================================================================
--- trunk/vhffs-panel/admin/broadcast/view.pl	2011-05-26 12:21:08 UTC (rev 1817)
+++ trunk/vhffs-panel/admin/broadcast/view.pl	2011-05-26 12:21:16 UTC (rev 1818)
@@ -33,78 +33,43 @@
 use strict;
 use utf8;
 use POSIX qw(locale_h);
-use HTML::Template;
 use locale;
 use Locale::gettext;
 use CGI;
 use CGI::Session;
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Group;
-use Vhffs::Main;
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Constants;
+use Vhffs::Panel::Admin;
 use Vhffs::Mailings;
 
-my $panel = new Vhffs::Panel::Main();
-exit 0 unless $panel;
-my $session = $panel->get_session;
-exit 0 unless $session;
+my $panel = new Vhffs::Panel::Admin();
 
-my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
-my $user = $panel->{'user'};
-my $cgi = $panel->{'cgi'};
+my $vhffs = $panel->{vhffs};
+my $cgi = $panel->{cgi};
 my $mid = $cgi->param("ID");
-my $template;
-my $subtemplate;
-my $templatesdir = $vhffs->get_config->get_templatedir;
-my $message;
 
 my $mailing = Vhffs::Mailings::get_mailing( $vhffs , $mid );
 
-if( $user->is_admin != 1 )
-{
-	$template = new HTML::Template( filename => $templatesdir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "You are not allowed to see it");
-	$template->param( MESSAGE => $message );
+if( !defined $mid ) {
+    $panel->render('misc/message.tt', {
+        message => gettext('CGI Error'),
+        refresh_url => '/admin/broadcast/list.pl'
+    });
+} elsif( !defined $mailing) {
+    $panel->render('misc/message.tt', {
+        message => gettext('Mailing not found'),
+        refresh_url => '/admin/broadcast/list.pl'
+    });
+} else {
+    if($mailing->{state} == 3) {
+        $mailing->{state} = gettext('Awaiting sending');
+    } elsif($mailing->{state} == 6) {
+        $mailing->{state} = gettext('Sent');
+    } else {
+        $mailing->{state} = gettext('Unknown');
+    }
+    $panel->render('admin/broadcast/view.tt', {
+        mailing => $mailing
+    });
 }
-elsif( ( ! defined $mid ) || ( ! defined $mailing ) )
-{
-	$template = new HTML::Template( filename => $templatesdir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "CGI Error !");
-	$template->param( MESSAGE => $message );
-}
-else
-{
-	$template = new HTML::Template( filename => $templatesdir."/panel/admin/misc/broadcast_view.tmpl" );
-	$template->param( TITLE => gettext("View mailing"));
-	$template->param( DATE_TEXT => gettext("Date"));
-	$template->param( SUBJECT_TEXT => gettext("Subject"));
-	$template->param( STATE_TEXT => gettext("State"));
-	$template->param( BODY_TEXT => gettext("Body"));
-	
-	$template->param( DATE => $mailing->{'date'} );
-	$template->param( SUBJECT => $mailing->{'subject'} );
-	$template->param( BODY => $mailing->{'message'} );
 
-	if( $mailing->{'state'} == 3 )
-	{
-		$template->param( STATE => gettext("Awaiting sending") );
-	}
-	elsif( $mailing->{'state'} == 6 )
-	{
-		$template->param( STATE => gettext("Send") );
-	}
-	else
-	{
-		$template->param( STATE => gettext("Unknown status") );
-	}
-
-}
-
-$panel->build( $template );
-$panel->display;
-

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-26 12:21:08 UTC (rev 1817)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-26 12:21:16 UTC (rev 1818)
@@ -3,7 +3,6 @@
 	admin/main/general-modo.tmpl \
 	admin/main/general.tmpl \
 	admin/main/main.tmpl \
-	admin/misc/broadcast_view.tmpl \
 	admin/misc/list.tmpl \
 	admin/misc/mailings_part.tmpl \
 	admin/misc/moderation_applied.tmpl \
@@ -42,6 +41,7 @@
 	admin/index.tt \
 	admin/broadcast/create.tt \
 	admin/broadcast/list.tt \
+	admin/broadcast/view.tt \
 	admin/misc/list.tt \
 	admin/misc/search.tt \
 	admin/object/edit.tt \

Added: trunk/vhffs-panel/templates/admin/broadcast/view.tt
===================================================================
--- trunk/vhffs-panel/templates/admin/broadcast/view.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/admin/broadcast/view.tt	2011-05-26 12:21:16 UTC (rev 1818)
@@ -0,0 +1,11 @@
+[% USE date %]
+<p><label>[% 'Date:' | i18n | html %]</label>
+    [% date.format(mailing.date, '%x') %]</p>
+<p><label>[% 'Subject:' | i18n | html %]</label>
+    [% mailing.subject | html %]</p>
+<p><label>[% 'State:' | i18n | html %]</label>
+    [% mailing.state %]</p>
+<p>[% 'Body:' | i18n | html %]</p>
+<div>
+[% mailing.message | html_para %]
+</div>

Deleted: trunk/vhffs-panel/templates/admin/misc/broadcast_view.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/misc/broadcast_view.tmpl	2011-05-26 12:21:08 UTC (rev 1817)
+++ trunk/vhffs-panel/templates/admin/misc/broadcast_view.tmpl	2011-05-26 12:21:16 UTC (rev 1818)
@@ -1,36 +0,0 @@
-<h1><TMPL_VAR ESCAPE=1 NAME="TITLE"></h1>
-
-<table>
-<tr>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="DATE_TEXT">
-	</td>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="DATE"> 
-	</td>
-</tr>
-<tr>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="SUBJECT_TEXT"> 
-	</td>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="SUBJECT"> 
-	</td>
-</tr>
-<tr>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="STATE_TEXT"> 
-	</td>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="STATE"> 
-	</td>
-</tr>
-<tr>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="BODY_TEXT"> 
-	</td>
-	<td>
-		<TMPL_VAR ESCAPE=1 NAME="BODY"> 
-	</td>
-</tr>
-</table>


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