當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。