本文整理汇总了PHP中AssetFileModel::getFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetFileModel::getFolder方法的具体用法?PHP AssetFileModel::getFolder怎么用?PHP AssetFileModel::getFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetFileModel
的用法示例。
在下文中一共展示了AssetFileModel::getFolder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getPathsForLocalAsset
/**
* Get paths for a local asset
*
* @param AssetFileModel $image
*/
private function _getPathsForLocalAsset(AssetFileModel $image)
{
$assetSourcePath = craft()->config->parseEnvironmentString($image->getSource()->settings['url']);
if (strrpos($assetSourcePath, 'http') !== false) {
$parsedUrl = parse_url($assetSourcePath);
$assetSourcePath = $parsedUrl['path'];
}
$this->sourcePath = ImagerService::fixSlashes(craft()->config->parseEnvironmentString($image->getSource()->settings['path']) . $image->getFolder()->path);
$this->targetPath = ImagerService::fixSlashes(craft()->imager->getSetting('imagerSystemPath') . $assetSourcePath . $image->getFolder()->path) . $image->id . '/';
$this->targetUrl = craft()->imager->getSetting('imagerUrl') . ImagerService::fixSlashes($assetSourcePath . $image->getFolder()->path, true) . $image->id . '/';
$this->sourceFilename = $this->targetFilename = $image->filename;
}
示例2: generateUrl
/**
* Generate a URL for a given Assets file in a Source Type.
*
* @param BaseAssetSourceType $sourceType
* @param AssetFileModel $file
*
* @return string
*/
public static function generateUrl(BaseAssetSourceType $sourceType, AssetFileModel $file)
{
$baseUrl = $sourceType->getBaseUrl();
$folderPath = $file->getFolder()->path;
$fileName = $file->filename;
$appendix = static::getUrlAppendix($sourceType, $file);
return $baseUrl . $folderPath . $fileName . $appendix;
}
示例3: _getS3Path
/**
* Get a file's S3 path.
*
* @param AssetFileModel $file
* @param $settings The source settings to use.
*
* @return string
*/
private function _getS3Path(AssetFileModel $file, $settings = null)
{
$folder = $file->getFolder();
return $this->_getPathPrefix($settings) . $folder->path . $file->filename;
}
示例4: finalizeTransfer
/**
* Finalize a file transfer between sources for the provided file.
*
* @param AssetFileModel $file The assetFileModel representing the file we're finalizing the transfer for.
*
* @return null
*/
public function finalizeTransfer(AssetFileModel $file)
{
$this->deleteSourceFile($file->getFolder()->path . $file->filename);
}
示例5: _getFileSystemPath
/**
* Get a file's system path.
*
* @param AssetFileModel $file
*
* @return string
*/
private function _getFileSystemPath(AssetFileModel $file)
{
$folder = $file->getFolder();
$fileSourceType = craft()->assetSources->getSourceTypeById($file->sourceId);
return $this->getSourceFileSystemPath($fileSourceType) . $folder->path . $file->filename;
}
示例6: transformExists
/**
* Return true if a transform exists at the location for a file.
*
* @param AssetFileModel $file
* @param $location
* @return mixed
*/
public function transformExists(AssetFileModel $file, $location)
{
$this->_prepareForRequests();
return (bool) @$this->_s3->getObjectInfo($this->getSettings()->bucket, $this->_getPathPrefix() . $file->getFolder()->fullPath . $location . '/' . $file->filename);
}
示例7: getUrlforTransformByFile
/**
* Get URL for a transform by File Model and transform.
*
* @param AssetFileModel $file
* @param $transform
* @return string
*/
public function getUrlforTransformByFile($file, $transform)
{
// Create URL to the image
$sourceType = craft()->assetSources->getSourceTypeById($file->sourceId);
$baseUrl = $sourceType->getBaseUrl();
$folderPath = $baseUrl . $file->getFolder()->fullPath;
$transformPath = $this->getTransformSubpath($transform);
return $folderPath . $transformPath . $file->filename;
}
示例8: getUrlForFile
/**
* Get URL for a file.
*
* @param AssetFileModel $file
* @param $transform
* @return string
*/
public function getUrlForFile(AssetFileModel $file, $transform = null)
{
$returnPlaceholder = false;
if (!$transform || !in_array(IOHelper::getExtension($file->filename), ImageHelper::getAcceptedExtensions())) {
$sourceType = craft()->assetSources->getSourceTypeById($file->sourceId);
$base = $sourceType->getBaseUrl();
return $base . $file->getFolder()->fullPath . $file->filename;
}
// Get the transform index model
$existingTransformData = craft()->assetTransforms->getTransformIndex($file, $transform);
// Does the file actually exist?
if ($existingTransformData->fileExists) {
return craft()->assetTransforms->getUrlforTransformByFile($file, $transform);
} else {
// File doesn't exist yet - load the TransformLoader and set the placeholder URL flag
$placeholderUrl = UrlHelper::getResourceUrl('images/blank.gif');
if (!$this->_includedTransformLoader) {
$entityPlaceholderUrl = htmlspecialchars($placeholderUrl, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
$spinnerUrl = UrlHelper::getResourceurl('images/spinner_transform.gif');
$actionUrl = UrlHelper::getActionUrl('assets/generateTransform');
craft()->templates->includeJsResource('js/TransformLoader.js');
craft()->templates->includeJs('new TransformLoader(' . JsonHelper::encode($placeholderUrl) . ', ' . JsonHelper::encode($entityPlaceholderUrl) . ', ' . JsonHelper::encode($spinnerUrl) . ', ' . JsonHelper::encode($actionUrl) . ');');
$this->_includedTransformLoader = true;
}
return $placeholderUrl . '#' . $existingTransformData->id;
}
}
示例9: _getRackspacePath
/**
* Get a file's S3 path.
*
* @param AssetFileModel $file
*
* @return string
*/
private function _getRackspacePath(AssetFileModel $file)
{
$folder = $file->getFolder();
return $this->_getPathPrefix() . $folder->path . $file->filename;
}
示例10: getAssetFilePath
/**
* @param AssetFileModel $asset
*
* @return string
*/
protected function getAssetFilePath(AssetFileModel $asset)
{
return $asset->getSource()->getSourceType()->getBasePath() . $asset->getFolder()->path . $asset->filename;
}
示例11: transformExists
/**
* Return true if a transform exists at the location for a file.
*
* @param AssetFileModel $file
* @param $location
* @return mixed
*/
public function transformExists(AssetFileModel $file, $location)
{
return (bool) $this->_getObjectInfo($this->_getPathPrefix() . $file->getFolder()->fullPath . $location . '/' . $file->filename);
}
示例12: copyTransform
/**
* Copy a transform for a file from source location to target location.
*
* @param AssetFileModel $file
* @param $source
* @param $target
* @return mixed
*/
public function copyTransform(AssetFileModel $file, $source, $target)
{
$fileFolder = $file->getFolder();
$basePath = $this->_getSourceFileSystemPath() . $fileFolder->fullPath;
IOHelper::copyFile($basePath . $source . '/' . $file->filename, $basePath . $target . '/' . $file->filename);
}