[vhffs-dev] [1839] No more HTML::Template in tag/request/details.

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


Revision: 1839
Author:   beuss
Date:     2011-06-02 23:08:42 +0200 (Thu, 02 Jun 2011)
Log Message:
-----------
No more HTML::Template in tag/request/details.

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Tag/Request.pm
    trunk/vhffs-panel/admin/tag/request/details.pl
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/admin/tag/request/details.tt

Modified: trunk/vhffs-api/src/Vhffs/Tag/Request.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag/Request.pm	2011-05-31 20:05:23 UTC (rev 1838)
+++ trunk/vhffs-api/src/Vhffs/Tag/Request.pm	2011-06-02 21:08:42 UTC (rev 1839)
@@ -40,6 +40,7 @@
 
 package Vhffs::Tag::Request;
 
+use Vhffs::ObjectFactory;
 
 sub create {
 	my ($main, $category, $tag, $requester, $tagged) = @_;

Modified: trunk/vhffs-panel/admin/tag/request/details.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/request/details.pl	2011-05-31 20:05:23 UTC (rev 1838)
+++ trunk/vhffs-panel/admin/tag/request/details.pl	2011-06-02 21:08:42 UTC (rev 1839)
@@ -34,8 +34,6 @@
 
 use utf8;
 use POSIX qw(locale_h);
-use DateTime;
-use DateTime::Locale;
 use locale;
 use Locale::gettext;
 use CGI;
@@ -45,91 +43,69 @@
 
 use lib '%VHFFS_LIB_DIR%';
 use Vhffs::Main;
-use Vhffs::ObjectFactory;
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Template;
+use Vhffs::Panel::Modo;
 use Vhffs::Tag;
 use Vhffs::Tag::Category;
 use Vhffs::Tag::Request;
    
-my $panel = new Vhffs::Panel::Main();
-exit 0 unless $panel;
-my $session = $panel->get_session;
-exit 0 unless $session;
-my $templatedir = $panel->{'templatedir'};
+my $panel = new Vhffs::Panel::Modo();
+
 my $cgi = $panel->{cgi};
 my $vhffs = $panel->{vhffs};
 
-$panel->check_modo;
-
 my $request_id;
+my $vars = {};
 
 unless(defined ($request_id = $cgi->param('request_id'))) {
-	my $url = '/admin/tag/request/list.pl?error='.gettext('CGI Error');
-	$panel->redirect($url);
+    $panel->render('misc/message.tt', {
+        message => gettext('CGI Error'),
+        refresh_url => '/admin/tag/request/list.pl'
+    });
 }
 
 my $request;
 
 unless(defined ($request = Vhffs::Tag::Request::get_by_request_id($vhffs, $request_id))) {
-	my $url = '/admin/tag/request/list.pl?error='.gettext('Tag request not found');
-	$panel->redirect($url);
+    $panel->render('misc/message.tt', {
+        message => gettext('Tag request not found'),
+        refresh_url => '/admin/tag/request/list.pl'
+    });
 }
 
-my $template = new Vhffs::Panel::Template( filename => $templatedir.'/panel/admin/tag/request/details.tmpl', die_on_bad_params => 0 );
-
 if(defined $cgi->param('accept_request_submit')) {
 	if(accept_request()) {
-		my $url = '/admin/tag/request/list.pl?msg='.gettext('Tag request accepted');
-		$panel->redirect($url);
+        $panel->render('misc/message.tt', {
+            message => gettext('Tag request accepted'),
+            refresh_url => '/admin/tag/request/list.pl'
+        });
 	} else {
-		$template->param('CATEGORY' => $cgi->param('category_label'));
-		$template->param('CATEGORY_DESCRIPTION' => $cgi->param('category_description'));
-		$template->param('TAG' => $cgi->param('tag_label'));
-		$template->param('TAG_DESCRIPTION' => $cgi->param('tag_description'));
+        $vars->{category_label} = $cgi->param('category_label');
+        $vars->{category_description} = $cgi->param('category_description');
+        $vars->{tag_label} = $cgi->param('tag_label');
+        $vars->{tag_description} = $cgi->param('tag_description');
 	}
 } elsif(defined $cgi->param('discard_request_submit')) {
 	$request->delete();
-	my $url = '/admin/tag/request/list.pl?msg='.gettext('Tag request deleted');
-	$panel->redirect($url);
-} else {
-	$template->param('CATEGORY' => $request->{category_label});
-	$template->param('TAG' => $request->{tag_label});
+    $panel->render('misc/message.tt', {
+        message => gettext('Tag request deleted'),
+        refresh_url => '/admin/tag/request/list.pl'
+    });
 }
 
-my $user = $panel->{user};
 $panel->set_title( gettext('Tag request details') );
-my $loc = DateTime::Locale->load($user->get_lang);
 
-my $dt = DateTime->from_epoch( epoch => $request->{created}, locale => $user->get_lang);
-
-my $tag_requester   = $request->get_requester;
-my $requester_param = defined($tag_requester) ? $tag_requester->get_username : gettext('DELETED');
-
-my $tagged_object   = $request->get_tagged;
-my $tagged_param    = defined($tagged_object) ? $tagged_object->get_label    : gettext('DELETED');
-
-$template->param('REQUEST_ID' => $request->{request_id});
-$template->param('REQUESTER' => $requester_param);
-$template->param('TAGGED' => $tagged_param);
-$template->param('CREATED' =>  $dt->strftime($loc->medium_date_format().' '.$loc->long_time_format()));
-$template->param('CATEGORIES' => Vhffs::Tag::Category::get_all($vhffs));
-
 my $category_id = $cgi->param('category');
 
 if(defined $category_id) {
-	$template->param('TAGS' => Vhffs::Tag::get_by_category_id($vhffs, $category_id));
-	$template->param('SELECTED_CATEGORY_ID' => $category_id);
-} else {
-	# Avoid warning in tmpl_expr
-	$template->param('SELECTED_CATEGORY_ID' => -1);
+    $vars->{category_tags} = Vhffs::Tag::get_by_category_id($vhffs, $category_id);
+    $vars->{selected_category} = $category_id;
 }
+$vars->{categories} = Vhffs::Tag::Category::get_all($vhffs);
+$vars->{request} = $request;
 
+$panel->render('admin/tag/request/details.tt', $vars);
 
-$panel->build($template);
-$panel->display;
 
-
 sub accept_request {
 	my $category_id = $cgi->param('category');
 	my $category_label = $cgi->param('category_label');
@@ -206,7 +182,7 @@
 	
 	my $object = $request->get_tagged();
 	if(defined $object) {
-		$user = $request->get_requester();
+		my $user = $request->get_requester();
 		$user = $panel->{user} unless(defined $user);
 		$object->add_tag($tag, $user);
 	}

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-31 20:05:23 UTC (rev 1838)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-06-02 21:08:42 UTC (rev 1839)
@@ -5,7 +5,6 @@
 	admin/main/main.tmpl \
 	admin/misc/list.tmpl \
 	admin/object/search.tmpl \
-	admin/tag/request/details.tmpl \
 	admin/tag/request/list.tmpl \
 	menu/context.tmpl \
 	menu/context-group.tmpl \
@@ -40,6 +39,7 @@
 	admin/tag/create.tt \
 	admin/tag/edit.tt \
 	admin/tag/list.tt \
+	admin/tag/request/details.tt \
 	admin/user/list.tt \
 	anonymous/account_created.tt \
 	anonymous/login.tt \

Added: trunk/vhffs-panel/templates/admin/tag/request/details.tt
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/request/details.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/admin/tag/request/details.tt	2011-06-02 21:08:42 UTC (rev 1839)
@@ -0,0 +1,46 @@
+[% USE date %]
+<p><label>[% 'Category:' | i18n | html %]</label>[% request.category_label | html %]</p>
+<p><label>[% 'Tag:' | i18n | html %]</label>[% request.tag_label | html %]</p>
+<p><label>[% 'Requester:' | i18n | html %]</label>[% request.get_requester ? request.get_requester.get_username : 'DELETED' %]</p>
+<p><label>[% 'Tagged object:' | i18n | html %]</label>[% request.get_tagged ? request.get_tagged.get_label : 'DELETED' %]</p>
+<p><label>[% 'Date:' | i18n | html %]</label>[% date.format(request.created, '%x') %]</p>
+<p class="info">[% 'You can either accept the request (and possibly change the name of the tag/category) or reattach it to an existing category and/or tag. If you choose to create a category, you\'ve to create the tag too.' | i18n | html %]</p>
+<fieldset>
+<legend>[% 'Manage request' | i18n | html %]</legend>
+<form name="manageTagRequestForm" id="manageTagRequestForm" action="/admin/tag/request/details.pl" method="post">
+<div style="width:50%;float:left">
+<h3>Category</h3>
+<p><select name="category" id="tagRequestCategorySelect">
+<option value="-1">--- [% 'Create category' | i18n | html %]</option>
+[% FOREACH c IN categories %]
+<option value="[% c.category_id %]"[% ' selected="selected"' IF selected_category == c.category_id %]>[% c.label | html %]</option>
+[% END %]
+</select></p>
+<p><input type="text" name="category_label" value="[% category_label | html %]"/></p>
+<p><textarea name="category_description" style="width:90%">[% category_description | html %]</textarea></p>
+</div>
+<div style="width:50%; float:right">
+<h3>Tag</h3>
+<select name="tag">
+<option value="-1">--- [% 'Create tag' | i18n | html %]</option>
+[% FOREACH t IN category_tags %]
+<option value="[% t.tag_id %]">[% t.label | html %]</option>
+[% END %]
+</select>
+<p><input type="text" name="tag_label" value="[% tag_label | html %]"/></p>
+<p><textarea name="tag_description" style="width:90%">[% tag_description | html %]</textarea></p>
+</div>
+<div style="clear:both"></div>
+<p class="button">
+	<input type="submit" name="accept_request_submit" value="[% 'Accept' | i18n | html %]"/>&nbsp;
+	<input type="submit" name="discard_request_submit" value="[% 'Refuse' | i18n | html %]"/>
+</p>
+<input type="hidden" name="request_id" value="[% request.request_id %]"/>
+</form>
+</fieldset>
+<script type="text/javascript">
+Event.observe($('tagRequestCategorySelect'), 'change', function(e) {
+	$('manageTagRequestForm').submit();
+});
+</script>
+


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