Changeset 25754 for trunk/include/derivative.inc.php
- Timestamp:
- Nov 29, 2013, 2:48:55 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/derivative.inc.php
r25504 r25754 20 20 // +-----------------------------------------------------------------------+ 21 21 22 /*A source image is used to get a derivative image. A source image is either the original file for a jpg or a 23 'representative' image of a non image file or a standard icon for the non-image file.*/ 22 /** 23 * @package Derivatives 24 */ 25 26 27 /** 28 * A source image is used to get a derivative image. It is either 29 * the original file for a jpg/png/... or a 'representative' image 30 * of a non image file or a standard icon for the non-image file. 31 */ 24 32 final class SrcImage 25 33 { … … 28 36 const DIM_NOT_GIVEN = 0x04; 29 37 38 /** @var int */ 30 39 public $id; 40 /** @var string */ 31 41 public $rel_path; 42 /** @var int */ 32 43 public $rotation = 0; 33 44 /** @var int[] */ 34 45 private $size=null; 46 /** @var int */ 35 47 private $flags=0; 36 48 37 /*@param infos assoc array of data from images table*/ 49 /** 50 * @param array $infos assoc array of data from images table 51 */ 38 52 function __construct($infos) 39 53 { … … 89 103 } 90 104 105 /** 106 * @return bool 107 */ 91 108 function is_original() 92 109 { … … 94 111 } 95 112 113 /** 114 * @return bool 115 */ 96 116 function is_mimetype() 97 117 { … … 99 119 } 100 120 121 /** 122 * @return string 123 */ 101 124 function get_path() 102 125 { … … 104 127 } 105 128 129 /** 130 * @return string 131 */ 106 132 function get_url() 107 133 { … … 114 140 } 115 141 142 /** 143 * @return bool 144 */ 116 145 function has_size() 117 146 { … … 119 148 } 120 149 121 /* @return a 2-element array containing width/height or null if dimensions are not available*/ 150 /** 151 * @return int[]|null 0=width, 1=height or null if fail to compute size 152 */ 122 153 function get_size() 123 154 { … … 138 169 139 170 140 /*Holds information (path, url, dimensions) about a derivative image. A derivative image is constructed from a source 141 image (SrcImage class) and derivative parameters (DerivativeParams class). 142 */ 171 /** 172 * Holds information (path, url, dimensions) about a derivative image. 173 * A derivative image is constructed from a source image (SrcImage class) 174 * and derivative parameters (DerivativeParams class). 175 */ 143 176 final class DerivativeImage 144 177 { 178 /** @var SrcImage */ 145 179 public $src_image; 146 180 /** @var array */ 147 181 private $params; 148 private $rel_path, $rel_url, $is_cached=true; 149 150 /* 151 @param type string of standard derivative param type (e.g. IMG_???) or a DerivativeParams object 152 @param src_image the source image of this derivative*/ 182 /** @var string */ 183 private $rel_path; 184 /** @var string */ 185 private $rel_url; 186 /** @var bool */ 187 private $is_cached=true; 188 189 /** 190 * @param string|DerivativeParams $type standard derivative param type (e.g. IMG_*) 191 * or a DerivativeParams object 192 * @param SrcImage $src_image the source image of this derivative 193 */ 153 194 function __construct($type, SrcImage $src_image) 154 195 { … … 166 207 } 167 208 209 /** 210 * Generates the url of a thumbnail. 211 * 212 * @param array|SrcImage $infos array of info from db or SrcImage 213 * @return string 214 */ 168 215 static function thumb_url($infos) 169 216 { … … 172 219 173 220 /** 174 @return derivative image url 175 @param type string of standard derivative param type (e.g. IMG_???) or a DerivativeParams object 176 @param infos assoc array of data from images table or a SrcImage object 177 */ 221 * Generates the url for a particular photo size. 222 * 223 * @param string|DerivativeParams $type standard derivative param type (e.g. IMG_*) 224 * or a DerivativeParams object 225 * @param array|SrcImage $infos array of info from db or SrcImage 226 * @return string 227 */ 178 228 static function url($type, $infos) 179 229 { … … 194 244 /** 195 245 * Return associative an array of all DerivativeImage for a specific image. 196 * Disabled derivative types can be still found in the return mapped to an246 * Disabled derivative types can be still found in the return, mapped to an 197 247 * enabled derivative (e.g. the values are not unique in the return array). 198 248 * This is useful for any plugin/theme to just use $deriv[IMG_XLARGE] even if … … 229 279 * Disabled derivatives fallback to an enabled derivative. 230 280 * 231 * @param string $type 281 * @param string $type standard derivative param type (e.g. IMG_*) 232 282 * @param array|SrcImage $src_image array of info from db or SrcImage 233 283 * @return DerivativeImage|null null if $type not found … … 255 305 } 256 306 307 /** 308 * @todo : documentation of DerivativeImage::build 309 */ 257 310 private static function build($src, &$params, &$rel_path, &$rel_url, &$is_cached=null) 258 311 { … … 335 388 } 336 389 390 /** 391 * @return string 392 */ 337 393 function get_path() 338 394 { … … 340 396 } 341 397 398 /** 399 * @return string 400 */ 342 401 function get_url() 343 402 { … … 353 412 } 354 413 414 /** 415 * @return bool 416 */ 355 417 function same_as_source() 356 418 { … … 358 420 } 359 421 360 422 /** 423 * @return string one if IMG_* or 'Original' 424 */ 361 425 function get_type() 362 426 { … … 366 430 } 367 431 368 /* returns the size of the derivative image*/ 432 /** 433 * @return int[] 434 */ 369 435 function get_size() 370 436 { … … 376 442 } 377 443 444 /** 445 * Returns the size as CSS rule. 446 * 447 * @return string 448 */ 378 449 function get_size_css() 379 450 { … … 385 456 } 386 457 458 /** 459 * Returns the size as HTML attributes. 460 * 461 * @return string 462 */ 387 463 function get_size_htm() 388 464 { … … 394 470 } 395 471 472 /** 473 * Returns literal size: $widthx$height. 474 * 475 * @return string 476 */ 396 477 function get_size_hr() 397 478 { … … 403 484 } 404 485 486 /** 487 * @param int $maxw 488 * @param int $mawh 489 * @return int[] 490 */ 405 491 function get_scaled_size($maxw, $maxh) 406 492 { … … 427 513 } 428 514 515 /** 516 * Returns the scaled size as HTML attributes. 517 * 518 * @param int $maxw 519 * @param int $mawh 520 * @return string 521 */ 429 522 function get_scaled_size_htm($maxw=9999, $maxh=9999) 430 523 { … … 436 529 } 437 530 531 /** 532 * @return bool 533 */ 438 534 function is_cached() 439 535 {
Note: See TracChangeset
for help on using the changeset viewer.