本文整理汇总了PHP中JFolder::cleanPath方法的典型用法代码示例。如果您正苦于以下问题:PHP JFolder::cleanPath方法的具体用法?PHP JFolder::cleanPath怎么用?PHP JFolder::cleanPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFolder
的用法示例。
在下文中一共展示了JFolder::cleanPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThumbnail
function getThumbnail($filename, $size = null, $options = array(), $relativePath = true, $cachePath = null)
{
$config =& hikashop_config();
$scalemode = 'inside';
$jconf = JFactory::getConfig();
$jdebug = $jconf->get('debug');
$ret = new stdClass();
$ret->success = false;
$ret->path = $filename;
$ret->height = 0;
$ret->width = 0;
$ret->req_height = 0;
$ret->req_width = 0;
$fullFilename = $filename;
if ($relativePath === true) {
$fullFilename = $this->uploadFolder . $filename;
}
if (is_string($relativePath)) {
$fullFilename = $relativePath . $filename;
}
$clean_filename = $fullFilename;
try {
$clean_filename = JPath::clean(realpath($fullFilename));
if (JPATH_ROOT != '' && strpos($clean_filename, JPath::clean(JPATH_ROOT)) !== 0) {
if (!defined('MULTISITES_MASTER_ROOT_PATH') || MULTISITES_MASTER_ROOT_PATH == '' || strpos($clean_filename, JPath::clean(MULTISITES_MASTER_ROOT_PATH)) !== 0) {
return $ret;
}
}
} catch (Exception $e) {
}
if ($cachePath !== false && empty($cachePath)) {
$cachePath = $this->uploadFolder;
} else {
if ($cachePath !== false) {
$cachePath = rtrim(JFolder::cleanPath($cachePath), DS) . DS;
}
}
if (!JFile::exists($fullFilename)) {
if ($jdebug && !empty($filename)) {
$p = JProfiler::getInstance('Application');
$dbgtrace = debug_backtrace();
$dbgfile = str_replace('\\', '/', $dbgtrace[0]['file']);
$dbgline = $dbgtrace[0]['line'];
unset($dbgtrace);
$p->mark('HikaShop image [' . $fullFilename . '] does not exists (from: ' . substr($dbgfile, strrpos($dbgfile, '/') + 1) . ':' . $dbgline . ')');
}
if (!isset($options['default'])) {
return $ret;
}
$ret->path = $filename = $config->get('default_image');
if ($ret->path == 'barcode.png') {
$fullFilename = HIKASHOP_MEDIA . 'images' . DS . $ret->path;
$ret->url = HIKASHOP_IMAGES . '/' . $ret->path;
$ret->origin_url = HIKASHOP_IMAGES . '/' . $ret->path;
$ret->filename = $ret->path;
} else {
$fullFilename = $this->uploadFolder . $ret->path;
}
if (!JFile::exists($fullFilename)) {
return $ret;
}
$clean_filename = JPath::clean(realpath($fullFilename));
unset($ret->url);
unset($ret->filename);
}
if (empty($size) || !is_array($size) || !isset($size['x']) && !isset($size[0]) && !isset($size['width'])) {
$size = array('x' => (int) $config->get('thumbnail_x', 100), 'y' => (int) $config->get('thumbnail_y', 100));
}
if (isset($size['width'])) {
$size = array('x' => (int) $size['width'], 'y' => (int) $size['height']);
}
if (!isset($size['x'])) {
$size = array('x' => (int) $size[0], 'y' => (int) $size[1]);
}
$optString = '';
if (!empty($options['forcesize'])) {
$optString .= 'f';
}
if (!empty($options['grayscale'])) {
$optString .= 'g';
}
if (!empty($options['blur'])) {
$optString .= 'b';
}
if (!empty($options['scale'])) {
switch ($options['scale']) {
case 'outside':
$scalemode = 'outside';
$optString .= 'sO';
case 'inside':
break;
}
}
if (!empty($options['background']) && is_string($options['background']) && strtolower($options['background']) != '#ffffff') {
$optString .= 'c' . trim(strtoupper($options['background']), '#');
}
if (!empty($options['radius']) && (int) $options['radius'] > 2) {
$optString .= 'r' . (int) $options['radius'];
}
$destFolder = 'thumbnails' . DS . $size['y'] . 'x' . $size['x'] . $optString;
//.........这里部分代码省略.........