[vhffs-dev] [1833] No more HTML::Template in tag/create

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


Revision: 1833
Author:   beuss
Date:     2011-05-31 22:04:33 +0200 (Tue, 31 May 2011)
Log Message:
-----------
No more HTML::Template in tag/create

Modified Paths:
--------------
    trunk/vhffs-panel/admin/tag/create.pl
    trunk/vhffs-panel/templates/Makefile.am

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

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

Modified: trunk/vhffs-panel/admin/tag/create.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/create.pl	2011-05-31 20:04:21 UTC (rev 1832)
+++ trunk/vhffs-panel/admin/tag/create.pl	2011-05-31 20:04:33 UTC (rev 1833)
@@ -37,50 +37,34 @@
 
 
 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;
 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};
+my $vars = {};
 
 if(defined $cgi->param('create_tag_submit')) {
 	if(create()) {
 		$panel->redirect('/admin/tag/index.pl?msg='.gettext('Tag successfully created'));
-		exit(0);
 	}
 }
 
-my $templatedir = $panel->{templatedir};
+$vars->{categories} = Vhffs::Tag::Category::get_all($panel->{vhffs});
+$panel->render('admin/tag/create.tt', $vars);
 
-my $template = new Vhffs::Panel::Template(filename => $templatedir.'/panel/admin/tag/create.tmpl', die_on_bad_params => 0);
-
-$panel->set_title(gettext('Create Tag'));
-
-$template->param( CATEGORY_TEXT => gettext('Category') );
-$template->param( CATEGORIES => Vhffs::Tag::Category::get_all($panel->{vhffs}) );
-$template->param( LABEL_TEXT => gettext('Label') );
-$template->param( DESCRIPTION_TEXT => gettext('Description') );
-$template->param( CREATE_TEXT => gettext('Create') );
-
-$panel->build( $template );
-$panel->display;
-
-
 sub create {
 	my $category_id = $cgi->param('category_id');
 	my $label = $cgi->param('label');
 	my $description = $cgi->param('description');
 	my $main = $panel->{vhffs};
-	
+
+    $vars->{label} = $label;
+    $vars->{description} = $description;
+    $vars->{category_id} = $category_id;
+
 	unless(defined $category_id && defined $label && defined $description) {
 		$panel->add_error( gettext('CGI Error!') );
 		return 0;
@@ -110,7 +94,8 @@
 	
 	unless(defined Vhffs::Tag::create($main, $label, $description, $panel->{user}, $category)) {
 		$panel->add_error( gettext('Unable to create tag') );
+        return 0;
 	}
 	
 	return 1;
-}
\ No newline at end of file
+}

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-31 20:04:21 UTC (rev 1832)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-31 20:04:33 UTC (rev 1833)
@@ -5,7 +5,6 @@
 	admin/main/main.tmpl \
 	admin/misc/list.tmpl \
 	admin/object/search.tmpl \
-	admin/tag/create.tmpl \
 	admin/tag/edit.tmpl \
 	admin/tag/list.tmpl \
 	admin/tag/category/create.tmpl \
@@ -40,6 +39,7 @@
 	admin/moderation/index.tt \
 	admin/object/edit.tt \
 	admin/object/list.tt \
+	admin/tag/create.tt \
 	admin/user/list.tt \
 	anonymous/account_created.tt \
 	anonymous/login.tt \

Deleted: trunk/vhffs-panel/templates/admin/tag/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/create.tmpl	2011-05-31 20:04:21 UTC (rev 1832)
+++ trunk/vhffs-panel/templates/admin/tag/create.tmpl	2011-05-31 20:04:33 UTC (rev 1833)
@@ -1,16 +0,0 @@
-<form name="createTag" accept-charset="utf-8" method="post">
-<p><label for="category"><TMPL_VAR NAME="CATEGORY_TEXT"></label>
-<select name="category_id" id="category">
-<TMPL_LOOP NAME="CATEGORIES">
-<option value="<TMPL_VAR NAME="CATEGORY_ID">"><TMPL_VAR NAME="LABEL"></option>
-</TMPL_LOOP>
-</select>
-</p>
-<p><label for="label"><TMPL_VAR NAME="LABEL_TEXT"></label>
-	<input type="text" name="label" id="label" value="<TMPL_VAR NAME="LABEL_VALUE">"/></p>
-<p><label for="description"><TMPL_VAR NAME="DESCRIPTION_TEXT"></label>
-	<textarea name="description" id="description"></textarea></p>
-<p class="button">
-	<input type="submit" name="create_tag_submit" value="<TMPL_VAR NAME="CREATE_TEXT">"/>
-</p> 
-</form>
\ No newline at end of file

Added: trunk/vhffs-panel/templates/admin/tag/create.tt
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/create.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/admin/tag/create.tt	2011-05-31 20:04:33 UTC (rev 1833)
@@ -0,0 +1,16 @@
+<form name="createTag" accept-charset="utf-8" method="post">
+<p><label for="category">[% 'Category:' | i18n | html %]</label>
+<select name="category_id" id="category">
+[% FOREACH c IN categories %]
+<option value="[% c.category_id %]"[% ' selected="selected"' IF c.category_id == category_id %]>[% c.label | html %]</option>
+[% END %]
+</select>
+</p>
+<p><label for="label">[% 'Label:' | i18n | html %]</label>
+	<input type="text" name="label" id="label" value="[% label | html %]"/></p>
+<p><label for="description">[% 'Description:' | i18n | html %]</label>
+	<textarea name="description" id="description">[% description | html %]</textarea></p>
+<p class="button">
+	<input type="submit" name="create_tag_submit" value="[% 'Create' | i18n | html %]"/>
+</p> 
+</form>


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