[interchange-cvs] interchange - racke modified code/Widget/htmlarea.widget

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Fri Dec 16 05:16:41 EST 2005


User:      racke
Date:      2005-12-16 10:16:40 GMT
Modified:  code/Widget htmlarea.widget
Log:
merged changes 1.6.2.1 vs 1.6.2.2
+++ 1.6.2.2 +++
merge fck widget with htmlarea widget

Revision  Changes    Path
1.8       +79 -23    interchange/code/Widget/htmlarea.widget


rev 1.8, prev_rev 1.7
Index: htmlarea.widget
===================================================================
RCS file: /var/cvs/interchange/code/Widget/htmlarea.widget,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- htmlarea.widget	26 Nov 2005 10:20:57 -0000	1.7
+++ htmlarea.widget	16 Dec 2005 10:16:40 -0000	1.8
@@ -1,6 +1,6 @@
 # Copyright 2005 Interchange Development Group (http://www.icdevgroup.org/)
 # Licensed under the GNU GPL v2. See file LICENSE for details.
-# $Id: htmlarea.widget,v 1.7 2005/11/26 10:20:57 racke Exp $
+# $Id: htmlarea.widget,v 1.8 2005/12/16 10:16:40 racke Exp $
 
 CodeDef htmlarea Widget 1
 CodeDef htmlarea Description Rich text editor
@@ -22,18 +22,28 @@
 
 =head1 DESCRIPTION
 
-The C<htmlarea> widget makes calls to HTMLArea, an excellent rich-text
-editor that replaces a C<TEXTAREA> component on supported browsers. It
-operates as a normal textarea otherwise.
+The C<htmlarea> widget makes calls to a rich-text editor that replaces 
+a C<TEXTAREA> component on supported browsers. It operates as a normal 
+textarea otherwise.
+
+Two flavours of rich-text editors are available, htmlarea (HTMLArea) and
+fckeditor (FCKeditor).
 
 Supported browsers include at least Mozilla 1.3.1 and higher, and
 MSIE 6 and higher.
 
 =head1 INSTALLATION
 
-To install, get HTMLArea-3.0-RC1 or later and install in the C<htmlarea>
-directory of your DocumentRoot. (That means that routines can be accessed
-with a base HREF of C</htmlarea/>.
+The flavour can be selected by the Interchange Variable HTMLAREA_FLAVOUR
+or the flavour option and defaults to htmlarea.
+
+To install the htmlarea flavour, get HTMLArea-3.0-RC1 or later and install 
+in the C<htmlarea> directory of your DocumentRoot. 
+That means that routines can be accessed with a base HREF of C</htmlarea/>).
+
+To install the fckeditor flavour, get FCKeditor 2.1 or later and install 
+in the C<fckeditor> directory of your DocumentRoot. 
+That means that routines can be accessed with a base HREF of C</fckeditor/>.
 
 Alternatively, you can set the Interchange Variable HTMLAREA_PATH to
 the appropriate path.
@@ -41,7 +51,7 @@
 This widget requires Interchange 5.0 and higher.
 
 If you are planning on using it outside of the Interchange UI, you must
-either have the output-style of layout (the "mike" demo) with a 
+either have the output-style of layout (the "standard" demo) with a 
 [scratch meta_header] call in the <HEAD> area, or you must place the
 equivalent of the following in the header of any page to use this widget:
 
@@ -52,9 +62,18 @@
 	</script>
 	<script type="text/javascript" src="[scratch tmp_hpath]htmlarea.js"></script>
 
+For the fckeditor flavour:
+
+    [tmp tmp_hpath][either]__HTMLAREA_PATH__[or]/htmlarea/[/either][/tmp]
+	<script type="text/javascript">
+	   _editor_url = "[scratch tmp_hpath]";
+	</script>
+	<script type="text/javascript" src="[scratch tmp_hpath]fckeditor.js"></script>
+
 The "en" is the language locale to use. If you use the output-style
 layout, this is automatically determined from the Interchange locale.
-You can also override this with the Variable HTMLAREA_LANG.
+You can also override this with the Variable HTMLAREA_LANG. This is not
+applicable for the fckeditor flavour.
 
 =head1 BUGS
 
@@ -70,6 +89,37 @@
 #::logDebug("called kupu widget, value=$opt->{value}");
 	use vars qw/$Tag/;
 
+	my %flavours = (htmlarea => {path => '/htmlarea/',
+					header => qq|
+<script type="text/javascript">
+   _editor_url = "{PATH}";
+   _editor_lang = "{LANG}";
+</script>
+<script type="text/javascript" src="{PATH}htmlarea.js"></script>
+|,
+					area => qq|<textarea id="htmlarea_{NAME}" rows="{HEIGHT}" cols={WIDTH} name="{NAME}"{ONMOUSE}>{VALUE}</textarea>|},
+					fckeditor => {path => '/fckeditor/',
+					header => qq|
+<script type="text/javascript" src="{PATH}fckeditor.js"></script>
+<script type="text/javascript">
+   _editor_url = "{PATH}";
+</script>|,
+					pre => qq|<script>
+window.onload = function()
+{
+    var {NAME}FCKeditor = new FCKeditor( '{NAME}' ) ;
+    {NAME}FCKeditor.BasePath = _editor_url ;
+    {NAME}FCKeditor.ReplaceTextarea() ;
+}
+
+</script>
+|,
+					area => qq|<textarea id="{NAME}" rows="{HEIGHT}" cols="{WIDTH}" name="{NAME}">{VALUE}</textarea>|,
+					post => ''
+});
+	
+	my $flavour = $opt->{flavour} || $::Variable->{HTMLAREA_FLAVOUR} || 'htmlarea';
+
 	my $fname = $opt->{form_name} || 'editor';
 
 	my $callpage = $opt->{append} || 'special/kupu';
@@ -87,17 +137,11 @@
 	if(! $::Scratch->{htmlarea_added}) {
 		$Tag->tmp({ name => 'htmlarea_added', body => 1 });
 		$::Scratch->{meta_header} ||= '';
-		my $path = $::Variable->{HTMLAREA_PATH} || '/htmlarea/';
+		my $path = $::Variable->{HTMLAREA_PATH} || $flavours{$flavour}->{path};
 		my $lang = $::Variable->{HTMLAREA_LANG} || $::Scratch->{mv_locale} || 'en';
 		$lang = substr($lang, 0, 2);
 		$path =~ s:/*$:/:;
-		$::Scratch->{meta_header} .= <<EOF;
-<script type="text/javascript">
-   _editor_url = "$path";
-   _editor_lang = "$lang";
-</script>
-<script type="text/javascript" src="${path}htmlarea.js"></script>
-EOF
+		$::Scratch->{meta_header} .= $Tag->uc_attr_list({hash => {path => $path, lang => $lang}}, $flavours{$flavour}->{header});
 	}
 
 	my $val;
@@ -117,20 +161,32 @@
 	}
 
 	if($Session->{browser} =~ /MSIE/) {
-	    $pre_scr = qq{
+		if ($flavour eq 'htmlarea') {
+		    $pre_scr = qq{
 <script>
 var htmlarea_needinit_$pname = true;
 </script>
 };
-		$onmouse = qq{ onMouseOver="if(htmlarea_needinit_$pname) { HTMLArea.replace('htmlarea_$pname'$htmlarea_config); htmlarea_needinit_$pname=false }"};
+			$onmouse = qq{ onMouseOver="if(htmlarea_needinit_$pname) { HTMLArea.replace('htmlarea_$pname'$htmlarea_config); htmlarea_needinit_$pname=false }"};
+		}
 	}
 	else {
-		$post_scr = <<EOF;
+		if ($flavour eq 'fckeditor') {
+			$post_scr = <<EOF;
+
+EOF
+		} else {
+			$post_scr = <<EOF;
 <script>
 	HTMLArea.replace('htmlarea_$pname'$htmlarea_config);
 </script>
 EOF
+		}
 	}
+
+	$pre_scr .= $Tag->uc_attr_list({hash => {name => $pname},
+									body => $flavours{$flavour}->{pre}});
+
 	$opt->{height} =~ s/\D+//;
 	$opt->{width} =~ s/\D+//;
 	
@@ -141,9 +197,9 @@
 	my $textra = $opt->{text_class} ? qq{ class="$opt->{text_class}"} : '';
 	$textra .= qq{ style="$opt->{text_style}"} if $opt->{text_style};
 
-	my $wid = qq{$pre_scr
-<textarea id="htmlarea_$pname" rows=$opt->{height} cols=$opt->{width} name=$pname$onmouse>$val</textarea>
-$post_scr};
+	my $wid = $pre_scr . $Tag->uc_attr_list({hash => {name => $pname,
+		height => $opt->{height}, width => $opt->{width}, mouse => $onmouse,
+		value => $val}, body => $flavours{$flavour}->{area}}) . $post_scr;
 	
 	return $wid;
 }








More information about the interchange-cvs mailing list