diff --git a/trunk/module/bug/control.php b/trunk/module/bug/control.php index db55aa331e..54a5b17bef 100644 --- a/trunk/module/bug/control.php +++ b/trunk/module/bug/control.php @@ -201,8 +201,7 @@ class bug extends control { $changes = $this->bug->update($bugID); if(dao::isError()) die(js::error(dao::getError())); - $this->loadModel('file'); - $files = $this->file->saveUpload('files', 'bug', $bugID); + $files = $this->loadModel('file')->saveUpload('bug', $bugID); if($this->post->comment != '' or !empty($changes) or !empty($files)) { $action = !empty($changes) ? 'Edited' : 'Commented'; diff --git a/trunk/module/bug/model.php b/trunk/module/bug/model.php index c3e56587fa..38b1ff157f 100644 --- a/trunk/module/bug/model.php +++ b/trunk/module/bug/model.php @@ -47,13 +47,13 @@ class bugModel extends model ->cleanInt('product, module, severity') ->specialChars('steps') ->join('mailto', ',') + ->remove('files, labels') ->get(); $this->dao->insert(TABLE_BUG)->data($bug)->autoCheck()->batchCheck('title,type', 'notempty')->exec(); if(!dao::isError()) { $bugID = $this->dao->lastInsertID(); - $this->loadModel('file'); - $this->file->saveUpload('files', 'bug', $bugID); + $this->loadModel('file')->saveUpload('bug', $bugID); return $bugID; } return false; @@ -79,9 +79,7 @@ class bugModel extends model foreach($bug as $key => $value) if(strpos($key, 'Date') !== false and !(int)substr($value, 0, 4)) $bug->$key = ''; $bug->mailto = ltrim(trim($bug->mailto), ','); if($bug->duplicateBug) $bug->duplicateBugTitle = $this->dao->findById($bug->duplicateBug)->from(TABLE_BUG)->fields('title')->fetch('title'); - - $this->loadModel('file'); - $bug->files = $this->file->getByObject('bug', $bugID); + $bug->files = $this->loadModel('file')->getByObject('bug', $bugID); return $bug; } @@ -94,7 +92,7 @@ class bugModel extends model ->cleanInt('product,module,severity,project,story,task') ->stripTags('title') ->specialChars('steps') - ->remove('comment') + ->remove('comment,fiels,labels') ->setDefault('project,module,project,story,task,duplicateBug', 0) ->add('lastEditedBy', $this->app->user->account) ->add('lastEditedDate', $now) diff --git a/trunk/module/bug/view/create.html.php b/trunk/module/bug/view/create.html.php index bdb050f3de..c6b0d7e546 100644 --- a/trunk/module/bug/view/create.html.php +++ b/trunk/module/bug/view/create.html.php @@ -153,10 +153,7 @@ function loadProjectStories(projectID) bug->files;?> - - - - + fetch('file', 'buildform');?> diff --git a/trunk/module/bug/view/edit.html.php b/trunk/module/bug/view/edit.html.php index 2b9b7df02b..26781d7bda 100644 --- a/trunk/module/bug/view/edit.html.php +++ b/trunk/module/bug/view/edit.html.php @@ -195,8 +195,8 @@ function setDuplicate(resolution) + fetch('file', 'buildform', 'filecount=2');?> files as $file) echo html::a($file->fullPath, $file->title);?> - diff --git a/trunk/module/bug/view/view.html.php b/trunk/module/bug/view/view.html.php index c64a9d3ee2..183c2aa3ea 100644 --- a/trunk/module/bug/view/view.html.php +++ b/trunk/module/bug/view/view.html.php @@ -46,6 +46,10 @@ bug->legendSteps;?>
steps);?>
+
+ bug->legendAttatch;?> +
files as $file) echo html::a($file->fullPath, $file->title, '_blank');?>
+
bug->legendAction;?> @@ -165,16 +169,6 @@
mailto); foreach($mailto as $account) echo ' ' . $users[$account]; ?>
-
- bug->legendAttatch;?> -
- files as $file) echo html::a($file->fullPath, $file->title, '_blank'); - ?> -
-
- -
bug->legendLinkBugs;?>
 
@@ -185,7 +179,6 @@
 
- diff --git a/trunk/module/file/control.php b/trunk/module/file/control.php index 643113d5bb..008ac1ef22 100644 --- a/trunk/module/file/control.php +++ b/trunk/module/file/control.php @@ -23,4 +23,10 @@ */ class file extends control { + /* 生成文件上传的表单。*/ + public function buildForm($fileCount = 2) + { + $this->view->fileCount = $fileCount; + $this->display(); + } } diff --git a/trunk/module/file/lang/zh-cn.php b/trunk/module/file/lang/zh-cn.php index 3a0e873e97..4929d674f8 100644 --- a/trunk/module/file/lang/zh-cn.php +++ b/trunk/module/file/lang/zh-cn.php @@ -22,3 +22,4 @@ * @link http://www.zentao.cn */ $lang->file->common = '附件'; +$lang->file->label = '标题:'; diff --git a/trunk/module/file/model.php b/trunk/module/file/model.php index a764f26be4..99812bf8ce 100644 --- a/trunk/module/file/model.php +++ b/trunk/module/file/model.php @@ -28,6 +28,7 @@ class fileModel extends model public $savePath = ''; public $webPath = ''; + /* 构造函数。*/ public function __construct() { parent::__construct(); @@ -35,6 +36,7 @@ class fileModel extends model $this->setWebPath(); } + /* 通过对象类型获取文件列表。*/ public function getByObject($objectType, $objectID) { $files = array(); @@ -48,11 +50,11 @@ class fileModel extends model } /* 保存上传的文件。*/ - public function saveUpload($htmlTagName = 'files', $objectType = '', $objectID = '') + public function saveUpload($objectType = '', $objectID = '') { $fileTitles = array(); $now = date('Y-m-d H:i:s'); - $files = $this->getUpload($htmlTagName); + $files = $this->getUpload(); foreach($files as $id => $file) { @@ -70,7 +72,7 @@ class fileModel extends model } /* 获取上传的文件信息。*/ - private function getUpload($htmlTagName) + private function getUpload($htmlTagName = 'files') { $files = array(); if(!isset($_FILES[$htmlTagName])) return $files; @@ -84,7 +86,7 @@ class fileModel extends model if(empty($filename)) continue; $file['extension'] = $this->getExtension($filename); $file['pathname'] = $this->setPathName($id, $file['extension']); - $file['title'] = pathinfo($filename, PATHINFO_FILENAME); + $file['title'] = isset($_POST['labels'][$id]) ? htmlspecialchars($_POST['labels'][$id]) : pathinfo($filename, PATHINFO_FILENAME); $file['size'] = $size[$id]; $file['tmpname'] = $tmp_name[$id]; $files[] = $file; @@ -96,7 +98,7 @@ class fileModel extends model extract($_FILES[$htmlTagName]); $file['extension'] = $this->getExtension($name); $file['pathname'] = $this->setPathName(0, $file['extension']); - $file['title'] = pathinfo($name, PATHINFO_FILENAME); + $file['title'] = isset($_POST['labels'][0]) ? htmlspecialchars($_POST['labels'][0]) : pathinfo($filename, PATHINFO_FILENAME); $file['size'] = $size; $file['tmpname'] = $tmp_name; return array($file); diff --git a/trunk/module/file/view/buildform.html.php b/trunk/module/file/view/buildform.html.php new file mode 100644 index 0000000000..4ba35ab79b --- /dev/null +++ b/trunk/module/file/view/buildform.html.php @@ -0,0 +1,4 @@ + + +file->label;?>
+