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


PHP Folder::getFullPath方法代码示例

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


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

示例1: testOnBeforeDelete

 /**
  * We need to test that the _versions folder isn't completed wiped by
  * {@link VersionedFileExtension::onBeforeDelete()} when there is more than the file currently being deleted.
  */
 public function testOnBeforeDelete()
 {
     // Create the second file
     $file2 = $this->folder->getFullPath() . 'test-file2.txt';
     file_put_contents($file2, 'first-version');
     $file2Obj = new File();
     $file2Obj->ParentID = $this->folder->ID;
     $file2Obj->Filename = $this->folder->getFilename() . 'test-file2.txt';
     $file2Obj->write();
     // Create a second version of the second file
     file_put_contents($file2Obj->getFullPath(), 'second-version');
     $file2Obj->createVersion();
     // Delete the second file
     $file2Obj->delete();
     // Ensure the _versions folder still exists
     $this->assertTrue(is_dir($this->folder->getFullPath()));
     $this->assertTrue(is_dir($this->folder->getFullPath() . '/_versions'));
     // Now delete the first file, and ensure the _versions folder no longer exists
     $this->file->delete();
     $this->assertTrue(is_dir($this->folder->getFullPath()));
     $this->assertFalse(is_dir($this->folder->getFullPath() . '/_versions'));
     // Now create another file to ensure that the _versions folder can be successfully re-created
     $file3 = $this->folder->getFullPath() . 'test-file3.txt';
     file_put_contents($file3, 'first-version');
     $file3Obj = new File();
     $file3Obj->ParentID = $this->folder->ID;
     $file3Obj->Filename = $this->folder->getFilename() . 'test-file3.txt';
     $file3Obj->write();
     $this->assertTrue(is_file($file3Obj->getFullPath()));
     $this->assertTrue(is_dir($this->folder->getFullPath() . '/_versions'));
 }
开发者ID:camfindlay,项目名称:silverstripe-versionedfiles,代码行数:35,代码来源:VersionedFileTest.php

示例2: find_or_make

 /**
  * Find the given folder or create it both as {@link Folder} database records
  * and on the filesystem. If necessary, creates parent folders as well.
  * 
  * @param $folderPath string Absolute or relative path to the file.
  *  If path is relative, its interpreted relative to the "assets/" directory.
  * @return Folder
  */
 public static function find_or_make($folderPath)
 {
     // Create assets directory, if it is missing
     if (!file_exists(ASSETS_PATH)) {
         Filesystem::makeFolder(ASSETS_PATH);
     }
     $folderPath = trim(Director::makeRelative($folderPath));
     // replace leading and trailing slashes
     $folderPath = preg_replace('/^\\/?(.*)\\/?$/', '$1', $folderPath);
     $parts = explode("/", $folderPath);
     $parentID = 0;
     $item = null;
     foreach ($parts as $part) {
         if (!$part) {
             continue;
         }
         // happens for paths with a trailing slash
         $item = DataObject::get_one("Folder", sprintf("\"Name\" = '%s' AND \"ParentID\" = %d", Convert::raw2sql($part), (int) $parentID));
         if (!$item) {
             $item = new Folder();
             $item->ParentID = $parentID;
             $item->Name = $part;
             $item->Title = $part;
             $item->write();
         }
         if (!file_exists($item->getFullPath())) {
             Filesystem::makeFolder($item->getFullPath());
         }
         $parentID = $item->ID;
     }
     return $item;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:40,代码来源:Folder.php

示例3:

 /**
  * This will return the full path string of the current folder object
  *
  * @author KnowledgeTree Team
  * @access public
  * @return string
  */
 function get_full_path()
 {
     $path = $this->folder->getFullPath();
     if (empty($path)) {
         $path = '/';
     }
     return $path;
 }
开发者ID:jpbauer,项目名称:knowledgetree,代码行数:15,代码来源:KTAPIFolder.inc.php

示例4: findOrMake

 static function findOrMake($folder)
 {
     $parts = explode("/", $folder);
     $parentID = 0;
     foreach ($parts as $part) {
         $item = DataObject::get_one("Folder", "Name = '{$part}' AND ParentID = {$parentID}");
         if (!$item) {
             $item = new Folder();
             $item->ParentID = $parentID;
             $item->Name = $part;
             $item->Title = $part;
             $item->write();
             if (!file_exists($item->getFullPath())) {
                 mkdir($item->getFullPath(), Filesystem::$folder_create_mask);
             }
         }
         $parentID = $item->ID;
     }
     return $item;
 }
开发者ID:ramziammar,项目名称:websites,代码行数:20,代码来源:Folder.php

示例5: findOrMake

	static function findOrMake($folderPath) {
		$folderPath = trim(Director::makeRelative($folderPath));
		// replace leading and trailing slashes
		$folderPath = preg_replace('/^\/?(.*)\/?$/', '$1', $folderPath);
		
		$parts = explode("/",$folderPath);
		$parentID = 0;

		foreach($parts as $part) {
			$item = DataObject::get_one("Folder", "Name = '$part' AND ParentID = $parentID");
			if(!$item) {
				$item = new Folder();
				$item->ParentID = $parentID;
				$item->Name = $part;
				$item->Title = $part;
				$item->write();
				if(!file_exists($item->getFullPath())) mkdir($item->getFullPath(),Filesystem::$folder_create_mask);
			}
			$parentID = $item->ID;
		}
		return $item;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:22,代码来源:Folder.php

示例6: find_or_make

 /**
  * Find the given folder or create it both as {@link Folder} database records
  * and on the filesystem. If necessary, creates parent folders as well. If it's
  * unable to find or make the folder, it will return null (as /assets is unable
  * to be represented by a Folder DataObject)
  *
  * @param $folderPath string Absolute or relative path to the file.
  *  If path is relative, its interpreted relative to the "assets/" directory.
  * @return Folder|null
  */
 public static function find_or_make($folderPath)
 {
     // Create assets directory, if it is missing
     if (!file_exists(ASSETS_PATH)) {
         Filesystem::makeFolder(ASSETS_PATH);
     }
     $folderPath = trim(Director::makeRelative($folderPath));
     // replace leading and trailing slashes
     $folderPath = preg_replace('/^\\/?(.*)\\/?$/', '$1', $folderPath);
     $parts = explode("/", $folderPath);
     $parentID = 0;
     $item = null;
     $filter = FileNameFilter::create();
     foreach ($parts as $part) {
         if (!$part) {
             continue;
         }
         // happens for paths with a trailing slash
         // Ensure search includes folders with illegal characters removed, but
         // err in favour of matching existing folders if $folderPath
         // includes illegal characters itself.
         $partSafe = $filter->filter($part);
         $item = Folder::get()->filter(array('ParentID' => $parentID, 'Name' => array($partSafe, $part)))->first();
         if (!$item) {
             $item = new Folder();
             $item->ParentID = $parentID;
             $item->Name = $partSafe;
             $item->Title = $part;
             $item->write();
         }
         if (!file_exists($item->getFullPath())) {
             Filesystem::makeFolder($item->getFullPath());
         }
         $parentID = $item->ID;
     }
     return $item;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:47,代码来源:Folder.php

示例7: newfolder

 /**
  * Creates a new folder at the level of {@link KickAssetAdmin::$currentFolder}
  *
  * @param SS_HTTPRequest
  * @return SS_HTTPResponse
  */
 public function newfolder(SS_HTTPRequest $r)
 {
     $f = new Folder();
     $f->ParentID = $this->currentFolder ? $this->currentFolder->ID : 0;
     $f->Name = "New-Folder";
     $f->Title = "New-Folder";
     $f->write();
     if (!file_exists($f->getFullPath())) {
         Filesystem::makeFolder($f->getFullPath());
     }
     return $this->browse($r);
 }
开发者ID:heyday,项目名称:KickAssets,代码行数:18,代码来源:KickAssetAdmin.php


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