本文整理汇总了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'));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}