| Total Complexity | 109 |
| Total Lines | 675 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like ImageManager often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ImageManager, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 17 | class ImageManager |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Configuration array. |
||
| 21 | */ |
||
| 22 | var $config; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Array of directory information. |
||
| 26 | */ |
||
| 27 | var $dirs; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Constructor. Create a new Image Manager instance. |
||
| 31 | * @param array $config configuration array, see config.inc.php |
||
| 32 | */ |
||
| 33 | function ImageManager($config) |
||
|
|
|||
| 34 | { |
||
| 35 | $this->config = $config; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Get the base directory. |
||
| 40 | * @return string base dir, see config.inc.php |
||
| 41 | */ |
||
| 42 | function getBaseDir() |
||
| 43 | { |
||
| 44 | Return $this->config['base_dir']; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Get the base URL. |
||
| 49 | * @return string base url, see config.inc.php |
||
| 50 | */ |
||
| 51 | function getBaseURL() |
||
| 52 | { |
||
| 53 | Return $this->config['base_url']; |
||
| 54 | } |
||
| 55 | |||
| 56 | function isValidBase() |
||
| 57 | { |
||
| 58 | return is_dir($this->getBaseDir()); |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Get the tmp file prefix. |
||
| 63 | * @return string tmp file prefix. |
||
| 64 | */ |
||
| 65 | function getTmpPrefix() |
||
| 66 | { |
||
| 67 | Return $this->config['tmp_prefix']; |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Get the sub directories in the base dir. |
||
| 72 | * Each array element contain |
||
| 73 | * the relative path (relative to the base dir) as key and the |
||
| 74 | * full path as value. |
||
| 75 | * @return array of sub directries |
||
| 76 | * <code>array('path name' => 'full directory path', ...)</code> |
||
| 77 | */ |
||
| 78 | function getDirs() |
||
| 79 | { |
||
| 80 | if(is_null($this->dirs)) |
||
| 81 | { |
||
| 82 | $dirs = $this->_dirs($this->getBaseDir(),'/'); |
||
| 83 | ksort($dirs); |
||
| 84 | $this->dirs = $dirs; |
||
| 85 | } |
||
| 86 | return $this->dirs; |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Recursively travese the directories to get a list |
||
| 91 | * of accessable directories. |
||
| 92 | * @param string $base the full path to the current directory |
||
| 93 | * @param string $path the relative path name |
||
| 94 | * @return array of accessiable sub-directories |
||
| 95 | * <code>array('path name' => 'full directory path', ...)</code> |
||
| 96 | */ |
||
| 97 | function _dirs($base, $path) |
||
| 98 | { |
||
| 99 | $base = Files::fixPath($base); |
||
| 100 | $dirs = array(); |
||
| 101 | |||
| 102 | if($this->isValidBase() == false) |
||
| 103 | return $dirs; |
||
| 104 | |||
| 105 | $d = @dir($base); |
||
| 106 | |||
| 107 | while (false !== ($entry = $d->read())) |
||
| 108 | { |
||
| 109 | //If it is a directory, and it doesn't start with |
||
| 110 | // a dot, and if is it not the thumbnail directory |
||
| 111 | if(is_dir($base.$entry) |
||
| 112 | && substr($entry,0,1) != '.' |
||
| 113 | && $this->isThumbDir($entry) == false) |
||
| 114 | { |
||
| 115 | $relative = Files::fixPath($path.$entry); |
||
| 116 | $fullpath = Files::fixPath($base.$entry); |
||
| 117 | $dirs[$relative] = $fullpath; |
||
| 118 | $dirs = array_merge($dirs, $this->_dirs($fullpath, $relative)); |
||
| 119 | } |
||
| 120 | } |
||
| 121 | $d->close(); |
||
| 122 | |||
| 123 | Return $dirs; |
||
| 124 | } |
||
| 125 | |||
| 126 | /** |
||
| 127 | * Get all the files and directories of a relative path. |
||
| 128 | * @param string $path relative path to be base path. |
||
| 129 | * @return array of file and path information. |
||
| 130 | * <code>array(0=>array('relative'=>'fullpath',...), 1=>array('filename'=>fileinfo array(),...)</code> |
||
| 131 | * fileinfo array: <code>array('url'=>'full url', |
||
| 132 | * 'relative'=>'relative to base', |
||
| 133 | * 'fullpath'=>'full file path', |
||
| 134 | * 'image'=>imageInfo array() false if not image, |
||
| 135 | * 'stat' => filestat)</code> |
||
| 136 | */ |
||
| 137 | function getFiles($path) |
||
| 138 | { |
||
| 139 | $files = array(); |
||
| 140 | $dirs = array(); |
||
| 141 | |||
| 142 | if($this->isValidBase() == false) |
||
| 143 | return array($files,$dirs); |
||
| 144 | |||
| 145 | $path = Files::fixPath($path); |
||
| 146 | $base = Files::fixPath($this->getBaseDir()); |
||
| 147 | $fullpath = Files::makePath($base,$path); |
||
| 148 | |||
| 149 | |||
| 150 | $d = @dir($fullpath); |
||
| 151 | |||
| 152 | while (false !== ($entry = $d->read())) |
||
| 153 | { |
||
| 154 | //not a dot file or directory |
||
| 155 | if(substr($entry,0,1) != '.') |
||
| 156 | { |
||
| 157 | if(is_dir($fullpath.$entry) |
||
| 158 | && $this->isThumbDir($entry) == false) |
||
| 159 | { |
||
| 160 | $relative = Files::fixPath($path.$entry); |
||
| 161 | $full = Files::fixPath($fullpath.$entry); |
||
| 162 | $count = $this->countFiles($full); |
||
| 163 | $dirs[$relative] = array('fullpath'=>$full,'entry'=>$entry,'count'=>$count); |
||
| 164 | } |
||
| 165 | else if(is_file($fullpath.$entry) && $this->isThumb($entry)==false && $this->isTmpFile($entry) == false) |
||
| 166 | { |
||
| 167 | $img = $this->getImageInfo($fullpath.$entry); |
||
| 168 | |||
| 169 | if(!(!is_array($img)&&$this->config['validate_images'])) |
||
| 170 | { |
||
| 171 | $file['url'] = Files::makePath($this->config['base_url'],$path).$entry; |
||
| 172 | $file['relative'] = $path.$entry; |
||
| 173 | $file['fullpath'] = $fullpath.$entry; |
||
| 174 | $file['image'] = $img; |
||
| 175 | $file['stat'] = stat($fullpath.$entry); |
||
| 176 | $files[$entry] = $file; |
||
| 177 | } |
||
| 178 | } |
||
| 179 | } |
||
| 180 | } |
||
| 181 | $d->close(); |
||
| 182 | ksort($dirs); |
||
| 183 | ksort($files); |
||
| 184 | |||
| 185 | Return array($dirs, $files); |
||
| 186 | } |
||
| 187 | |||
| 188 | /** |
||
| 189 | * Count the number of files and directories in a given folder |
||
| 190 | * minus the thumbnail folders and thumbnails. |
||
| 191 | */ |
||
| 192 | function countFiles($path) |
||
| 193 | { |
||
| 194 | $total = 0; |
||
| 195 | |||
| 196 | if(is_dir($path)) |
||
| 197 | { |
||
| 198 | $d = @dir($path); |
||
| 199 | |||
| 200 | while (false !== ($entry = $d->read())) |
||
| 201 | { |
||
| 202 | //echo $entry."<br>"; |
||
| 203 | if(substr($entry,0,1) != '.' |
||
| 204 | && $this->isThumbDir($entry) == false |
||
| 205 | && $this->isTmpFile($entry) == false |
||
| 206 | && $this->isThumb($entry) == false) |
||
| 207 | { |
||
| 208 | $total++; |
||
| 209 | } |
||
| 210 | } |
||
| 211 | $d->close(); |
||
| 212 | } |
||
| 213 | return $total; |
||
| 214 | } |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Get image size information. |
||
| 218 | * @param string $file the image file |
||
| 219 | * @return array of getImageSize information, |
||
| 220 | * false if the file is not an image. |
||
| 221 | */ |
||
| 222 | function getImageInfo($file) |
||
| 223 | { |
||
| 224 | Return @getImageSize($file); |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Check if the file contains the thumbnail prefix. |
||
| 229 | * @param string $file filename to be checked |
||
| 230 | * @return true if the file contains the thumbnail prefix, false otherwise. |
||
| 231 | */ |
||
| 232 | function isThumb($file) |
||
| 239 | } |
||
| 240 | |||
| 241 | /** |
||
| 242 | * Check if the given directory is a thumbnail directory. |
||
| 243 | * @param string $entry directory name |
||
| 244 | * @return true if it is a thumbnail directory, false otherwise |
||
| 245 | */ |
||
| 246 | function isThumbDir($entry) |
||
| 247 | { |
||
| 248 | if($this->config['thumbnail_dir'] == false |
||
| 249 | || strlen(trim($this->config['thumbnail_dir'])) == 0) |
||
| 250 | Return false; |
||
| 251 | else |
||
| 252 | Return ($entry == $this->config['thumbnail_dir']); |
||
| 253 | } |
||
| 254 | |||
| 255 | /** |
||
| 256 | * Check if the given file is a tmp file. |
||
| 257 | * @param string $file file name |
||
| 258 | * @return boolean true if it is a tmp file, false otherwise |
||
| 259 | */ |
||
| 260 | function isTmpFile($file) |
||
| 261 | { |
||
| 262 | $len = strlen($this->config['tmp_prefix']); |
||
| 263 | if(substr($file,0,$len)==$this->config['tmp_prefix']) |
||
| 264 | Return true; |
||
| 265 | else |
||
| 266 | Return false; |
||
| 267 | } |
||
| 268 | |||
| 269 | /** |
||
| 270 | * For a given image file, get the respective thumbnail filename |
||
| 271 | * no file existence check is done. |
||
| 272 | * @param string $fullpathfile the full path to the image file |
||
| 273 | * @return string of the thumbnail file |
||
| 274 | */ |
||
| 275 | function getThumbName($fullpathfile) |
||
| 276 | { |
||
| 277 | $path_parts = pathinfo($fullpathfile); |
||
| 278 | |||
| 279 | $thumbnail = $this->config['thumbnail_prefix'].$path_parts['basename']; |
||
| 280 | |||
| 281 | if($this->config['safe_mode'] == true |
||
| 282 | || strlen(trim($this->config['thumbnail_dir'])) == 0) |
||
| 283 | { |
||
| 284 | Return Files::makeFile($path_parts['dirname'],$thumbnail); |
||
| 285 | } |
||
| 286 | else |
||
| 287 | { |
||
| 288 | if(strlen(trim($this->config['thumbnail_dir'])) > 0) |
||
| 289 | { |
||
| 290 | $path = Files::makePath($path_parts['dirname'],$this->config['thumbnail_dir']); |
||
| 291 | if(!is_dir($path)) |
||
| 292 | Files::createFolder($path); |
||
| 293 | Return Files::makeFile($path,$thumbnail); |
||
| 294 | } |
||
| 295 | else //should this ever happen? |
||
| 296 | { |
||
| 297 | //error_log('ImageManager: Error in creating thumbnail name'); |
||
| 298 | } |
||
| 299 | } |
||
| 300 | } |
||
| 301 | |||
| 302 | /** |
||
| 303 | * Similar to getThumbName, but returns the URL, base on the |
||
| 304 | * given base_url in config.inc.php |
||
| 305 | * @param string $relative the relative image file name, |
||
| 306 | * relative to the base_dir path |
||
| 307 | * @return string the url of the thumbnail |
||
| 308 | */ |
||
| 309 | function getThumbURL($relative) |
||
| 310 | { |
||
| 311 | $path_parts = pathinfo($relative); |
||
| 312 | $thumbnail = $this->config['thumbnail_prefix'].$path_parts['basename']; |
||
| 313 | if($path_parts['dirname']=='\\') $path_parts['dirname']='/'; |
||
| 314 | |||
| 315 | if($this->config['safe_mode'] == true |
||
| 316 | || strlen(trim($this->config['thumbnail_dir'])) == 0) |
||
| 317 | { |
||
| 318 | $path = Files::fixPath($path_parts['dirname']); |
||
| 319 | $url_path = Files::makePath($this->getBaseURL(), $path); |
||
| 320 | Return Files::makeFile($url_path,$thumbnail); |
||
| 321 | } |
||
| 322 | else |
||
| 323 | { |
||
| 324 | if(strlen(trim($this->config['thumbnail_dir'])) > 0) |
||
| 325 | { |
||
| 326 | $path = Files::makePath($path_parts['dirname'],$this->config['thumbnail_dir']); |
||
| 327 | $url_path = Files::makePath($this->getBaseURL(), $path); |
||
| 328 | Return Files::makeFile($url_path,$thumbnail); |
||
| 329 | } |
||
| 330 | else //should this ever happen? |
||
| 331 | { |
||
| 332 | //error_log('ImageManager: Error in creating thumbnail url'); |
||
| 333 | } |
||
| 334 | |||
| 335 | } |
||
| 336 | } |
||
| 337 | |||
| 338 | /** |
||
| 339 | * Check if the given path is part of the subdirectories |
||
| 340 | * under the base_dir. |
||
| 341 | * @param string $path the relative path to be checked |
||
| 342 | * @return boolean true if the path exists, false otherwise |
||
| 343 | */ |
||
| 344 | function validRelativePath($path) |
||
| 345 | { |
||
| 346 | $dirs = $this->getDirs(); |
||
| 347 | if($path == '/' || $path == '') |
||
| 348 | Return true; |
||
| 349 | //check the path given in the url against the |
||
| 350 | //list of paths in the system. |
||
| 351 | for($i = 0; $i < count($dirs); $i++) |
||
| 352 | { |
||
| 353 | $key = key($dirs); |
||
| 354 | //we found the path |
||
| 355 | if($key == $path) |
||
| 356 | Return true; |
||
| 357 | |||
| 358 | next($dirs); |
||
| 359 | } |
||
| 360 | Return false; |
||
| 361 | } |
||
| 362 | |||
| 363 | /** |
||
| 364 | * Process uploaded files, assumes the file is in |
||
| 365 | * $_FILES['upload'] and $_POST['dir'] is set. |
||
| 366 | * The dir must be relative to the base_dir and exists. |
||
| 367 | * If 'validate_images' is set to true, only file with |
||
| 368 | * image dimensions will be accepted. |
||
| 369 | * @return null |
||
| 370 | */ |
||
| 371 | function processUploads() |
||
| 387 | } |
||
| 388 | } |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Process upload files. The file must be an |
||
| 392 | * uploaded file. If 'validate_images' is set to |
||
| 393 | * true, only images will be processed. Any duplicate |
||
| 394 | * file will be renamed. See Files::copyFile for details |
||
| 395 | * on renaming. |
||
| 396 | * @param string $relative the relative path where the file |
||
| 397 | * should be copied to. |
||
| 398 | * @param array $file the uploaded file from $_FILES |
||
| 399 | * @return boolean true if the file was processed successfully, |
||
| 400 | * false otherwise |
||
| 401 | */ |
||
| 402 | function _processFiles($relative, $file) |
||
| 403 | { |
||
| 404 | |||
| 405 | if($file['error']!=0) |
||
| 406 | { |
||
| 407 | Return false; |
||
| 408 | } |
||
| 409 | |||
| 410 | if(!is_file($file['tmp_name'])) |
||
| 411 | { |
||
| 412 | Return false; |
||
| 413 | } |
||
| 414 | |||
| 415 | if(!is_uploaded_file($file['tmp_name'])) |
||
| 416 | { |
||
| 417 | Files::delFile($file['tmp_name']); |
||
| 418 | Return false; |
||
| 419 | } |
||
| 420 | |||
| 421 | |||
| 422 | if($this->config['validate_images'] == true) |
||
| 423 | { |
||
| 424 | $imgInfo = @getImageSize($file['tmp_name']); |
||
| 425 | if(!is_array($imgInfo)) |
||
| 426 | { |
||
| 427 | Files::delFile($file['tmp_name']); |
||
| 428 | Return false; |
||
| 429 | } |
||
| 430 | } |
||
| 431 | |||
| 432 | //now copy the file |
||
| 433 | $path = Files::makePath($this->getBaseDir(),$relative); |
||
| 434 | $result = Files::copyFile($file['tmp_name'], $path, $file['name']); |
||
| 435 | |||
| 436 | //no copy error |
||
| 437 | if(!is_int($result)) |
||
| 438 | { |
||
| 439 | $dimensionsIndex = isset($_REQUEST['uploadSize']) ? $_REQUEST['uploadSize'] : 0; |
||
| 440 | // If maximum size is specified, constrain image to it. |
||
| 441 | if ($this->config['maxWidth'][$dimensionsIndex] > 0 && $this->config['maxHeight'][$dimensionsIndex] > 0) |
||
| 442 | { |
||
| 443 | $img = Image_Transform::factory(IMAGE_CLASS); |
||
| 444 | $img->load($path . $result); |
||
| 445 | |||
| 446 | // image larger than max dimensions? |
||
| 447 | if ($img->img_x > $this->config['maxWidth'][$dimensionsIndex] || $img->img_y > $this->config['maxHeight'][$dimensionsIndex]) |
||
| 448 | { |
||
| 449 | $percentage = min($this->config['maxWidth'][$dimensionsIndex] / $img->img_x, $this->config['maxHeight'][$dimensionsIndex] / $img->img_y); |
||
| 450 | $img->scale($percentage); |
||
| 451 | } |
||
| 452 | |||
| 453 | $img->save($path . $result); |
||
| 454 | $img->free(); |
||
| 455 | } |
||
| 456 | } |
||
| 457 | |||
| 458 | //delete tmp files. |
||
| 459 | Files::delFile($file['tmp_name']); |
||
| 460 | Return false; |
||
| 461 | } |
||
| 462 | |||
| 463 | /** |
||
| 464 | * Get the URL of the relative file. |
||
| 465 | * basically appends the relative file to the |
||
| 466 | * base_url given in config.inc.php |
||
| 467 | * @param string $relative a file the relative to the base_dir |
||
| 468 | * @return string the URL of the relative file. |
||
| 469 | */ |
||
| 470 | function getFileURL($relative) |
||
| 471 | { |
||
| 472 | Return Files::makeFile($this->getBaseURL(),$relative); |
||
| 473 | } |
||
| 474 | |||
| 475 | /** |
||
| 476 | * Get the fullpath to a relative file. |
||
| 477 | * @param string $relative the relative file. |
||
| 478 | * @return string the full path, .ie. the base_dir + relative. |
||
| 479 | */ |
||
| 480 | function getFullPath($relative) |
||
| 481 | { |
||
| 482 | Return Files::makeFile($this->getBaseDir(),$relative);; |
||
| 483 | } |
||
| 484 | |||
| 485 | /** |
||
| 486 | * Get the default thumbnail. |
||
| 487 | * @return string default thumbnail, empty string if |
||
| 488 | * the thumbnail doesn't exist. |
||
| 489 | */ |
||
| 490 | function getDefaultThumb() |
||
| 491 | { |
||
| 492 | if(is_file($this->config['default_thumbnail'])) |
||
| 493 | Return $this->config['default_thumbnail']; |
||
| 494 | else |
||
| 495 | Return ''; |
||
| 496 | } |
||
| 497 | |||
| 498 | |||
| 499 | /** |
||
| 500 | * Get the thumbnail url to be displayed. |
||
| 501 | * If the thumbnail exists, and it is up-to-date |
||
| 502 | * the thumbnail url will be returns. If the |
||
| 503 | * file is not an image, a default image will be returned. |
||
| 504 | * If it is an image file, and no thumbnail exists or |
||
| 505 | * the thumbnail is out-of-date (i.e. the thumbnail |
||
| 506 | * modified time is less than the original file) |
||
| 507 | * then a thumbs.php?img=filename.jpg is returned. |
||
| 508 | * The thumbs.php url will generate a new thumbnail |
||
| 509 | * on the fly. If the image is less than the dimensions |
||
| 510 | * of the thumbnails, the image will be display instead. |
||
| 511 | * @param string $relative the relative image file. |
||
| 512 | * @return string the url of the thumbnail, be it |
||
| 513 | * actually thumbnail or a script to generate the |
||
| 514 | * thumbnail on the fly. |
||
| 515 | */ |
||
| 516 | function getThumbnail($relative) |
||
| 517 | { |
||
| 518 | $fullpath = Files::makeFile($this->getBaseDir(),$relative); |
||
| 519 | |||
| 520 | //not a file??? |
||
| 521 | if(!is_file($fullpath)) |
||
| 522 | Return $this->getDefaultThumb(); |
||
| 523 | |||
| 524 | $imgInfo = @getImageSize($fullpath); |
||
| 525 | |||
| 526 | //not an image |
||
| 527 | if(!is_array($imgInfo)) |
||
| 528 | Return $this->getDefaultThumb(); |
||
| 529 | |||
| 530 | //the original image is smaller than thumbnails, |
||
| 531 | //so just return the url to the original image. |
||
| 532 | if ($imgInfo[0] <= $this->config['thumbnail_width'] |
||
| 533 | && $imgInfo[1] <= $this->config['thumbnail_height']) |
||
| 534 | Return $this->getFileURL($relative); |
||
| 535 | |||
| 536 | $thumbnail = $this->getThumbName($fullpath); |
||
| 537 | |||
| 538 | //check for thumbnails, if exists and |
||
| 539 | // it is up-to-date, return the thumbnail url |
||
| 540 | if(is_file($thumbnail)) |
||
| 541 | { |
||
| 542 | if(filemtime($thumbnail) >= filemtime($fullpath)) |
||
| 543 | Return $this->getThumbURL($relative); |
||
| 544 | } |
||
| 545 | |||
| 546 | //well, no thumbnail was found, so ask the thumbs.php |
||
| 547 | //to generate the thumbnail on the fly. |
||
| 548 | Return 'thumbs.php?img='.rawurlencode($relative); |
||
| 549 | } |
||
| 550 | |||
| 551 | /** |
||
| 552 | * Delete and specified files. |
||
| 553 | * @return boolean true if delete, false otherwise |
||
| 554 | */ |
||
| 555 | function deleteFiles() |
||
| 556 | { |
||
| 557 | if(isset($_GET['delf'])) |
||
| 558 | $this->_delFile(rawurldecode($_GET['delf'])); |
||
| 559 | } |
||
| 560 | |||
| 561 | /** |
||
| 562 | * Delete and specified directories. |
||
| 563 | * @return boolean true if delete, false otherwise |
||
| 564 | */ |
||
| 565 | function deleteDirs() |
||
| 571 | } |
||
| 572 | |||
| 573 | /** |
||
| 574 | * Delete the relative file, and any thumbnails. |
||
| 575 | * @param string $relative the relative file. |
||
| 576 | * @return boolean true if deleted, false otherwise. |
||
| 577 | */ |
||
| 578 | function _delFile($relative) |
||
| 595 | } |
||
| 596 | |||
| 597 | /** |
||
| 598 | * Delete directories recursively. |
||
| 599 | * @param string $relative the relative path to be deleted. |
||
| 600 | * @return boolean true if deleted, false otherwise. |
||
| 601 | */ |
||
| 602 | function _delDir($relative) |
||
| 603 | { |
||
| 604 | $fullpath = Files::makePath($this->getBaseDir(),$relative); |
||
| 605 | if($this->countFiles($fullpath) <= 0) |
||
| 606 | return Files::delFolder($fullpath,true); //delete recursively. |
||
| 607 | else |
||
| 608 | Return false; |
||
| 609 | } |
||
| 610 | |||
| 611 | /** |
||
| 612 | * Create new directories. |
||
| 613 | * If in safe_mode, nothing happens. |
||
| 614 | * @return boolean true if created, false otherwise. |
||
| 615 | */ |
||
| 616 | function processNewDir() |
||
| 631 | } |
||
| 632 | } |
||
| 633 | |||
| 634 | /** |
||
| 635 | * Do some graphic library method checkings |
||
| 636 | * @param string $library the graphics library, GD, NetPBM, or IM. |
||
| 637 | * @param string $method the method to check. |
||
| 638 | * @return boolean true if able, false otherwise. |
||
| 639 | */ |
||
| 640 | function validGraphicMethods($library,$method) |
||
| 641 | { |
||
| 642 | switch ($library) |
||
| 643 | { |
||
| 654 | } |
||
| 655 | |||
| 656 | function _checkIMLibrary($method) |
||
| 663 | } |
||
| 664 | |||
| 665 | /** |
||
| 666 | * Check the GD library functionality. |
||
| 667 | * @param string $library the graphics library, GD, NetPBM, or IM. |
||
| 668 | * @return boolean true if able, false otherwise. |
||
| 669 | */ |
||
| 670 | function _checkGDLibrary($method) |
||
| 692 | } |
||
| 693 | } |
||
| 696 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.