package WebGUI::Asset::RichEdit; =head1 LEGAL ------------------------------------------------------------------- WebGUI is Copyright 2001-2009 Plain Black Corporation. ------------------------------------------------------------------- Please read the legal notices (docs/legal.txt) and the license (docs/license.txt) that came with this distribution before using this software. ------------------------------------------------------------------- http://www.plainblack.com info@plainblack.com ------------------------------------------------------------------- =cut use strict; use WebGUI::Form; use WebGUI::International; use JSON; use Tie::IxHash; use Moose; use WebGUI::Definition::Asset; extends 'WebGUI::Asset'; define assetName => ['assetName', 'Asset_RichEdit']; define icon => 'richEdit.gif'; define tableName => 'RichEdit'; property disableRichEditor => ( fieldType => 'yesNo', default => 0, label => ['disable rich edit', 'Asset_RichEdit'], hoverHelp => ['disable rich edit description', 'Asset_RichEdit'], ); property askAboutRichEdit => ( fieldType => 'yesNo', default => 0, label => ['using rich edit', 'Asset_RichEdit'], hoverHelp => ['using rich edit description', 'Asset_RichEdit'], ); property validElements => ( fieldType => 'textarea', default => 'a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]', label => ['elements', 'Asset_RichEdit'], hoverHelp => ['elements description', 'Asset_RichEdit'], subtext => ['elements subtext', 'Asset_RichEdit'], uiLevel => 9, ); property preformatted => ( fieldType => 'yesNo', default => 0, label => ['preformatted', 'Asset_RichEdit'], hoverHelp => ['preformatted description', 'Asset_RichEdit'], uiLevel => 9, ); property editorWidth => ( fieldType => 'integer', default => 0, label => ['editor width', 'Asset_RichEdit'], hoverHelp => ['editor width description', 'Asset_RichEdit'], uiLevel => 9, ); property editorHeight => ( fieldType => 'integer', default => 0, label => ['editor height', 'Asset_RichEdit'], hoverHelp => ['editor height description', 'Asset_RichEdit'], uiLevel => 9, ); property sourceEditorWidth => ( fieldType => 'integer', default => 0, label => ['source editor height', 'Asset_RichEdit'], hoverHelp => ['source editor height description', 'Asset_RichEdit'], ); property sourceEditorHeight => ( fieldType => 'integer', default => 0, label => ['source editor height', 'Asset_RichEdit'], hoverHelp => ['source editor height description', 'Asset_RichEdit'], ); property useBr => ( fieldType => 'yesNo', default => 0, label => ['use br', 'Asset_RichEdit'], hoverHelp => ['use br description', 'Asset_RichEdit'], uiLevel => 9, ); property removeLineBreaks => ( fieldType => 'yesNo', default => 0, label => ['remove line breaks', 'Asset_RichEdit'], hoverHelp => ['remove line breaks description', 'Asset_RichEdit'], uiLevel => 9, ); property nowrap => ( fieldType => 'yesNo', default => 0, label => ['no wrap', 'Asset_RichEdit'], hoverHelp => ['no wrap description', 'Asset_RichEdit'], uiLevel => 9, ); property directionality => ( fieldType => 'selectBox', default => 'ltr', label => ['directionality', 'Asset_RichEdit'], hoverHelp => ['directionality description', 'Asset_RichEdit'], options => \&_directionality_options, ); sub _directionality_options { my $session = shift->session; my $i18n = WebGUI::International->new($session, 'Asset_RichEdit'); return { ltr=>$i18n->get('left to right'), rtl=>$i18n->get('right to left'), }; } property toolbarLocation => ( fieldType => 'selectBox', default => 'bottom', label => ['toolbar location', 'Asset_RichEdit'], hoverHelp => ['toolbar location description', 'Asset_RichEdit'], options => \&_toolbarLocation_options, ); sub _toolbarLocation_options { my $session = shift->session; my $i18n = WebGUI::International->new($session, 'Asset_RichEdit'); return { top => $i18n->get('top'), bottom => $i18n->get('bottom'), }; } property cssFile => ( fieldType => 'text', default => undef, label => ['css file', 'Asset_RichEdit'], hoverHelp => ['css file description', 'Asset_RichEdit'], ); property toolbarRow1 => ( fieldType => 'checkList', default => undef, label => '', ); property toolbarRow2 => ( fieldType => 'checkList', default => undef, label => '', ); property toolbarRow3 => ( fieldType => 'checkList', default => undef, label => '', ); property enableContextMenu => ( fieldType => "yesNo", default => 0, label => ['enable context menu', 'Asset_RichEdit'], hoverHelp => ['enable context menu description', 'Asset_RichEdit'], ); property inlinePopups => ( fieldType => "yesNo", default => 0, label => ['inline popups', 'Asset_RichEdit'], hoverHelp => ['inline popups description', 'Asset_RichEdit'], ); property allowMedia => ( fieldType => "yesNo", default => 0, label => ['editForm allowMedia label', 'Asset_RichEdit'], hoverHelp => ['editForm allowMedia description', 'Asset_RichEdit'], ); has '+uiLevel' => ( default => 5, ); =head1 NAME Package WebGUI::Asset::RichEdit =head1 DESCRIPTION A configuration for rich editor. =head1 SYNOPSIS use WebGUI::Asset::RichEdit; =head1 METHODS These methods are available from this class: =cut #------------------------------------------------------------------- =head2 getEditForm ( ) Returns the WebGUI::FormBuilder object that will be used in generating the edit page for this asset. =cut override getEditForm => sub { my $self = shift; my $f = super(); my $i18n = WebGUI::International->new($self->session,'Asset_RichEdit'); my %buttons; tie %buttons, "Tie::IxHash"; %buttons = ( 'formatselect' => $i18n->get('formatselect'), 'styleselect' => $i18n->get('styleselect'), 'fontselect' => $i18n->get('fontselect'), 'fontsizeselect' => $i18n->get('fontsizeselect'), 'bold' => $i18n->get('bold'), 'italic' => $i18n->get('italic'), 'underline' => $i18n->get('underline'), 'strikethrough' => $i18n->get('strikethrough'), 'sub' => $i18n->get('sub'), 'sup' => $i18n->get('sup'), 'justifyleft' => $i18n->get('justifyleft'), 'justifycenter' => $i18n->get('justifycenter'), 'justifyright' => $i18n->get('justifyright'), 'numlist' => $i18n->get('numlist'), 'outdent' => $i18n->get('outdent'), 'indent' => $i18n->get('indent'), 'forecolor' => $i18n->get('forecolor'), 'backcolor' => $i18n->get('backcolor'), 'link' => $i18n->get('link'), 'unlink' => $i18n->get('unlink'), 'wgpagetree' => $i18n->get('pagetree'), 'image' => $i18n->get('image'), 'wginsertimage' => $i18n->get('insertImage'), 'media' => $i18n->get('media'), 'emotions' => $i18n->get('emotions'), 'wgmacro' => $i18n->get('collateral'), 'hr' => $i18n->get('hr'), 'advhr' => $i18n->get('advhr'), 'inserttime' => $i18n->get('inserttime'), 'insertdate' => $i18n->get('insertdate'), 'anchor' => $i18n->get('anchor'), 'tablecontrols' => $i18n->get('tablecontrols'), 'visualaid' => $i18n->get('visualaid'), 'charmap' => $i18n->get('charmap'), 'search' => $i18n->get('search'), 'replace' => $i18n->get('replace'), 'cut' => $i18n->get('cut'), 'copy' => $i18n->get('Copy'), 'paste' => $i18n->get('paste'), 'undo' => $i18n->get('undo'), 'redo' => $i18n->get('redo'), 'pastetext' => $i18n->get('pastetext'), 'pasteword' => $i18n->get('pasteword'), 'removeformat' => $i18n->get('removeformat'), 'cleanup' => $i18n->get('cleanup'), 'iespell' => $i18n->get('iespell'), 'save' => $i18n->get('save'), 'preview' => $i18n->get('preview'), 'print' => $i18n->get('print'), 'spellchecker' => $i18n->get('Server Side Spell Checker'), 'code' => $i18n->get('code'), 'fullscreen' => $i18n->get('fullscreen'), 'help' => $i18n->get('help'), # 'advlink' => "Advanced Link", # 'spacer' => "Toolbar Spacer", # 'separator' => "Toolbar Separator", # 'rowseparator' => "Toolbar Row Separator", # 'advimage' => "Advanced Image", ); my $buttonGrid = sprintf qq!
| %s | %s | %s | %s | |
| '.$buttons{$key}.' | '.WebGUI::Form::checkbox($self->session, { value=>$key, name=>"toolbarRow1", checked=>$checked1 }).' | '.WebGUI::Form::checkbox($self->session, { value=>$key, name=>"toolbarRow2", checked=>$checked2 }).' | '.WebGUI::Form::checkbox($self->session, { value=>$key, name=>"toolbarRow3", checked=>$checked3 }).' | '; if ($key eq 'spellchecker' && !($self->session->config->get('availableDictionaries'))) { $buttonGrid .= $i18n->get('no dictionaries'); } $buttonGrid .= ' |