1 |
8 |
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 |
214 |
ahitrov |
<% join(',', @imgstr) %> |
8 |
8 |
ahitrov@rambler.ru |
); |
9 |
|
|
<%args> |
10 |
|
|
|
11 |
|
|
$class => undef |
12 |
|
|
$id => undef |
13 |
|
|
|
14 |
|
|
</%args> |
15 |
|
|
<%init> |
16 |
|
|
|
17 |
|
|
return unless $class && $id; |
18 |
|
|
my $document = $keeper->get_document_by_id ( $id, class => $class ); |
19 |
|
|
return unless ref $document; |
20 |
|
|
|
21 |
|
|
my @images; |
22 |
|
|
my @props = grep { $_->{type} eq 'images' || $_->{type} eq 'image' } $document->structure; |
23 |
|
|
foreach my $prop ( @props ) { |
24 |
|
|
if ( $prop->{type} eq 'images' ) { |
25 |
|
|
my $images = $document->get_image($prop->{attr}); |
26 |
|
|
if ( ref $images && exists $images->{maxnumber} && $images->{maxnumber} ) { |
27 |
|
|
for ( 1..$images->{maxnumber} ) { |
28 |
|
|
my $image = $images->{"image_$_"}; |
29 |
|
|
if ( ref $image && exists $image->{filename} ) { |
30 |
|
|
my $img_path = ($state->{images_dir} =~ /^http:/ ? $state->{images_dir} : '').($image->{filename} =~ /^\// ? '' : '/').$image->{filename}; |
31 |
|
|
my $name = $image->{alt} || $prop->{attr}.": image_$_"; |
32 |
|
|
$name =~ s/"/\\"/g; |
33 |
214 |
ahitrov |
push @images, { url => $img_path, name => $name, mini => (exists $image->{mini} ? $image->{mini} : undef) }; |
34 |
8 |
ahitrov@rambler.ru |
} |
35 |
|
|
} |
36 |
|
|
} |
37 |
|
|
} else { |
38 |
|
|
my $image = $document->get_image($prop->{attr}); |
39 |
|
|
if ( ref $image && exists $image->{filename} ) { |
40 |
|
|
my $img_path = ($state->{images_dir} =~ /^http:/ ? $state->{images_dir} : '').($image->{filename} =~ /^\// ? '' : '/').$image->{filename}; |
41 |
|
|
my $name = $image->{alt} || $document->name.' ('.$prop->{attr}.')'; |
42 |
|
|
$name =~ s/"/\\"/g; |
43 |
214 |
ahitrov |
push @images, { url => $img_path, name => $name, mini => (exists $image->{mini} ? $image->{mini} : undef) }; |
44 |
8 |
ahitrov@rambler.ru |
} |
45 |
|
|
} |
46 |
|
|
} |
47 |
|
|
return unless @images; |
48 |
|
|
my $comma = 0; |
49 |
214 |
ahitrov |
my @imgstr; |
50 |
|
|
foreach my $img ( @images ) { |
51 |
|
|
push @imgstr, '["'.$img->{name}.'","'.$img->{url}.'"]'; |
52 |
|
|
if ( exists $img->{mini} && ref $img->{mini} eq 'HASH' ) { |
53 |
|
|
while ( my ($dim, $mini) = each %{$img->{mini}} ) { |
54 |
|
|
next unless ref $mini eq 'HASH' && exists $mini->{filename}; |
55 |
|
|
push @imgstr, '["'.$img->{name}.'. Mini: '.$dim.'","'.$mini->{filename}.'"]'; |
56 |
|
|
} |
57 |
|
|
} |
58 |
|
|
} |
59 |
8 |
ahitrov@rambler.ru |
|
60 |
|
|
</%init> |