View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006253 | mantisbt | feature | public | 2005-09-15 17:18 | 2006-09-12 00:52 |
Reporter | asmaloney | Assigned To | vboctor | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Fixed in Version | 1.1.0a1 | ||||
Summary | 0006253: Inlining of other types of files | ||||
Description | It would be nice to be able to have text files inline as well as the images. I typically get reports with a screenshot and a txt file and it is tedious to have to download the txt files and open them with another app. Alternatively, it would make sense to be able to click them and have them shown in a new browser window. | ||||
Tags | No tags attached. | ||||
Attached Files | showtxtfiles.patch (2,978 bytes)
Index: core/file_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/file_api.php,v retrieving revision 1.72 diff -u -r1.72 file_api.php --- core/file_api.php 11 Aug 2005 01:53:02 -0000 1.72 +++ core/file_api.php 11 Jan 2006 22:24:31 -0000 @@ -183,6 +183,54 @@ PRINT ' (' . lang_get( 'cached' ) . ')'; } + + if ( $t_can_download && + ( $v_filesize <= config_get( 'preview_attachments_inline_max_size' ) ) && + ( $v_filesize != 0 ) && + ( in_array( strtolower( file_get_extension( $t_file_display_name ) ), array( 'txt','patch' ), true ) ) ) { + $c_id=number_format($v_id); + $t_bug_file_table = config_get( 'mantis_bug_file_table' ); + + echo "<script language='JavaScript'> +<!-- +function swap_content( span ) { +displayType = ( document.getElementById( span ).style.display == 'none' ) ? 'block' : 'none'; +document.getElementById( span ).style.display = displayType; +} + + --> + </script>"; + PRINT "[<a class=\"small\" href='#' id='attmlink_".$c_id."' onClick='swap_content(\"attm_".$c_id."\");return false;'>". lang_get( 'show_content' ) ."</a>]<blockquote style='display:none' id='attm_".$c_id."' class=''><pre>"; + switch ( config_get( 'file_upload_method' ) ) { + case DISK: + if ( file_exists( $v_diskfile ) ) { + $v_content=file_get_contents( $v_diskfile ); + } + break; + case FTP: + if ( file_exists( $v_diskfile ) ) { + file_get_contents( $v_diskfile ); + } else { + $ftp = file_ftp_connect(); + file_ftp_get ( $ftp, $v_diskfile, $v_diskfile ); + file_ftp_disconnect( $ftp ); + $v_content=file_get_contents( $v_diskfile ); + } + break; + default: + $query = "SELECT * + FROM $t_bug_file_table + WHERE id='$c_id'"; + $result = db_query( $query ); + $row = db_fetch_array( $result ); + $v_content=$row['content']; + } + echo htmlspecialchars($v_content); + + PRINT "</pre></blockquote>"; + } + + if ( $t_can_download && ( $v_filesize <= config_get( 'preview_attachments_inline_max_size' ) ) && ( $v_filesize != 0 ) && Index: lang/strings_english.txt =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/lang/strings_english.txt,v retrieving revision 1.268 diff -u -r1.268 strings_english.txt --- lang/strings_english.txt 17 Dec 2005 23:08:52 -0000 1.268 +++ lang/strings_english.txt 11 Jan 2006 22:12:45 -0000 @@ -602,6 +602,9 @@ $s_bugnote_updated_msg = 'Note has been successfully updated...'; $s_edited_on = 'edited on: '; +# file_api.php +$s_show_content ='Show content'; + # index.php $s_click_to_login = 'Click here to login'; | ||||
How do you like this implementation? http://dracoblue.gamehost.at/mantis/view.php?id=130# I'll upload the patchfile when I am back at home. |
|
Here is an implementation for .txt and .patch files. Easy to change in file_api.php if more are needed. Do not forget to set $g_preview_attachments_inline_max_size high enough. Best regards, |
|
Thanks for your contribtion. It is added to CVS. I've also added the following configuration options: Extenstions for text files that can be expanded inline.$g_preview_text_extensions = array( 'txt', 'diff', 'patch' ); Extensions for images that can be expanded inline.$g_preview_image_extensions = array( 'bmp', 'png', 'gif', 'jpg', 'jpeg' ); |
|