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


PHP Files\View类代码示例

本文整理汇总了PHP中OC\Files\View的典型用法代码示例。如果您正苦于以下问题:PHP View类的具体用法?PHP View怎么用?PHP View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: rename

 /**
  * rename a file
  *
  * @param string $dir
  * @param string $oldname
  * @param string $newname
  * @return array
  */
 public function rename($dir, $oldname, $newname)
 {
     $result = array('success' => false, 'data' => NULL);
     // rename to non-existing folder is denied
     if (!$this->view->file_exists($dir)) {
         $result['data'] = array('message' => (string) $this->l10n->t('The target folder has been moved or deleted.', array($dir)), 'code' => 'targetnotfound');
         // rename to existing file is denied
     } else {
         if ($this->view->file_exists($dir . '/' . $newname)) {
             $result['data'] = array('message' => $this->l10n->t("The name %s is already used in the folder %s. Please choose a different name.", array($newname, $dir)));
         } else {
             if ($newname !== '.' and $this->view->rename($dir . '/' . $oldname, $dir . '/' . $newname)) {
                 // successful rename
                 $meta = $this->view->getFileInfo($dir . '/' . $newname);
                 $fileinfo = \OCA\Files\Helper::formatFileInfo($meta);
                 $result['success'] = true;
                 $result['data'] = $fileinfo;
             } else {
                 // rename failed
                 $result['data'] = array('message' => $this->l10n->t('%s could not be renamed', array($oldname)));
             }
         }
     }
     return $result;
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:33,代码来源:app.php

示例15: testPrepareParameters

 /**
  * @dataProvider prepareParametersData
  */
 public function testPrepareParameters($params, $filePosition, $stripPath, $highlightParams, $expected, $createFolder = '')
 {
     if ($createFolder !== '') {
         $this->view->mkdir('/' . \OCP\User::getUser() . '/files/' . $createFolder);
     }
     $this->assertEquals($expected, $this->parameterHelper->prepareParameters($params, $filePosition, $stripPath, $highlightParams));
 }
开发者ID:ArcherSys,项目名称:ArcherSysOSCloud7,代码行数:10,代码来源:parameterhelpertest.php


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