本文整理汇总了PHP中OC\Files\View类的典型用法代码示例。如果您正苦于以下问题:PHP View类的具体用法?PHP View怎么用?PHP View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了View类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
//clear all proxies and hooks so we can do clean testing
\OC_Hook::clear('OC_Filesystem');
//set up temporary storage
$this->storage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::clearMounts();
$storage = new \OC\Files\Storage\Temporary(array());
\OC\Files\Filesystem::mount($storage, array(), '/');
$datadir = str_replace('local::', '', $storage->getId());
$config = \OC::$server->getConfig();
$this->datadir = $config->getSystemValue('cachedirectory', \OC::$SERVERROOT . '/data/cache');
$config->setSystemValue('cachedirectory', $datadir);
\OC_User::clearBackends();
\OC_User::useBackend(new \Test\Util\User\Dummy());
//login
\OC_User::createUser('test', 'test');
$this->user = \OC_User::getUser();
\OC_User::setUserId('test');
//set up the users dir
$this->rootView = new \OC\Files\View('');
$this->rootView->mkdir('/test');
$this->instance = new \OC\Cache\File();
// forces creation of cache folder for subsequent tests
$this->instance->set('hack', 'hack');
}
开发者ID:Commenter123,项目名称:core,代码行数:27,代码来源:file.php
示例2: getAllVersions
/**
* Gets all versions of a note
*
* @NoAdminRequired
* @NoCSRFRequired
* @CORS
*
* @return array
*/
public function getAllVersions()
{
$source = $this->request->getParam("file_name", "");
list($uid, $filename) = Storage::getUidAndFilename($source);
$versions = Storage::getVersions($uid, $filename, $source);
$versionsResults = array();
if (is_array($versions) && count($versions) > 0) {
require_once __DIR__ . '/../3rdparty/finediff/finediff.php';
$users_view = new View('/' . $uid);
$currentData = $users_view->file_get_contents('files/' . $filename);
// $previousData = $currentData;
// $versions = array_reverse( $versions, true );
foreach ($versions as $versionData) {
// get timestamp of version
$mtime = (int) $versionData["version"];
// get filename of note version
$versionFileName = 'files_versions/' . $filename . '.v' . $mtime;
// load the data from the file
$data = $users_view->file_get_contents($versionFileName);
// calculate diff between versions
$opcodes = \FineDiff::getDiffOpcodes($currentData, $data);
$html = \FineDiff::renderDiffToHTMLFromOpcodes($currentData, $opcodes);
$versionsResults[] = array("timestamp" => $mtime, "humanReadableTimestamp" => $versionData["humanReadableTimestamp"], "diffHtml" => $html, "data" => $data);
// $previousData = $data;
}
// $versionsResults = array_reverse( $versionsResults );
}
return array("file_name" => $source, "versions" => $versionsResults);
}
开发者ID:pbek,项目名称:qownnotesapi,代码行数:38,代码来源:noteapicontroller.php
示例3: getMaximumStorageUsage
/**
* @param string $userName
* @return integer
*/
public function getMaximumStorageUsage($userName)
{
$view = new FilesView('/' . $userName . '/files');
$freeSpace = (int) $view->free_space();
$usedSpace = $view->getFileInfo('/')->getSize();
return $freeSpace + $usedSpace;
}
开发者ID:xn--nding-jua,项目名称:ocusagecharts,代码行数:11,代码来源:storage.php
示例4: setUp
protected function setUp()
{
$app = new Application();
$this->container = $app->getContainer();
$this->container['Config'] = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
$this->container['AppName'] = 'files_sharing';
$this->container['UserSession'] = $this->getMockBuilder('\\OC\\User\\Session')->disableOriginalConstructor()->getMock();
$this->container['URLGenerator'] = $this->getMockBuilder('\\OC\\URLGenerator')->disableOriginalConstructor()->getMock();
$this->urlGenerator = $this->container['URLGenerator'];
$this->shareController = $this->container['ShareController'];
// Store current user
$this->oldUser = \OC_User::getUser();
// Create a dummy user
$this->user = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(12, ISecureRandom::CHAR_LOWER);
\OC_User::createUser($this->user, $this->user);
\OC_Util::tearDownFS();
\OC_User::setUserId('');
Filesystem::tearDown();
\OC_User::setUserId($this->user);
\OC_Util::setupFS($this->user);
// Create a dummy shared file
$view = new View('/' . $this->user . '/files');
$view->file_put_contents('file1.txt', 'I am such an awesome shared file!');
$this->token = \OCP\Share::shareItem(Filesystem::getFileInfo('file1.txt')->getType(), Filesystem::getFileInfo('file1.txt')->getId(), \OCP\Share::SHARE_TYPE_LINK, 'IAmPasswordProtected!', 1);
}
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:25,代码来源:sharecontroller.php
示例5: show
/**
* Get the template for a specific activity-event in the activities
*
* @param array $activity An array with all the activity data in it
* @return string
*/
public static function show($activity)
{
$tmpl = new Template('activity', 'activity.box');
$tmpl->assign('formattedDate', Util::formatDate($activity['timestamp']));
$tmpl->assign('formattedTimestamp', \OCP\relative_modified_date($activity['timestamp']));
$tmpl->assign('user', $activity['user']);
$tmpl->assign('displayName', User::getDisplayName($activity['user']));
if ($activity['app'] === 'files') {
// We do not link the subject as we create links for the parameters instead
$activity['link'] = '';
}
$tmpl->assign('event', $activity);
if ($activity['file']) {
$rootView = new View('/' . $activity['affecteduser'] . '/files');
$exist = $rootView->file_exists($activity['file']);
$is_dir = $rootView->is_dir($activity['file']);
unset($rootView);
// show a preview image if the file still exists
$mimetype = \OC_Helper::getFileNameMimeType($activity['file']);
if (!$is_dir && \OC::$server->getPreviewManager()->isMimeSupported($mimetype) && $exist) {
$tmpl->assign('previewLink', Util::linkTo('files', 'index.php', array('dir' => dirname($activity['file']))));
$tmpl->assign('previewImageLink', Util::linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
} else {
$tmpl->assign('previewLink', Util::linkTo('files', 'index.php', array('dir' => $activity['file'])));
$tmpl->assign('previewImageLink', \OC_Helper::mimetypeIcon($is_dir ? 'dir' : $mimetype));
$tmpl->assign('previewLinkIsDir', true);
}
}
return $tmpl->fetchPage();
}
开发者ID:yheric455042,项目名称:owncloud82,代码行数:36,代码来源:display.php
示例6: getThumbnail
/**
* @param string $path
* @param int $maxX
* @param int $maxY
* @param boolean $scalingup
* @param \OC\Files\View $fileview
* @return bool|\OC_Image
*/
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
{
$content = $fileview->fopen($path, 'r');
$content = stream_get_contents($content);
//don't create previews of empty text files
if (trim($content) === '') {
return false;
}
$lines = preg_split("/\r\n|\n|\r/", $content);
$fontSize = 5;
//5px
$lineSize = ceil($fontSize * 1.25);
$image = imagecreate($maxX, $maxY);
imagecolorallocate($image, 255, 255, 255);
$textColor = imagecolorallocate($image, 0, 0, 0);
foreach ($lines as $index => $line) {
$index = $index + 1;
$x = (int) 1;
$y = (int) ($index * $lineSize) - $fontSize;
imagestring($image, 1, $x, $y, $line, $textColor);
if ($index * $lineSize >= $maxY) {
break;
}
}
$image = new \OC_Image($image);
return $image->valid() ? $image : false;
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:35,代码来源:txt.php
示例7: byUsername
/**
* @param string $userName
* @return integer
*/
public function byUsername($userName)
{
$view = new FilesView('/' . $userName . '/files');
$freeSpace = (int) $view->free_space();
$fileInfo = $view->getFileInfo('/');
Assertion::notEmpty($fileInfo);
$usedSpace = $fileInfo->getSize();
return KiloBytes::allocateUnits($freeSpace + $usedSpace)->units();
}
开发者ID:arnovr,项目名称:owncloud-statistics,代码行数:13,代码来源:Quota.php
示例8: 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;
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:13,代码来源:quotaplugin.php
示例9: testChangeLock
public function testChangeLock()
{
Filesystem::initMountPoints($this->recipientUid);
$recipientView = new View('/' . $this->recipientUid . '/files');
$recipientView->lockFile('bar.txt', ILockingProvider::LOCK_SHARED);
$recipientView->changeLock('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
$recipientView->unlockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
$this->assertTrue(true);
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:9,代码来源:locking.php
示例10: validate
/**
* Check if genesis is valid
* @param \OC\Files\View $view
* @param string $path relative to the view
* @throws \Exception
*/
protected function validate($view, $path)
{
if (!$view->file_exists($path)) {
throw new \Exception('Document not found ' . $path);
}
if (!$view->is_file($path)) {
throw new \Exception('Object ' . $path . ' is not a file.');
}
//TODO check if it is a valid odt
}
开发者ID:Ebimedia,项目名称:owncloud,代码行数:16,代码来源:genesis.php
示例11: getPrivateKey
/**
* @brief retrieve the ENCRYPTED private key from a user
*
* @param \OC\Files\View $view
* @param string $user
* @return string private key or false (hopefully)
* @note the key returned by this method must be decrypted before use
*/
public static function getPrivateKey($view, $user)
{
$path = '/' . $user . '/' . 'files_encryption' . '/' . $user . '.private.key';
$key = false;
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
if ($view->file_exists($path)) {
$key = $view->file_get_contents($path);
}
\OC_FileProxy::$enabled = $proxyStatus;
return $key;
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:20,代码来源:keymanager.php
示例12: 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();
}
}
开发者ID:brunomilet,项目名称:owncloud-core,代码行数:17,代码来源:changewatcher.php
示例13: run
public function run()
{
$view = new View('/');
$children = $view->getDirectoryContent('/');
foreach ($children as $child) {
if ($view->is_dir($child->getPath())) {
$thumbnailsFolder = $child->getPath() . '/thumbnails';
if ($view->is_dir($thumbnailsFolder)) {
$view->rmdir($thumbnailsFolder);
}
}
}
}
开发者ID:evanjt,项目名称:core,代码行数:13,代码来源:preview.php
示例14: 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());
}
开发者ID:GitHubUser4234,项目名称:core,代码行数:17,代码来源:PropagationTestCase.php
示例15: impl
/**
* @return Directory
*/
private function impl()
{
$rootView = new View();
$user = \OC::$server->getUserSession()->getUser();
Filesystem::initMountPoints($user->getUID());
if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) {
$rootView->mkdir('/' . $user->getUID() . '/uploads');
}
$view = new View('/' . $user->getUID() . '/uploads');
$rootInfo = $view->getFileInfo('');
$impl = new Directory($view, $rootInfo);
return $impl;
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:16,代码来源:uploadhome.php
示例16: getChildInfo
/**
* @param \OCP\Files\FileInfo $dir
* @param \OC\Files\View $view
* @return array
*/
function getChildInfo($dir, $view)
{
$children = $view->getDirectoryContent($dir->getPath());
$result = array();
foreach ($children as $child) {
$formated = \OCA\Files\Helper::formatFileInfo($child);
if ($child->getType() === 'dir') {
$formated['children'] = getChildInfo($child, $view);
}
$formated['mtime'] = $formated['mtime'] / 1000;
$result[] = $formated;
}
return $result;
}
开发者ID:samj1912,项目名称:repo,代码行数:19,代码来源:shareinfo.php
示例17: verifyMountPoint
/**
* check if the parent folder exists otherwise move the mount point up
*
* @param array $share
* @return string
*/
private function verifyMountPoint(&$share)
{
$mountPoint = basename($share['file_target']);
$parent = dirname($share['file_target']);
if (!$this->recipientView->is_dir($parent)) {
$parent = Helper::getShareFolder();
}
$newMountPoint = \OCA\Files_Sharing\Helper::generateUniqueTarget(\OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint), [], $this->recipientView);
if ($newMountPoint !== $share['file_target']) {
$this->updateFileTarget($newMountPoint, $share);
$share['file_target'] = $newMountPoint;
$share['unique_name'] = true;
}
return $newMountPoint;
}
开发者ID:DanielTosello,项目名称:owncloud,代码行数:21,代码来源:sharedmount.php
示例18: getChangePropagator
/**
* @param string $user
* @return \OC\Files\Cache\ChangePropagator
*/
public function getChangePropagator($user)
{
$activeUser = $this->userSession->getUser();
// for the local user we want to propagator from the active view, not any cached one
if ($activeUser && $activeUser->getUID() === $user && Filesystem::getView() instanceof View) {
// it's important that we take the existing propagator here to make sure we can listen to external changes
$this->changePropagators[$user] = Filesystem::getView()->getUpdater()->getPropagator();
}
if (isset($this->changePropagators[$user])) {
return $this->changePropagators[$user];
}
$view = new View('/' . $user . '/files');
$this->changePropagators[$user] = $view->getUpdater()->getPropagator();
return $this->changePropagators[$user];
}
开发者ID:nem0xff,项目名称:core,代码行数:19,代码来源:propagationmanager.php
示例19: prepareFileParam
/**
* Prepares a file parameter for usage
*
* Removes the path from filenames and adds highlights
*
* @param string $param
* @param bool $stripPath Shall we remove the path from the filename
* @param bool $highlightParams
* @return string
*/
protected function prepareFileParam($param, $stripPath, $highlightParams)
{
$param = $this->fixLegacyFilename($param);
$is_dir = $this->rootView->is_dir('/' . User::getUser() . '/files' . $param);
if ($is_dir) {
$fileLink = Util::linkTo('files', 'index.php', array('dir' => $param));
} else {
$parentDir = substr_count($param, '/') == 1 ? '/' : dirname($param);
$fileName = basename($param);
$fileLink = Util::linkTo('files', 'index.php', array('dir' => $parentDir, 'scrollto' => $fileName));
}
$param = trim($param, '/');
list($path, $name) = $this->splitPathFromFilename($param);
if (!$stripPath || $path === '') {
if (!$highlightParams) {
return $param;
}
return '<a class="filename" href="' . $fileLink . '">' . Util::sanitizeHTML($param) . '</a>';
}
if (!$highlightParams) {
return $name;
}
$title = ' title="' . $this->l->t('in %s', array(Util::sanitizeHTML($path))) . '"';
return '<a class="filename tooltip" href="' . $fileLink . '"' . $title . '>' . Util::sanitizeHTML($name) . '</a>';
}
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:35,代码来源:parameterhelper.php
示例20: copy
/**
* Copies a file or directory.
*
* This method must work recursively and delete the destination
* if it exists
*
* @param string $source
* @param string $destination
* @throws \Sabre\DAV\Exception\ServiceUnavailable
* @return void
*/
public function copy($source, $destination)
{
if (!$this->fileView) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
}
// this will trigger existence check
$this->getNodeForPath($source);
list($destinationDir, $destinationName) = \Sabre\HTTP\URLUtil::splitPath($destination);
try {
$this->fileView->verifyPath($destinationDir, $destinationName);
} catch (\OCP\Files\InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage());
}
try {
$this->fileView->copy($source, $destination);
} catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
} catch (ForbiddenException $ex) {
throw new Forbidden($ex->getMessage(), $ex->getRetry());
} catch (LockedException $e) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
list($destinationDir, ) = \Sabre\HTTP\URLUtil::splitPath($destination);
$this->markDirty($destinationDir);
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:36,代码来源:objecttree.php
注:本文中的OC\Files\View类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论