[vhffs-dev] [1835] No more HTML::Template in tag/list |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1835
Author: beuss
Date: 2011-05-31 22:04:56 +0200 (Tue, 31 May 2011)
Log Message:
-----------
No more HTML::Template in tag/list
Modified Paths:
--------------
trunk/vhffs-panel/admin/tag/list.pl
trunk/vhffs-panel/templates/Makefile.am
Added Paths:
-----------
trunk/vhffs-panel/templates/admin/tag/list.tt
Removed Paths:
-------------
trunk/vhffs-panel/templates/admin/tag/list.tmpl
Modified: trunk/vhffs-panel/admin/tag/list.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/list.pl 2011-05-31 20:04:45 UTC (rev 1834)
+++ trunk/vhffs-panel/admin/tag/list.pl 2011-05-31 20:04:56 UTC (rev 1835)
@@ -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;
-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_tag_submit')) {
@@ -62,28 +53,13 @@
}
}
-my $templatedir = $panel->{templatedir};
-my $template = new Vhffs::Panel::Template(filename => $templatedir.'/panel/admin/tag/list.tmpl', die_on_bad_params => 0 );
-
$panel->set_title(gettext('Tags'));
+my $vars = {
+ tags => Vhffs::Tag::get_all($panel->{vhffs})
+};
+$panel->render('admin/tag/list.tt', $vars);
-my $tags = Vhffs::Tag::get_all($panel->{vhffs});
-# We should really drop HTML::Template....
-my $user = $panel->{user};
-my $loc = DateTime::Locale->load($user->get_lang);
-foreach(@$tags) {
- 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();
- $_->{category_name} = $_->get_category()->{label};
-}
-
-$template->param( 'TAGS' => $tags );
-
-$panel->build( $template );
-$panel->display;
-
sub delete_tag {
my $tag_id = $cgi->param('tag_id');
my $tag = Vhffs::Tag::get_by_tag_id($panel->{vhffs}, $tag_id);
Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am 2011-05-31 20:04:45 UTC (rev 1834)
+++ trunk/vhffs-panel/templates/Makefile.am 2011-05-31 20:04:56 UTC (rev 1835)
@@ -5,7 +5,6 @@
admin/main/main.tmpl \
admin/misc/list.tmpl \
admin/object/search.tmpl \
- admin/tag/list.tmpl \
admin/tag/category/create.tmpl \
admin/tag/category/edit.tmpl \
admin/tag/category/list.tmpl \
@@ -40,6 +39,7 @@
admin/object/list.tt \
admin/tag/create.tt \
admin/tag/edit.tt \
+ admin/tag/list.tt \
admin/user/list.tt \
anonymous/account_created.tt \
anonymous/login.tt \
Deleted: trunk/vhffs-panel/templates/admin/tag/list.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/list.tmpl 2011-05-31 20:04:45 UTC (rev 1834)
+++ trunk/vhffs-panel/templates/admin/tag/list.tmpl 2011-05-31 20:04:56 UTC (rev 1835)
@@ -1,30 +0,0 @@
-<a href="/admin/tag/create.pl"><TMPL_I18N KEY="Create new tag"></a>
-<TMPL_IF NAME="TAGS">
-<table border="1">
-<thead>
-<tr>
-<th><TMPL_I18N KEY="Category"></th><th><TMPL_I18N KEY="Label"></th><th><TMPL_I18N KEY="Description"></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="TAGS">
-<tr>
-<td><TMPL_VAR NAME="category_name"></td>
-<td><TMPL_VAR NAME="label" ESCAPE="1"></td><td><TMPL_VAR NAME="description" ESCAPE="1"></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="tag_id" value="<TMPL_VAR NAME="tag_id">"/>
- <input type="submit" value="<TMPL_I18N KEY="Edit">"/>
-</form></td>
-<td><form action="#" method="post">
- <input type="hidden" name="tag_id" value="<TMPL_VAR NAME="tag_id">"/>
- <input type="submit" value="<TMPL_I18N KEY="Delete">" name="delete_tag_submit"/>
-</form></td>
-</tr>
-</TMPL_LOOP>
-</tbody>
-</table>
-</TMPL_IF>
\ No newline at end of file
Added: trunk/vhffs-panel/templates/admin/tag/list.tt
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/list.tt (rev 0)
+++ trunk/vhffs-panel/templates/admin/tag/list.tt 2011-05-31 20:04:56 UTC (rev 1835)
@@ -0,0 +1,37 @@
+[% USE date %]
+<p><a href="/admin/tag/create.pl">[% 'Create new tag.' | i18n | html %]</a></p>
+[% IF tags.size() > 0 %]
+<table border="1">
+ <thead>
+ <tr>
+ <th>[% 'Category' | i18n | html %]</th><th>[% 'Label' | i18n | html %]</th>
+ <th>[% 'Description' | 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 t IN tags %]
+<tr>
+ <td>[% t.get_category.label | html %]</td>
+ <td>[% t.label | html %]</td>
+ <td>[% t.description | html %]</td>
+ <td>[% date.format(t.updated, '%x') %]</td>
+ <td>[% t.get_updater.get_username | html %]</td>
+ <td><form action="edit.pl" method="post">
+ <input type="hidden" name="tag_id" value="[% t.tag_id %]"/>
+ <input type="submit" value="[% 'Edit' | i18n | html %]"/>
+ </form></td>
+ <td><form action="#" method="post">
+ <input type="hidden" name="tag_id" value="[% t.tag_id %]"/>
+ <input type="submit" value="[% 'Delete' | i18n | html %]" name="delete_tag_submit"/>
+ </form></td>
+ </tr>
+[% END %]
+ </tbody>
+</table>
+[% ELSE %]
+ <p>[% 'No tag found.' | i18n | html %]
+[% END %]