- 浏览: 14500 次
最新评论
mantis附件图片预览
- 博客分类:
- 技术杂绘
mantis在bug详情查看页面里,可以查看bug关联的附件。如果附件类型是文本或者图片时可以提供预览。print_api.php的下面这个函数就是输入附件内容的。 # List the attachments belonging to the specified bug. This is used from within # bug_view_page.php function print_bug_attachments_list( $p_bug_id ) { $t_attachments = file_get_visible_attachments( $p_bug_id ); $t_attachments_count = count( $t_attachments ); $i = 0; $image_previewed = false; foreach ( $t_attachments as $t_attachment ) { $t_file_display_name = string_display_line( $t_attachment['display_name'] ); $t_filesize = number_format( $t_attachment['size'] ); $t_date_added = date( config_get( 'normal_date_format' ), $t_attachment['date_added'] ); if ( $image_previewed ) { $image_previewed = false; echo '
'; } if ( $t_attachment['can_download'] ) { $t_href_start = ""; $t_href_end = ''; } else { $t_href_start = ''; $t_href_end = ''; } if ( !$t_attachment['exists'] ) { print_file_icon( $t_file_display_name ); echo ' ' . $t_file_display_name . '' . lang_get( 'word_separator' ) . '(' . lang_get( 'attachment_missing' ) . ')'; } else { echo $t_href_start; print_file_icon( $t_file_display_name ); echo $t_href_end . ' ' . $t_href_start . $t_file_display_name . $t_href_end . ' (' . $t_filesize . ' ' . lang_get( 'bytes' ) . ') ' . '' . $t_date_added . ''; if ( $t_attachment['can_delete'] ) { echo ' ['; print_link( 'bug_file_delete.php?file_id=' . $t_attachment['id'] . form_security_param( 'bug_file_delete' ), lang_get( 'delete_link' ), false, 'small' ); echo ']'; } if ( ( FTP == config_get( 'file_upload_method' ) ) && $t_attachment['exists'] ) { echo ' (' . lang_get( 'cached' ) . ')'; } if ( $t_attachment['preview'] && ( $t_attachment['type'] == 'text' ) ) { $c_id = db_prepare_int( $t_attachment['id'] ); $t_bug_file_table = db_get_table( 'bug_file' ); echo ""; echo " [" . lang_get( 'show_content' ) . "]"; echo " [" . lang_get( 'hide_content' ) . "]"; echo ""; /** @todo Refactor into a method that gets contents for download / preview. */ switch( config_get( 'file_upload_method' ) ) { case DISK: if ( $t_attachment['exists'] ) { $v_content = file_get_contents( $t_attachment['diskfile'] ); } break; case FTP: if( file_exists( $t_attachment['exists'] ) ) { file_get_contents( $t_attachment['diskfile'] ); } else { $ftp = file_ftp_connect(); file_ftp_get( $ftp, $t_attachment['diskfile'], $t_attachment['diskfile'] ); file_ftp_disconnect( $ftp ); $v_content = file_get_contents( $t_attachment['diskfile'] ); } break; default: $query = "SELECT * FROM $t_bug_file_table WHERE id=" . db_param(); $result = db_query_bound( $query, Array( $c_id ) ); $row = db_fetch_array( $result ); $v_content = $row['content']; } echo htmlspecialchars( $v_content ); echo "\n"; } if ( $t_attachment['can_download'] && $t_attachment['preview'] && $t_attachment['type'] == 'image' ) { $t_preview_style = 'border: 0;'; $t_max_width = config_get( 'preview_max_width' ); if( $t_max_width > 0 ) { $t_preview_style .= ' max-width:' . $t_max_width . 'px;'; } $t_max_height = config_get( 'preview_max_height' ); if( $t_max_height > 0 ) { $t_preview_style .= ' max-height:' . $t_max_height . 'px;'; } $t_preview_style = 'style="' . $t_preview_style . '"'; $t_title = file_get_field( $t_attachment['id'], 'title' ); $t_image_url = $t_attachment['download_url'] . '&show_inline=1' . form_security_param( 'file_show_inline' ); echo "\n
$t_href_start$t_href_end"; $image_previewed = true; } } if ( $i != ( $t_attachments_count - 1 ) ) { echo "
\n"; $i++; } } } 对上面的函数稍作修改,添加一个可显示或隐藏图片预览区域的按钮。下面代码中调用了lang_get('hide_content')
需要在lang目录下相应语言文件里面加入$s_hide_content变量 # List the attachments belonging to the specified bug. This is used from within # bug_view_page.php function print_bug_attachments_list( $p_bug_id ) { $t_attachments = file_get_visible_attachments( $p_bug_id ); $t_attachments_count = count( $t_attachments ); $i = 0; $image_previewed = false; foreach ( $t_attachments as $t_attachment ) { $t_file_display_name = string_display_line( $t_attachment['display_name'] ); $t_filesize = number_format( $t_attachment['size'] ); $t_date_added = date( config_get( 'normal_date_format' ), $t_attachment['date_added'] ); if ( $image_previewed ) { $image_previewed = false; echo '
'; } if ( $t_attachment['can_download'] ) { $t_href_start = ""; $t_href_end = ''; } else { $t_href_start = ''; $t_href_end = ''; } if ( !$t_attachment['exists'] ) { print_file_icon( $t_file_display_name ); echo ' ' . $t_file_display_name . '' . lang_get( 'word_separator' ) . '(' . lang_get( 'attachment_missing' ) . ')'; } else { echo $t_href_start; print_file_icon( $t_file_display_name ); echo $t_href_end . ' ' . $t_href_start . $t_file_display_name . $t_href_end . ' (' . $t_filesize . ' ' . lang_get( 'bytes' ) . ') ' . '' . $t_date_added . ''; if ( $t_attachment['can_delete'] ) { echo ' ['; print_link( 'bug_file_delete.php?file_id=' . $t_attachment['id'] . form_security_param( 'bug_file_delete' ), lang_get( 'delete_link' ), false, 'small' ); echo ']'; } if ( ( FTP == config_get( 'file_upload_method' ) ) && $t_attachment['exists'] ) { echo ' (' . lang_get( 'cached' ) . ')'; } if ( $t_attachment['preview'] && ( $t_attachment['type'] == 'text' ) ) { $c_id = db_prepare_int( $t_attachment['id'] ); $t_bug_file_table = db_get_table( 'bug_file' ); echo ""; echo " [" . lang_get( 'show_content' ) . "]"; echo " [" . lang_get( 'hide_content' ) . "]"; echo ""; /** @todo Refactor into a method that gets contents for download / preview. */ switch( config_get( 'file_upload_method' ) ) { case DISK: if ( $t_attachment['exists'] ) { $v_content = file_get_contents( $t_attachment['diskfile'] ); } break; case FTP: if( file_exists( $t_attachment['exists'] ) ) { file_get_contents( $t_attachment['diskfile'] ); } else { $ftp = file_ftp_connect(); file_ftp_get( $ftp, $t_attachment['diskfile'], $t_attachment['diskfile'] ); file_ftp_disconnect( $ftp ); $v_content = file_get_contents( $t_attachment['diskfile'] ); } break; default: $query = "SELECT * FROM $t_bug_file_table WHERE id=" . db_param(); $result = db_query_bound( $query, Array( $c_id ) ); $row = db_fetch_array( $result ); $v_content = $row['content']; } echo htmlspecialchars( $v_content ); echo "\n"; } if ( $t_attachment['can_download'] && $t_attachment['preview'] && $t_attachment['type'] == 'image' ) { $t_preview_style = 'border: 0;'; $t_max_width = config_get( 'preview_max_width' ); if( $t_max_width > 0 ) { $t_preview_style .= ' max-width:' . $t_max_width . 'px;'; } $t_max_height = config_get( 'preview_max_height' ); if( $t_max_height > 0 ) { $t_preview_style .= ' max-height:' . $t_max_height . 'px;'; } $t_preview_style = 'style="' . $t_preview_style . '"'; $t_title = file_get_field( $t_attachment['id'], 'title' ); $t_image_url = $t_attachment['download_url'] . '&show_inline=1' . form_security_param( 'file_show_inline' ); echo ""; echo " [" . lang_get( 'show_content' ) . "" . lang_get( 'hide_content' ) . "]"; echo "\n
$t_href_start$t_href_end"; $image_previewed = true; } } if ( $i != ( $t_attachments_count - 1 ) ) { echo "
\n"; $i++; } } }
发表评论
-
转贴 有关js 函数验证和字符串查找替换的方法
2012-07-06 09:52 665/* ************************** ... -
正则表达式JS变量
2012-07-06 09:45 610str="苹果有大苹果小苹果之分"; ... -
java正则表达式学习
2012-07-06 09:37 657正则表达式的基础: 表达式 说明 \t 制表符. ... -
HL7 Message examples
2012-07-06 09:30 1093i am now in university(HIT@We ... -
UML建模图组件库,软件设计,UML绘制 ,打印,自动代码产生,软件,VC++,VB,控件源程序
2012-07-03 13:43 885UML建模图组件库,软件设计,UML绘制 ,打印,自动 ... -
在Flex Mobile中构建“本地”菜单
2012-07-02 12:15 736Adobe Flash Builder 4 简体中文正式版 ... -
探究 Flex 组件的生命周期
2012-07-02 12:15 611简介: 最为新一 ... -
在Eclipse下使用Ant编译Flex程序
2012-07-02 12:15 582我的机器内存1G,如果使用Eclipse Flex插件编译 ... -
flex与mysql交互
2012-07-02 12:14 668这个小例子通过remoteobject的通讯方法。实现fl ... -
实现FLEX 通过AMF跟PHP通信
2012-07-02 12:14 550AMF flex一种远调用 ... -
Flex引擎
2012-07-01 09:48 804游戏引擎 1、FFilmation 是一个2.5D游 ... -
Ant Flex project 应用
2012-07-01 09:48 701写一个Ant脚本,xml大 ... -
Flex 拖拽范例
2012-07-01 09:48 709Flex由于在其Framwork里加入了DragDrop管 ... -
myeclipse6.5+flex 3 + tomcat6.0 + ds-console.war环境搭建
2012-07-01 09:48 721安装环境:myeclipse6 ... -
探究 Flex 组件的生命周期
2012-07-01 09:48 498简介: 最为新一 ... -
[转载]【笔记本电脑报价】笔记本电脑
2012-06-30 16:11 719[转载]【笔记本电脑报 ... -
[转载]Android原生(Native)C开发之四:SDL移植笔记
2012-06-30 16:11 705[转载]Android原生(Native)C开发之四:SDL移 ... -
[转载]人力资源管理师(二级)复习笔记-第三章 培训与开发
2012-06-30 16:11 721[转载]人力资源管理师( ... -
[转载]《0岁潜能开发 开发无限能力的ESP教育法》笔记
2012-06-30 16:11 672[转载]《0岁潜能开发 开发无限能力的ESP教育法》笔记 ...
相关推荐
TGT图片直接预览,缩略图就可看
Mantis是一个轻量级的brower的bug管理系统,界面直观,简单易用,安装简单,支持多语言,多数据库。
mantis简介及使用方法总结
testlink的使用过程及mantis使用过程
Mantis详细使用教程
Mantis操作手册Mantis操作手册Mantis操作手册Mantis操作手册
mantisbt-1.2.17和EasyPHP-12.1_with_PHP-5.4.6-setup.exe安装心得体会,以及一些修改配置文件的方法和注意事项。对安装配置mantis缺陷管理体统,有一定的参考价值。希望可以能帮助到你。
mantis安装经验
Mantis是一个轻量级的brower的bug管理系统,界面直观,简单易用,安装简单,支持多语言,多数据库。 备注: 稳定版集成图形报表、邮箱提醒等功能
mantis的安装及配置pdf,mantis的安装及配置pdf,mantis的安装及配置pdf,mantis的安装及配置pdf,mantis的安装及配置pdf,
Mantis_使用说明 Mantis_使用说明 Mantis_使用说明 Mantis_使用说明 Mantis_使用说明 Mantis_使用说明
BUG_Mantis使用手册BUG_Mantis使用手册BUG_Mantis使用手册BUG_Mantis使用手册BUG_Mantis使用手册BUG_Mantis使用手册BUG_Mantis使用手册
资源名称: 需要大于10个字符 *关键字(Tag): 多个关键字请用空格分隔,最多填写5个。点击右侧Tag快速添加
Mantis开源bug管理软件。需要php、mysql支持。
用cas实现mantis单点登录和登出,详细讲了mantis的程序修改用cas实现SSO,已经在实际中应用,非常有帮助
借助XAMPP安装Mantis(Mantis for Windows)_最简单适用 1.安装之前,下载下列软件 XAMPP --->Apache,php,MySQL架设包 1.7.1 Mantis-1.1.6 2.安装xampp 执行刚下载的执行档即可 3.建立MySQL的使用者账号 利用xampp...
mantis 简单使用说明 pdf 文档
Mantis配置注意事项
mantis管理工具、apache.msi、iis6.rar、php.tar.gz以及mantis安装工具
包括了Mantis安装记要、mantis 1.0.6配置安装、关于mantis和phpmyadmin的问题 很全面,请结合我发布的《Apache在windows下的安装与配置图解(最新版)》一起配置