%#============================================================================ %# ePortal - WEB Based daily organizer %# Author - S.Rusakov %# %# Copyright (c) 2000-2004 Sergey Rusakov. All rights reserved. %# This program is open source software %# %# %#----------------------------------------------------------------------------   <&| /dialog.mc:edit_dialog, title => pick_lang(rus => "Ресурс каталога", eng => "Catalogue resource"), width => 550, obj => $obj, multipart => 1, focus => 'title' &> <& /dialog.mc:read_only, id => 'recordtype' &> <&| /dialog.mc:cell &>
<& /dialog.mc:field, id => 'parent_id' &> <& /dialog.mc:field, id => 'title' &> %# <& /dialog.mc:buttons, ok_label => pick_lang(rus => "Сохранить ресурс", eng => "Save the resource"), %# apply_button => 1 &> %# %# LINK ============================================================ %# % if ($obj->recordtype eq 'link') { <& /dialog.mc:field, id => 'url' &> % } %# %# Text of resource ============================================================ %# % if ($obj->recordtype eq 'file') { <&| /dialog.mc:cell, -align => 'center' &> <% pick_lang(rus => "Текст ресурса", eng => "Text of resource") %>
<& /dialog.mc:textarea, id => 'text', -class => 's10' &> <& /dialog.mc:field, id => 'texttype' &> % } %# %# Composite resource ====================================================== %# % if ($obj->recordtype eq 'composite') { <&| /dialog.mc:collapse, collapse => 0, title => pick_lang(rus => "Категории ресурса", eng => "Resource categories") &> <& /dialog.mc:field, id => 'catname_date' &> <& /dialog.mc:field, id => 'catname_1' &> <&| /dialog.mc:cell, -class => 'memo' &> <&| /rus.mc &> Чтобы использовать какую-либо категорию необходимо дать ей имя. Группировка по дате является обязательной. <&| /eng.mc &> Name a category to before use it. Unnamed categories are unused. Groupping by date is required. % } %# %# OTHER ============================================================ %# <&| /dialog.mc:collapse, title => pick_lang(rus => "Дополнительные свойства", eng => "More info") &> <& /dialog.mc:field, id => 'nickname' &> <& /dialog.mc:field, id => 'priority' &> <& /dialog.mc:field, id => 'hidden' &> <& /dialog.mc:field, id => 'show_files', -label => pick_lang({rus => 'Показывать прикрепленные файлы', eng => 'Show attached files'}) &> <& /dialog.mc:field, id => 'show_info', -label => pick_lang({rus => 'Показывать общ.информацию', eng => 'Show common info'}) &> <&| /dialog.mc:cell, -align=>'center' &> <% pick_lang({rus => "Краткое описание", eng => "Short description"}) %>:
<& /dialog.mc:textarea, id => 'memo' &> %# %# New Attachment ============================================================ %# % if ($obj->recordtype eq 'file') { <&| /dialog.mc:collapse, title => pick_lang(rus => "Присоединенные файлы", eng => "Files attached") &> <&| /dialog.mc:cell &>
<&| /dialog.mc:label_value_row, label => pick_lang(rus => "Файл", eng => "File"), id => "upload_file" &> <% CGI::filefield({-name => 'upload_file', -class => 'dlgfield'}) %> <% CGI::submit({-name => 'dlgb_apply', -class => 'button', -value => pick_lang(rus => "Прикрепить!", eng => "Attach!")}) %> <& /dialog.mc:checkbox, id => 'load_as_text', checkbox_label => pick_lang(rus => "Как текст ресурса", eng => "As resource text"), value => 0 &> <&| /dialog.mc:cell, -align => 'right' &> %# %# List Attachments ============================================================ %# % $att = new ePortal::Attachment; % $att->restore_where(obj => $obj); % if ($att->rows) { <&| /dialog.mc:cell, -align => 'center' &>
<&| /list.mc, obj => new ePortal::Attachment, no_footer => 2, -width => '80%', rows => 10, restore_where => { obj => $obj } &> <& /list.mc:column_image &> <&| /list.mc:column, id => 'filename', -style => 'color: #9966ff;', title => pick_lang(rus => "Имя файла", eng => "File name") &> <% $_->filename |h %> <&| /list.mc:column, id => 'filesize', title => pick_lang(rus => "Размер", eng => "Size"), -align => 'center' &> <% $_->FileSize . ' ' . pick_lang(rus => "байт", eng => "bytes") %> <& /list.mc:column_checkbox &> <& /list.mc:action_bar, popup_menu => { -values => ['delete'], -labels => { delete => pick_lang(rus => "Удалить", eng => "Delete")}} &> % } % } # recordtype eq 'file' %# %# Access rights ============================================================ %# % if ($obj->xacl_check_admin) { <&| /dialog.mc:collapse, title => pick_lang(rus => "Права доступа", eng => "Access rights") &> <& /dialog.mc:read_only, id => 'uid' &> <& /dialog.mc:field, id => 'xacl_read' &> <& /dialog.mc:field, id => 'xacl_write' &> <& /dialog.mc:field, id => 'xacl_admin' &> % } <&| /dialog.mc:cell &>  <& /dialog.mc:buttons, ok_label => pick_lang(rus => "Сохранить ресурс", eng => "Save the resource"), apply_button => 1 &> %# %# Additional information =================================================== %# <&| /dialog.mc:cell &>
<& /dialog.mc:read_only, id => 'ts' &> <& /dialog.mc:read_only, id => 'clicks' &> <& /dialog.mc:read_only, id => 'hits' &>

<&| /rus.mc &> Дополнительную информацию о форматировании текста смотрите здесь

%#=== @METAGS attr ========================================================= <%attr> Title => {rus => "Ресурс каталога", eng => "Catalogue resource"} %#=== @METAGS onStartRequest ==================================================== <%method onStartRequest><%perl> $obj = new ePortal::Catalog; # Get arguments from request and prepare objects my $back_url = $m->comp('/dialog.mc:back_url'); my $new_att = new ePortal::Attachment; my $updated_successfully = undef; # restore object to edit $obj->restore_or_throw($ARGS{objid}) if $ARGS{objid}; # Get default or new values from URL. Do not save the object ! $m->comp('/dialog.mc:htmlSave', obj => $obj); # Upload a file $new_att->upload(r => $r); if ($new_att->check_id and $obj->Title eq '') { $obj->Title( $new_att->Filename ); } if ($new_att->check_id and $ARGS{load_as_text}) { $obj->Text( $new_att->save_to_string ); } #initialize ACL if ( ! $obj->check_id ) { # new object my $parent = $obj->parent; $obj->set_acl_from_obj($parent) if $parent; } # Save the object if ( $m->comp('/dialog.mc:isButtonPressed', button => 'ok' ) or $m->comp('/dialog.mc:isButtonPressed', button => 'apply' )) { $updated_successfully = try { # actually update the object $obj->save(); # 1 on update, 0 on insert, undef on error if ( $ARGS{load_as_text} == 0 and $new_att->check_id) { $new_att->link_with_object($obj); } 1; # success } catch ePortal::Exception::DataNotValid with { my $E = shift; $session{ErrorMessage} = $E->text; undef; }; } # Clear unsuccessful uploads $new_att->delete if ($new_att->check_id) and ($new_att->state ne 'ok'); # do redirect if ( $m->comp('/dialog.mc:isButtonPressed', button => 'cancel' )) { throw ePortal::Exception::Abort(-text => $back_url); } elsif ($updated_successfully and $m->comp('/dialog.mc:isButtonPressed', button => 'ok' )) { throw ePortal::Exception::Abort(-text => $back_url); } # delete attachment if ( $m->comp('/list.mc:list_action') eq 'delete' ) { my $new_att = new ePortal::Attachment; foreach ($m->comp('/list.mc:checkboxes')) { if ( $new_att->restore($_) ) { $new_att->delete; } } } # Redirect to GET after POST if ( $r->method eq 'POST' ) { if ( $obj->check_id ) { # existing object # delete BIG and unwanted arguments from request delete $ARGS{$_} foreach ( qw/text load_as_text uid ts/, grep { /^xacl_/ } keys %ARGS); $ARGS{objid} = $obj->id; $ARGS{title} ||= $obj->Title; } return href($ENV{SCRIPT_NAME}, %ARGS); } %#=== @metags once ========================================================= <%once> my ($obj, $att); %#=== @metags cleanup ========================================================= <%cleanup> ($obj, $att) = ();