[interchange-cvs] interchange - heins modified code/Widget/fck.widget

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Sun Oct 9 14:02:35 EDT 2005


User:      heins
Date:      2005-10-09 18:02:35 GMT
Added:     code/Widget fck.widget
Log:
* Add basic widget that gives access to the FCKeditor rich text
  editor.

* TODO: Integrate file browser component.

* Documentation in .widget file.

Revision  Changes    Path
1.1                  interchange/code/Widget/fck.widget


rev 1.1, prev_rev 1.0
Index: fck.widget
===================================================================
CodeDef fck Widget 1
CodeDef fck Description FCK rich text editor
CodeDef fck Documentation <<EOD
=head1 NAME

HTMLArea widget for Interchange

=head1 SYNOPSIS

  [display type=fck name=foo height=NN width=NNN]

 or

  [table-editor
  	widget.foo=fck
	...
  ]

=head1 DESCRIPTION

The C<fck> widget makes calls to FCKeditor, an excellent rich-text
editor that replaces a C<TEXTAREA> component on supported browsers. It
operates as a normal textarea otherwise.

Supported browsers include at least Mozilla 1.3.1 and higher, including
Firefox, and MSIE 6 and higher.

=head1 INSTALLATION

To install, 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 FCKEDITOR_PATH to
the appropriate path.

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 
[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:

    [tmp tmp_hpath][either]__FCKEDITOR_PATH__[or]/fckeditor/[/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 FCKEDITOR_LANG.

=head1 BUGS

A bug in MSIE doesn't allow initialization of a textarea until the
complete document is loaded. This means that the editor toolbox will not
show up until the mouse enters the C<TEXTAREA>.

EOD

CodeDef fck Routine <<EOR
sub {
	my ($opt) = @_;
#::logDebug("called kupu widget, value=$opt->{value}");
	use vars qw/$Tag/;

	my $fname = $opt->{form_name} || 'editor';

	my $callpage = $opt->{append} || 'special/kupu';

	my $pname = $opt->{name};

	my $wname = $opt->{window_name} || "ic_kupu_$pname";

	$pname =~ s/\W/_/g;

	unless(defined $opt->{close_window}) {
		$opt->{close_window} = 1;
	}

	if(! $::Scratch->{fck_added}) {
		$Tag->tmp({ name => 'fck_added', body => 1 });
		$::Scratch->{meta_header} ||= '';
		my $path = $::Variable->{FCKEDITOR_PATH} || '/fckeditor/';
		my $lang = $::Variable->{FCKEDITOR_LANG} || $::Scratch->{mv_locale} || 'en';
		$lang = substr($lang, 0, 2);
		$path =~ s:/*$:/:;
		$::Scratch->{meta_header} .= <<EOF;
<script type="text/javascript" src="${path}fckeditor.js"></script>
<script type="text/javascript">
   _editor_url = "$path";
</script>
EOF
	}

	my $val;
	if($opt->{value} =~ /</) {
		$val = HTML::Entities::encode($opt->{value});
	}
	else {
		$val = $opt->{value};
	}
	my $pre_scr = '';
	my $post_scr = '';
	my $onmouse = '';

	my $edname = $pname . 'FCKeditor';

	$pre_scr = qq{
<script>
window.onload = function()
{
    var $edname = new FCKeditor( '$pname' ) ;
    $edname.BasePath = _editor_url ;
    $edname.ReplaceTextarea() ;
}

</script>
};

	$opt->{height} =~ s/\D+//;
	$opt->{width} =~ s/\D+//;
	
	$opt->{anchor_style} ||= 'font-size: smaller';

	my $extra = $opt->{anchor_class} ? qq{ class="$opt->{anchor_class}"} : '';
	$extra .= qq{ style="$opt->{anchor_style}"} if $opt->{anchor_style};
	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="$pname" rows=$opt->{height} cols=$opt->{width} name=$pname>$val</textarea>
$post_scr};
	
	return $wid;
}
EOR








More information about the interchange-cvs mailing list