[Rt-commit] r4109 - in rt/branches/3.7-EXPERIMENTAL: .
html/Ticket/Attachment html/Ticket/Attachment/WithHeaders
html/Ticket/Elements
ruz at bestpractical.com
ruz at bestpractical.com
Wed Nov 16 19:54:28 EST 2005
Author: ruz
Date: Wed Nov 16 19:54:26 2005
New Revision: 4109
Added:
rt/branches/3.7-EXPERIMENTAL/html/Ticket/Attachment/WithHeaders/
rt/branches/3.7-EXPERIMENTAL/html/Ticket/Attachment/WithHeaders/dhandler
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/html/Ticket/Attachment/dhandler
rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowTransactionAttachments
Log:
r1315 at cubic-pc: cubic | 2005-11-17 03:57:12 +0300
r1298 at cubic-pc: cubic | 2005-11-16 23:06:11 +0300
* new comp /Ticket/Attachment/WithHeaders/dhandler
that allow user to download attachmentes with
MIME headers
Added: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Attachment/WithHeaders/dhandler
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Attachment/WithHeaders/dhandler Wed Nov 16 19:54:26 2005
@@ -0,0 +1,25 @@
+<%perl>
+ # we don't need transaction id
+ my ($id) = $m->dhandler_arg =~ /^(\d+)/;
+ unless ( $id ) {
+ # wrong url format
+ Abort("Corrupted attachment URL");
+ }
+
+ my $AttachmentObj = new RT::Attachment( $session{'CurrentUser'} );
+ $AttachmentObj->Load( $id );
+ unless ( $AttachmentObj->id ) {
+ Abort("Couldn't load attachment #$id");
+ }
+
+ # XXX: should we check handle html here and integrate headers into html?
+ $r->content_type( 'text/plain' );
+ $m->clear_buffer;
+ $m->out( $AttachmentObj->Headers );
+ $m->out( "\n\n" );
+ $m->out( $AttachmentObj->OriginalContent );
+ $m->abort;
+</%perl>
+<%attr>
+AutoFlush => 0
+</%attr>
Modified: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Attachment/dhandler
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Ticket/Attachment/dhandler (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Attachment/dhandler Wed Nov 16 19:54:26 2005
@@ -44,15 +44,15 @@
%#
%# END BPS TAGGED BLOCK }}}
<%perl>
- my ($ticket, $trans,$attach, $filename);
- my $arg = $m->dhandler_arg; # get rest of path
- if ($arg =~ '^(\d+)/(\d+)') {
+ my ($ticket, $trans,$attach, $filename);
+ my $arg = $m->dhandler_arg; # get rest of path
+ if ($arg =~ '^(\d+)/(\d+)') {
$trans = $1;
$attach = $2;
- }
+ }
else {
Abort("Corrupted attachment URL.");
- }
+ }
my $AttachmentObj = new RT::Attachment($session{'CurrentUser'});
$AttachmentObj->Load($attach) || Abort("Attachment '$attach' could not be loaded");
Modified: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowTransactionAttachments
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowTransactionAttachments (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Elements/ShowTransactionAttachments Wed Nov 16 19:54:26 2005
@@ -53,7 +53,7 @@
chomp $headers;
# localize the common headers (like 'Subject:'), too.
- $headers =~ s/^([^:]+)(?=:)/loc($1)/em;
+ $headers =~ s/^(?!\s)([^:]+)(?=:)/loc($1)/em;
$m->comp(
'ShowMessageHeaders',
Headers => $headers,
@@ -65,24 +65,26 @@
# {{{ if there's any size at all, show the download link
my $size = $message->ContentLength;
if ($size) {
-
-</%perl>
+
+</%PERL>
<div class="downloadattachment">
-<%perl>
+<%PERL>
- # show a download link
- if ( $size > 1024 ) {
- $size = loc( "[_1]k", int( $size / 102.4 ) / 10 );
- }
- else {
+ # show a download link
+ if ( $size > 1024 ) {
+ $size = loc( "[_1]k", int( $size / 102.4 ) / 10 );
+ }
+ else {
$size = loc( "[_1]b", $size );
- }
-
+ }
+
</%PERL>
-<a href="<%$AttachPath%>/<%$Transaction->Id%>/<%$message->Id%>/<%$message->Filename | u%>"><&|/l&>Download</&> <%$message->Filename || loc('(untitled)') %></a>
-<span class="downloadcontenttype">
-[<%$message->ContentType%> <% $size %>]
-</span>
+<a href="<% $AttachPath %>/<% $Transaction->Id %>/<% $message->Id %>/<% $message->Filename | u%>">
+<&|/l&>Download</&> <% $message->Filename || loc('(untitled)') %></a>
+% if ( !$message->Filename && $message->ContentType =~ /text/ ) {
+<span>[<a href="<% $AttachPath %>/WithHeaders/<% $message->Id %>"><% loc('with headers') %></a>]</span>
+% }
+<span class="downloadcontenttype">[<% $message->ContentType %> <% $size %>]</span>
</div>
% }
% # }}}
More information about the Rt-commit
mailing list