當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JFolder::cleanPath方法代碼示例

本文整理匯總了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;
//.........這裏部分代碼省略.........
開發者ID:q0821,項目名稱:esportshop,代碼行數:101,代碼來源:image.php


注:本文中的JFolder::cleanPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。