Revision 36

Date:
2010/07/12 15:05:07
Author:
ahitrov@rambler.ru
Revision Log:
Более настраиваемый поиск связанных документов
Компонента отправки почты (требует Mime::Lite)
Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/core/comps/contenido/components/inputs/pickup.msn

     
    88 88 $doc = $keeper->get_document_by_id ( $check, %{$prop->{lookup_opts}} );
    89 89 }
    90 90 $lookup_string = '/contenido/find_document.html?nf='.$name.'_docname&vf='.$name.'_value';
    91 $lookup_string .= '&class='.$prop->{lookup_opts}->{class} if exists $prop->{lookup_opts}->{class};
    92 $lookup_string .= '&s='.$prop->{lookup_opts}->{s} if exists $prop->{lookup_opts}->{s};
    93 $lookup_string .= '&search_by='.$prop->{lookup_opts}->{search_by} if exists $prop->{lookup_opts}->{search_by};
    91 if ( exists $prop->{lookup_opts} && ref $prop->{lookup_opts} eq 'HASH' ) {
    92 while ( my ($param, $value) = each %{ $prop->{lookup_opts} } ) {
    93 $lookup_string .= '&'.$param.'='.$value;
    94 }
    95 }
    94 96 } else {
    95 97 $error = 'Похоже неверное описание lookup_opts в документе';
    96 98 }
  • utf8/core/comps/contenido/find_document.html

     
    66 66 <input type="hidden" maxlength="255" name="nf" value="<% $nf %>">
    67 67 <input type="hidden" maxlength="255" name="vf" value="<% $vf %>">
    68 68 <input type="hidden" maxlength="255" name="show" value="<% $show %>">
    69 % if ( $class ) {
    70 <input type="hidden" maxlength="255" name="class" value="<% $class %>">
    69 % while ( my ($param, $value) = each %params ) {
    70 <input type="hidden" maxlength="255" name="<% $param %>" value="<% $value %>">
    71 71 % }
    72 % if ( $s ) {
    73 <input type="hidden" maxlength="255" name="s" value="<% $s %>">
    74 % }
    75 72 <input type="hidden" maxlength="255" name="search_by" value="<% $search_by %>">
    76 73 </p></form></div>
    77 74 % }
     
    86 83 nf => $nf,
    87 84 vf => $vf,
    88 85 show => $show,
    89 $class ? ( class => $class ) : (),
    90 $s ? ( s => $s ) : (),
    86 %params,
    91 87 $search_by ? ( search_by => $search_by ) : (),
    92 88 $search ? ( search => $search ) : (),
    93 89 } &>
     
    111 107 </html>
    112 108 <%args>
    113 109
    114 $search_by => undef
    115 $search => undef
    116 $class => undef
    117 110 $show => 'name'
    118 $s => undef
    119 111 $nf => undef
    120 112 $vf => undef
    121 113 $p => 1
     
    124 116 <%init>
    125 117
    126 118 return unless $nf && $vf;
    127 my ($docs, $total, %params);
    119 my ($docs, $total);
    128 120 my $size = 20;
    129 121
    130 $params{s} = $s if $s;
    131 $params{class} = $class if $class;
    122 my %params = %ARGS;
    123 delete $params{nf};
    124 delete $params{vf};
    125 delete $params{show};
    126 delete $params{p};
    127
    128 my $search_by = delete $params{search_by};
    129 my $search = delete $params{search};
    130
    132 131 if ( $search_by && $search ) {
    133 $params{$search_by} = '%'.$search.'%';
    132 $params{$search_by} = '%'.$search.'%';
    134 133 $params{ilike} = 1;
    135 134 }
    136 135
  • utf8/core/comps/inc/sendmail.msn

     
    1 <%args>
    2
    3 $email => undef
    4
    5 </%args>
    6 <%init>
    7
    8 return unless ref $email;
    9
    10 use MIME::Lite;
    11 use MIME::Base64;
    12
    13 my $subject = $email->{subject};
    14 $subject = MIME::Base64::encode($subject);
    15 $subject =~ s/\s+$//si;
    16 $subject = '=?utf-8?B?'.$subject.'?=';
    17
    18 my $emailfrom;
    19 my ($from, $efrom) = $email->{from} =~ /^(.*?)<(.*?)>/ ? ($1, $2) : $email->{from} =~ /<(.*?)>/ ? ('',$1) : ('',$email->{from});
    20 if ( $from ) {
    21 $from = MIME::Base64::encode($from);
    22 $from =~ s/\s+$//si;
    23 $from = '=?utf-8?B?'.$from.'?=';
    24 $emailfrom = $from.' <'.$efrom.'>';
    25 } else {
    26 $emailfrom = $efrom;
    27 }
    28
    29 my $emailto;
    30 my ($to, $eto) = $email->{to} =~ /^(.*?)<(.*?)>/ ? ($1, $2) : $email->{to} =~ /<(.*?)>/ ? ('',$1) : ('',$email->{to});
    31 if ( $to ) {
    32 $to = MIME::Base64::encode($to);
    33 $to =~ s/\s+$//si;
    34 $to = '=?utf-8?B?'.$to.'?=';
    35 $emailto = $to.' <'.$eto.'>';
    36 } else {
    37 $emailto = $eto;
    38 }
    39 my $ccmail;
    40 if ( exists $email->{cc} && ref $email->{cc} eq 'ARRAY' ) {
    41 foreach my $cc ( @{ $email->{cc} } ) {
    42 my ($cce, $ecce) = $cc =~ /^(.*?)<(.*?)>/ ? ($1, $2) : $cc =~ /<(.*?)>/ ? ('',$1) : ('',$cc);
    43 $cc = $ecce;
    44 }
    45 $ccmail = join ', ', @{$email->{cc}};
    46 } elsif ( exists $email->{cc} && $email->{cc} ) {
    47 my ($cce, $ecce) = $email->{cc} =~ /^(.*?)<(.*?)>/ ? ($1, $2) : $email->{cc} =~ /<(.*?)>/ ? ('',$1) : ('',$email->{cc});
    48 $ccmail = $ecce;
    49 }
    50
    51
    52 my $body = $email->{body};
    53 warn Dumper($email);
    54 my $dt = Contenido::DateTime->new;
    55 $dt->set_locale('en_EN');
    56 my $pdate = $dt->strftime("%a, %d %b %Y %H:%M:%S %z");
    57 my $msg = MIME::Lite->new(
    58 To => $emailto,
    59 From => $emailfrom,
    60 $ccmail ? ( Cc => $ccmail ) : (),
    61 Subject => $subject,
    62 Encoding=> 'binary',
    63 Date => $pdate,
    64 Type => 'multipart/related;type="multipart/alternative";charset="utf-8"',
    65 );
    66 $msg->attach(
    67 'Type' => 'text/html;charset="utf-8"',
    68 'Data' => $body,
    69 'Disposition' => '',
    70 );
    71
    72 $msg->send();
    73
    74 </%init>