[Rt-commit] r18453 - rt/3.8/trunk/share/html/Ticket/Elements
ruz at bestpractical.com
ruz at bestpractical.com
Wed Feb 18 21:16:35 EST 2009
Author: ruz
Date: Wed Feb 18 21:16:34 2009
New Revision: 18453
Modified:
rt/3.8/trunk/share/html/Ticket/Elements/ShowTransactionAttachments
Log:
* use a local function to render attachments
* make difference between large text and not text
* show additional information when displaying named texts is disabled
* loc strings have been changed
Modified: rt/3.8/trunk/share/html/Ticket/Elements/ShowTransactionAttachments
==============================================================================
--- rt/3.8/trunk/share/html/Ticket/Elements/ShowTransactionAttachments (original)
+++ rt/3.8/trunk/share/html/Ticket/Elements/ShowTransactionAttachments Wed Feb 18 21:16:34 2009
@@ -72,19 +72,82 @@
<div class="messageattachments">
% } else {
<div class="messagebody">
-%}
+% }
<%PERL>
-# {{{ if it has a content-disposition: attachment, don't show inline
-unless ( ($message->GetHeader('Content-Disposition')||"") =~ /attachment/i ) {
- my $content;
+$render_attachment->( $message );
+
+$m->comp(
+ $m->current_comp,
+ %ARGS,
+ Parent => $message->id,
+ ParentObj => $message
+);
+
+</%PERL>
+</div>
+% }
+<%ARGS>
+$Ticket => undef
+$Transaction => undef
+$ShowHeaders => 0
+$Collapsed => undef
+$DownloadableHeaders => 1
+$ShowTitleBarCommands => 1
+$RowNum => 1
+$AttachPath => RT->Config->Get('WebPath')."/Ticket/Attachment"
+$UpdatePath => RT->Config->Get('WebPath')."/Ticket/Update.html"
+$EmailRecordPath => RT->Config->Get('WebPath')."/Ticket/ShowEmailRecord.html"
+$Attachments => undef
+$AttachmentContent => {}
+$ShowBody => 1
+$Parent => 0
+$ParentObj => undef
+</%ARGS>
+<%INIT>
+my @DisplayHeaders=qw(_all);
+if ( $Transaction->Type =~ /EmailRecord$/ ) {
+ @DisplayHeaders = qw(To Cc Bcc);
+}
+
+# If the transaction has anything attached to it at all
+elsif (!$ShowHeaders) {
+ @DisplayHeaders = qw(To From RT-Send-Cc Cc Bcc Date Subject);
+ push @DisplayHeaders, 'RT-Send-Bcc' if RT->Config->Get('ShowBccHeader');
+}
+
+my $size_to_str = sub {
+ my $size = shift;
+ # show a download link
+ if ( $size > 1024*1024 ) {
+ $size = loc( "[_1]b", int( $size / 1024 / 102.4 ) / 10 );
+ }
+ elsif ( $size > 1024 ) {
+ $size = loc( "[_1]k", int( $size / 102.4 ) / 10 );
+ }
+ else {
+ $size = loc( "[_1]b", $size );
+ }
+ return $size;
+};
+
+my $render_attachment = sub {
+ my $message = shift;
+
+ # if it has a content-disposition: attachment, don't show inline
+ return if ($message->GetHeader('Content-Disposition')||"") =~ /attachment/i;
# If it's text
- if ( $message->ContentType =~ m{^(text|message)}i
- && !( $message->Filename && RT->Config->Get('SuppressInlineTextFiles', $session{'CurrentUser'} ) )
- && ( !RT->Config->Get( 'MaxInlineBody', $session{'CurrentUser'} )
- || $size <= RT->Config->Get('MaxInlineBody', $session{'CurrentUser'} ) ) )
- {
+ if ( $message->ContentType =~ m{^(text|message)}i ) {
+ my $max_size = RT->Config->Get( 'MaxInlineBody', $session{'CurrentUser'} );
+ if ( $message->Filename && RT->Config->Get('SuppressInlineTextFiles', $session{'CurrentUser'} ) ) {
+ $m->out('<p>'. loc( 'Text file is not shown because it is disabled in preferences.' ) .'</p>');
+ return;
+ }
+ elsif ( $max_size && $message->ContentLength > $max_size ) {
+ $m->out('<p>'. loc( 'Message body not shown because it is too large.' ) .'</p>');
+ return;
+ }
if (
@@ -107,6 +170,7 @@
)
{
+ my $content;
if ( $AttachmentContent->{ $message->id } ) {
$content = $AttachmentContent->{ $message->id }->Content;
}
@@ -158,65 +222,10 @@
}
elsif ( $message->ContentLength > 0 ) {
$m->out( '<p>' .
- loc( 'Message body not shown because it is too large or is not plain text.' ) .
+ loc( 'Message body not shown because it is not plain text.' ) .
'</p>'
);
}
-}
-
-# }}}
-
-$m->comp(
- $m->current_comp,
- %ARGS,
- Parent => $message->id,
- ParentObj => $message
-);
-
-</%PERL>
-</div>
-% }
-<%ARGS>
-$Ticket => undef
-$Transaction => undef
-$ShowHeaders => 0
-$Collapsed => undef
-$DownloadableHeaders => 1
-$ShowTitleBarCommands => 1
-$RowNum => 1
-$AttachPath => RT->Config->Get('WebPath')."/Ticket/Attachment"
-$UpdatePath => RT->Config->Get('WebPath')."/Ticket/Update.html"
-$EmailRecordPath => RT->Config->Get('WebPath')."/Ticket/ShowEmailRecord.html"
-$Attachments => undef
-$AttachmentContent => {}
-$ShowBody => 1
-$Parent => 0
-$ParentObj => undef
-</%ARGS>
-<%INIT>
-my @DisplayHeaders=qw(_all);
-if ( $Transaction->Type =~ /EmailRecord$/ ) {
- @DisplayHeaders = qw(To Cc Bcc);
-}
-
-# If the transaction has anything attached to it at all
-elsif (!$ShowHeaders) {
- @DisplayHeaders = qw(To From RT-Send-Cc Cc Bcc Date Subject);
- push @DisplayHeaders, 'RT-Send-Bcc' if RT->Config->Get('ShowBccHeader');
-}
-
-my $size_to_str = sub {
- my $size = shift;
- # show a download link
- if ( $size > 1024*1024 ) {
- $size = loc( "[_1]b", int( $size / 1024 / 102.4 ) / 10 );
- }
- elsif ( $size > 1024 ) {
- $size = loc( "[_1]k", int( $size / 102.4 ) / 10 );
- }
- else {
- $size = loc( "[_1]b", $size );
- }
- return $size;
};
+
</%INIT>
More information about the Rt-commit
mailing list