[vhffs-dev] [1750] No more HTML::Template in object/resubmit.pl

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


Revision: 1750
Author:   beuss
Date:     2011-05-15 16:54:44 +0200 (Sun, 15 May 2011)
Log Message:
-----------
No more HTML::Template in object/resubmit.pl

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Main.pm
    trunk/vhffs-panel/object/resubmit.pl
    trunk/vhffs-panel/templates/Makefile.am

Added Paths:
-----------
    trunk/vhffs-panel/templates/object/resubmit.tt

Removed Paths:
-------------
    trunk/vhffs-panel/templates/misc/resubmit.tmpl

Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2011-05-15 14:54:33 UTC (rev 1749)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2011-05-15 14:54:44 UTC (rev 1750)
@@ -638,6 +638,9 @@
 			}, 1],
             stringify_status => sub {
                 return Vhffs::Functions::status_string_from_status_id( $_[0] );
+            },
+            stringify_type => sub {
+                Vhffs::Functions::type_string_from_type_id( $_[0] );
             }
 		},
         PRE_CHOMP => 1

Modified: trunk/vhffs-panel/object/resubmit.pl
===================================================================
--- trunk/vhffs-panel/object/resubmit.pl	2011-05-15 14:54:33 UTC (rev 1749)
+++ trunk/vhffs-panel/object/resubmit.pl	2011-05-15 14:54:44 UTC (rev 1750)
@@ -31,7 +31,6 @@
 
 use utf8;
 use POSIX qw(locale_h);
-use HTML::Template;
 use locale;
 use Locale::gettext;
 use CGI;
@@ -39,13 +38,9 @@
 use strict;
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Main;
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Group;
+use Vhffs::Group;
 use Vhffs::Constants;
-use Vhffs::Object;
 use Vhffs::ObjectFactory;
 
 my $panel = new Vhffs::Panel::Main();
@@ -59,24 +54,24 @@
 my $cgi = $panel->{cgi};
 
 my $oid = $cgi->param('oid');
-$panel->add_error( gettext('CGI Error !') ) unless defined $oid;
 
-my $object;
-if( defined $oid )  {
-	$object = Vhffs::ObjectFactory::fetch_object( $vhffs , $oid );
-	$panel->add_error( gettext('This object does not exist') ) unless defined $object;
+unless(defined $oid) {
+    $panel->render('misc/message.tt', { message => gettext('CGI Error !') } );
 }
 
-if( defined $object  &&  $object->get_status != Vhffs::Constants::VALIDATION_REFUSED )  {
-	$panel->add_error( gettext('This object is not in refused state') );
-	undef $object;
+my $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $oid );
+unless(defined $object) {
+	$panel->render('misc/message.tt', { message => gettext('This object does not exist') } );
 }
 
-if( defined $object  &&  $object->get_owner_uid != $user->get_uid )  {
-	$panel->add_error( gettext('You are not allowed to do it, you don\'t own this object') );
-	undef $object;
+unless($object->get_status == Vhffs::Constants::VALIDATION_REFUSED )  {
+    $panel->render('misc/message.tt', { message => gettext('This object is not in refused state') } );
 }
 
+unless($object->get_owner_uid == $user->get_uid )  {
+    $panel->render('misc/message.tt', { message => gettext('You are not allowed to do it, you don\'t own this object') } );
+}
+
 my $submitted = $cgi->param('submitted');
 
 if( $submitted && $object ) {
@@ -84,16 +79,13 @@
 	my $description = Encode::decode_utf8( $cgi->param('description') );
 	unless( defined $description ) {
 		$panel->add_error( gettext('CGI Error !') );
-	}
-	elsif( $description =~ /^\s*$/ ) {
+	} elsif( $description =~ /^\s*$/ ) {
 		$panel->add_error( gettext('You must enter a description') );
-	}
-	elsif ( $object->resubmit_for_moderation( $description ) )  {
+	} elsif ( $object->resubmit_for_moderation( $description ) ) {
 		my $url;
 		if( $object->get_type == Vhffs::Constants::TYPE_GROUP ) {
 			$url = '/group/index.pl?msg='.gettext('The new description has been submitted');
-		}
-		else {
+		} else {
 			my $group = Vhffs::Group::get_by_gid( $vhffs , $object->get_owner_gid );
 			$url = '/group/view.pl?group='.$group->get_groupname.'&msg='.gettext('The new description has been submitted');
 		}
@@ -106,33 +98,8 @@
 
 
 $panel->set_title( gettext('Propose a new description') );
+my $vars = {
+    object => $object
+};
+$panel->render('object/resubmit.tt', $vars);
 
-if( $panel->has_errors ) {
-
-	$panel->build;
-	$panel->display;
-}
-elsif( !$submitted ) {
-
-	my $template = new HTML::Template( filename => $templatedir.'/panel/misc/resubmit.tmpl' );
-
-	$template->param( OBJECTTYPE_TEXT => gettext('Object type') );
-	$template->param( OBJECTTYPE => Vhffs::Functions::type_string_from_type_id( $object->get_type ) );
-
-	$template->param( OBJECTNAME_TEXT => gettext('Object name') );
-	$template->param( OBJECTNAME => $object->get_label );
-
-	$template->param( REFUSEREASON_TEXT => gettext('Reason of refusal') );
-	$template->param( REFUSEREASON => $object->get_refuse_reason );
-
-	$template->param( DESCRIPTION_TEXT => gettext('Description') );
-	$template->param( DESCRIPTION => $object->get_description );
-
-	$template->param( WARNING_PUBLIC => gettext("Please consider that this description is going to be displayed in the public area. So you have to write it in impersonal form. You should take care to write it with correct grammar and tenses. Take all the time you need to fill it with the best content you are able to do.") ) if( $panel->is_public  &&  ( $object->get_type == Vhffs::Constants::TYPE_GROUP  ||  $object->get_type == Vhffs::Constants::TYPE_WEB ) );
-
-	$template->param( OID => $object->get_oid );
-	$template->param( SEND => gettext('Submit') );
-
-	$panel->build( $template );
-	$panel->display;
-}

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2011-05-15 14:54:33 UTC (rev 1749)
+++ trunk/vhffs-panel/templates/Makefile.am	2011-05-15 14:54:44 UTC (rev 1750)
@@ -88,7 +88,6 @@
 	misc/infos.tmpl \
 	misc/service_index.tmpl \
 	misc/simplemsg.tmpl \
-	misc/resubmit.tmpl \
 	mysql/create.tmpl \
 	mysql/prefs.tmpl \
 	git/create.tmpl \
@@ -129,6 +128,7 @@
 	misc/service-index.tt \
 	misc/welcome.tt \
 	object/delete.tt \
+	object/resubmit.tt \
 	pgsql/create.tt \
 	pgsql/prefs.tt \
 	repository/create.tt \

Deleted: trunk/vhffs-panel/templates/misc/resubmit.tmpl
===================================================================
--- trunk/vhffs-panel/templates/misc/resubmit.tmpl	2011-05-15 14:54:33 UTC (rev 1749)
+++ trunk/vhffs-panel/templates/misc/resubmit.tmpl	2011-05-15 14:54:44 UTC (rev 1750)
@@ -1,26 +0,0 @@
-<form method="post" action="" class="largeLabel" accept-charset="utf-8">
-	<p>
-		<label><TMPL_VAR ESCAPE=1 NAME="OBJECTTYPE_TEXT">:</label> <TMPL_VAR ESCAPE=1 NAME="OBJECTTYPE">
-	</p>
-	<p>
-		<label><TMPL_VAR ESCAPE=1 NAME="OBJECTNAME_TEXT">:</label> <TMPL_VAR ESCAPE=1 NAME="OBJECTNAME">
-	</p>
-	<p>
-		<label><TMPL_VAR ESCAPE=1 NAME="REFUSEREASON_TEXT">:</label> <TMPL_VAR ESCAPE=1 NAME="REFUSEREASON">
-	</p>
-	<p>
-		<label for="description">
-			<TMPL_VAR ESCAPE=1 NAME="DESCRIPTION_TEXT">:
-		</label>
-		<textarea name="description" id="description" cols="45" rows="7"><TMPL_VAR ESCAPE=1 NAME="DESCRIPTION"></textarea>
-	</p>
-	<TMPL_IF NAME="WARNING_PUBLIC">
-	<p>
-		<TMPL_VAR ESCAPE=1 NAME="WARNING_PUBLIC">
-	</p>
-	</TMPL_IF>
-	<input type="hidden" name="oid" value="<TMPL_VAR ESCAPE=1 NAME="OID">" />
-	<p class="button" id="buttonSend">
-		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="SEND">" name="submitted" />
-	</p>
-</form>

Added: trunk/vhffs-panel/templates/object/resubmit.tt
===================================================================
--- trunk/vhffs-panel/templates/object/resubmit.tt	                        (rev 0)
+++ trunk/vhffs-panel/templates/object/resubmit.tt	2011-05-15 14:54:44 UTC (rev 1750)
@@ -0,0 +1,25 @@
+<form method="post" action="" class="largeLabel" accept-charset="utf-8">
+	<p>
+		<label>[% 'Object type:' | i18n | html %]</label>
+            [% object.get_type | stringify_type | html %]
+	</p>
+	<p>
+		<label>[% 'Object name:' | i18n | html %]</label>
+            [% object.get_label | html %]
+	</p>
+	<p>
+		<label>[% 'Reason of refusal:' | i18n | html %]</label>
+            [% object.get_refuse_reason | html %]
+	</p>
+	<p>
+		<label for="description">[% 'New description:' | i18n | html %]</label>
+		<textarea name="description" id="description" cols="45" rows="7">[% object.get_description | html %]</textarea>
+	</p>
+[% IF has_public_area %]
+	<p>[% 'Please consider that this description is going to be displayed in the public area. So you have to write it in impersonal form. You should take care to write it with correct grammar and tenses. Take all the time you need to fill it with the best content you are able to do.' | i18n | html %]</p>
+[% END %]
+	<input type="hidden" name="oid" value="[% object.get_oid %]" />
+	<p class="button" id="buttonSend">
+		<input type="submit" value="[% 'Update' | i18n | html %]" name="submitted" />
+	</p>
+</form>


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