Line # Revision Author
1 3 ahitrov@rambler.ru // This list may be created by a server logic page PHP/ASP/ASPX/JSP in some backend system.
2 // There images will be displayed as a dropdown in all image dialogs if the "external_link_image_url"
3 // option is defined in TinyMCE init.
4
5 var tinyMCEImageList = new Array(
6 // Name, URL
7 % foreach my $img ( @images ) {
8 % if ( $comma++ ) {
9 ,
10 % }
11 ["<% $img->{name} %>", "<% $img->{url} %>"]\
12 % }
13 );
14 <%args>
15
16 $class => undef
17 $id => undef
18
19 </%args>
20 <%init>
21
22 return unless $class && $id;
23 my $document = $keeper->get_document_by_id ( $id, class => $class );
24 return unless ref $document;
25
26 my @images;
27 my @props = grep { $_->{type} eq 'images' || $_->{type} eq 'image' } $document->structure;
28 foreach my $prop ( @props ) {
29 if ( $prop->{type} eq 'images' ) {
30 my $images = $document->get_image($prop->{attr});
31 if ( ref $images && exists $images->{maxnumber} && $images->{maxnumber} ) {
32 for ( 1..$images->{maxnumber} ) {
33 my $image = $images->{"image_$_"};
34 if ( ref $image && exists $image->{filename} ) {
35 my $img_path = ($state->{images_dir} =~ /^http:/ ? $state->{images_dir} : '').($image->{filename} =~ /^\// ? '' : '/').$image->{filename};
36 my $name = $image->{alt} || $prop->{attr}.": image_$_";
37 $name =~ s/"/\\"/g;
38 push @images, { url => $img_path, name => $name };
39 }
40 }
41 }
42 } else {
43 my $image = $document->get_image($prop->{attr});
44 if ( ref $image && exists $image->{filename} ) {
45 my $img_path = ($state->{images_dir} =~ /^http:/ ? $state->{images_dir} : '').($image->{filename} =~ /^\// ? '' : '/').$image->{filename};
46 my $name = $image->{alt} || $document->name.' ('.$prop->{attr}.')';
47 $name =~ s/"/\\"/g;
48 push @images, { url => $img_path, name => $name };
49 }
50 }
51 }
52 return unless @images;
53 my $comma = 0;
54
55 </%init>