本文整理汇总了PHP中OC\Files\Filesystem::getView方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getView方法的具体用法?PHP Filesystem::getView怎么用?PHP Filesystem::getView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Filesystem
的用法示例。
在下文中一共展示了Filesystem::getView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extract
/**
* get metadata info for a media file
*
* @param $path
* @return array
*/
public function extract($path)
{
if (ini_get('allow_url_fopen')) {
$file = \OC\Files\Filesystem::getView()->getAbsolutePath($path);
$data = @$this->getID3->analyze('oc://' . $file);
} else {
// Fallback to the local FS
$file = \OC\Files\Filesystem::getLocalFile($path);
}
\getid3_lib::CopyTagsToComments($data);
return $data;
}
示例2: __construct
public function __construct($imagePath, $user = null, $square = false)
{
if (!Filesystem::isValidPath($imagePath)) {
return;
}
if (is_null($user)) {
$this->view = Filesystem::getView();
$this->user = \OCP\User::getUser();
} else {
$this->view = new View('/' . $user . '/files');
$this->user = $user;
}
$this->useOriginal = (substr($imagePath, -4) === '.svg' or substr($imagePath, -5) === '.svgz');
if ($this->useOriginal) {
$this->path = $imagePath;
} else {
$galleryDir = \OC_User::getHome($this->user) . '/gallery/' . $this->user . '/';
if (strrpos($imagePath, '.')) {
$extension = substr($imagePath, strrpos($imagePath, '.') + 1);
$image = substr($imagePath, 0, strrpos($imagePath, '.'));
} else {
$extension = '';
$image = $imagePath;
}
if ($square) {
$extension = 'square.' . $extension;
}
$this->path = $galleryDir . $image . '.' . $extension;
if (!file_exists($this->path)) {
$this->create($imagePath, $square);
}
}
}
示例3: determineIcon
public static function determineIcon($file)
{
if ($file['type'] === 'dir') {
$dir = $file['directory'];
$absPath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir . '/' . $file['name']);
$mount = \OC\Files\Filesystem::getMountManager()->find($absPath);
if (!is_null($mount)) {
$sid = $mount->getStorageId();
if (!is_null($sid)) {
$sid = explode(':', $sid);
if ($sid[0] === 'shared') {
return \OC_Helper::mimetypeIcon('dir-shared');
}
if ($sid[0] !== 'local' and $sid[0] !== 'home') {
return \OC_Helper::mimetypeIcon('dir-external');
}
}
}
return \OC_Helper::mimetypeIcon('dir');
}
if ($file['isPreviewAvailable']) {
$pathForPreview = $file['directory'] . '/' . $file['name'];
return \OC_Helper::previewIcon($pathForPreview) . '&c=' . $file['etag'];
}
return \OC_Helper::mimetypeIcon($file['mimetype']);
}
示例4: unlink
/**
* Deletes the given file by moving it into the trashbin.
*
* @param string $path
*/
public function unlink($path)
{
if (self::$disableTrash) {
return $this->storage->unlink($path);
}
$normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
$result = true;
if (!isset($this->deletedFiles[$normalized])) {
$view = Filesystem::getView();
$this->deletedFiles[$normalized] = $normalized;
if ($filesPath = $view->getRelativePath($normalized)) {
$filesPath = trim($filesPath, '/');
$result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath);
// in cross-storage cases the file will be copied
// but not deleted, so we delete it here
if ($result) {
$this->storage->unlink($path);
}
} else {
$result = $this->storage->unlink($path);
}
unset($this->deletedFiles[$normalized]);
} else {
if ($this->storage->file_exists($path)) {
$result = $this->storage->unlink($path);
}
}
return $result;
}
示例5: generateFileToken
public function generateFileToken($fileId, $version)
{
// Get the FS view of the current user.
$view = \OC\Files\Filesystem::getView();
// Get the virtual path (if the file is shared).
$path = $view->getPath($fileId);
if (!$view->is_file($path) || !$view->isUpdatable($path)) {
throw new \Exception('Invalid fileId.');
}
// Figure out the real owner, if not us.
$owner = $view->getOwner($path);
// Create a view into the owner's FS.
$view = new \OC\Files\View('/' . $owner . '/files');
// Find the real path.
$path = $view->getPath($fileId);
if (!$view->is_file($path)) {
throw new \Exception('Invalid fileId.');
}
$editor = \OC::$server->getUserSession()->getUser()->getUID();
$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(32, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER . \OCP\Security\ISecureRandom::CHAR_DIGITS);
\OC::$server->getLogger()->debug('Issuing token for {editor} file {fileId}, version {version} owned by {owner}, path {path}: {token}', ['owner' => $owner, 'editor' => $editor, 'fileId' => $fileId, 'version' => $version, 'path' => $path, 'token' => $token]);
$wopi = new \OCA\Richdocuments\Db\Wopi([$owner, $editor, $fileId, $version, $path, $token, time() + self::TOKEN_LIFETIME_SECONDS]);
if (!$wopi->insert()) {
throw new \Exception('Failed to add wopi token into database');
}
return $token;
}
示例6: getFreeSpace
/**
* @param $parentUri
* @return mixed
*/
public function getFreeSpace($parentUri)
{
if (is_null($this->fileView)) {
// initialize fileView
$this->fileView = \OC\Files\Filesystem::getView();
}
$freeSpace = $this->fileView->free_space($parentUri);
return $freeSpace;
}
示例7: getMounts
/**
* get all storages for $dir
*
* @param string $dir
* @return \OC\Files\Mount\MountPoint[]
*/
protected function getMounts($dir)
{
//TODO: move to the node based fileapi once that's done
\OC_Util::tearDownFS();
\OC_Util::setupFS($this->user);
$absolutePath = Filesystem::getView()->getAbsolutePath($dir);
$mountManager = Filesystem::getMountManager();
$mounts = $mountManager->findIn($absolutePath);
$mounts[] = $mountManager->find($absolutePath);
$mounts = array_reverse($mounts);
//start with the mount of $dir
return $mounts;
}
示例8: impl
/**
* @return Directory
*/
private function impl()
{
//
// TODO: we need to mount filesystem of the give user
//
$user = \OC::$server->getUserSession()->getUser();
if ($this->getName() !== $user->getUID()) {
return new SimpleCollection($this->getName());
}
$view = \OC\Files\Filesystem::getView();
$rootInfo = $view->getFileInfo('');
$impl = new Directory($view, $rootInfo);
return $impl;
}
示例9: unshareChildren
public static function unshareChildren($params)
{
$path = Filesystem::getView()->getAbsolutePath($params['path']);
$view = new \OC\Files\View('/');
// find share mount points within $path and unmount them
$mountManager = \OC\Files\Filesystem::getMountManager();
$mountedShares = $mountManager->findIn($path);
foreach ($mountedShares as $mount) {
if ($mount->getStorage()->instanceOfStorage('OCA\\Files_Sharing\\ISharedStorage')) {
$mountPoint = $mount->getMountPoint();
$view->unlink($mountPoint);
}
}
}
示例10: deleteHook
public static function deleteHook($arguments)
{
// save delete file info
$view = \OC\Files\Filesystem::getView();
if (!is_null($view)) {
$path = $arguments['path'];
$info = $view->getFileInfo($path);
if ($info) {
self::$deleteFileInfo[$path] = $info;
}
}
// save storage information
self::$preStorageInfo = \OC_Helper::getStorageInfo('/');
}
示例11: rename
public static function rename($args)
{
self::preDispatch();
$fileId = intval(Helper::getArrayValueByKey($args, 'file_id', 0));
$name = Helper::getArrayValueByKey($_POST, 'name');
$view = \OC\Files\Filesystem::getView();
$path = $view->getPath($fileId);
if (isset($name) && $view->is_file($path) && $view->isUpdatable($path)) {
$newPath = dirname($path) . '/' . $name;
if ($view->rename($path, $newPath)) {
\OCP\JSON::success();
return;
}
}
\OCP\JSON::error(array('message' => Config::getL10n()->t('You don\'t have permission to rename this document')));
}
示例12: __construct
public function __construct($imagePath, $user = null, $square = false)
{
if (!Filesystem::isValidPath($imagePath)) {
return;
}
if (is_null($user)) {
$this->view = Filesystem::getView();
$this->user = \OCP\USER::getUser();
} else {
$this->view = new View('/' . $user . '/files');
$this->user = $user;
}
$galleryDir = \OC_User::getHome($this->user) . '/gallery/' . $this->user . '/';
$this->path = $galleryDir . $imagePath . '.png';
if (!file_exists($this->path)) {
self::create($imagePath, $square);
}
}
示例13: __construct
/**
* @param array $barriers of given quota barriers which are to be used to fire a quota change
*/
public function __construct($barriers = null, $view = null)
{
if (is_null($barriers)) {
$barriers = \OC_Config::getValue('webhook_barriers', array());
}
if (!is_array($barriers)) {
\OC_Log::write('webhooks', "Invalid barriers given: {$barriers}", \OC_Log::ERROR);
$barriers = array();
}
sort($barriers);
$this->barriers = $barriers;
$this->notifications = new Notifications();
$this->subscriptions = new Subscriptions();
if (is_null($view)) {
$view = \OC\Files\Filesystem::getView();
}
$this->view = $view;
}
示例14: av_scan
public static function av_scan($path)
{
$path = $path[\OC\Files\Filesystem::signal_param_path];
if ($path != '') {
if (isset($_POST['dirToken'])) {
//Public upload case
$filesView = \OC\Files\Filesystem::getView();
} else {
$filesView = \OCP\Files::getStorage("files");
}
if (!is_object($filesView)) {
\OCP\Util::writeLog('files_antivirus', 'Can\'t init filesystem view', \OCP\Util::WARN);
return;
}
// check if path is a directory
if ($filesView->is_dir($path)) {
return;
}
// we should have a file to work with, and the file shouldn't
// be empty
$fileExists = $filesView->file_exists($path);
if ($fileExists && $filesView->filesize($path) > 0) {
$fileStatus = self::scanFile($filesView, $path);
$result = $fileStatus->getNumericStatus();
switch ($result) {
case Status::SCANRESULT_UNCHECKED:
//TODO: Show warning to the user: The file can not be checked
break;
case Status::SCANRESULT_INFECTED:
//remove file
$filesView->unlink($path);
Notification::sendMail($path);
$message = \OCP\Util::getL10N('files_antivirus')->t("Virus detected! Can't upload the file %s", array(basename($path)));
\OCP\JSON::error(array("data" => array("message" => $message)));
exit;
break;
case Status::SCANRESULT_CLEAN:
//do nothing
break;
}
}
}
}
示例15: joinAsUser
/**
* @NoAdminRequired
*/
public function joinAsUser($fileId)
{
try {
$view = \OC\Files\Filesystem::getView();
$path = $view->getPath($fileId);
if ($view->isUpdatable($path)) {
$file = new File($fileId);
$response = Db\Session::start($this->uid, $file);
} else {
$info = $view->getFileInfo($path);
$response = array('permissions' => $info['permissions'], 'id' => $fileId);
}
$response = array_merge($response, array('status' => 'success'));
} catch (\Exception $e) {
$this->logger->warning('Starting a session failed. Reason: ' . $e->getMessage(), array('app' => $this->appName));
$response = array('status' => 'error');
}
return $response;
}