* Rewrite file module.
This commit is contained in:
+30
-62
@@ -21,18 +21,10 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function buildForm($fileCount = 1, $percent = 0.9, $filesName = "files", $labelsName = "labels")
|
||||
public function buildForm(int $fileCount = 1, float $percent = 0.9, string $filesName = "files", string $labelsName = "labels")
|
||||
{
|
||||
if(!file_exists($this->file->savePath))
|
||||
{
|
||||
printf($this->lang->file->errorNotExists, $this->file->savePath);
|
||||
return false;
|
||||
}
|
||||
elseif(!is_writable($this->file->savePath))
|
||||
{
|
||||
printf($this->lang->file->errorCanNotWrite, $this->file->savePath, $this->file->savePath);
|
||||
return false;
|
||||
}
|
||||
if(!file_exists($this->file->savePath)) return printf($this->lang->file->errorNotExists, $this->file->savePath);
|
||||
if(!is_writable($this->file->savePath)) return printf($this->lang->file->errorCanNotWrite, $this->file->savePath, $this->file->savePath);
|
||||
|
||||
$this->view->filesName = $filesName;
|
||||
$this->view->labelsName = $labelsName;
|
||||
@@ -46,36 +38,28 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxUpload($uid = '')
|
||||
public function ajaxUpload(string $uid = '')
|
||||
{
|
||||
$file = $this->file->getUpload('imgFile');
|
||||
|
||||
if(!isset($file[0]) or !in_array($file[0]['extension'], $this->config->file->imageExtensions))
|
||||
{
|
||||
return print(json_encode(array('result' => 'fail', 'message' => $this->lang->file->errorFileFormate)));
|
||||
}
|
||||
if(!isset($file[0]) or !in_array($file[0]['extension'], $this->config->file->imageExtensions)) return print(json_encode(array('result' => 'fail', 'message' => $this->lang->file->errorFileFormate)));
|
||||
|
||||
$file = $file[0];
|
||||
if($file)
|
||||
{
|
||||
if($file['size'] == 0)
|
||||
{
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api')
|
||||
{
|
||||
return print(json_encode(array('status' => 'error', 'message' => $this->lang->file->errorFileUpload)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return print(json_encode(array('error' => 1, 'message' => $this->lang->file->errorFileUpload)));
|
||||
}
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return print(json_encode(array('status' => 'error', 'message' => $this->lang->file->errorFileUpload)));
|
||||
return print(json_encode(array('error' => 1, 'message' => $this->lang->file->errorFileUpload)));
|
||||
}
|
||||
|
||||
if(@move_uploaded_file($file['tmpname'], $this->file->savePath . $this->file->getSaveName($file['pathname'])))
|
||||
{
|
||||
/* Compress image for jpg and bmp. */
|
||||
$file = $this->file->compressImage($file);
|
||||
|
||||
$file['addedBy'] = $this->app->user->account;
|
||||
$file['addedDate'] = helper::today();
|
||||
$file['addedBy'] = $this->app->user->account;
|
||||
$file['addedDate'] = helper::today();
|
||||
unset($file['tmpname']);
|
||||
$this->dao->insert(TABLE_FILE)->data($file)->exec();
|
||||
|
||||
@@ -88,22 +72,13 @@ class file extends control
|
||||
$_SERVER['SCRIPT_NAME'] = 'index.php';
|
||||
return $this->send(array('status' => 'success', 'id' => $fileID, 'url' => $url));
|
||||
}
|
||||
else
|
||||
{
|
||||
return print(json_encode(array('error' => 0, 'url' => $url)));
|
||||
}
|
||||
return print(json_encode(array('error' => 0, 'url' => $url)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = strip_tags(sprintf($this->lang->file->errorCanNotWrite, $this->file->savePath, $this->file->savePath));
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api')
|
||||
{
|
||||
return $this->send(array('status' => 'error', 'message' => $error));
|
||||
}
|
||||
else
|
||||
{
|
||||
return print(json_encode(array('error' => 1, 'message' => $error)));
|
||||
}
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'error', 'message' => $error));
|
||||
return print(json_encode(array('error' => 1, 'message' => $error)));
|
||||
}
|
||||
}
|
||||
return $this->send(array('status' => 'error', 'message' => $this->lang->file->uploadImagesExplain));
|
||||
@@ -117,7 +92,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function preview($fileID, $mouse = '')
|
||||
public function preview(int $fileID, string $mouse = '')
|
||||
{
|
||||
return print($this->fetch('file', 'download', "fileID=$fileID&mouse=$mouse"));
|
||||
}
|
||||
@@ -130,7 +105,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function download($fileID, $mouse = '')
|
||||
public function download(int $fileID, string $mouse = '')
|
||||
{
|
||||
if(session_id() != $this->app->sessionID) helper::restartSession($this->app->sessionID);
|
||||
$file = $this->file->getById($fileID);
|
||||
@@ -142,17 +117,13 @@ class file extends control
|
||||
$this->view->error = $this->lang->file->fileNotFound;
|
||||
return $this->display();
|
||||
}
|
||||
else
|
||||
{
|
||||
return print($this->lang->file->fileNotFound);
|
||||
}
|
||||
return print($this->lang->file->fileNotFound);
|
||||
}
|
||||
|
||||
if(!$this->file->checkPriv($file))
|
||||
{
|
||||
echo js::alert($this->lang->file->accessDenied);
|
||||
if(isInModal()) return print(js::reload('parent.parent'));
|
||||
return print(js::locate(helper::createLink('my', 'index'), 'parent.parent'));
|
||||
if(isInModal()) return $this->send(array('result' => 'success', 'message' => $this->lang->file->accessDenied, 'closeModal' => true, 'load' => true));
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->file->accessDenied, 'load' => helper::createLink('my', 'index')));
|
||||
}
|
||||
|
||||
/* Judge the mode, down or open. */
|
||||
@@ -200,10 +171,7 @@ class file extends control
|
||||
$this->view->error = $this->lang->file->fileNotFound;
|
||||
return $this->display();
|
||||
}
|
||||
else
|
||||
{
|
||||
return print($this->lang->file->fileNotFound);
|
||||
}
|
||||
return print($this->lang->file->fileNotFound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +321,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function sendDownHeader($fileName, $fileType, $content, $type = 'content')
|
||||
public function sendDownHeader(string $fileName, string $fileType, string $content, string $type = 'content')
|
||||
{
|
||||
$this->file->sendDownHeader($fileName, $fileType, $content, $type);
|
||||
}
|
||||
@@ -366,7 +334,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function delete($fileID, $confirm = 'no')
|
||||
public function delete(int $fileID, string $confirm = 'no')
|
||||
{
|
||||
if($confirm == 'no')
|
||||
{
|
||||
@@ -402,7 +370,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function printFiles($files, $fieldset, $object = null, $method = 'view', $showDelete = true, $showEdit = true)
|
||||
public function printFiles(array $files, string $fieldset, object|null $object = null, string $method = 'view', bool $showDelete = true, bool $showEdit = true)
|
||||
{
|
||||
$this->view->files = $files;
|
||||
$this->view->fieldset = $fieldset;
|
||||
@@ -423,7 +391,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function edit($fileID)
|
||||
public function edit(int $fileID)
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
@@ -475,7 +443,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxPasteImg($uid = '')
|
||||
public function ajaxPasteImg(string $uid = '')
|
||||
{
|
||||
if($_POST) return print($this->file->pasteImage($this->post->editor, $uid, true));
|
||||
}
|
||||
@@ -488,7 +456,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function uploadImages($module, $params, $uid = '', $locate = false)
|
||||
public function uploadImages(string $module, string $params, string $uid = '', string $locate = '')
|
||||
{
|
||||
if($locate)
|
||||
{
|
||||
@@ -534,7 +502,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function buildExportTPL($module, $templateID = 0)
|
||||
public function buildExportTPL(string $module, int $templateID = 0)
|
||||
{
|
||||
$templates = $this->file->getExportTemplate($module);
|
||||
$templatePairs[] = $this->lang->file->defaultTPL;
|
||||
@@ -553,7 +521,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxSaveTemplate($module)
|
||||
public function ajaxSaveTemplate(string $module)
|
||||
{
|
||||
$templateID = $this->file->saveExportTemplate($module);
|
||||
if(dao::isError())
|
||||
@@ -571,7 +539,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxDeleteTemplate($templateID)
|
||||
public function ajaxDeleteTemplate(int $templateID)
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_USERTPL)->where('id')->eq($templateID)->andWhere('account')->eq($this->app->user->account)->exec();
|
||||
}
|
||||
@@ -583,7 +551,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function read($fileID)
|
||||
public function read(int $fileID)
|
||||
{
|
||||
if(!($this->app->company->guest and $this->app->user->account == 'guest') and !$this->loadModel('user')->isLogon()) return print(js::locate($this->createLink('user', 'login')));
|
||||
$file = $this->file->getById($fileID);
|
||||
@@ -619,7 +587,7 @@ class file extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxcloseBizGuide(string $moduleName)
|
||||
public function ajaxCloseBizGuide(string $moduleName)
|
||||
{
|
||||
$path = "{$this->app->user->account}.{$moduleName}.closeBizGuide@rnd";
|
||||
$this->loadModel('setting')->setItem($path, 1);
|
||||
|
||||
+28
-50
@@ -40,7 +40,7 @@ class fileModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getByObject($objectType, $objectID, $extra = '')
|
||||
public function getByObject(string $objectType, string $objectID, string $extra = ''): array
|
||||
{
|
||||
$files = $this->dao->select('*')->from(TABLE_FILE)
|
||||
->where('objectType')->eq($objectType)
|
||||
@@ -51,18 +51,7 @@ class fileModel extends model
|
||||
->orderBy('id')
|
||||
->fetchAll('id');
|
||||
|
||||
foreach($files as $file)
|
||||
{
|
||||
if($objectType == 'traincourse' or $objectType == 'traincontents')
|
||||
{
|
||||
$file->realPath = $this->app->getWwwRoot() . 'data/course/' . $file->pathname;
|
||||
$file->webPath = 'data/course/' . $file->pathname;
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->setFileWebAndRealPaths($file);
|
||||
}
|
||||
|
||||
foreach($files as $file) $this->setFileWebAndRealPaths($file);
|
||||
return $files;
|
||||
}
|
||||
|
||||
@@ -71,49 +60,30 @@ class fileModel extends model
|
||||
*
|
||||
* @param int $fileID
|
||||
* @access public
|
||||
* @return object
|
||||
* @return object|false
|
||||
*/
|
||||
public function getById($fileID)
|
||||
public function getById(int $fileID): object|false
|
||||
{
|
||||
$file = $this->dao->findById($fileID)->from(TABLE_FILE)->fetch();
|
||||
if(empty($file)) return false;
|
||||
|
||||
if($file->objectType == 'traincourse' or $file->objectType == 'traincontents')
|
||||
{
|
||||
$file->realPath = $this->app->getWwwRoot() . 'data/course/' . $file->pathname;
|
||||
$file->webPath = 'data/course/' . $file->pathname;
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
$this->setFileWebAndRealPaths($file);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get files by ID list.
|
||||
*
|
||||
* @param string $fileIdList
|
||||
* @param string|array $fileIdList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getByIdList(string $fileIdList): array
|
||||
public function getByIdList(string|array $fileIdList): array
|
||||
{
|
||||
if(empty($fileIdList)) return array();
|
||||
|
||||
$files = $this->dao->select('*')->from(TABLE_FILE)->where('id')->in($fileIdList)->orderBy('id')->fetchAll('id');
|
||||
foreach($files as $file)
|
||||
{
|
||||
if($file->objectType == 'traincourse' || $file->objectType == 'traincontents')
|
||||
{
|
||||
$file->realPath = $this->app->getWwwRoot() . 'data/course/' . $file->pathname;
|
||||
$file->webPath = 'data/course/' . $file->pathname;
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->setFileWebAndRealPaths($file);
|
||||
}
|
||||
foreach($files as $file) $this->setFileWebAndRealPaths($file);
|
||||
|
||||
return $files;
|
||||
}
|
||||
@@ -129,7 +99,7 @@ class fileModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function saveUpload($objectType = '', $objectID = 0, $extra = '', $filesName = 'files', $labelsName = 'labels')
|
||||
public function saveUpload(string $objectType = '', int $objectID = 0, string $extra = '', string $filesName = 'files', string $labelsName = 'labels'): array
|
||||
{
|
||||
$fileTitles = array();
|
||||
$now = helper::today();
|
||||
@@ -164,14 +134,13 @@ class fileModel extends model
|
||||
* @param string $filesName
|
||||
* @param string $labelsName
|
||||
* @access public
|
||||
* @return array
|
||||
* @return object
|
||||
*/
|
||||
public function saveAFile($file, $objectType = '', $objectID = 0, $extra = '', $filesName = 'files', $labelsName = 'labels')
|
||||
public function saveAFile(object $file, string $objectType = '', int $objectID = 0, string $extra = '', string $filesName = 'files', string $labelsName = 'labels'): object|false
|
||||
{
|
||||
$fileTitle = new stdclass();
|
||||
$now = helper::today();
|
||||
$now = helper::today();
|
||||
|
||||
if($file['size'] == 0) return array();
|
||||
if($file['size'] == 0) return false;
|
||||
if(!move_uploaded_file($file['tmpname'], $this->savePath . $this->getSaveName($file['pathname']))) return false;
|
||||
|
||||
$file = $this->compressImage($file);
|
||||
@@ -183,6 +152,8 @@ class fileModel extends model
|
||||
$file['extra'] = $extra;
|
||||
unset($file['tmpname']);
|
||||
$this->dao->insert(TABLE_FILE)->data($file)->exec();
|
||||
|
||||
$fileTitle = new stdclass();
|
||||
$fileTitle->id = $this->dao->lastInsertId();
|
||||
$fileTitle->title = $file['title'];
|
||||
|
||||
@@ -208,11 +179,10 @@ class fileModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getUpload($htmlTagName = 'files', $labelsName = 'labels')
|
||||
public function getUpload(string $htmlTagName = 'files', string $labelsName = 'labels'): array
|
||||
{
|
||||
$files = array();
|
||||
if(!isset($_FILES[$htmlTagName])) return $files;
|
||||
|
||||
if(!is_array($_FILES[$htmlTagName]['error']) and $_FILES[$htmlTagName]['error'] != 0) return $files;
|
||||
|
||||
$this->app->loadClass('purifier', true);
|
||||
@@ -236,7 +206,7 @@ class fileModel extends model
|
||||
$file['title'] = $purifier->purify($file['title']);
|
||||
$file['size'] = $size[$id];
|
||||
$file['tmpname'] = $tmp_name[$id];
|
||||
$files[] = $file;
|
||||
$files[] = $file;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -470,9 +440,17 @@ class fileModel extends model
|
||||
*/
|
||||
public function setFileWebAndRealPaths(object $file): void
|
||||
{
|
||||
$pathName = $this->getRealPathName($file->pathname);
|
||||
$file->realPath = $this->savePath . $pathName;
|
||||
$file->webPath = $this->webPath . $pathName;
|
||||
if($file->objectType == 'traincourse' or $file->objectType == 'traincontents')
|
||||
{
|
||||
$file->realPath = $this->app->getWwwRoot() . 'data/course/' . $file->pathname;
|
||||
$file->webPath = $this->config->webRoot . 'data/course/' . $file->pathname;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pathName = $this->getRealPathName($file->pathname);
|
||||
$file->realPath = $this->savePath . $pathName;
|
||||
$file->webPath = $this->webPath . $pathName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -583,7 +561,7 @@ class fileModel extends model
|
||||
|
||||
if(isset($objectGroup[$objectType]))
|
||||
{
|
||||
$groupName = $objectGroup[$objectType];
|
||||
$groupName = $objectGroup[$objectType];
|
||||
$groupID = $this->dao->findByID($objectID)->from($table)->fetch($groupName);
|
||||
return $this->loadModel($groupName)->checkPriv($groupID);
|
||||
}
|
||||
|
||||
@@ -4,28 +4,26 @@ include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/file.class.php';
|
||||
su('admin');
|
||||
|
||||
$file = zdTable('file');
|
||||
$file->pathname->range('202305/0414225006610005,202305/0414225006610006,202305/0414225006610007,202305/0414225006610008,202305/0414225006610009,202305/0414225006610010,202305/0414225006610011');
|
||||
$file->gen(20);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 fileModel->getById();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试查询 fileID 1 的信息 >> 这是一个文件名称1.txt,txt,task,1,/data/upload/1/202001/0414225006610001
|
||||
测试查询 fileID 2 的信息 >> 这是一个文件名称2.doc,doc,bug,2,/data/upload/1/202002/0414225006610002
|
||||
测试查询 fileID 11 的信息 >> 这是一个文件名称11.xlsx,xlsx,traincourse,11,data/course/202002/0414225006610011.xlsx
|
||||
测试查询 fileID 24 的信息 >> 这是一个文件名称24.avi,avi,traincontents,24,data/course/202006/0414225006610024.avi
|
||||
测试查询 fileID 81 的信息 >> 这是一个文件名称81.tar,tar,story,81,/data/upload/1/202009/0414225006610081
|
||||
测试查询 fileID 101 的信息 >> 0
|
||||
|
||||
*/
|
||||
|
||||
$fileID = array(1, 2, 11, 24, 81, 101);
|
||||
$fileID = array(5, 6, 7, 8, 9, 101);
|
||||
|
||||
$file = new fileTest();
|
||||
$file->objectModel->config->webRoot = '/';
|
||||
|
||||
r($file->getByIdTest($fileID[0])) && p('title,extension,objectType,objectID,webPath') && e('这是一个文件名称1.txt,txt,task,1,/data/upload/1/202001/0414225006610001'); // 测试查询 fileID 1 的信息
|
||||
r($file->getByIdTest($fileID[1])) && p('title,extension,objectType,objectID,webPath') && e('这是一个文件名称2.doc,doc,bug,2,/data/upload/1/202002/0414225006610002'); // 测试查询 fileID 2 的信息
|
||||
r($file->getByIdTest($fileID[2])) && p('title,extension,objectType,objectID,webPath') && e('这是一个文件名称11.xlsx,xlsx,traincourse,11,data/course/202002/0414225006610011.xlsx'); // 测试查询 fileID 11 的信息
|
||||
r($file->getByIdTest($fileID[3])) && p('title,extension,objectType,objectID,webPath') && e('这是一个文件名称24.avi,avi,traincontents,24,data/course/202006/0414225006610024.avi'); // 测试查询 fileID 24 的信息
|
||||
r($file->getByIdTest($fileID[4])) && p('title,extension,objectType,objectID,webPath') && e('这是一个文件名称81.tar,tar,story,81,/data/upload/1/202009/0414225006610081'); // 测试查询 fileID 81 的信息
|
||||
r($file->getByIdTest($fileID[5])) && p('title,extension,objectType,objectID,webPath') && e('0'); // 测试查询 fileID 101 的信息
|
||||
r($file->getByIdTest($fileID[0])) && p('title,extension,objectType,objectID,webPath') && e('文件标题5,wps,traincourse,5,/data/course/202305/0414225006610009'); // 测试查询 fileID 5 的信息
|
||||
r($file->getByIdTest($fileID[1])) && p('title,extension,objectType,objectID,webPath') && e('文件标题6,wri,traincontents,6,/data/course/202305/0414225006610010'); // 测试查询 fileID 6 的信息
|
||||
r($file->getByIdTest($fileID[2])) && p('title,extension,objectType,objectID,webPath') && e('文件标题7,pdf,task,7,-data/upload/1/202305/0414225006610011'); // 测试查询 fileID 7 的信息
|
||||
r($file->getByIdTest($fileID[3])) && p('title,extension,objectType,objectID,webPath') && e('文件标题8,ppt,bug,8,-data/upload/1/202305/0414225006610005'); // 测试查询 fileID 8 的信息
|
||||
r($file->getByIdTest($fileID[4])) && p('title,extension,objectType,objectID,webPath') && e('文件标题9,pptx,story,9,-data/upload/1/202305/0414225006610006'); // 测试查询 fileID 9 的信息
|
||||
r($file->getByIdTest($fileID[5])) && p() && e('0'); // 测试查询 fileID 101 的信息
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/file.class.php';
|
||||
su('admin');
|
||||
|
||||
$file = zdTable('file');
|
||||
$file->pathname->range('202305/0414225006610005,202305/0414225006610006,202305/0414225006610007,202305/0414225006610008,202305/0414225006610009,202305/0414225006610010,202305/0414225006610011');
|
||||
$file->gen(20);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 fileModel->getByIdList();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$fileIdList = array(5, 6, 7, 8, 9, 101);
|
||||
|
||||
$file = new fileTest();
|
||||
$file->objectModel->config->webRoot = '/';
|
||||
|
||||
$fileList = $file->objectModel->getByIdList($fileIdList);
|
||||
r($fileList[5]) && p('title,extension,objectType,objectID,webPath') && e('文件标题5,wps,traincourse,5,/data/course/202305/0414225006610009'); // 测试查询 fileID 5 的信息
|
||||
r($fileList[6]) && p('title,extension,objectType,objectID,webPath') && e('文件标题6,wri,traincontents,6,/data/course/202305/0414225006610010'); // 测试查询 fileID 6 的信息
|
||||
r($fileList[7]) && p('title,extension,objectType,objectID,webPath') && e('文件标题7,pdf,task,7,-data/upload/1/202305/0414225006610011'); // 测试查询 fileID 7 的信息
|
||||
r($fileList[8]) && p('title,extension,objectType,objectID,webPath') && e('文件标题8,ppt,bug,8,-data/upload/1/202305/0414225006610005'); // 测试查询 fileID 8 的信息
|
||||
r($fileList[9]) && p('title,extension,objectType,objectID,webPath') && e('文件标题9,pptx,story,9,-data/upload/1/202305/0414225006610006'); // 测试查询 fileID 9 的信息
|
||||
r($file->objectModel->getByIdList(array())) && p() && e('0'); // 传入空的参数
|
||||
@@ -4,31 +4,28 @@ include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/file.class.php';
|
||||
su('admin');
|
||||
|
||||
$file = zdTable('file');
|
||||
$file->pathname->range('202305/0414225006610005,202305/0414225006610006,202305/0414225006610007,202305/0414225006610008,202305/0414225006610009,202305/0414225006610010,202305/0414225006610011');
|
||||
$file->gen(20);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 fileModel->getByObject();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取 traincourse id 5 的文件 >> 这是一个文件名称5.wps,wps,traincourse,5,data/course/202005/0414225006610005.wps
|
||||
获取 traincontents id 6 的文件 >> 这是一个文件名称6.wri,wri,traincontents,6,data/course/202006/0414225006610006.wri
|
||||
获取 task id 7 的文件 >> 这是一个文件名称7.pdf,pdf,task,7,/data/upload/1/202007/0414225006610007
|
||||
获取 bug id 8 的文件 >> 这是一个文件名称8.ppt,ppt,bug,8,/data/upload/1/202008/0414225006610008
|
||||
获取 story id 9 的文件 >> 这是一个文件名称9.pptx,pptx,story,9,/data/upload/1/202009/0414225006610009
|
||||
获取 testcase id 10 的文件 >> 这是一个文件名称10.xls,xls,testcase,10,/data/upload/1/202001/0414225006610010
|
||||
获取 testcase id 5 的文件 >> 0
|
||||
|
||||
*/
|
||||
$objectType = array('traincourse', 'traincontents', 'task', 'bug', 'story', 'testcase');
|
||||
$objectID = array(5, 6, 7, 8, 9, 10);
|
||||
$extra = 0;
|
||||
|
||||
$file = new fileTest();
|
||||
$file->objectModel->config->webRoot = '/';
|
||||
|
||||
r($file->getByObjectTest($objectType[0], $objectID[0])) && p('5:title,extension,objectType,objectID,webPath') && e('这是一个文件名称5.wps,wps,traincourse,5,data/course/202005/0414225006610005.wps'); // 获取 traincourse id 5 的文件
|
||||
r($file->getByObjectTest($objectType[1], $objectID[1])) && p('6:title,extension,objectType,objectID,webPath') && e('这是一个文件名称6.wri,wri,traincontents,6,data/course/202006/0414225006610006.wri'); // 获取 traincontents id 6 的文件
|
||||
r($file->getByObjectTest($objectType[2], $objectID[2])) && p('7:title,extension,objectType,objectID,webPath') && e('这是一个文件名称7.pdf,pdf,task,7,/data/upload/1/202007/0414225006610007'); // 获取 task id 7 的文件
|
||||
r($file->getByObjectTest($objectType[3], $objectID[3])) && p('8:title,extension,objectType,objectID,webPath') && e('这是一个文件名称8.ppt,ppt,bug,8,/data/upload/1/202008/0414225006610008'); // 获取 bug id 8 的文件
|
||||
r($file->getByObjectTest($objectType[4], $objectID[4])) && p('9:title,extension,objectType,objectID,webPath') && e('这是一个文件名称9.pptx,pptx,story,9,/data/upload/1/202009/0414225006610009'); // 获取 story id 9 的文件
|
||||
r($file->getByObjectTest($objectType[5], $objectID[5])) && p('10:title,extension,objectType,objectID,webPath') && e('这是一个文件名称10.xls,xls,testcase,10,/data/upload/1/202001/0414225006610010'); // 获取 testcase id 10 的文件
|
||||
r($file->getByObjectTest($objectType[5], $objectID[0])) && p() && e('0'); // 获取 testcase id 5 的文件
|
||||
r($file->getByObjectTest($objectType[0], $objectID[0])) && p('5:title,extension,objectType,objectID,webPath') && e('文件标题5,wps,traincourse,5,/data/course/202305/0414225006610009'); // 获取 traincourse id 5 的文件
|
||||
r($file->getByObjectTest($objectType[1], $objectID[1])) && p('6:title,extension,objectType,objectID,webPath') && e('文件标题6,wri,traincontents,6,/data/course/202305/0414225006610010'); // 获取 traincontents id 6 的文件
|
||||
r($file->getByObjectTest($objectType[2], $objectID[2])) && p('7:title,extension,objectType,objectID,webPath') && e('文件标题7,pdf,task,7,-data/upload/1/202305/0414225006610011'); // 获取 task id 7 的文件
|
||||
r($file->getByObjectTest($objectType[3], $objectID[3])) && p('8:title,extension,objectType,objectID,webPath') && e('文件标题8,ppt,bug,8,-data/upload/1/202305/0414225006610005'); // 获取 bug id 8 的文件
|
||||
r($file->getByObjectTest($objectType[4], $objectID[4])) && p('9:title,extension,objectType,objectID,webPath') && e('文件标题9,pptx,story,9,-data/upload/1/202305/0414225006610006'); // 获取 story id 9 的文件
|
||||
r($file->getByObjectTest($objectType[5], $objectID[5])) && p('10:title,extension,objectType,objectID,webPath') && e('文件标题10,xls,testcase,10,-data/upload/1/202305/0414225006610007'); // 获取 testcase id 10 的文件
|
||||
r($file->getByObjectTest($objectType[5], $objectID[0])) && p() && e('0'); // 获取 testcase id 5 的文件
|
||||
|
||||
Reference in New Issue
Block a user