Changeset 6857
- Timestamp:
- Apr 30, 2008, 4:09:16 AM (14 years ago)
- Location:
- OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img.php
r6856 r6857 258 258 function create_cache($output_gdimg) 259 259 { 260 $this->create_cache_subdir($this->cache_fullpath, $this->cache_dir); 261 $this->generator->createCache($this->cache_fullpath, $output_gdimg); 260 $this->generator->createCache($this->cache_fullpath, $this->cache_dir, $output_gdimg); 262 261 } 263 262 … … 267 266 function create_cache_from_raw_img() 268 267 { 269 $this->create_cache_subdir($this->cache_fullpath, $this->cache_dir); 270 $this->generator->createCacheFromRawImage($this->cache_fullpath, $this->raw_img); 271 } 272 273 /** 274 * キャッシュ用サブディレクトリの作成 275 * @access protected 276 */ 277 function create_cache_subdir($cache_fullpath, $cache_dir) 278 { 279 $subdir = dirname($cache_fullpath); 280 if (!is_dir($subdir)) { 281 // mkdir recursive 282 $_dir = $cache_dir; 283 if (!is_dir($_dir) && !mkdir($_dir)) { 284 return false; 285 } 286 $relative_path = substr($subdir, strlen($cache_dir)+1); 287 $parts = explode('/', $relative_path); 288 foreach ($parts as $part) { 289 $_dir .= '/' . $part; 290 if (!is_dir($_dir) && !mkdir($_dir)) { 291 return false; 292 } 293 } 294 } 268 $this->generator->createCacheFromRawImage($this->cache_fullpath, $this->cache_dir, $this->raw_img); 295 269 } 296 270 -
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Generator.php
r6855 r6857 97 97 } 98 98 99 function createCacheFromRawImage($cache_fullpath, $ raw_img)99 function createCacheFromRawImage($cache_fullpath, $cache_dir, $raw_img) 100 100 { 101 $this->createCacheSubdir($cache_fullpath, $cache_dir); 102 101 103 if ($this->getOutputFormat() == 'png') { 102 104 touch($cache_fullpath); … … 110 112 } 111 113 112 function createCache($cache_fullpath, $ output_gdimg)114 function createCache($cache_fullpath, $cache_dir, $output_gdimg) 113 115 { 116 $this->createCacheSubdir($cache_fullpath, $cache_dir); 117 114 118 touch($cache_fullpath); 115 119 switch ($this->getOutputFormat()) { … … 125 129 imagepng($output_gdimg, $cache_fullpath); 126 130 break; 131 } 132 } 133 134 function createCacheSubdir($cache_fullpath, $cache_dir) 135 { 136 $subdir = dirname($cache_fullpath); 137 if (!is_dir($subdir)) { 138 // mkdir recursive 139 $_dir = $cache_dir; 140 if (!is_dir($_dir) && !mkdir($_dir)) { 141 return false; 142 } 143 $relative_path = substr($subdir, strlen($cache_dir)+1); 144 $parts = explode('/', $relative_path); 145 foreach ($parts as $part) { 146 $_dir .= '/' . $part; 147 if (!is_dir($_dir) && !mkdir($_dir)) { 148 return false; 149 } 150 } 127 151 } 128 152 }
Note: See TracChangeset
for help on using the changeset viewer.