This commit is contained in:
wangyidong
2015-12-23 16:33:47 +08:00
parent 4ebfcc3ac8
commit 82f04a6a22
8 changed files with 62 additions and 53 deletions
+6 -11
View File
@@ -416,19 +416,14 @@ class bug extends control
if($this->session->bugImagesFile)
{
$extractPath = $this->session->bugImagesFile;
if(is_dir($extractPath))
$files = $this->session->bugImagesFile;
foreach($files as $fileName => $file)
{
$titles = array();
$files = glob($extractPath . '/*');
sort($files);
foreach($files as $fileName)
{
$fileName = basename($fileName);
$titles[$fileName] = preg_replace('/^\d+_/', '', pathinfo($fileName, PATHINFO_FILENAME));
}
$this->view->titles = $titles;
$title = $file['title'];
$titles[$title] = $fileName;
}
krsort($titles);
$this->view->titles = $titles;
}
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->batchCreate;
+7 -8
View File
@@ -140,14 +140,11 @@ class bugModel extends model
if(!empty($data->uploadImage[$i]))
{
$fileName = htmlspecialchars_decode($data->uploadImage[$i]);
$realPath = $this->session->bugImagesFile . $fileName;
$fileName = $data->uploadImage[$i];
$file = $this->session->bugImagesFile[$fileName];
$file = array();
$file['extension'] = $this->file->getExtension($fileName);
$file['pathname'] = $this->file->setPathName($i, $file['extension']);
$file['title'] = str_replace(".{$file['extension']}", '', $fileName);
$file['size'] = filesize($realPath);
$realPath = $file['realpath'];
unset($file['realpath']);
if(rename($realPath, $this->file->savePath . $file['pathname']))
{
if(in_array($file['extension'], $this->config->file->imageExtensions))
@@ -194,7 +191,9 @@ class bugModel extends model
if(!empty($data->uploadImage) and $this->session->bugImagesFile)
{
$classFile = $this->app->loadClass('zfile');
if(is_dir($this->session->bugImagesFile)) $classFile->removeDir($this->session->bugImagesFile);
$file = current($_SESSION['bugImagesFile']);
$realPath = dirname($file['realpath']);
if(is_dir($realPath)) $classFile->removeDir($realPath);
unset($_SESSION['bugImagesFile']);
}
+1 -1
View File
@@ -57,7 +57,7 @@
?>
<?php $i = 0; ?>
<?php if(!empty($titles)):?>
<?php foreach($titles as $fileName => $bugTitle):?>
<?php foreach($titles as $bugTitle => $fileName):?>
<?php
$moduleID = $i == 0 ? $moduleID : 'ditto';
$projectID = $i == 0 ? $projectID : 'ditto';
+4 -4
View File
@@ -330,13 +330,13 @@ class file extends control
if(@move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname']))
{
$zipFile = $this->file->savePath . $file['pathname'];
$filePath = $this->file->extractZip($zipFile);
$zipFile = $this->file->savePath . $file['pathname'];
$files = $this->file->extractZip($zipFile);
unlink($zipFile);
if(!$filePath) die(js::alert($this->lang->file->errorExtract));
if(!$files) die(js::alert($this->lang->file->errorExtract));
$this->session->set($module . 'ImagesFile', $filePath);
$this->session->set($module . 'ImagesFile', $files);
die(js::locate($this->createLink($module, 'batchCreate', helper::safe64Decode($params)), 'parent.parent'));
}
}
+23 -3
View File
@@ -413,18 +413,38 @@ class fileModel extends model
$filePath = $parentPath . str_replace('.zip', '', basename($zipFile)) . '/';
if(is_dir($filePath)) $classFile->removeDir($filePath);
mkdir($filePath);
$this->app->loadClass('pclzip', true);
$zip = new pclzip($zipFile);
$files = $zip->listContent();
foreach($files as $uploadFile)
foreach($files as $i => $uploadFile)
{
$extension = strtolower(substr(strrchr($uploadFile['filename'], '.'), 1));
if(empty($extension) or !in_array($extension, $this->config->file->imageExtensions)) return false;
}
if($zip->extract(PCLZIP_OPT_PATH, $filePath) == 0) return false;
return $filePath;
$extractedFiles = array();
foreach($files as $i => $uploadFile)
{
$fileName = mb_convert_encoding($uploadFile['filename'], 'UTF-8', 'gb2312');
$file = array();
$file['extension'] = $this->getExtension($fileName);
$file['pathname'] = $this->setPathName($i, $file['extension']);
$file['title'] = str_replace(".{$file['extension']}", '', $fileName);
$file['size'] = $uploadFile['size'];
$fileName = basename($file['pathname']);
$file['realpath'] = $filePath . $fileName;
$list = $zip->extract(PCLZIP_OPT_BY_NAME, $uploadFile['filename'], PCLZIP_OPT_EXTRACT_AS_STRING);
if($list)
{
file_put_contents($file['realpath'], $list[0]['content']);
$extractedFiles[$fileName] = $file;
}
}
return $extractedFiles;
}
/**
+7 -15
View File
@@ -201,10 +201,7 @@ class story extends control
$mails = $this->story->batchCreate($productID, $branch);
if(dao::isError()) die(js::error(dao::getError()));
foreach($mails as $mail)
{
$this->sendmail($mail->storyID, $mail->actionID);
}
foreach($mails as $mail) $this->sendmail($mail->storyID, $mail->actionID);
die(js::locate($this->createLink('product', 'browse', "productID=$productID&branch=$branch"), 'parent'));
}
@@ -226,19 +223,14 @@ class story extends control
/* Process upload images. */
if($this->session->storyImagesFile)
{
$extractPath = $this->session->storyImagesFile;
if(is_dir($extractPath))
$files = $this->session->storyImagesFile;
foreach($files as $fileName => $file)
{
$titles = array();
$files = glob($extractPath . '/*');
sort($files);
foreach($files as $fileName)
{
$fileName = basename($fileName);
$titles[$fileName] = preg_replace('/^\d+_/', '', pathinfo($fileName, PATHINFO_FILENAME));
}
$this->view->titles = $titles;
$title = $file['title'];
$titles[$title] = $fileName;
}
krsort($titles);
$this->view->titles = $titles;
}
$moduleOptionMenu['same'] = $this->lang->story->same;
+13 -10
View File
@@ -222,6 +222,7 @@ class storyModel extends model
public function batchCreate($productID = 0, $branch = 0)
{
$now = helper::now();
$mails = array();
$stories = fixer::input('post')->get();
$batchNum = count(reset($stories));
@@ -242,9 +243,10 @@ class storyModel extends model
}
if(isset($stories->uploadImage)) $this->loadModel('file');
for($i = 0; $i < $batchNum; $i++)
{
if($stories->title[$i] != '')
if(!empty($stories->title[$i]))
{
$data = new stdclass();
$data->module = $stories->module[$i];
@@ -275,18 +277,17 @@ class storyModel extends model
$specData->story = $storyID;
$specData->version = 1;
$specData->title = $stories->title[$i];
if($stories->spec[$i] != '') $specData->spec = nl2br($stories->spec[$i]);
$specData->spec = '';
if(!empty($stories->spec[$i])) $specData->spec = nl2br($stories->spec[$i]);
if(!empty($stories->uploadImage[$i]))
{
$fileName = htmlspecialchars_decode($stories->uploadImage[$i]);
$realPath = $this->session->storyImagesFile . $fileName;
$fileName = $stories->uploadImage[$i];
$file = $this->session->storyImagesFile[$fileName];
$realPath = $file['realpath'];
unset($file['realpath']);
$file = array();
$file['extension'] = $this->file->getExtension($fileName);
$file['pathname'] = $this->file->setPathName($i, $file['extension']);
$file['title'] = str_replace(".{$file['extension']}", '', $fileName);
$file['size'] = filesize($realPath);
if(rename($realPath, $this->file->savePath . $file['pathname']))
{
$file['addedBy'] = $this->app->user->account;
@@ -321,7 +322,9 @@ class storyModel extends model
if(!empty($stories->uploadImage) and $this->session->storyImagesFile)
{
$classFile = $this->app->loadClass('zfile');
if(is_dir($this->session->storyImagesFile)) $classFile->removeDir($this->session->storyImagesFile);
$file = current($_SESSION['storyImagesFile']);
$realPath = dirname($file['realpath']);
if(is_dir($realPath)) $classFile->removeDir($realPath);
unset($_SESSION['storyImagesFile']);
}
+1 -1
View File
@@ -41,7 +41,7 @@
</thead>
<?php $i = 0; ?>
<?php if(!empty($titles)):?>
<?php foreach($titles as $fileName => $storyTitle):?>
<?php foreach($titles as $storyTitle => $fileName):?>
<?php $moduleID = $i == 0 ? $moduleID : 'same';?>
<?php $planID = $i == 0 ? '' : 'same';?>
<?php $pri = $i == 0 ? '' : 'same';?>