View Issue Details

IDProjectCategoryView StatusLast Update
0005758mantisbtfeaturepublic2011-06-21 03:42
ReporterPatPowerMan Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status newResolutionopen 
Product Version1.0.0a3 
Summary0005758: Possibility to add a link to a uploaded file (without repeating the whole server-path)
Description

After uploading a file called "example.zip", I can see the link for it:

http://servername/php/Mantis/file_download.php?file_id=65&type=bug

It would be great, If I could add a shortcut to this "example.zip" in a bugnote.
I know that I can add a link to another bug with #bugnumber and direct to a bugnote with ~bugnote.

But how can I link to a uploaded file? What about att:// or something like this?

TagsNo tags attached.

Activities

malaussena

malaussena

2005-06-09 12:43

reporter   ~0010452

It could be related too with the 0006607.

PatPowerMan

PatPowerMan

2005-06-10 04:18

reporter   ~0010469

You mean 0005607?

malaussena

malaussena

2005-06-10 06:34

reporter   ~0010472

Oops ! Sorry, you're right ! :-S

PatPowerMan

PatPowerMan

2005-07-07 09:18

reporter   ~0010678

Last edited: 2005-07-07 09:19

I made a 'very quick & very dirty' Workaround for this.
Before you apply this changes, you have to know:
a) there is no security implemented!
b) there is no language-support implemented!
c) everything is added in the \core\string_api.php

If you're still interested:

1.) ADD this line in the function string_display_links( $p_string )
$p_string = string_process_att_link( $p_string );

then add the above function in the same \core\string_api.php

function string_process_att_link( $p_string, $p_include_anchor=true ) {
$t_tag = '£';
$t_path = config_get( 'path' );

preg_match_all( '/(^|.+?)(?:(?<=^|\W)' . preg_quote($t_tag) . '(\d+)|$)/s',
                        $p_string, $t_matches, PREG_SET_ORDER );
$t_result = '';

if ( $p_include_anchor ) {
    foreach ( $t_matches as $t_match ) {

        $t_result .= $t_match[1];

        if ( isset( $t_match[2] ) ) {

            $t_att_id = $t_match[2];

            $t_file_display_name = search_attachment ( $t_att_id );
            $t_name = show_fileicon ( $t_file_display_name );

            $t_href_start   = "<a href=\"file_download.php?file_id=$t_att_id&amp;type=bug\" target=_new">";
            $t_href_picture = '<img src="' . $t_path . 'images/'. $t_name . '" width="16" height="16" border="0" align="absmiddle"/>';
            $t_href_end     = '</a>';

            $t_result .= $t_href_start;                         
            $t_result .= $t_href_picture;
            $t_result .= $t_href_end;                       
            $t_result .= '&nbsp';               

            $t_result .= $t_href_start;                             
            $t_result .= 'Beilage: '.$t_file_display_name;  
            $t_result .= $t_href_end;                                                   
        }               
    }
}

return $t_result;

}

Because in this function are 2 new 'subfunction' called
search_attachment
and
show_fileicon
we need this this two function too. Add it at the end of \core\string_api.php:

function search_attachment ( $p_att_id ) {

    $ps_att_filename = file_get_field ($p_att_id, filename);

    $t_file_display_name = file_get_display_name( $ps_att_filename );

    return $t_file_display_name;

}

function show_fileicon ( $p_filename ) {

    $t_file_type_icons = config_get( 'file_type_icons' );
    $ext = strtolower( file_get_extension( $p_filename ) );
    if ( is_blank( $ext ) || !isset( $t_file_type_icons[$ext] ) ) {
        $ext = '?';
        }
    $t_name = $t_file_type_icons[$ext];

    return $t_name;
}

I hope, some mantis-php-pro's can have a look for this code and add it without all the disadvantage from this quick and dirty suggestion.

PatPowerMan

PatPowerMan

2005-07-07 09:23

reporter   ~0010679

With this suggestion you can link a uploaded file like this:
£5

would display:
(Pdf-Picture) Beilage: IP Migration Guide.pdf