本文整理匯總了PHP中CUtils::pathinfo_utf方法的典型用法代碼示例。如果您正苦於以下問題:PHP CUtils::pathinfo_utf方法的具體用法?PHP CUtils::pathinfo_utf怎麽用?PHP CUtils::pathinfo_utf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CUtils
的用法示例。
在下文中一共展示了CUtils::pathinfo_utf方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getList
/**
* 獲取events數據
*/
public function getList($path, $time, $deviceUuid, $pageSize, $currentPage)
{
$user = $this->user;
$userId = $user['id'];
$time = $this->getTime($time);
if ($path != "") {
$path = MiniUtil::joinPath($path);
}
$total = MiniEvent::getInstance()->getTotal($path, $time, $userId, $deviceUuid);
$totalPage = ceil($total / $pageSize);
$events = MiniEvent::getInstance()->getByCondition($path, $userId, $time, $deviceUuid, $pageSize, ($currentPage - 1) * $pageSize);
$itemList = array();
$data = array();
foreach ($events as $event) {
$item = array();
$device = MiniUserDevice::getInstance()->getUserDevice($event['user_device_id']);
$item['create_user_id'] = $device['user_id'];
$item['file_path'] = MiniUtil::getRelativePath($event['file_path']);
$item['action'] = $event['action'];
$item['user_name'] = $user['user_name'];
$item['user_device_type'] = $device['user_device_type'];
if ($device['user_id'] == $userId) {
$item['user_self'] = true;
} else {
$item['user_self'] = false;
$user = MiniUser::getInstance()->getById($device['user_id']);
$userMetas = MiniUserMeta::getInstance()->getUserMetas($device['user_id']);
if (isset($userMetas['nick'])) {
$item['user_name'] = $userMetas['nick'];
} else {
$item['user_name'] = $user['user_name'];
}
}
$item['created_at'] = MiniUtil::formatTime(strtotime($event['created_at']));
$item['user_device_name'] = $device['user_device_name'];
$item['context'] = MiniUtil::getRelativePath($event['context']);
$item['device_uuid'] = $device['user_device_uuid'];
if ($event['action'] == 2) {
//判斷是否是重命名還是創建
$fromParent = CUtils::pathinfo_utf($event['file_path']);
$toParent = CUtils::pathinfo_utf($event['context']);
if ($fromParent['dirname'] == $toParent['dirname']) {
$item['action'] = MConst::RENAME;
}
}
$itemList[] = $item;
}
$data['events'] = $itemList;
$data['totalPage'] = $totalPage;
return $data;
}
示例2: handleCreateByPath
/**
*
* 根據路徑創建目錄
*/
public function handleCreateByPath($path)
{
if ($path == "/{$this->_userId}" || $path == "\\" || $path == "/{$this->_userId}/") {
return 0;
}
$event_uuid = MiniUtil::getEventRandomString(46);
$file = UserFile::model()->find(array('condition' => 'file_path=:file_path', 'params' => array(':file_path' => $path)));
if (empty($file) || is_null($file)) {
$pathInfo = CUtils::pathinfo_utf($path);
$parenPath = $pathInfo["dirname"];
$fileName = $pathInfo["basename"];
$parentId = $this->handleCreateByPath($parenPath);
$file = new UserFile();
$file['user_id'] = $this->_userId;
$file['file_type'] = 1;
$file['parent_file_id'] = $parentId;
$file['file_create_time'] = time();
$file['file_update_time'] = time();
$file['file_name'] = $fileName;
$file['file_path'] = $path;
$file['is_deleted'] = 0;
$file['version_id'] = 0;
$file['file_size'] = 0;
$file["event_uuid"] = $event_uuid;
$file->save();
$file['sort'] = $file['id'];
$file->save();
// 創建事件
MiniEvent::getInstance()->createEvent($this->_userId, $this->_deviceId, $this->_action, $path, $path, $event_uuid, $this->share_filter->type);
$this->share_filter->handlerAction($this->_action, $this->_deviceId, $path, $path);
} else {
//
// 回收站插件: -1保留值 0正常 1刪除
// 這裏由is_deleted==1 特別修改為 is_deleted!=0
// By Kindac 2012/11/5
//
if ($file["is_deleted"] != 0) {
$file["is_deleted"] = 0;
$file["file_update_time"] = time();
$file["event_uuid"] = $event_uuid;
//
// 遞歸創建父目錄
//
$pathInfo = CUtils::pathinfo_utf($path);
$parenPath = $pathInfo["dirname"];
$this->handleCreateByPath($parenPath);
$file->save();
MiniEvent::getInstance()->createEvent($this->_userId, $this->_deviceId, $this->_action, $path, $path, $event_uuid, $this->share_filter->type);
$this->share_filter->handlerAction($this->_action, $this->_deviceId, $path, $path);
}
}
return $file["id"];
}
示例3: revertFile
/**
* 還原回收站文件
*/
public function revertFile($fileIds)
{
if ($fileIds === '' && strlen($fileIds) <= 0) {
return 0;
}
$models = $this->findAll("id in(" . $fileIds . ")");
$device_id = Yii::app()->session["deviceId"];
foreach ($models as $model) {
$share_filter = MSharesFilter::init();
$user_id = $model['user_id'];
$path = $model['file_path'];
$context = $path;
$share_filter->handlerCheckByFile($user_id, $model);
// 確保父目錄被還原
$createFolder = new CreateFolder();
$createFolder->_deviceId = $device_id;
$createFolder->_userId = $user_id;
$createFolder->share_filter = $share_filter;
$pathInfo = CUtils::pathinfo_utf($path);
try {
$parentId = $createFolder->handleCreateByPath($pathInfo["dirname"]);
} catch (ApiException $e) {
Yii::log($e->getMessage());
continue;
}
$event_uuid = MiniUtil::getEventRandomString(46);
$action = 0;
// 創建文件夾
if ($model['file_type'] == 0) {
//
// 如果是文件,需要創建版本
//
$user = Yii::app()->session['user'];
$device = UserDevice::model()->findByUserIdAndType($user['id'], CConst::DEVICE_WEB);
$deviceName = $device["user_device_name"];
$this->_saveFileMeta($path, $model['version_id'], $user['id'], $user['name'], CConst::WEB_RESTORE, $deviceName, $model['file_size']);
$action = CConst::CREATE_FILE;
$version = FileVersion::model()->findByPk((int) $model['version_id']);
$context = array("hash" => $version['file_signature'], "rev" => (int) $model["version_id"], "bytes" => (int) $model["file_size"]);
$context = serialize($context);
}
MiniEvent::getInstance()->createEvent($user_id, $device_id, $action, $path, $context, $event_uuid, $share_filter->type);
$model['event_uuid'] = $event_uuid;
$model['file_update_time'] = time();
$model["is_deleted"] = 0;
$model->save();
$share_filter->handlerAction($action, $device_id, $path, unserialize($context));
}
return TRUE;
}
示例4: invoke
//.........這裏部分代碼省略.........
$this->rename = false;
// 檢查移動方式
if ($this->rename == true) {
// 先copy再刪除,如果是移動共享文件夾則隻copy,再執行shareManager取消共享
$copy_handler = new MCopyController();
$copy_handler->isOutput = false;
$response = $copy_handler->invoke();
$_REQUEST['path'] = $params["from_path"];
$delete_handler = new MDeleteController();
$delete_handler->isOutput = false;
$delete_handler->completely_remove = true;
$delete_handler->invoke();
if (MUserManager::getInstance()->isWeb() === true) {
$this->buildWebResponse();
exit;
return;
}
echo json_encode($response);
return;
}
$file_name = MUtils::get_basename($to_path);
// 檢查文件名是否有效
$is_invalid = MUtils::checkNameInvalid($file_name);
if ($is_invalid) {
throw new MFileopsException(Yii::t('api', 'The file or folder name is invalid'), MConst::HTTP_CODE_400);
}
// 檢查是否移動到其子目錄下
if (strpos($to_path, $from_path . "/") === 0) {
throw new MFileopsException(Yii::t('api', 'Can not be moved to the subdirectory'), MConst::HTTP_CODE_403);
}
if ($to_path == "/{$this->_userId}" || $to_path == "/{$this->_userId}/") {
throw new MFileopsException(Yii::t('api', 'Can not be moved to the error directory'), MConst::HTTP_CODE_403);
}
$from_parent = CUtils::pathinfo_utf($from_path);
$to_parent = CUtils::pathinfo_utf($to_path);
$privilegeModel = new PrivilegeBiz();
if (!(count($to_parts) == 3)) {
$isSharedPath = false;
$toPathArr = explode('/', $to_path);
$masterId = $toPathArr[1];
if ($masterId != $this->_userId) {
$isSharedPath = true;
} else {
$model = new GeneralFolderPermissionBiz($to_parent['dirname']);
if ($model->isParentShared($to_parent['dirname'])) {
//如果是父目錄被共享
$isSharedPath = true;
}
}
if ($isSharedPath) {
$toPrivilege = UserPermissionBiz::getInstance()->getPermission($to_parent['dirname'], $this->_userId);
if (empty($toPrivilege)) {
$toPrivilege['permission'] = MConst::SUPREME_PERMISSION;
} else {
$this->to_share_filter->slaves = $privilegeModel->getSlaveIdsByPath($toPrivilege['share_root_path']);
$this->to_share_filter->is_shared = true;
}
} else {
$toPrivilege['permission'] = MConst::SUPREME_PERMISSION;
}
$toFilter = new MiniPermission($toPrivilege['permission']);
} else {
if ($to_parent['dirname'] == $from_parent['dirname']) {
$isSharedPath = false;
$fromPathArr = explode('/', $from_path);
$masterId = $fromPathArr[1];
示例5: get_local_path
/**
*
* 獲取一個本地的文件地址,如果是遠程文件則先進行下載
* @param unknown_type $path
*/
function get_local_path($path)
{
$direct = new MFilesystemDirect();
if ($this->isExistLocal()) {
return $direct->localPath($path);
}
$from = $this->documentStorePath($path) . $path;
$pathArray = CUtils::pathinfo_utf($path);
$to = DOCUMENT_TEMP . $pathArray["filename"];
$direct->touch($to);
$this->getFileSystemObject()->get($from, $to, $resumepos = 0);
return $to;
}
示例6: handleMoveFile
/**
*
* 移動文件
* @param string $fromPath
* @param string $toPath
*/
private function handleMoveFile($fromPath, $toPath)
{
$createFolder = new CreateFolder();
$createFolder->_deviceId = $this->to_share_filter->master;
$createFolder->_userId = $this->_userId;
$pathInfo = CUtils::pathinfo_utf($this->toPath);
$parentId = $createFolder->handleCreateByPath($pathInfo["dirname"]);
// 重命名
$name = $this->handleRename($parentId, $pathInfo["basename"]);
$this->toPath = $pathInfo["dirname"] . "/" . $name;
//
// 如果是存在同名的已經刪除的記錄,則刪除之
//
$deleted = UserFile::model()->findByAttributes(array("user_id" => $this->_userId, "file_path" => $this->toPath, "is_deleted" => 1));
if ($deleted) {
$deleted->delete();
}
// 修改屬性後 保存
$this->from["file_path"] = $this->toPath;
$this->from["file_name"] = $name;
$this->from["event_uuid"] = MiniUtil::getEventRandomString(46);
$this->from["parent_file_id"] = $parentId;
$this->from["user_id"] = $this->to_share_filter->master;
$this->from->save();
// 更新meta
$this->handleFileMeta($this->toPath, $this->from["version_id"], $this->_userId, $this->_userNick, CConst::CREATE_FILE, $this->_deviceName, $this->from['file_size']);
// 創建事件
MiniEvent::getInstance()->createEvent($this->_userId, $this->_deviceId, $this->_action, $this->fromPath, $this->toPath, $this->from["event_uuid"]);
$this->to_share_filter->handlerAction($this->_action, $this->_deviceId, $this->fromPath, $this->toPath);
}
示例7: handlerCheckMove
/**
* 檢查是否在同一個共享目錄下移動
* @param integer $from_master
* @param integer $to_master
* @param string $from_path
* @param string $to_path
* @return boolean
*/
public function handlerCheckMove($from_master, $to_master, $from_path, $to_path, $to_is_shared = FALSE)
{
if ($this->is_shared == false && $to_is_shared == false) {
return false;
}
//
// 在共享目錄內部拷貝
//
$to = '/' . $to_master . $to_path;
if (!empty($this->_shared_path) && strpos($to, $this->_shared_path . '/') === 0) {
return false;
}
$from_parent = CUtils::pathinfo_utf($from_path);
$to_parent = CUtils::pathinfo_utf($to_path);
if ($from_master == $to_master && $to_parent['dirname'] == $from_parent['dirname']) {
return false;
}
return true;
}
示例8: handleCopyFolder
/**
*
* 複製文件夾
* @param string $fromPath
* @param string $toPath
*/
public function handleCopyFolder($fromPath, $toPath)
{
$createFolder = new CreateFolder();
$createFolder->_deviceId = $this->_deviceId;
$createFolder->_userId = $this->_userId;
$createFolder->share_filter = $this->to_share_filter;
$pathInfo = CUtils::pathinfo_utf($toPath);
$parentId = $createFolder->handleCreateByPath($pathInfo["dirname"]);
// 重命名
$name = $this->handleRename($parentId, $pathInfo["basename"]);
$this->toPath = $pathInfo["dirname"] . "/" . $name;
//
// 如果是存在同名的已經刪除的記錄,則還原之
//
$target = UserFile::model()->findByAttributes(array("user_id" => $this->_userId, "file_path" => $toPath, "is_deleted" => 1));
if (!$target) {
$target = new UserFile();
$target["user_id"] = $this->_userId;
$target["parent_file_id"] = $parentId;
$target["file_create_time"] = time();
}
$target["file_type"] = 1;
$target["is_deleted"] = 0;
$target["version_id"] = $this->from["version_id"];
$target["file_size"] = $this->from["file_size"];
$target["file_path"] = $toPath;
$target["file_name"] = $name;
$target["file_update_time"] = time();
$target["event_uuid"] = MiniUtil::getEventRandomString(46);
$target->save();
// 創建事件
MiniEvent::getInstance()->createEvent($this->_userId, $this->_deviceId, 0, $toPath, $toPath, $target["event_uuid"]);
$this->to_share_filter->handlerAction(0, $this->_deviceId, $toPath, $toPath);
// copy 所有的文件,創建文件的時候會將父目錄創建
$handler = new UserFile();
$children = $handler->getChildrenFileByPath($fromPath);
foreach ($children as $child) {
$this->from = $child;
$childFromPath = $child["file_path"];
$index = strlen($this->fromPath);
$childtoPath = substr_replace($childFromPath, $this->toPath, 0, $index);
$this->handleCopyFile($childFromPath, $childtoPath);
}
// copy 所有的文件夾,補償沒有子文件的 路徑
$folders = $handler->getChildrenFileByPath($fromPath, 1);
$createFolder = new CreateFolder();
$createFolder->_deviceId = $this->_deviceId;
$createFolder->_userId = $this->_userId;
$createFolder->share_filter = $this->to_share_filter;
foreach ($folders as $folder) {
$childFromPath = $folder["file_path"];
$index = strlen($this->fromPath);
$childtoPath = substr_replace($childFromPath, $this->toPath, 0, $index);
$parentId = $createFolder->handleCreateByPath($childtoPath);
}
}