当前位置: 首页>>代码示例>>PHP>>正文


PHP CUtils::pathinfo_utf方法代码示例

本文整理汇总了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;
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:54,代码来源:EventBiz.php

示例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"];
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:57,代码来源:CreateFolder.php

示例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;
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:53,代码来源:UserFile.php

示例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];
开发者ID:youngsun45,项目名称:miniyun,代码行数:67,代码来源:MMoveController.php

示例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;
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:18,代码来源:MFilesystem.php

示例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);
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:36,代码来源:Move.php

示例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;
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:27,代码来源:MSharesFilter.php

示例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);
     }
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:62,代码来源:Copy.php


注:本文中的CUtils::pathinfo_utf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。