upgrading to TinyMCE 3

This commit is contained in:
Graham Knop 2008-03-27 22:12:33 +00:00
parent d245e8ef48
commit cc75819ca9
2274 changed files with 25785 additions and 107069 deletions

View file

@ -19,7 +19,10 @@ use WebGUI::Asset;
use WebGUI::Form;
use WebGUI::Utility;
use WebGUI::International;
eval 'use Text::Aspell'; # Optional
use JSON;
BEGIN {
eval { require Text::Aspell }; # Optional
}
our @ISA = qw(WebGUI::Asset);
@ -58,92 +61,96 @@ A hash reference passed in from a subclass definition.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session,'Asset_RichEdit');
push(@{$definition}, {
assetName=>$i18n->get('assetName'),
icon=>'richEdit.gif',
uiLevel => 5,
tableName=>'RichEdit',
className=>'WebGUI::Asset::RichEdit',
properties=>{
disableRichEditor=>{
fieldType=>'yesNo',
defaultValue=>0
},
askAboutRichEdit=>{
fieldType=>'yesNo',
defaultValue=>0
},
validElements=>{
fieldType=>'textarea',
defaultValue=>'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]'
},
preformatted=>{
fieldType=>'yesNo',
defaultValue=>0
},
editorWidth=>{
fieldType=>'integer',
defaultValue=>0
},
editorHeight=>{
fieldType=>'integer',
defaultValue=>0
},
sourceEditorWidth=>{
fieldType=>'integer',
defaultValue=>0
},
sourceEditorHeight=>{
fieldType=>'integer',
defaultValue=>0
},
useBr=>{
fieldType=>'yesNo',
defaultValue=>0
},
removeLineBreaks=>{
fieldType=>'yesNo',
defaultValue=>0
},
nowrap=>{
fieldType=>'yesNo',
defaultValue=>0
},
directionality=>{
fieldType=>'selectBox',
defaultValue=>'ltr'
},
toolbarLocation=>{
fieldType=>'selectBox',
defaultValue=>'bottom'
},
cssFile=>{
fieldType=>'text',
defaultValue=>undef
},
toolbarRow1=>{
fieldType=>'checkList',
defaultValue=>undef
},
toolbarRow2=>{
fieldType=>'checkList',
defaultValue=>undef
},
toolbarRow3=>{
fieldType=>'checkList',
defaultValue=>undef
},
enableContextMenu => {
fildType => "yesNo",
defaultValue => 0
}
}
});
return $class->SUPER::definition($session, $definition);
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session,'Asset_RichEdit');
push(@{$definition}, {
assetName => $i18n->get('assetName'),
icon => 'richEdit.gif',
uiLevel => 5,
tableName => 'RichEdit',
className => 'WebGUI::Asset::RichEdit',
properties => {
disableRichEditor => {
fieldType => 'yesNo',
defaultValue => 0,
},
askAboutRichEdit => {
fieldType => 'yesNo',
defaultValue => 0,
},
validElements => {
fieldType => 'textarea',
defaultValue => '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]',
},
preformatted => {
fieldType => 'yesNo',
defaultValue => 0,
},
editorWidth => {
fieldType => 'integer',
defaultValue => 0,
},
editorHeight => {
fieldType => 'integer',
defaultValue => 0,
},
sourceEditorWidth => {
fieldType => 'integer',
defaultValue => 0,
},
sourceEditorHeight => {
fieldType => 'integer',
defaultValue => 0,
},
useBr => {
fieldType => 'yesNo',
defaultValue => 0,
},
removeLineBreaks => {
fieldType => 'yesNo',
defaultValue => 0,
},
nowrap=>{
fieldType => 'yesNo',
defaultValue => 0,
},
directionality => {
fieldType => 'selectBox',
defaultValue => 'ltr',
},
toolbarLocation => {
fieldType => 'selectBox',
defaultValue => 'bottom',
},
cssFile => {
fieldType => 'text',
defaultValue => undef,
},
toolbarRow1 => {
fieldType => 'checkList',
defaultValue => undef,
},
toolbarRow2 => {
fieldType => 'checkList',
defaultValue => undef,
},
toolbarRow3 => {
fieldType => 'checkList',
defaultValue => undef,
},
enableContextMenu => {
fieldType => "yesNo",
defaultValue => 0,
},
inlinePopups => {
fieldType => "yesNo",
defaultValue => 0,
},
},
});
return $class->SUPER::definition($session, $definition);
}
@ -193,7 +200,7 @@ sub getEditForm {
'forecolor' => $i18n->get('forecolor'),
'backcolor' => $i18n->get('backcolor'),
'link' => $i18n->get('link'),
'pagetree' => $i18n->get('pagetree'),
'wgpagetree' => $i18n->get('pagetree'),
'anchor' => $i18n->get('anchor'),
'unlink' => $i18n->get('unlink'),
'tablecontrols' => $i18n->get('tablecontrols'),
@ -203,10 +210,10 @@ sub getEditForm {
'inserttime' => $i18n->get('inserttime'),
'insertdate' => $i18n->get('insertdate'),
'image' => $i18n->get('image'),
'insertImage' => $i18n->get('insertImage'),
'flash' => $i18n->get('flash'),
'wginsertimage' => $i18n->get('insertImage'),
'media' => $i18n->get('media'),
'charmap' => $i18n->get('charmap'),
'collateral' => $i18n->get('collateral'),
'wgmacro' => $i18n->get('collateral'),
'emotions' => $i18n->get('emotions'),
'help' => $i18n->get('help'),
'iespell' => $i18n->get('iespell'),
@ -216,7 +223,6 @@ sub getEditForm {
'save' => $i18n->get('save'),
'preview' => $i18n->get('preview'),
'fullscreen' => $i18n->get('fullscreen'),
'zoom' => $i18n->get('zoom'),
'print' => $i18n->get('print'),
'spellchecker' => $i18n->get('Server Side Spell Checker'),
# 'advlink' => "Advanced Link",
@ -383,6 +389,12 @@ sub getEditForm {
-hoverHelp=>$i18n->get('enable context menu description'),
-name=>"enableContextMenu"
);
$tabform->getTab("properties")->yesNo(
-value=>$self->getValue("inlinePopups"),
-label=>$i18n->get('inline popups'),
-hoverHelp=>$i18n->get('inline popups description'),
-name=>"inlinePopups"
);
return $tabform;
}
@ -407,8 +419,8 @@ my $sql = "select asset.assetId, assetData.revisionDate from RichEdit left join
tie %richEditors, 'Tie::IxHash';
while (my ($id, $version) = $sth->array) {
$richEditors{$id} = WebGUI::Asset::RichEdit->new($session, $id, undef, $version)->getTitle;
}
$sth->finish;
}
$sth->finish;
return \%richEditors;
}
@ -433,47 +445,51 @@ sub getRichEditor {
my $self = shift;
return '' if ($self->getValue('disableRichEditor'));
my $nameId = shift;
#my @toolbarRows = grep{@$_} map{[split "\n", $self->getValue("toolbarRow$_")]} (1..3);
my @toolbarRows = map{[split "\n", $self->getValue("toolbarRow$_")]} (1..3);
push(@{$toolbarRows[0]},"contextmenu") if ($self->getValue("enableContextMenu"));
my @toolbarButtons = map{ @{$_} } @toolbarRows;
my @plugins;
my @plugins;
my %loadPlugins;
push @plugins, "safari";
push @plugins, "contextmenu"
if $self->getValue("enableContextMenu");
push @plugins, "inlinepopups"
if $self->getValue("inlinePopups");
my @toolbarRows = map{[split "\n", $self->getValue("toolbarRow$_")]} (1..3);
my @toolbarButtons = map{ @{$_} } @toolbarRows;
my $i18n = WebGUI::International->new($self->session, 'Asset_RichEdit');
my %config = (
mode => "exact",
elements => $nameId,
theme => "advanced",
relative_urls => "false",
remove_script_host => "true",
auto_reset_designmode => "true",
cleanup_callback => "tinyMCE_WebGUI_Cleanup",
urlconvertor_callback => "tinyMCE_WebGUI_URLConvertor",
theme_advanced_resizing => "true",
relative_urls => JSON::false(),
remove_script_host => JSON::true(),
auto_reset_designmode => JSON::true(),
cleanup_callback => "tinyMCE_WebGUI_Cleanup",
urlconvertor_callback => "tinyMCE_WebGUI_URLConvertor",
theme_advanced_resizing => JSON::true(),
(map { "theme_advanced_buttons".($_+1) => (join ',', @{$toolbarRows[$_]}) }
(0..$#toolbarRows)),
ask => $self->getValue("askAboutRichEdit") ? "true" : "false",
preformatted => $self->getValue("preformatted") ? "true" : "false",
force_br_newlines => $self->getValue("useBr") ? "true" : "false",
force_p_newlines => $self->getValue("useBr") ? "false" : "true",
remove_linebreaks => $self->getValue("removeLineBreaks") ? "true" : "false",
nowrap => $self->getValue("nowrap") ? "true" : "false",
ask => $self->getValue("askAboutRichEdit") ? JSON::true() : JSON::false(),
preformatted => $self->getValue("preformatted") ? JSON::true() : JSON::false(),
force_br_newlines => $self->getValue("useBr") ? JSON::true() : JSON::false(),
force_p_newlines => $self->getValue("useBr") ? JSON::false() : JSON::true(),
remove_linebreaks => $self->getValue("removeLineBreaks") ? JSON::true() : JSON::false(),
nowrap => $self->getValue("nowrap") ? JSON::true() : JSON::false(),
directionality => $self->getValue("directionality"),
theme_advanced_toolbar_location => $self->getValue("toolbarLocation"),
theme_advanced_statusbar_location => "bottom",
valid_elements => $self->getValue("validElements"),
wg_userIsVisitor => $self->session->user->userId eq '1' ? 'true' : 'false',
wg_userIsVisitor => $self->session->user->userId eq '1' ? JSON::true() : JSON::false(),
);
foreach my $button (@toolbarButtons) {
if ($button eq "spellchecker" && $self->session->config->get('availableDictionaries')) {
push(@plugins,"spellchecker");
$config{spellchecker_languages} =
join(',', map { ($_->{default} ? '+' : '').$_->{name}.'='.$_->{id} } @{$self->session->config->get('availableDictionaries')});
join(',', map { ($_->{default} ? '+' : '').$_->{name}.'='.$_->{id} } @{$self->session->config->get('availableDictionaries')});
}
push(@plugins,"table") if ($button eq "tablecontrols");
push(@plugins,"save") if ($button eq "save");
push(@plugins,"advhr") if ($button eq "advhr");
push(@plugins,"fullscreen") if ($button eq "fullscreen");
push(@plugins,"table") if ($button eq "tablecontrols");
push(@plugins,"save") if ($button eq "save");
push(@plugins,"advhr") if ($button eq "advhr");
push(@plugins,"fullscreen") if ($button eq "fullscreen");
if ($button eq "advimage") {
push(@plugins,"advimage");
$config{external_link_list_url} = "";
@ -483,8 +499,9 @@ sub getRichEditor {
$config{file_browser_callback} = "mcFileManager.filebrowserCallBack";
push(@plugins,"advlink");
}
push(@plugins,"emotions") if ($button eq "emotions");
push(@plugins,"iespell") if ($button eq "iespell");
push(@plugins,"emotions") if ($button eq "emotions");
push(@plugins,"iespell") if ($button eq "iespell");
$config{gecko_spellcheck} = 'true' if ($button eq "iespell");
if ($button eq "paste" || $button eq "pastetext" || $button eq "pasteword") {
push(@plugins,"paste");
}
@ -493,18 +510,24 @@ sub getRichEditor {
$config{plugin_insertdate_timeFormat} = "%H:%M:%S";
push(@plugins,"insertdatetime");
}
push(@plugins,"preview") if ($button eq "preview");
push(@plugins,"zoom") if ($button eq "zoom");
if ($button eq "flash") {
push(@plugins,"flash");
$config{flash_external_list_url} = "";
push(@plugins,"preview") if ($button eq "preview");
if ($button eq "media") {
push(@plugins,"media");
}
push(@plugins,"searchreplace") if ($button eq "search" || $button eq "replace" || $button eq "searchreplace");
push(@plugins,"print") if ($button eq "print");
push(@plugins,"contextmenu") if ($button eq "contextmenu");
push(@plugins,"insertImage") if ($button eq "insertImage");
push(@plugins,"collateral") if ($button eq "collateral");
push(@plugins,"pagetree") if ($button eq "pagetree");
push(@plugins,"searchreplace") if ($button eq "search" || $button eq "replace" || $button eq "searchreplace");
push(@plugins,"print") if ($button eq "print");
if ($button eq "wginsertimage") {
push @plugins, "-wginsertimage";
$loadPlugins{wginsertimage} = $self->session->url->extras("tinymce-webgui/plugins/wginsertimage/editor_plugin.js");
}
if ($button eq "wgpagetree") {
push @plugins, "-wgpagetree";
$loadPlugins{wgpagetree} = $self->session->url->extras("tinymce-webgui/plugins/wgpagetree/editor_plugin.js");
}
if ($button eq "wgmacro") {
push @plugins, "-wgmacro";
$loadPlugins{wgmacro} = $self->session->url->extras("tinymce-webgui/plugins/wgmacro/editor_plugin.js");
}
if ($button eq "code") {
$config{theme_advanced_source_editor_width} = $self->getValue("sourceEditorWidth") if ($self->getValue("sourceEditorWidth") > 0);
$config{theme_advanced_source_editor_height} = $self->getValue("sourceEditorHeight") if ($self->getValue("sourceEditorHeight") > 0);
@ -515,26 +538,18 @@ sub getRichEditor {
$language = $i18n->getLanguage("English","languageAbbreviation");
}
$config{language} = $language;
$config{content_css} = $self->getValue("cssFile") || $self->session->url->extras('tinymce2/defaultcontent.css');
$config{content_css} = $self->getValue("cssFile") || $self->session->url->extras('tinymce-webgui/defaultcontent.css');
$config{width} = $self->getValue("editorWidth") if ($self->getValue("editorWidth") > 0);
$config{height} = $self->getValue("editorHeight") if ($self->getValue("editorHeight") > 0);
$config{plugins} = join(",",@plugins);
my @directives;
foreach my $key (keys %config) {
if ($config{$key} eq "true" || $config{$key} eq "false") {
push(@directives,$key." : ".$config{$key});
} else {
push(@directives,$key." : '".$config{$key}."'");
}
}
$self->session->style->setScript($self->session->url->extras('tinymce2/jscripts/tiny_mce/tiny_mce.js'),{type=>"text/javascript"});
$self->session->style->setScript($self->session->url->extras("tinymce2/jscripts/webgui.js"),{type=>"text/javascript"});
return '<script type="text/javascript">
tinyMCE.init({
'.join(",\n ",@directives).'
});
</script>';
$self->session->style->setScript($self->session->url->extras('tinymce/jscripts/tiny_mce/tiny_mce_src.js'),{type=>"text/javascript"});
$self->session->style->setScript($self->session->url->extras("tinymce-webgui/callbacks.js"),{type=>"text/javascript"});
my $out = "<script type=\"text/javascript\">\n";
while (my ($plugin, $path) = each %loadPlugins) {
$out .= "tinymce.PluginManager.load('$plugin', '$path');\n";
}
$out .= "tinyMCE.init(" . JSON::encode_json(\%config) . ");\n</script>";
}

View file

@ -155,98 +155,37 @@ Asset picker for the rich editor.
=cut
sub www_pageTree {
my $session = shift;
$session->http->setCacheControl("none");
$session->style->setRawHeadTags(q|<style type="text/css">
.base {
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, Arial, sans-serif;
font-size: 12px;
}
a {
color: #0f3ccc;
text-decoration: none;
}
a:hover {
color: #000080;
text-decoration: underline;
}
.selectLink {
color: #cc7700;
}
.crumb {
color: orange;
}
.crumbTrail {
padding: 3px;
background-color: #eeeeee;
-moz-border-radius: 10px;
}
.traverse {
font-size: 15px;
}
</style>
|);
$session->style->setScript($session->url->extras('tinymce2/jscripts/tiny_mce/tiny_mce_popup.js'),{type=>"text/javascript"});
my $i18n = WebGUI::International->new($session);
my $f = WebGUI::HTMLForm->new($session,-action=>"#");
$f->text(
-name=>"url",
-label=>$i18n->get(104),
-hoverHelp=>$i18n->get('104 description'),
);
my %options = ();
tie %options, 'Tie::IxHash';
%options = ("_self"=>$i18n->get('link in same window'),
"_blank"=>$i18n->get('link in new window'));
$f->selectBox(
-name=>"target",
-label=>$i18n->get('target'),
-hoverHelp=>$i18n->get('target description'),
-options=>\%options
);
$f->button(
-name=>"button",
-value=>$i18n->get('done'),
-extras=>'onclick="createLink()"'
);
my $output = ' <fieldset><legend>'.$i18n->get('insert a link').'</legend>'.$f->print.'</fieldset>'.<<"JS"
<script type="text/javascript">
//<![CDATA[
function createLink() {
if (window.opener) {
if (document.getElementById("url_formId").value == "") {
alert("@{[$i18n->get("link enter alert")]}");
document.getElementById("url_formId").focus();
}
var link = '<a href="'+"^" + "/(" + document.getElementById("url_formId").value+');"';
var target = document.getElementById('target_formId').value;
if (target != '_self') link += ' target="' + target + '"';
link += '>' + window.opener.tinyMCE.selectedInstance.selection.getSelectedHTML() + '</a>';
window.opener.tinyMCE.execCommand("mceInsertContent",false,link);
window.close();
my $session = shift;
$session->http->setCacheControl("none");
$session->style->setLink($session->url->extras('/tinymce-webgui/plugins/wgpagetree/css/pagetree.css'),{ type=>'text/css', rel=>"stylesheet" });
$session->style->setRawHeadTags(<<"JS");
<style type="text/css">body { margin: 0 }</style>
<script type="text/javascript">//<![CDATA[
function selectLink(href) {
if (window.parent && window.parent.WGPageTreeDialog) {
window.parent.WGPageTreeDialog.setUrl(href);
}
}
//]]>
</script>
//]]></script>
JS
.'<fieldset><legend>'.$i18n->get('pages').'</legend> ';
$output .= '<div class="base">';
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session);
my @crumb;
my $ancestors = $base->getLineage(["self","ancestors"],{returnObjects=>1});
foreach my $ancestor (@{$ancestors}) {
push(@crumb,'<a href="'.$ancestor->getUrl("op=formHelper;class=HTMLArea;sub=pageTree").'" class="crumb">'.$ancestor->get("menuTitle").'</a>');
}
$output .= '<div class="crumbTrail">'.join(" &gt; ", @crumb)."</div><br />\n";
my $children = $base->getLineage(["children"],{returnObjects=>1});
foreach my $child (@{$children}) {
next unless $child->canView;
$output .= '<a href="#" class="selectLink"
onclick="document.getElementById(\'url_formId\').value=\''.$child->get("url").'\'">['.$i18n->get("select").']</a>
<a href="'.$child->getUrl("op=formHelper;class=HTMLArea;sub=pageTree").'" class="traverse">'.$child->get("menuTitle").'</a>'."<br />\n";
}
$output .= '</div></fieldset>';
return $session->style->process($output, 'PBtmpl0000000000000137');
my $i18n = WebGUI::International->new($session);
my $output = '<div class="nav">';
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session);
my @crumb;
my $ancestors = $base->getLineage(["self","ancestors"],{returnObjects=>1});
foreach my $ancestor (@{$ancestors}) {
push(@crumb,'<a href="'.$ancestor->getUrl("op=formHelper;class=HTMLArea;sub=pageTree").'" class="crumb">'.$ancestor->get("menuTitle").'</a>');
}
$output .= '<div class="crumbTrail">'.join(" &gt; ", @crumb)."</div>\n<ul>";
my $children = $base->getLineage(["children"],{returnObjects=>1});
foreach my $child (@{$children}) {
next unless $child->canView;
$output .= '<li><a href="#" class="selectLink" onclick="selectLink(\'' . $child->get('url') . '\'); return false;">['
. $i18n->get("select") . ']</a> <a href="' . $child->getUrl("op=formHelper;class=HTMLArea;sub=pageTree")
. '" class="traverse">' . $child->get("menuTitle") . '</a>'."</li>\n";
}
$output .= '</ul></div>';
return $session->style->process($output, 'PBtmpl0000000000000137');
}
#-------------------------------------------------------------------
@ -259,75 +198,66 @@ Each link display a thumbnail of the image via www_viewThumbnail.
=cut
sub www_imageTree {
my $session = shift;
$session->http->setCacheControl("none");
$session->style->setRawHeadTags(q| <style type="text/css">
.base {
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, Arial, sans-serif;
font-size: 12px;
}
a {
color: #0f3ccc;
text-decoration: none;
}
a:hover {
color: #000080;
text-decoration: underline;
}
.selectLink {
color: #cc7700;
}
.crumb {
color: orange;
}
.crumbTrail {
padding: 3px;
background-color: #eeeeee;
-moz-border-radius: 10px;
}
.traverse {
font-size: 15px;
}
</style>|);
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getMedia($session);
my @crumb;
my $ancestors = $base->getLineage(["self","ancestors"],{returnObjects=>1});
my $media;
my @output;
push(@output, '<div class="base">');
my $i18n = WebGUI::International->new($session, 'Operation_FormHelpers');
foreach my $ancestor (@{$ancestors}) {
push(@crumb,'<a class="crumb" href="'.$ancestor->getUrl("op=formHelper;class=HTMLArea;sub=imageTree").'">'.$ancestor->get("menuTitle").'</a>');
# check if we are in (a subdirectory of) Media
if ($ancestor->get('assetId') eq 'PBasset000000000000003') {
$media = $ancestor;
}
}
if ($media) {
# if in (a subdirectory of) Media, give user the ability to create folders or upload images
push(@output, '<p>[ <a href="');
push(@output, $base->getUrl('op=formHelper;class=HTMLArea;sub=addFolder'));
push(@output, '">'.$i18n->get('Create new folder').'</a> ] &nbsp; [ <a href="');
push(@output, $base->getUrl('op=formHelper;class=HTMLArea;sub=addImage'));
push(@output, '">'.$i18n->get('Upload new image').'</a> ]</p>');
} else {
$media = WebGUI::Asset->getMedia($session);
# if not in Media, provide a direct link to it
push(@output, '<p>[ <a href="'.$media->getUrl('op=formHelper;class=HTMLArea;sub=imageTree').'">'.$media->get('title').'</a> ]</p>');
}
push(@output, '<div class="crumbTrail">'.join(" &gt; ", @crumb)."</div><br />\n");
my $children = $base->getLineage(["children"],{returnObjects=>1});
foreach my $child (@{$children}) {
next unless $child->canView;
if ($child->get("className") =~ /^WebGUI::Asset::File::Image/) {
push(@output, '<a class="selectLink" href="'.$child->getUrl("op=formHelper;class=HTMLArea;sub=viewThumbnail").'" target="viewer">['.$i18n->get("select","WebGUI").']</a> ');
} else {
push(@output, ' ['.$i18n->get("select","WebGUI")."] ");
}
push(@output, '<a class="traverse" href="'.$child->getUrl("op=formHelper;class=HTMLArea;sub=imageTree").'">'.$child->get("menuTitle").'</a>'."<br />\n");
}
push(@output, '</div>');
return $session->style->process(join('', @output), 'PBtmpl0000000000000137');
my $session = shift;
$session->http->setCacheControl("none");
$session->style->setLink($session->url->extras('/tinymce-webgui/plugins/wginsertimage/css/insertimage.css'),{ type=>'text/css', rel=>"stylesheet" });
$session->style->setRawHeadTags(<<"JS");
<style type="text/css">body { margin: 0 }</style>
<script type="text/javascript">//<![CDATA[
function selectImage(url, thumburl) {
if (window.parent && window.parent.WGInsertImageDialog) {
window.parent.WGInsertImageDialog.setUrl(url, thumburl);
}
}
//]]></script>
JS
my $i18n = WebGUI::International->new($session, 'Operation_FormHelpers');
my $output = '<div class="nav">';
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getMedia($session);
my @crumb;
my $media;
my $ancestors = $base->getLineage(["self","ancestors"],{returnObjects=>1});
foreach my $ancestor (@{$ancestors}) {
push(@crumb,'<a href="'.$ancestor->getUrl("op=formHelper;class=HTMLArea;sub=imageTree").'" class="crumb">'.$ancestor->get("menuTitle").'</a>');
if ($ancestor->get('assetId') eq 'PBasset000000000000003') {
$media = $ancestor;
}
}
if ($media) {
# if in (a subdirectory of) Media, give user the ability to create folders or upload images
$output .= '<div>[ <a href="' . $base->getUrl('op=formHelper;class=HTMLArea;sub=addFolder')
. '">' . $i18n->get('Create new folder') . '</a> ] &nbsp; [ <a href="'
. $base->getUrl('op=formHelper;class=HTMLArea;sub=addImage') . '">'
. $i18n->get('Upload new image').'</a> ]</div>';
} else {
$media = WebGUI::Asset->getMedia($session);
# if not in Media, provide a direct link to it
$output .= '<div>[ <a href="' . $media->getUrl('op=formHelper;class=HTMLArea;sub=imageTree') . '">'
. $media->get('title') . '</a> ]</div>';
}
$output .= '<div class="crumbTrail">'.join(" &gt; ", @crumb)."</div>\n<ul>";
my $useAssetUrls = $session->config->get("richEditorsUseAssetUrls");
my $children = $base->getLineage(["children"],{returnObjects=>1});
foreach my $child (@{$children}) {
next unless $child->canView;
$output .= '<li>';
if ($child->isa('WebGUI::Asset::File::Image')) {
$output .= '<a href="#" class="selectLink" onclick="selectImage(\''
. ($useAssetUrls ? $child->getUrl : $child->getFileUrl) . '\',\''
. $session->url->getSiteURL . $session->url->gateway($child->get('url'), 'op=formHelper;class=HTMLArea;sub=viewThumbnail')
. '\'); return false;">[' . $i18n->get("select", 'WebGUI') . ']</a>';
}
else {
$output .= '<span class="noselect">[' . $i18n->get("select", 'WebGUI') . ']</span>';
}
$output .= ' <a href="' . $child->getUrl("op=formHelper;class=HTMLArea;sub=imageTree")
. '" class="traverse">' . $child->get("menuTitle") . "</a></li>\n";
}
$output .= '</ul></div>';
return $session->style->process($output, 'PBtmpl0000000000000137');
}
#-------------------------------------------------------------------
@ -340,35 +270,21 @@ URL in the session object is used to determine which Image is used.
=cut
sub www_viewThumbnail {
my $session = shift;
$session->http->setCacheControl("none");
my $image = WebGUI::Asset->newByUrl($session);
my $i18n = WebGUI::International->new($session);
my $output;
if ($image->get("className") =~ /WebGUI::Asset::File::Image/) {
$output = '<div align="center">';
$output .= '<img src="'.$image->getThumbnailUrl.'" style="border-style:none;" alt="'.$i18n->get('preview').'" />';
$output .= '<br />';
$output .= $image->get("filename");
$output .= '</div>';
$output .= '<script type="text/javascript">';
$output .= "//<![CDATA[\n";
if ( $session->config->get("richEditorsUseAssetUrls")) {
$output .= "\nvar src = '".$image->getUrl."';\n";
} else {
$output .= "\nvar src = '".$image->getFileUrl."';\n";
}
$output .= "if(src.length > 0) {
var manager=window.parent;
if(manager)
manager.document.getElementById('txtFileName').value = src;
}
//]]>
</script>\n";
} else {
$output = '<div align="center"><img src="'.$session->url->extras('tinymce2/images/icon.gif').'" style="border-style:none;" alt="'.$i18n->get('image manager').'" /></div>';
}
return $session->style->process($output, 'PBtmpl0000000000000137');
my $session = shift;
$session->http->setCacheControl("none");
$session->style->setLink($session->url->extras('/tinymce-webgui/plugins/wginsertimage/css/insertimage.css'),{ type=>'text/css', rel=>"stylesheet" });
my $image = WebGUI::Asset->newByUrl($session);
my $i18n = WebGUI::International->new($session);
my $output = '<div class="preview">';
if ($image->isa('WebGUI::Asset::File::Image')) {
$output .= '<div><img src="' . $image->getThumbnailUrl . '" alt="' . $i18n->get('preview') . '" /></div>'
. $image->get("filename") . '</div>';
}
else {
$output .= '<div><img src="' . $session->url->extras('tinymce/images/icon.gif') . '" alt="'
. $i18n->get('image manager') . '" /></div>';
}
return $session->style->process($output, 'PBtmpl0000000000000137');
}
#-------------------------------------------------------------------

View file

@ -276,10 +276,10 @@ our $I18N = {
message => q|WebGUI Image|,
lastUpdated => 1115150778,
},
'flash' => {
message => q|Flash Movie|,
lastUpdated => 1115150778,
},
'media' => {
message => q|Embedded Media / Flash|,
lastUpdated => 1206564394,
},
'charmap' => {
message => q|Special Character|,
lastUpdated => 1115150778,
@ -320,10 +320,6 @@ our $I18N = {
message => q|Preview|,
lastUpdated => 1115150778,
},
'zoom' => {
message => q|Zoom (IE Only)|,
lastUpdated => 1115150778,
},
'print' => {
message => q|Print|,
lastUpdated => 1115150778,
@ -452,6 +448,15 @@ option is set to Yes, then all whitespace entered into the form will be preserve
lastUpdated => 0,
},
'inline popups' => {
message => q|Inline Popups|,
lastUpdated => 1206653834,
},
'inline popups description' => {
message => q|Shows popups inline instead of in a popup browser window.|,
lastUpdated => 1206653834,
},
};
1;