本文整理汇总了PHP中File::getFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getFilename方法的具体用法?PHP File::getFilename怎么用?PHP File::getFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::getFilename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetFilename
/**
* Tests File::getFilename
*/
public function testGetFilename()
{
$spl = $this->getFileInfo();
$file = new File($spl);
$filename = $file->getFilename();
$this->assertEquals($spl->getFilename(), $filename);
}
示例2: getCacheFile
protected function getCacheFile(File $file)
{
if (!$GLOBALS['phorkie']['cfg']['cachedir'] || !is_dir($GLOBALS['phorkie']['cfg']['cachedir'])) {
return null;
}
return $GLOBALS['phorkie']['cfg']['cachedir'] . '/' . $file->repo->id . '-' . $file->repo->hash . '-' . str_replace('/', '-', $file->getFilename()) . '.html';
}
示例3: execute
function execute()
{
$file_or_folder = $this->file_or_folder;
if (self::$dummy_mode) {
echo "Adding : " . $file_or_folder . "<br />";
return;
}
$root_dir_path = self::$root_dir->getPath();
$file_or_folder = str_replace("\\", "/", $file_or_folder);
$file_list = array();
//se finisce con lo slash è una directory
if (substr($file_or_folder, strlen($file_or_folder) - 1, 1) == "/") {
//creo la cartella
$target_dir = new Dir(DS . $root_dir_path . $file_or_folder);
$target_dir->touch();
$source_dir = new Dir($this->module_dir->getPath() . $file_or_folder);
foreach ($source_dir->listFiles() as $elem) {
if ($elem->isDir()) {
$file_list = array_merge($file_list, $this->add($file_or_folder . $elem->getName() . DS));
} else {
$file_list = array_merge($file_list, $this->add($file_or_folder . $elem->getFilename()));
}
}
} else {
$source_file = new File($this->module_dir->getPath() . $file_or_folder);
$target_file = new File($root_dir_path . $file_or_folder);
$target_dir = $target_file->getDirectory();
$target_dir->touch();
$source_file->copy($target_dir);
$file_list[] = $target_dir->newFile($source_file->getFilename())->getPath();
}
return $file_list;
}
示例4: testFilename
function testFilename()
{
$f_txt = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/test_file.txt");
$this->assertEqual("test_file.txt", $f_txt->getFilename());
$f_css = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/css_test.css");
$this->assertEqual("css_test.css", $f_css->getFilename());
$f_plug_txt = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/ext_test.plug.txt");
$this->assertEqual("ext_test.plug.txt", $f_plug_txt->getFilename());
}
示例5: put
/**
* @param File $f
* @throws Exception
*/
public function put(File $f)
{
$fp = fopen($f->getFullPath(), 'r');
if (!$fp) {
throw new Exception("Unable to open file: " . $f->getFilename());
}
$headers = array();
if (!empty($this->config[self::FORCE_DL])) {
$headers['Content-Disposition'] = 'attachment; filename=' . ($f->hasMethod('getFriendlyName') ? $f->getFriendlyName() : $f->Name);
}
$this->getContainer()->uploadObject($this->getRelativeLinkFor($f), $fp, $headers);
}
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-cloudassets-rackspace,代码行数:16,代码来源:RackspaceBucket.php
示例6: put
/**
* @param File $f
* @throws Exception
*/
public function put(File $f)
{
$fp = fopen($f->getFullPath(), 'r');
if (!$fp) {
throw new Exception('Unable to open file: ' . $f->getFilename());
}
$uploader = UploadBuilder::newInstance()->setClient($this->client)->setSource($f->getFullPath())->setBucket($this->containerName)->setKey($this->getRelativeLinkFor($f))->build();
try {
$uploader->upload();
} catch (MultipartUploadException $e) {
$uploader->abort();
}
}
示例7: put
/**
* @param File $f
* @throws Exception
*/
public function put(File $f)
{
$fp = fopen($f->getFullPath(), 'r');
if (!$fp) {
throw new Exception('Unable to open file: ' . $f->getFilename());
}
$uploader = new MultipartUploader($this->client, $f->getFullPath(), array('bucket' => $this->containerName, 'key' => $this->getRelativeLinkFor($f)));
try {
$uploader->upload();
} catch (MultipartUploadException $e) {
// warning: below exception gets silently swallowed!
error_log('S3Bucket: failed to put file: ' . $e->getPrevious()->getMessage());
throw new Exception('S3Bucket: failed to put file: ' . $e->getPrevious()->getMessage(), 0, $e);
}
}
示例8: migrateFile
/**
* Migrate a single file
*
* @param string $base Absolute base path (parent of assets folder)
* @param File $file
* @param type $legacyFilename
* @return bool True if this file is imported successfully
*/
protected function migrateFile($base, File $file, $legacyFilename)
{
// Make sure this legacy file actually exists
$path = $base . '/' . $legacyFilename;
if (!file_exists($path)) {
return false;
}
// Copy local file into this filesystem
$filename = $file->getFilename();
$result = $file->setFromLocalFile($path, $filename, null, null, array('conflict' => AssetStore::CONFLICT_OVERWRITE));
// Move file if the APL changes filename value
if ($result['Filename'] !== $filename) {
$this->setFilename($result['Filename']);
}
// Save
$file->write();
return true;
}
示例9: updateCloudStatus
/**
* Performs two functions:
* 1. Wraps this object in CloudFile (etc) by changing the classname if it should be and is not
* 2. Uploads the file to the cloud storage if it doesn't contain the placeholder
*
* @return File
*/
public function updateCloudStatus()
{
if ($this->inUpdate) {
return;
}
$this->inUpdate = true;
$cloud = CloudAssets::inst();
// does this file fall under a cloud bucket?
$bucket = $cloud->map($this->owner->getFilename());
if ($bucket) {
// does this file need to be wrapped?
$wrapClass = $cloud->getWrapperClass($this->owner->ClassName);
if (!empty($wrapClass)) {
if ($wrapClass != $this->owner->ClassName) {
$cloud->getLogger()->debug("CloudAssets: wrapping {$this->owner->ClassName} to {$wrapClass}. ID={$this->owner->ID}");
$this->owner->ClassName = $wrapClass;
$this->owner->write();
$wrapped = DataObject::get($wrapClass)->byID($this->owner->ID);
if ($wrapped->hasMethod('onAfterCloudWrap')) {
$wrapped->onAfterCloudWrap();
}
} else {
$wrapped = $this->owner;
}
// does this file need to be uploaded to storage?
if ($wrapped->canBeInCloud() && $wrapped->isCloudPutNeeded() && !Config::inst()->get('CloudAssets', 'uploads_disabled')) {
try {
if ($wrapped->hasMethod('onBeforeCloudPut')) {
$wrapped->onBeforeCloudPut();
}
$cloud->getLogger()->debug("CloudAssets: uploading file " . $wrapped->getFilename());
$bucket->put($wrapped);
$wrapped->setCloudMeta('LastPut', time());
$wrapped->CloudStatus = 'Live';
$wrapped->CloudSize = filesize($this->owner->getFullPath());
$wrapped->write();
$wrapped->convertToPlaceholder();
if ($wrapped->hasMethod('onAfterCloudPut')) {
$wrapped->onAfterCloudPut();
}
} catch (Exception $e) {
$wrapped->CloudStatus = 'Error';
$wrapped->write();
$cloud->getLogger()->error("CloudAssets: Failed bucket upload: " . $e->getMessage() . " for " . $wrapped->getFullPath());
// Fail silently for now. This will cause the local copy to be served.
}
} elseif ($wrapped->CloudStatus !== 'Live' && $wrapped->containsPlaceholder()) {
// If this is a duplicate file, update the status
// This shouldn't happen ever and won't happen often but when it does this will be helpful
$dup = File::get()->filter(array('Filename' => $wrapped->Filename, 'CloudStatus' => 'Live'))->first();
if ($dup && $dup->exists()) {
$cloud->getLogger()->warn("CloudAssets: fixing status for duplicate file: {$wrapped->ID} and {$dup->ID}");
$wrapped->CloudStatus = $dup->CloudStatus;
$wrapped->CloudSize = $dup->CloudSize;
$wrapped->CloudMetaJson = $dup->CloudMetaJson;
$wrapped->write();
}
}
$this->inUpdate = false;
return $wrapped;
}
}
$this->inUpdate = false;
return $this->owner;
}
示例10: getFilename
public function getFilename()
{
return parent::getFilename() . '/';
}
示例11: getPharDestination
/**
* @param File $file
*
* @return string
*/
private function getPharDestination(File $file)
{
return $this->pharDirectory . DIRECTORY_SEPARATOR . $file->getFilename();
}
示例12: testFilename
public function testFilename()
{
$filename = new Filename('foo.phar');
$file = new File($filename, 'bar');
$this->assertSame($filename, $file->getFilename());
}
示例13: getThumbnailURLForFile
/**
* @param File $file
* @return string
*/
protected function getThumbnailURLForFile(File $file)
{
if ($file && $file->exists() && file_exists(Director::baseFolder() . '/' . $file->getFilename())) {
if ($file->hasMethod('getThumbnail')) {
return $file->getThumbnail($this->getConfig('previewMaxWidth'), $this->getConfig('previewMaxHeight'))->getURL();
} elseif ($file->hasMethod('getThumbnailURL')) {
return $file->getThumbnailURL($this->getConfig('previewMaxWidth'), $this->getConfig('previewMaxHeight'));
} elseif ($file->hasMethod('SetRatioSize')) {
return $file->SetRatioSize($this->getConfig('previewMaxWidth'), $this->getConfig('previewMaxHeight'))->getURL();
} else {
return $file->Icon();
}
}
return false;
}
示例14: toHtml
/**
* Converts the code to HTML
*
* @param File $file File to render
* @param Tool_Result $res Tool result to integrate
*
* @return string HTML
*/
public function toHtml(File $file, Tool_Result $res = null)
{
return '<div class="image">' . '<img' . ' src="' . htmlspecialchars($file->getLink('raw')) . '"' . ' alt="' . htmlspecialchars($file->getFilename()) . '"' . '/>' . '</div>';
}
示例15: link
/**
* @param File $phar
* @param string $destination
*/
private function link(File $phar, $destination)
{
$this->output->writeInfo(sprintf('Symlinking %s to %s', $phar->getFilename(), $destination));
symlink($this->pharDirectory . DIRECTORY_SEPARATOR . $phar->getFilename(), $destination);
}