[vhffs-dev] [1698] No more HTML::Template in group history.

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


Revision: 1698
Author:   beuss
Date:     2011-05-09 22:42:44 +0200 (Mon, 09 May 2011)
Log Message:
-----------
No more HTML::Template in group history.

Object history and group history templates have been merged.

Modified Paths:
--------------
    trunk/vhffs-panel/group/history.pl
    trunk/vhffs-panel/templates/misc/history.tt

Modified: trunk/vhffs-panel/group/history.pl
===================================================================
--- trunk/vhffs-panel/group/history.pl	2011-05-09 20:42:35 UTC (rev 1697)
+++ trunk/vhffs-panel/group/history.pl	2011-05-09 20:42:44 UTC (rev 1698)
@@ -32,7 +32,6 @@
 
 use utf8;
 use POSIX qw(locale_h);
-use HTML::Template;
 use locale;
 use Locale::gettext;
 use CGI;
@@ -44,7 +43,6 @@
 use Vhffs::Group;
 use Vhffs::Main;
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Group;
 use Vhffs::Functions;
 use Vhffs::ObjectFactory;
 
@@ -62,49 +60,26 @@
 my $group = Vhffs::Group::get_by_groupname( $vhffs , $cgi->param('group') );
 
 unless( defined $group ) {
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'Error. This group doesn\'t exists') );
+    $panel->render('misc/message.tt', { message => gettext( 'Error. This group doesn\'t exists') });
 } elsif( $group->get_status != Vhffs::Constants::ACTIVATED ) {
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'This object is not functional yet. Please wait creation or moderation.') );
+    $panel->render('misc/message.tt', { message => gettext( 'This object is not functional yet. Please wait creation or moderation.') });
 } elsif( ! $user->can_view( $group ) ) {
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this (ACL rights)' ) );
+    $panel->render('misc/message.tt', { message => gettext( 'You\'re not allowed to do this (ACL rights)' ) } );
 } else {
 	my $history = $group->get_full_history;
 
 	$panel->set_title( gettext('Project History') );
-	$template = new HTML::Template( filename => $templatedir.'/panel/group/history.tmpl', global_vars => 1 );
-	$template->param( HDATE => gettext('Date') );
-	$template->param( HTYPE => gettext('Type') );
-	$template->param( HNAME => gettext('Name') );
-	$template->param( HEVENT => gettext('Event') );
-        $template->param( MODERATOR => $user->is_moderator || $user->is_admin );
 
-	unless(@{$history}) {
-		$template->param( HISTORY_PART => gettext('No event about this group') );
-	} else {
-        my $output = '';
-        my $history_tmpl = new HTML::Template( filename => $templatedir.'/panel/group/history_part.tmpl' );
-        use DateTime;
-        use DateTime::Locale;
-        my $loc = DateTime::Locale->load($user->get_lang);
-        foreach (@{$history}) {
-            my $dt = DateTime->from_epoch( epoch => $_->{date}, locale => $user->get_lang);
-            $history_tmpl->param( DATE => $dt->strftime($loc->medium_date_format() ) );
-            $history_tmpl->param( TIME => $dt->strftime($loc->long_time_format() )  );
-            $history_tmpl->param( TYPE => Vhffs::Functions::type_string_from_type_id( $_->{type} ) );
-            my $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $_->{object_id} );
-            $history_tmpl->param( NAME => $object->get_label );
-            $history_tmpl->param( EVENT => $_->{message} );
-            $history_tmpl->param( MODERATOR => $user->is_moderator || $user->is_admin );
-            $history_tmpl->param( SOURCE => $_->{source} );
+    use DateTime;
+    use DateTime::Locale;
+    my $loc = DateTime::Locale->load($user->get_lang);
 
-            $output .= $history_tmpl->output;
-        }
-		$template->param( HISTORY_PART => $output );
-	}
+    foreach (@{$history}) {
+        my $dt = DateTime->from_epoch( epoch => $_->{date}, locale => $user->get_lang);
+        $_->{date} = $dt->format_cldr($loc->date_format_medium().' '.$loc->time_format_long());
+        $_->{object} = Vhffs::ObjectFactory::fetch_object( $vhffs , $_->{object_id} );
+        $_->{object_type} = Vhffs::Functions::type_string_from_type_id( $_->{type} );
+    }
+    $panel->render('misc/history.tt', { history => $history });
 }
 
-$panel->build( $template );
-$panel->display;

Modified: trunk/vhffs-panel/templates/misc/history.tt
===================================================================
--- trunk/vhffs-panel/templates/misc/history.tt	2011-05-09 20:42:35 UTC (rev 1697)
+++ trunk/vhffs-panel/templates/misc/history.tt	2011-05-09 20:42:44 UTC (rev 1698)
@@ -4,6 +4,8 @@
     <thead>
     <tr>
         <th>[% 'Date' | i18n | html %]</th>
+        [% IF history.0.object.defined() %]<th>[% 'Object type' | i18n %]</th>
+        <th>[% 'Object label' | i18n %]</th>[% END %]
         <th>[% 'Event' | i18n | html %]</th>
         [% IF current_user.is_moderator() || current_user.is_admin() %]<th>[% 'Source' | i18n | html %]</td>[% END %]
     </tr>
@@ -12,6 +14,8 @@
 [% FOREACH h IN history %]
     <tr>
         <td>[% h.date %]</td>
+        [% IF h.object.defined() %]<td>[% h.object_type | html %]</td>
+        <td>[% h.object.get_label %]</td>[% END %]
         <td>[% h.message %]</td>
         [% IF current_user.is_moderator() || current_user.is_admin() %]<td>[% h.source || 'N/A' %]</td>[% END %]
     </tr>


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