Revision 3 (by ahitrov@rambler.ru, 2010/03/24 15:19:32) |
The CORE
|
// This list may be created by a server logic page PHP/ASP/ASPX/JSP in some backend system.
// There images will be displayed as a dropdown in all image dialogs if the "external_link_image_url"
// option is defined in TinyMCE init.
var tinyMCEImageList = new Array(
// Name, URL
% foreach my $img ( @images ) {
% if ( $comma++ ) {
,
% }
["<% $img->{name} %>", "<% $img->{url} %>"]\
% }
);
<%args>
$class => undef
$id => undef
</%args>
<%init>
return unless $class && $id;
my $document = $keeper->get_document_by_id ( $id, class => $class );
return unless ref $document;
my @images;
my @props = grep { $_->{type} eq 'images' || $_->{type} eq 'image' } $document->structure;
foreach my $prop ( @props ) {
if ( $prop->{type} eq 'images' ) {
my $images = $document->get_image($prop->{attr});
if ( ref $images && exists $images->{maxnumber} && $images->{maxnumber} ) {
for ( 1..$images->{maxnumber} ) {
my $image = $images->{"image_$_"};
if ( ref $image && exists $image->{filename} ) {
my $img_path = ($state->{images_dir} =~ /^http:/ ? $state->{images_dir} : '').($image->{filename} =~ /^\// ? '' : '/').$image->{filename};
my $name = $image->{alt} || $prop->{attr}.": image_$_";
$name =~ s/"/\\"/g;
push @images, { url => $img_path, name => $name };
}
}
}
} else {
my $image = $document->get_image($prop->{attr});
if ( ref $image && exists $image->{filename} ) {
my $img_path = ($state->{images_dir} =~ /^http:/ ? $state->{images_dir} : '').($image->{filename} =~ /^\// ? '' : '/').$image->{filename};
my $name = $image->{alt} || $document->name.' ('.$prop->{attr}.')';
$name =~ s/"/\\"/g;
push @images, { url => $img_path, name => $name };
}
}
}
return unless @images;
my $comma = 0;
</%init>