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


PHP View::is_dir方法代码示例

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


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

示例1: 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 function show($activity)
 {
     $tmpl = new Template('activity', 'stream.item');
     $tmpl->assign('formattedDate', $this->dateTimeFormatter->formatDateTime($activity['timestamp']));
     $tmpl->assign('formattedTimestamp', Template::relative_modified_date($activity['timestamp']));
     if (strpos($activity['subjectformatted']['markup']['trimmed'], '<a ') !== false) {
         // We do not link the subject as we create links for the parameters instead
         $activity['link'] = '';
     }
     $tmpl->assign('event', $activity);
     if ($activity['file']) {
         $this->view->chroot('/' . $activity['affecteduser'] . '/files');
         $exist = $this->view->file_exists($activity['file']);
         $is_dir = $this->view->is_dir($activity['file']);
         $tmpl->assign('previewLink', $this->getPreviewLink($activity['file'], $is_dir));
         // show a preview image if the file still exists
         $mimeType = Files::getMimeType($activity['file']);
         if ($mimeType && !$is_dir && $this->preview->isMimeSupported($mimeType) && $exist) {
             $tmpl->assign('previewImageLink', $this->urlGenerator->linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
         } else {
             $mimeTypeIcon = Template::mimetype_icon($is_dir ? 'dir' : $mimeType);
             $mimeTypeIcon = substr($mimeTypeIcon, -4) === '.png' ? substr($mimeTypeIcon, 0, -4) . '.svg' : $mimeTypeIcon;
             $tmpl->assign('previewImageLink', $mimeTypeIcon);
             $tmpl->assign('previewLinkIsDir', true);
         }
     }
     return $tmpl->fetchPage();
 }
开发者ID:AARNet,项目名称:activity,代码行数:34,代码来源:display.php

示例2: listCertificates

 /**
  * Returns all certificates trusted by the user
  *
  * @return \OCP\ICertificate[]
  */
 public function listCertificates()
 {
     if (!$this->config->getSystemValue('installed', false)) {
         return array();
     }
     $path = $this->getPathToCertificates() . 'uploads/';
     if (!$this->view->is_dir($path)) {
         return array();
     }
     $result = array();
     $handle = $this->view->opendir($path);
     if (!is_resource($handle)) {
         return array();
     }
     while (false !== ($file = readdir($handle))) {
         if ($file != '.' && $file != '..') {
             try {
                 $result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
             } catch (\Exception $e) {
             }
         }
     }
     closedir($handle);
     return $result;
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:30,代码来源:CertificateManager.php

示例3: 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

示例4: verifyMountPoint

 /**
  * check if the parent folder exists otherwise move the mount point up
  *
  * @param \OCP\Share\IShare $share
  * @param SharedMount[] $mountpoints
  * @return string
  */
 private function verifyMountPoint(\OCP\Share\IShare $share, array $mountpoints)
 {
     $mountPoint = basename($share->getTarget());
     $parent = dirname($share->getTarget());
     if (!$this->recipientView->is_dir($parent)) {
         $parent = Helper::getShareFolder();
     }
     $newMountPoint = $this->generateUniqueTarget(\OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint), $this->recipientView, $mountpoints);
     if ($newMountPoint !== $share->getTarget()) {
         $this->updateFileTarget($newMountPoint, $share);
     }
     return $newMountPoint;
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:20,代码来源:sharedmount.php

示例5: testAreAllPreviewsDeleted

 public function testAreAllPreviewsDeleted()
 {
     $sampleFile = '/' . $this->user . '/files/test.txt';
     $this->rootView->file_put_contents($sampleFile, 'dummy file data');
     $x = 50;
     $y = 50;
     $preview = new \OC\Preview($this->user, 'files/', 'test.txt', $x, $y);
     $preview->getPreview();
     $fileInfo = $this->rootView->getFileInfo($sampleFile);
     $fileId = $fileInfo['fileid'];
     $thumbCacheFolder = '/' . $this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/';
     $this->assertEquals($this->rootView->is_dir($thumbCacheFolder), true);
     $preview->deleteAllPreviews();
     $this->assertEquals($this->rootView->is_dir($thumbCacheFolder), false);
 }
开发者ID:Romua1d,项目名称:core,代码行数:15,代码来源:preview.php

示例6: 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

示例7: 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) {
         $parent_dir = $param;
     } else {
         $parent_dir = substr_count($param, '/') == 1 ? '/' : dirname($param);
     }
     $fileLink = Util::linkTo('files', 'index.php', array('dir' => $parent_dir));
     $param = trim($param, '/');
     if (!$stripPath) {
         if (!$highlightParams) {
             return $param;
         }
         return '<a class="filename" href="' . $fileLink . '">' . Util::sanitizeHTML($param) . '</a>';
     }
     if (!$highlightParams) {
         return $this->stripPathFromFilename($param);
     }
     $title = $param;
     $title = ' title="' . Util::sanitizeHTML($title) . '"';
     $newParam = $this->stripPathFromFilename($param);
     return '<a class="filename tooltip" href="' . $fileLink . '"' . $title . '>' . Util::sanitizeHTML($newParam) . '</a>';
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:35,代码来源:parameterhelper.php

示例8: 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

示例9: 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;
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:33,代码来源:ViewInfoCache.php

示例10: 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

示例11: decryptUsersFiles

 /**
  * encrypt files from the given user
  *
  * @param string $uid
  * @param ProgressBar $progress
  * @param string $userCount
  */
 protected function decryptUsersFiles($uid, ProgressBar $progress, $userCount)
 {
     $this->setupUserFS($uid);
     $directories = array();
     $directories[] = '/' . $uid . '/files';
     while ($root = array_pop($directories)) {
         $content = $this->rootView->getDirectoryContent($root);
         foreach ($content as $file) {
             $path = $root . '/' . $file['name'];
             if ($this->rootView->is_dir($path)) {
                 $directories[] = $path;
                 continue;
             } else {
                 try {
                     $progress->setMessage("decrypt files for user {$userCount}: {$path}");
                     $progress->advance();
                     if ($this->decryptFile($path) === false) {
                         $progress->setMessage("decrypt files for user {$userCount}: {$path} (already decrypted)");
                         $progress->advance();
                     }
                 } catch (\Exception $e) {
                     if (isset($this->failed[$uid])) {
                         $this->failed[$uid][] = $path;
                     } else {
                         $this->failed[$uid] = [$path];
                     }
                 }
             }
         }
     }
 }
开发者ID:kenwi,项目名称:core,代码行数:38,代码来源:decryptall.php

示例12: testCreateMaxAndNormalPreviewsAtFirstRequest

	/**
	 * Tests if a preview of max dimensions gets created
	 *
	 * @dataProvider dimensionsDataProvider
	 *
	 * @param int $sampleId
	 * @param int $widthAdjustment
	 * @param int $heightAdjustment
	 * @param bool $keepAspect
	 * @param bool $scalingUp
	 */
	public function testCreateMaxAndNormalPreviewsAtFirstRequest(
		$sampleId, $widthAdjustment, $heightAdjustment, $keepAspect = false, $scalingUp = false
	) {
		//$this->markTestSkipped('Not testing this at this time');

		// Get the right sample for the experiment
		$this->getSample($sampleId);
		$sampleWidth = $this->sampleWidth;
		$sampleHeight = $this->sampleHeight;
		$sampleFileId = $this->sampleFileId;

		// Adjust the requested size so that we trigger various test cases
		$previewWidth = $sampleWidth + $widthAdjustment;
		$previewHeight = $sampleHeight + $heightAdjustment;
		$this->keepAspect = $keepAspect;
		$this->scalingUp = $scalingUp;

		// Generates the max preview
		$preview = $this->createPreview($previewWidth, $previewHeight);

		// There should be no cached thumbnails
		$thumbnailFolder = '/' . self::TEST_PREVIEW_USER1 . '/' . \OC\Preview::THUMBNAILS_FOLDER .
						   '/' . $sampleFileId;
		$this->assertSame(false, $this->rootView->is_dir($thumbnailFolder));

		$image = $preview->getPreview();
		$this->assertNotSame(false, $image);

		$maxThumbCacheFile = $this->buildCachePath(
			$sampleFileId, $this->maxPreviewWidth, $this->maxPreviewHeight, true, '-max'
		);

		$this->assertSame(
			true, $this->rootView->file_exists($maxThumbCacheFile), "$maxThumbCacheFile \n"
		);

		// We check the dimensions of the file we've just stored
		$maxPreview = imagecreatefromstring($this->rootView->file_get_contents($maxThumbCacheFile));

		$this->assertEquals($this->maxPreviewWidth, imagesx($maxPreview));
		$this->assertEquals($this->maxPreviewHeight, imagesy($maxPreview));

		// A thumbnail of the asked dimensions should also have been created (within the constraints of the max preview)
		list($limitedPreviewWidth, $limitedPreviewHeight) =
			$this->simulatePreviewDimensions($previewWidth, $previewHeight);

		$actualWidth = $image->width();
		$actualHeight = $image->height();

		$this->assertEquals(
			(int)$limitedPreviewWidth, $image->width(), "$actualWidth x $actualHeight \n"
		);
		$this->assertEquals((int)$limitedPreviewHeight, $image->height());

		// And it should be cached
		$this->checkCache($sampleFileId, $limitedPreviewWidth, $limitedPreviewHeight);

		$preview->deleteAllPreviews();
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:70,代码来源:preview.php

示例13: moveUserEncryptionFolder

 /**
  * move user encryption folder to new root folder
  *
  * @param string $user
  * @param string $oldRoot
  * @param string $newRoot
  * @throws \Exception
  */
 protected function moveUserEncryptionFolder($user, $oldRoot, $newRoot)
 {
     if ($this->userManager->userExists($user)) {
         $source = $oldRoot . '/' . $user . '/files_encryption';
         $target = $newRoot . '/' . $user . '/files_encryption';
         if ($this->rootView->is_dir($source) && $this->targetExists($target) === false) {
             $this->prepareParentFolder($newRoot . '/' . $user);
             $this->rootView->rename($source, $target);
         }
     }
 }
开发者ID:evanjt,项目名称:core,代码行数:19,代码来源:changekeystorageroot.php

示例14: testKeySetPreperation

 function testKeySetPreperation()
 {
     $basePath = '/' . self::TEST_USER . '/files';
     $path = '/folder1/subfolder/subsubfolder/file.txt';
     $this->assertFalse($this->view->is_dir($basePath . '/testKeySetPreperation'));
     TestProtectedKeymanagerMethods::testKeySetPreperation($this->view, $basePath . $path);
     // check if directory structure was created
     $this->assertTrue($this->view->is_dir($basePath . $path));
     // cleanup
     $this->view->deleteAll($basePath . '/folder1');
 }
开发者ID:samj1912,项目名称:repo,代码行数:11,代码来源:keymanager.php

示例15: testDescryptAllWithBrokenFiles

 function testDescryptAllWithBrokenFiles()
 {
     $file1 = "/decryptAll1" . $this->getUniqueID() . ".txt";
     $file2 = "/decryptAll2" . $this->getUniqueID() . ".txt";
     $util = new \OCA\Files_Encryption\Util($this->view, $this->userId);
     $this->view->file_put_contents($this->userId . '/files/' . $file1, $this->dataShort);
     $this->view->file_put_contents($this->userId . '/files/' . $file2, $this->dataShort);
     $fileInfoEncrypted1 = $this->view->getFileInfo($this->userId . '/files/' . $file1);
     $fileInfoEncrypted2 = $this->view->getFileInfo($this->userId . '/files/' . $file2);
     $this->assertTrue($fileInfoEncrypted1 instanceof \OC\Files\FileInfo);
     $this->assertTrue($fileInfoEncrypted2 instanceof \OC\Files\FileInfo);
     $this->assertEquals($fileInfoEncrypted1['encrypted'], 1);
     $this->assertEquals($fileInfoEncrypted2['encrypted'], 1);
     // rename keyfile for file1 so that the decryption for file1 fails
     // Expected behaviour: decryptAll() returns false, file2 gets decrypted anyway
     $this->view->rename($this->userId . '/files_encryption/keys/' . $file1 . '/fileKey', $this->userId . '/files_encryption/keys/' . $file1 . '/fileKey.moved');
     // need to reset key cache that we don't use the cached key
     $this->resetKeyCache();
     // decrypt all encrypted files
     $result = $util->decryptAll();
     $this->assertFalse($result);
     $fileInfoUnencrypted1 = $this->view->getFileInfo($this->userId . '/files/' . $file1);
     $fileInfoUnencrypted2 = $this->view->getFileInfo($this->userId . '/files/' . $file2);
     $this->assertTrue($fileInfoUnencrypted1 instanceof \OC\Files\FileInfo);
     $this->assertTrue($fileInfoUnencrypted2 instanceof \OC\Files\FileInfo);
     // file1 should be still encrypted; file2 should be decrypted
     $this->assertEquals(1, $fileInfoUnencrypted1['encrypted']);
     $this->assertEquals(0, $fileInfoUnencrypted2['encrypted']);
     // keyfiles and share keys should still exist
     $this->assertTrue($this->view->is_dir($this->userId . '/files_encryption/keys/'));
     $this->assertTrue($this->view->file_exists($this->userId . '/files_encryption/keys/' . $file1 . '/fileKey.moved'));
     $this->assertTrue($this->view->file_exists($this->userId . '/files_encryption/keys/' . $file1 . '/' . $this->userId . '.shareKey'));
     // rename the keyfile for file1 back
     $this->view->rename($this->userId . '/files_encryption/keys/' . $file1 . '/fileKey.moved', $this->userId . '/files_encryption/keys/' . $file1 . '/fileKey');
     // try again to decrypt all encrypted files
     $result = $util->decryptAll();
     $this->assertTrue($result);
     $fileInfoUnencrypted1 = $this->view->getFileInfo($this->userId . '/files/' . $file1);
     $fileInfoUnencrypted2 = $this->view->getFileInfo($this->userId . '/files/' . $file2);
     $this->assertTrue($fileInfoUnencrypted1 instanceof \OC\Files\FileInfo);
     $this->assertTrue($fileInfoUnencrypted2 instanceof \OC\Files\FileInfo);
     // now both files should be decrypted
     $this->assertEquals(0, $fileInfoUnencrypted1['encrypted']);
     $this->assertEquals(0, $fileInfoUnencrypted2['encrypted']);
     // keyfiles and share keys should be deleted
     $this->assertFalse($this->view->is_dir($this->userId . '/files_encryption/keys/'));
     //cleanup
     $backupPath = $this->getBackupPath('decryptAll');
     $this->view->unlink($this->userId . '/files/' . $file1);
     $this->view->unlink($this->userId . '/files/' . $file2);
     $this->view->deleteAll($backupPath);
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:52,代码来源:util.php


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