%#============================================================================ %# ePortal - WEB Based daily organizer %# Author - S.Rusakov %# %# Copyright (c) 2000-2004 Sergey Rusakov. All rights reserved. %# This program is open source software %# %#---------------------------------------------------------------------------- <%doc> =head1 NAME dialog.mc - Dialog contruction module. =head1 SYNOPSIS This Mason component replaces obsoleted ePortal::HTML::Dialog package. C is used to draw a dialog like windows. Some methods are used for easy creation of dialogs to edit C objects. =head2 Usage <&| /dialog.mc, parameters ... &> content of the dialog <%method onStartRequest><%perl> $obj = new ePortal::Catalog; $m->comp('/dialog.mc:handle_request', obj => $obj); =head2 Parameters =over 4 =item * width,align These parameters are passed to tag. =item * color,bgcolor Colors used =item * title, title_url, title_popup, title_class The title of dialog =item * icons ArrayRef to HASHes with infomation about icons to place on the right side of the title. This HASH is passed directly to C global function. icons => [ { src => '/images/image.gif', href => 'some.where.htm', title => 'alt description for icons' } ] =item * xxx_icon Some of icons are known to dialog.mc. No need for them to pass image source url. Icon names are B B - URL for the icon B - popup title for the icon where B is a name of icon. =back =head1 METHODS =cut <%perl> # ---------------------------------------------------------------------- # Global Dialog configuration my $D = { width => $ARGS{width} || '70%', bgcolor => $ARGS{bgcolor} || '#FFFFFF', color => $ARGS{color} || '#CCCCFF', align => $ARGS{align}, title => $ARGS{title}, # The title of dialog title_popup => $ARGS{title_popup}, # a Popup message for title title_url => $ARGS{title_url}, # A URL to anchor from title title_class => $ARGS{title_class} || 'sidemenu', icons => [], # array of hashes of icon description }; $gdata{dialog} = $D; # ---------------------------------------------------------------------- # Add optional icons to dialog caption my %well_known_icons = ( q => pick_lang(rus => "Помощь", eng => "Help"), edit => pick_lang(rus => "Настроить", eng => "Setup"), min => pick_lang(rus => "Свернуть", eng => "Minimize"), max => pick_lang(rus => "Развернуть", eng => "Maximize"), x => pick_lang(rus => "Закрыть", eng => "Close dialog"), copy => pick_lang(rus => "Копировать", eng => "Copy object"), up => pick_lang(rus => "Передвинуть выше", eng => "Move up"), down => pick_lang(rus => "Передвинуть ниже", eng => "Move down"), ); foreach (qw/down up q copy edit min max x/ ) { # well known icons next if ! exists $ARGS{$_."_icon"}; if ( exists($ARGS{$_."_icon"}) and $ARGS{$_."_icon"} eq '1') { $ARGS{$_."_icon"} = href($ENV{SCRIPT_NAME}, 'dlgb_'.$_ => 1); } push @{$D->{icons}} , { src => "/images/ePortal/dlg_" . $_ . ".png", href => $ARGS{$_."_icon"}, title => $ARGS{$_ . "_icon_title"} || $well_known_icons{$_} }; } my $html_icons = join(' ', map { img(%{$_}) } @{$D->{icons}}); my $content = $ARGS{content} || $m->content; if ( $D->{title_url} ) { $D->{title_html} = CGI::a( {-href => $D->{title_url}, -title => $D->{title_popup}}, $D->{title}); } else { $D->{title_html} = $D->{title}; } %if ($ePortal::DEBUG) { %} % if ($D->{align} or $ARGS{extra}) { <&| SELF:_table3td, align => $D->{align}, extra => $ARGS{extra} &> <& SELF:_dialog, D => $D, html_icons => $html_icons, content => $content &> % } else { <& SELF:_dialog, D => $D, html_icons => $html_icons, content => $content &> % } %if ($ePortal::DEBUG) { %} %delete $gdata{dialog}; %#=== @metags _dialog ==================================================== <%method _dialog> % my $D = $ARGS{D}; % my $html_icons = $ARGS{html_icons}; % my $content = $ARGS{content}; %# Start of the dialog
%# a Row with dialog's content (start of table)
<% $D->{title_html} %> <% $html_icons %>
<% $content %>
<%filter> # ---------------------------------------------------------------------- # remove empty lines from dialog content if ( ! /