Mailing List Archive

svn commit: r1663197 - /perl/embperl/trunk/Embperl/Form/Control/textarea.pm
Author: richter
Date: Mon Mar 2 07:14:24 2015
New Revision: 1663197

URL: http://svn.apache.org/r1663197
Log:
textarea with html

Modified:
perl/embperl/trunk/Embperl/Form/Control/textarea.pm

Modified: perl/embperl/trunk/Embperl/Form/Control/textarea.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/textarea.pm?rev=1663197&r1=1663196&r2=1663197&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/textarea.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/textarea.pm Mon Mar 2 07:14:24 2015
@@ -22,7 +22,96 @@ use base 'Embperl::Form::Control' ;

use Embperl::Inline ;

+use vars qw{%fdat} ;

+use constant ALLOWED_HTML_TAGS => {map { $_ => 1 } qw{p br img ol ul td th tr td div h1 h2 h3 h4 h5 h6 pre strong em u s sub sup li blockquote caption table tbody tfoot thead hr span big small tt code kbd samp var del ins cite address } };
+
+
+# ---------------------------------------------------------------------------
+#
+# init - init the new control
+#
+
+sub init
+
+ {
+ my ($self) = @_ ;
+
+ return $self ;
+ }
+
+# ------------------------------------------------------------------------------------------
+#
+# _filter_html - remove all not allowed html tags
+#
+
+sub _filter_html
+ {
+ my ($self, $dataref) = @_ ;
+
+ $$dataref =~ s/(<\/?(\w+?).+?>)/ALLOWED_HTML_TAGS->{$2}?$1:''/ge ;
+ }
+
+# ------------------------------------------------------------------------------------------
+#
+# get_display_text - returns the text that should be displayed
+#
+
+sub get_display_text
+ {
+ my ($self, $req, $value) = @_ ;
+
+ $value = $self -> get_value ($req) if (!defined ($value)) ;
+
+ $self -> _filter_html (\$value) if ($self -> {format} eq 'html') ;
+
+ return $value ;
+ }
+
+
+
+# ------------------------------------------------------------------------------------------
+#
+# init_data - daten aufteilen
+#
+
+sub init_data
+ {
+ my ($self, $req, $parentctrl, $force) = @_ ;
+
+ return if ($self -> {format} ne 'html') ;
+
+ my $fdat = $req -> {docdata} || \%fdat ;
+ my $name = $self->{name} ;
+ $self -> _filter_html (\{$fdat->{$name}}) ;
+
+ return ;
+ }
+
+# ---------------------------------------------------------------------------
+#
+# init_markup - add any dynamic markup to the form data
+#
+
+sub init_markup
+
+ {
+ my ($self, $req, $parentctl, $method) = @_ ;
+
+ return $self -> init_data ($req, $parentctl) ;
+ }
+
+# ------------------------------------------------------------------------------------------
+#
+# prepare_fdat - daten zusammenfuehren
+#
+
+sub prepare_fdat
+ {
+ my ($self, $req) = @_ ;
+
+ return $self -> init_data ($req) ;
+ }

1 ;

@@ -41,7 +130,10 @@ $]
[- $self -> SUPER::show ($req) -]
[$else$]

+[#
<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} +] [+ $self -> {state} +]" style="width: 348px">
+#]
+<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} +] [+ $self -> {state} +]">
<tr>
<td class="ef-label-box ef-label-box-width-full [$ if $self->{labelclass} $][+ " $self->{labelclass}" +][$ endif $]">
[-
@@ -76,6 +168,7 @@ $]
<textarea type="text" name="[+ $self -> {force_name} || $self -> {name} +]" [+ do { local $escmode = 0 ; $attrs} +]
[# [$if $self -> {cols} $]cols="[+ $self->{cols} +]"[$endif$] #]
[$if $self -> {rows} $]rows="[+ $self->{rows} +]"[$endif$]
+[$if $self -> {format} eq 'html' $]_ef_attach="ef_ckeditor"[$endif$]
></textarea>
[* return $ctrlid ; *]
[$endsub$]



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org