package Egg::Plugin::WYSIWYG::FCKeditor; # # Masatoshi Mizuno ElusheE<64>cpan.orgE # # $Id: FCKeditor.pm 337 2008-05-14 12:30:09Z lushe $ # use strict; use warnings; our $VERSION = '3.00'; sub _setup { my($e)= @_; $e->isa('Egg::Plugin::Tools') || die q{ I want 'Egg::Plugin::Tools' loaded. }; my $c= $e->config->{plugin_wysiwyg_fckeditor} ||= {}; $c->{width} ||= '100%'; $c->{height} ||= '450px'; $c->{style} ||= "width:$c->{width}; height:$c->{height}"; $c->{instance} ||= 'FCKfield'; $c->{tool_bar} ||= 'Default'; $c->{base_uri} ||= '/FCKeditor'; $c->{base_uri}=~s{/+$} []; $e->next::method; } sub fck { $_[0]->{fck_editor} ||= Egg::Plugin::WYSIWYG::FCKeditor::handler->new(@_); } package Egg::Plugin::WYSIWYG::FCKeditor::handler; use strict; use base qw/ Egg::Base /; sub new { my($class, $e)= @_; $class->SUPER::new($e, $e->config->{plugin_wysiwyg_fckeditor}); } sub is_compat { return $_[0]->{is_compat} if exists($_[0]->{is_compat}); $_[0]->{is_compat}= do { my $a= $_[0]->e->request->agent; ($a=~/MSIE/i and $a!~/mac/i and $a!~/Opera/i) ? do { return 0 if $a!~m{\d}; substr($a, index($a, 'MSIE')+ 5, 3)>= 5.5 ? 1: 0; }: ($a=~/Gecko\//i) ? do { substr($a, index($a,'Gecko/')+ 6, 8)>= 20030210 ? 1: 0; }: do { 0 }; }; } sub html { my $self= shift; my $attr= $_[1] ? {@_}: (ref($_[0]) eq 'HASH' ? $_[0]: {}); if ($attr->{width} or $attr->{height}) { $attr->{style}= 'width:' . ($attr->{width} || $self->params->{width}) . ';height:'. ($attr->{height} || $self->params->{height}); } my $p= { %{$self->params}, %$attr }; my $query; if ($query= $self->e->request->param($p->{instance}) || "") { $query= $self->e->escape_html($query); } return $self->is_compat ? do { <$query END_HTML }: do { my $uri= "$p->{base_uri}/editor/fckeditor.html" . "?InstanceName=$p->{instance}&Toolbar=$p->{tool_bar}"; <