本文整理匯總了PHP中OC\Files\View::getPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::getPath方法的具體用法?PHP View::getPath怎麽用?PHP View::getPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OC\Files\View
的用法示例。
在下文中一共展示了View::getPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: assertEtagsNotChanged
/**
* @param string[] $users
* @param string $subPath
*/
protected function assertEtagsNotChanged($users, $subPath = '')
{
$oldUser = \OC::$server->getUserSession()->getUser();
foreach ($users as $user) {
$this->loginAsUser($user);
$id = $this->fileIds[$user][$subPath];
$path = $this->rootView->getPath($id);
$etag = $this->rootView->getFileInfo($path)->getEtag();
$this->assertEquals($this->fileEtags[$id], $etag, 'Failed asserting that the etag for "' . $subPath . '" of user ' . $user . ' has not changed');
$this->fileEtags[$id] = $etag;
}
$this->loginAsUser($oldUser->getUID());
}
示例2: isLocal
public function isLocal()
{
$this->init();
$ownerPath = $this->ownerView->getPath($this->share['item_source']);
list($targetStorage) = $this->ownerView->resolvePath($ownerPath);
return $targetStorage->isLocal();
}
示例3: shareNotificationForOriginalOwners
/**
* Add notifications for the owners whose files have been reshared
*
* @param string $currentOwner
* @param string $subject
* @param string $shareWith
* @param int $fileSource
* @param string $itemType
*/
protected function shareNotificationForOriginalOwners($currentOwner, $subject, $shareWith, $fileSource, $itemType)
{
// Get the full path of the current user
$this->view->chroot('/' . $currentOwner . '/files');
try {
$path = $this->view->getPath($fileSource);
} catch (NotFoundException $e) {
return;
}
/**
* Get the original owner and his path
*/
$owner = $this->view->getOwner($path);
if ($owner !== $currentOwner) {
$this->reshareNotificationForSharer($owner, $subject, $shareWith, $fileSource, $itemType);
}
/**
* Get the sharee who shared the item with the currentUser
*/
$this->view->chroot('/' . $currentOwner . '/files');
$mount = $this->view->getMount($path);
if (!$mount instanceof IMountPoint) {
return;
}
$storage = $mount->getStorage();
if (!$storage->instanceOfStorage('OC\\Files\\Storage\\Shared')) {
return;
}
/** @var \OC\Files\Storage\Shared $storage */
$shareOwner = $storage->getSharedFrom();
if ($shareOwner === '' || $shareOwner === null || $shareOwner === $owner || $shareOwner === $currentOwner) {
return;
}
$this->reshareNotificationForSharer($shareOwner, $subject, $shareWith, $fileSource, $itemType);
}
示例4: findInfoById
/**
* @param string $user
* @param int $fileId
* @param string $filePath
* @return array
*/
protected function findInfoById($user, $fileId, $filePath)
{
$this->view->chroot('/' . $user . '/files');
$cache = ['path' => $filePath, 'exists' => false, 'is_dir' => false, 'view' => ''];
$notFound = false;
try {
$path = $this->view->getPath($fileId);
$cache['path'] = $path;
$cache['is_dir'] = $this->view->is_dir($path);
$cache['exists'] = true;
} catch (NotFoundException $e) {
// The file was not found in the normal view, maybe it is in
// the trashbin?
$this->view->chroot('/' . $user . '/files_trashbin');
try {
$path = $this->view->getPath($fileId);
$cache = ['path' => substr($path, strlen('/files')), 'exists' => true, 'is_dir' => $this->view->is_dir($path), 'view' => 'trashbin'];
} catch (NotFoundException $e) {
$notFound = true;
}
}
$this->cacheId[$user][$fileId] = $cache;
if ($notFound) {
$this->cacheId[$user][$fileId]['path'] = null;
}
return $cache;
}
示例5: getUidAndFilename
public static function getUidAndFilename($filename)
{
$uid = \OC\Files\Filesystem::getOwner($filename);
\OC\Files\Filesystem::initMountPoints($uid);
if ($uid != \OCP\User::getUser()) {
$info = \OC\Files\Filesystem::getFileInfo($filename);
$ownerView = new \OC\Files\View('/' . $uid . '/files');
$filename = $ownerView->getPath($info['fileid']);
}
return array($uid, $filename);
}
示例6: releaseLock
/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
*/
public function releaseLock($path, $type, ILockingProvider $provider)
{
/** @var \OCP\Files\Storage $targetStorage */
list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
$targetStorage->releaseLock($targetInternalPath, $type, $provider);
// unlock the parent folders of the owner when unlocking the share as recipient
if ($path === '') {
$sourcePath = $this->ownerView->getPath($this->share['file_source']);
$this->ownerView->unlockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
}
}
示例7: propagateForOwner
/**
* @param array $share
* @param string $internalPath
* @param \OC\Files\Cache\ChangePropagator $propagator
*/
private function propagateForOwner($share, $internalPath, ChangePropagator $propagator)
{
// note that we have already set up the filesystem for the owner when mounting the share
$view = new View('/' . $share['uid_owner'] . '/files');
$shareRootPath = $view->getPath($share['item_source']);
if (!is_null($shareRootPath)) {
$path = $shareRootPath . '/' . $internalPath;
$path = Filesystem::normalizePath($path);
$propagator->addChange($path);
$propagator->propagateChanges();
}
}
示例8: getUidAndFilename
/**
* @param string $filename
* @return array
* @throws \OC\User\NoUserException
*/
public static function getUidAndFilename($filename)
{
$uid = \OC\Files\Filesystem::getOwner($filename);
\OC\Files\Filesystem::initMountPoints($uid);
if ($uid != \OCP\User::getUser()) {
$info = \OC\Files\Filesystem::getFileInfo($filename);
$ownerView = new \OC\Files\View('/' . $uid . '/files');
try {
$filename = $ownerView->getPath($info['fileid']);
} catch (NotFoundException $e) {
$filename = null;
}
}
return [$uid, $filename];
}
示例9: update
/**
* update keyfiles and share keys recursively
*
* @param int $fileSource file source id
*/
private function update($fileSource)
{
$path = \OC\Files\Filesystem::getPath($fileSource);
$info = \OC\Files\Filesystem::getFileInfo($path);
$owner = \OC\Files\Filesystem::getOwner($path);
$view = new \OC\Files\View('/' . $owner . '/files');
$ownerPath = $view->getPath($info->getId());
$absPath = '/' . $owner . '/files' . $ownerPath;
$mount = $this->mountManager->find($path);
$mountPoint = $mount->getMountPoint();
// if a folder was shared, get a list of all (sub-)folders
if ($this->view->is_dir($absPath)) {
$allFiles = $this->util->getAllFiles($absPath, $mountPoint);
} else {
$allFiles = array($absPath);
}
$encryptionModule = $this->encryptionManager->getDefaultEncryptionModule();
foreach ($allFiles as $path) {
$usersSharing = $this->file->getAccessList($path);
$encryptionModule->update($path, $this->uid, $usersSharing);
}
}
示例10: getPreview
/**
* @param string $owner
* @param int $fileId
* @param string $filePath
* @return array
*/
protected function getPreview($owner, $fileId, $filePath)
{
$this->view->chroot('/' . $owner . '/files');
$path = $this->view->getPath($fileId);
if ($path === null || $path === '' || !$this->view->file_exists($path)) {
return $this->getPreviewFromPath($filePath);
}
$is_dir = $this->view->is_dir($path);
$preview = ['link' => $this->getPreviewLink($path, $is_dir), 'source' => '', 'isMimeTypeIcon' => true];
// show a preview image if the file still exists
if ($is_dir) {
$preview['source'] = $this->getPreviewPathFromMimeType('dir');
} else {
$fileInfo = $this->view->getFileInfo($path);
if ($this->preview->isAvailable($fileInfo)) {
$preview['isMimeTypeIcon'] = false;
$preview['source'] = $this->urlGenerator->linkToRoute('core_ajax_preview', ['file' => $path, 'c' => $this->view->getETag($path), 'x' => 150, 'y' => 150]);
} else {
$preview['source'] = $this->getPreviewPathFromMimeType($fileInfo->getMimetype());
}
}
return $preview;
}
示例11: getUidAndFilename
/**
* @param string $filename
* @return array
* @throws \OC\User\NoUserException
* @throws NotFoundException
*/
public function getUidAndFilename($filename)
{
$info = $this->getFileInfo($filename);
if (!$info instanceof \OCP\Files\FileInfo) {
throw new NotFoundException($this->getAbsolutePath($filename) . ' not found');
}
$uid = $info->getOwner()->getUID();
if ($uid != \OCP\User::getUser()) {
Filesystem::initMountPoints($uid);
$ownerView = new View('/' . $uid . '/files');
try {
$filename = $ownerView->getPath($info['fileid']);
} catch (NotFoundException $e) {
throw new NotFoundException('File with id ' . $info['fileid'] . ' not found for user ' . $uid);
}
}
return [$uid, $filename];
}
示例12: propagateById
public function propagateById($id)
{
if (isset($this->propagatingIds[$id])) {
return;
}
$this->propagatingIds[$id] = true;
$shares = Share::getAllSharesForFileId($id);
foreach ($shares as $share) {
// propagate down the share tree
$this->markDirty($share, microtime(true));
// propagate up the share tree
if ($this->isRecipientOfShare($share)) {
$user = $share['uid_owner'];
$view = new View('/' . $user . '/files');
$path = $view->getPath($share['file_source']);
$watcher = new ChangeWatcher($view, $this->manager->getSharePropagator($user));
$watcher->writeHook(['path' => $path]);
}
}
unset($this->propagatingIds[$id]);
}
示例13: getPath
/**
* Get the path of a file by id
*
* Note that the resulting path is not guaranteed to be unique for the id, multiple paths can point to the same file
*
* @param int $id
* @throws NotFoundException
* @return string
*/
public static function getPath($id)
{
return self::$defaultInstance->getPath($id);
}
示例14: getOwnerViewAndPath
/**
*
* @return string owner of the current file item
* @throws \Exception
*/
public function getOwnerViewAndPath($useDefaultRoot = false)
{
if ($this->isPublicShare()) {
if (isset($this->sharing['uid_owner'])) {
$owner = $this->sharing['uid_owner'];
if (!\OC::$server->getUserManager()->userExists($this->sharing['uid_owner'])) {
throw new \Exception('Share owner' . $this->sharing['uid_owner'] . ' does not exist ');
}
\OC_Util::tearDownFS();
\OC_Util::setupFS($this->sharing['uid_owner']);
} else {
throw new \Exception($this->fileId . ' is a broken share');
}
$view = new View('/' . $owner . '/files');
} else {
$owner = \OC::$server->getUserSession()->getUser()->getUID();
$root = '/' . $owner;
if ($useDefaultRoot) {
$root .= '/' . 'files';
}
$view = new View($root);
}
$path = $view->getPath($this->fileId);
if (!$path) {
throw new \Exception($this->fileId . ' can not be resolved');
}
$this->path = $path;
$this->owner = $owner;
if (!$view->file_exists($this->path)) {
throw new \Exception($this->path . ' doesn\'t exist');
}
return array($view, $this->path);
}
示例15: getOwnerPath
/**
* get owner and path relative to data/<owner>/files
*
* @param string $path path to file for current user
* @return array ['owner' => $owner, 'path' => $path]
* @throw \InvalidArgumentException
*/
protected function getOwnerPath($path)
{
$info = Filesystem::getFileInfo($path);
$owner = Filesystem::getOwner($path);
$view = new View('/' . $owner . '/files');
$path = $view->getPath($info->getId());
if ($path === null) {
throw new \InvalidArgumentException('No file found for ' . $info->getId());
}
return array($owner, $path);
}