[vhffs-dev] [1838] No more HTML::Template in tag/category/list

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


Revision: 1838
Author:   beuss
Date:     2011-05-31 22:05:23 +0200 (Tue, 31 May 2011)
Log Message:
-----------
No more HTML::Template in tag/category/list

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Tag/Category.pm
    trunk/vhffs-panel/admin/tag/category/list.pl
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/admin/tag/category/list.tt

Removed Paths:
-------------
    trunk/vhffs-panel/templates/admin/tag/category/list.tmpl

Modified: trunk/vhffs-api/src/Vhffs/Tag/Category.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag/Category.pm	2011-05-31 20:05:15 UTC (rev 1837)
+++ trunk/vhffs-api/src/Vhffs/Tag/Category.pm	2011-05-31 20:05:23 UTC (rev 1838)
@@ -165,8 +165,8 @@
 }
 
 sub get_visibility_string {
-	my($visibility_id) = @_;
-	return $VISIBILITY_STRING[$visibility_id];
+	my($self) = @_;
+	return $VISIBILITY_STRING[$self->{visibility}];
 }
 
 1;

Modified: trunk/vhffs-panel/admin/tag/category/list.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/category/list.pl	2011-05-31 20:05:15 UTC (rev 1837)
+++ trunk/vhffs-panel/admin/tag/category/list.pl	2011-05-31 20:05:23 UTC (rev 1838)
@@ -34,24 +34,15 @@
 use POSIX qw(locale_h);
 use locale;
 use Locale::gettext;
-use DateTime;
-use DateTime::Locale;
 use strict;
 
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Admin;
-use Vhffs::Panel::Template;
+use Vhffs::Panel::Modo;
 use Vhffs::Tag::Category;
 
-my $panel = new Vhffs::Panel::Main();
-exit 0 unless $panel;
-my $session = $panel->get_session;
-exit 0 unless $session;
+my $panel = new Vhffs::Panel::Modo();
 
-$panel->check_modo;
-
 my $cgi = $panel->{cgi};
 
 if(defined $cgi->param('delete_category_submit')) {
@@ -62,28 +53,12 @@
 	}
 }
 
-my $templatedir = $panel->{templatedir};
-
-my $template = new Vhffs::Panel::Template(filename => $templatedir.'/panel/admin/tag/category/list.tmpl', die_on_bad_params => 0 );
-
 $panel->set_title(gettext('Tag categories'));
 
-my $categories =  Vhffs::Tag::Category::get_all($panel->{vhffs});
-# We should really drop HTML::Template....
-my $user = $panel->{user};
-my $loc = DateTime::Locale->load($user->get_lang);
-foreach(@$categories) {
-	my $dt = DateTime->from_epoch( epoch => $_->{updated}, locale => $user->get_lang);
-	$_->{updated} = $dt->strftime($loc->medium_date_format().' '.$loc->long_time_format());
-	$_->{updater_name} = $_->get_updater()->get_username();
-	$_->{visibility_string} = Vhffs::Tag::Category::get_visibility_string($_->{visibility});
-}
+my $vars = {};
+$vars->{categories} = Vhffs::Tag::Category::get_all($panel->{vhffs});
+$panel->render('admin/tag/category/list.tt', $vars);
 
-$template->param( 'CATEGORIES' => $categories );
-
-$panel->build( $template );
-$panel->display;
-
 sub delete_category {
 	my $category_id = $cgi->param('category_id');
 	my $category = Vhffs::Tag::Category::get_by_category_id($panel->{vhffs}, $category_id);

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-31 20:05:15 UTC (rev 1837)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-31 20:05:23 UTC (rev 1838)
@@ -5,7 +5,6 @@
 	admin/main/main.tmpl \
 	admin/misc/list.tmpl \
 	admin/object/search.tmpl \
-	admin/tag/category/list.tmpl \
 	admin/tag/request/details.tmpl \
 	admin/tag/request/list.tmpl \
 	menu/context.tmpl \
@@ -37,6 +36,7 @@
 	admin/object/list.tt \
 	admin/tag/category/create.tt \
 	admin/tag/category/edit.tt \
+	admin/tag/category/list.tt \
 	admin/tag/create.tt \
 	admin/tag/edit.tt \
 	admin/tag/list.tt \

Deleted: trunk/vhffs-panel/templates/admin/tag/category/list.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/category/list.tmpl	2011-05-31 20:05:15 UTC (rev 1837)
+++ trunk/vhffs-panel/templates/admin/tag/category/list.tmpl	2011-05-31 20:05:23 UTC (rev 1838)
@@ -1,27 +0,0 @@
-<table border="1">
-<thead>
-<tr>
-<th><TMPL_I18N KEY="Label"></th><th><TMPL_I18N KEY="Description"></th>
-<th><TMPL_I18N KEY="Visibility"></th><th><TMPL_I18N KEY="Updated"></th>
-<th><TMPL_I18N KEY="By"></th><th><TMPL_I18N KEY="Edit"></th>
-<th><TMPL_I18N KEY="Delete"></th>
-</tr>
-</thead>
-<tbody>
-<TMPL_LOOP NAME="CATEGORIES">
-<tr>
-<td><TMPL_VAR NAME="label"></td><td><TMPL_VAR NAME="description"></td>
-<td><TMPL_VAR NAME="visibility_string"></td><td><TMPL_VAR NAME="updated"></td>
-<td><TMPL_VAR NAME="updater_name"></td>
-<td><form action="edit.pl" method="post">
-	<input type="hidden" name="category_id" value="<TMPL_VAR NAME="category_id">"/>
-	<input type="submit" value="<TMPL_I18N KEY="Edit">"/>
-</form></td>
-<td><form action="#" method="post">
-	<input type="hidden" name="category_id" value="<TMPL_VAR NAME="category_id">"/>
-	<input type="submit" value="<TMPL_I18N KEY="Delete">" name="delete_category_submit"/>
-</form></td>
-</tr>
-</TMPL_LOOP>
-</tbody>
-</table>
\ No newline at end of file

Added: trunk/vhffs-panel/templates/admin/tag/category/list.tt
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/category/list.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/admin/tag/category/list.tt	2011-05-31 20:05:23 UTC (rev 1838)
@@ -0,0 +1,34 @@
+[% USE date %]
+[% USE dumper %]
+<p><a href="/admin/tag/category/create.pl">[% 'Add a category.' | i18n | html %]</a></p>
+[% IF categories.size() > 0 %]
+<table border="1">
+    <thead>
+        <tr>
+            <th>[% 'Label' | i18n | html %]</th><th>[% 'Description' | i18n | html %]</th>
+            <th>[% 'Visibility' | i18n | html %]</th><th>[% 'Updated' | i18n | html %]</th>
+            <th>[% 'By' | i18n | html %]</th><th>[% 'Edit' | i18n | html %]</th>
+            <th>[% 'Delete' | i18n | html %]</th>
+        </tr>
+    </thead>
+    <tbody>
+[% FOREACH c IN categories %]
+        <tr>
+            <td>[% c.label | html %]</td><td>[% c.description | html %]</td>
+            <td>[% c.get_visibility_string | i18n | html %]</td><td>[% date.format(c.updated, '%x') %]</td>
+            <td>[% c.get_updater.get_username | html %]</td>
+            <td><form action="edit.pl" method="post">
+            	<input type="hidden" name="category_id" value="[% c.category_id %]"/>
+            	<input type="submit" value="[% 'Edit' | i18n | html %]"/>
+            </form></td>
+            <td><form action="#" method="post">
+            	<input type="hidden" name="category_id" value="[% c.category_id %]"/>
+                <input type="submit" value="[% 'Delete' | i18n | html %]" name="delete_category_submit"/>
+            </form></td>
+        </tr>
+[% END %]
+    </tbody>
+</table>
+[% ELSE %]
+<p>[% 'No category found.' | i18n | html %]</p>
+[% END %]


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