本文整理汇总了PHP中CUtils::convertStandardPath方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtils::convertStandardPath方法的具体用法?PHP CUtils::convertStandardPath怎么用?PHP CUtils::convertStandardPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtils
的用法示例。
在下文中一共展示了CUtils::convertStandardPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invoke
/**
* move 执行入口
* @param bool $isPath - Use path to move if true ,or use id.
*/
public function invoke($isPath = true)
{
// 初始化入口
$device = new UserDevice();
$device = $device->findByUserIdAndType($this->_userId, CConst::DEVICE_WEB);
$this->_deviceId = $device["id"];
$this->_deviceName = $device["user_device_name"];
$user = User::model()->findByPk($this->_userId);
$this->_userNick = $user["user_name"];
$this->master = $this->_userId;
//
// 空间检查
//
$this->handleSpace();
if ($isPath) {
$this->fromPath = CUtils::convertStandardPath($this->fromPath);
$this->toPath = CUtils::convertStandardPath($this->toPath);
$this->initByPath();
} else {
$this->initById();
}
//
// 判断是否是共享
//
$from_share_filter = MSharesFilter::init();
$from_share_filter->handlerCheckByFile($this->_userId, $this->from);
$this->rename = false;
if ($from_share_filter->_is_shared_path && $this->toParent['id'] == 0) {
$this->rename = true;
} elseif ($from_share_filter->is_shared) {
$this->master = $from_share_filter->master;
$this->fromPath = '/' . $this->master . $from_share_filter->_path;
$this->from = UserFile::model()->findByAttributes(array('is_deleted' => 0, 'file_path' => $this->fromPath));
if (!$this->from) {
throw new ApiException("Not found");
}
}
//
// 检查移动原路径与目标路径是否一致,一致则返回成功
//
if ($this->fromPath === $this->toPath) {
$this->handleResult(false, 0, "已存在同名的文件");
return;
}
//
// 检查是否移动到其子目录下
//
if (strpos($this->toPath, $this->fromPath . "/") === 0) {
$this->result["msg"] = "不能移动到子目录";
return;
}
if ($this->toPath == "/{$this->_userId}" || $this->toPath == "/{$this->_userId}/") {
$this->result["msg"] = "目标目录不存在";
return;
}
//
// 命名检查
//
if (CUtils::checkNameInvalid($this->toPath) != 0 || CUtils::checkNameInvalid($this->toPath) != 0) {
$this->result["msg"] = "命名不能包含下列字符串: ^|?*\\<\":>";
return;
}
//
// 存在同名的则,拒绝
//
$target = UserFile::model()->findByAttributes(array("user_id" => $this->_userId, "file_path" => $this->toPath, "is_deleted" => 0));
if ($target) {
$this->handleResult(false, 0, "已存在同名的文件");
return;
}
$index = strlen("/{$this->from['user_id']}");
$fpath = substr_replace($this->fromPath, "", 0, $index);
$index = strlen("/{$this->toParent['user_id']}");
$tpath = substr_replace($this->toPath, "", 0, $index);
//
// 检查移动方式
//
if ($isPath == false && $this->rename == false && ($from_share_filter->handlerCheckMove($from_share_filter->master, $this->to_share_filter->master, $fpath, $tpath) || $this->to_share_filter->is_shared)) {
//
// 先copy再删除,如果是移动共享文件夹则只copy,再执行shareManager取消共享
//
$copy = new Copy();
$copy->_userId = $this->_userId;
$copy->toId = $this->toParent['id'];
$copy->fromId = $this->from['id'];
try {
$copy->invoke(false);
} catch (Exception $e) {
$this->result["msg"] = "操作失败";
return;
}
if ($this->from['file_type'] == 2 && $this->from['user_id'] != $this->to_share_filter->operator) {
$file_meta = FileMeta::model()->findByAttributes(array('meta_key' => 'shared_folders', 'file_path' => $this->from['file_path']));
if (!$file_meta) {
$this->result["msg"] = "操作失败";
return;
//.........这里部分代码省略.........
示例2: invoke
/**
*
* 外部调用入口
* @param bool $isParentId
*/
public function invoke($isParentId = true)
{
// TODO 应该使用path创建
$device = UserDevice::model()->find("user_id={$this->_userId} and user_device_type=1");
$this->_deviceId = $device["id"];
$this->_operator = $this->_userId;
//
// 空间检查
//
$this->handleSpace();
if ($this->_parentId == 0) {
$this->_path = "/{$this->_userId}/{$this->cname}";
} elseif ($isParentId) {
$parent = UserFile::model()->findByPk($this->_parentId);
if (empty($parent)) {
$this->handleResult(false, 3, "父目录不存在");
return;
}
if ($parent["file_type"] == 0) {
$this->handleResult(false, 3, "父目录不存在");
return;
}
$this->_path = $parent["file_path"] . "/" . $this->cname;
$this->_userId = $parent['user_id'];
} else {
$this->_path = "/{$this->_userId}/{$this->_path}";
}
//
// 命名检查
//
if (CUtils::checkNameInvalid($this->_path) != 0) {
$this->result["msg"] = "命名不能包含下列字符串: ^|?*\\<\":>";
return;
}
//
// 检查是否存在
//
$file = UserFile::model()->find(array('condition' => 'file_path=:file_path', 'params' => array(':file_path' => $this->_path)));
if ($file) {
if ($file["is_deleted"] == 0) {
$this->result["message"] = "文件夹已经存在";
return;
}
}
$this->_path = CUtils::convertStandardPath($this->_path);
//
// 共享检查
//
$index = strlen("/{$this->_userId}");
$path = substr_replace($this->_path, "", 0, $index);
if ($this->share_filter->handlerCheck($this->_userId, $path)) {
$this->_userId = $this->share_filter->master;
$this->_path = '/' . $this->_userId . $this->share_filter->_path;
}
$this->cid = $this->handleCreateByPath($this->_path);
$this->result["state"] = true;
$this->result["code"] = 0;
$this->result["message"] = "创建文件夹成功";
$this->result["cname"] = $this->cname;
$this->result['aid'] = $this->aid;
$this->result['cid'] = $this->cid;
}
示例3: invoke
/**
*
* Copy 执行入口
* @param bool $isPath Use path to move if true ,or use id.
*/
public function invoke($isPath = true)
{
// 初始化入口
$device = new UserDevice();
$device = $device->findByUserIdAndType($this->_userId, CConst::DEVICE_WEB);
$this->_deviceId = $device["id"];
$this->_deviceName = $device["user_device_name"];
$user = User::model()->findByPk($this->_userId);
$this->_userNick = $user["user_name"];
//
// 空间检查
//
$this->handleSpace();
if ($isPath) {
$this->fromPath = CUtils::convertStandardPath($this->fromPath);
$this->toPath = CUtils::convertStandardPath($this->toPath);
$this->initByPath();
} else {
$this->initById();
}
//
// 检查复制原路径与目标路径是否一致,一致则返回失败
//
if ($this->fromPath === $this->toPath) {
$this->result["data"][$this->fromId]["state"] = false;
$this->handleResult(false, 0, "已存在同名文件");
return;
}
//
// 检查是否移动到其子目录下
//
if (strpos($this->toPath, $this->fromPath . "/") === 0) {
$this->result["msg"] = "不能移动到子目录";
return;
}
if ($this->toPath == "/{$this->_userId}" || $this->toPath == "/{$this->_userId}/") {
$this->result["msg"] = "目标目录不存在";
return;
}
//
// 存在同名的则,拒绝
//
$target = UserFile::model()->findByAttributes(array("user_id" => $this->_userId, "file_path" => $this->toPath, "is_deleted" => 0));
if ($target) {
$this->handleResult(false, 0, "已存在同名的文件");
return;
}
// 文件直接进行移动
if ($this->from["file_type"] == 0) {
$this->handleCopyFile($this->fromPath, $this->toPath);
} else {
// 文件夹涉及子对象
$this->handleCopyFolder($this->fromPath, $this->toPath);
}
// 成功
$this->handleResult(true, 0, "复制成功");
$this->result["data"][$this->fromId]["state"] = true;
}