Ignore:
Timestamp:
Nov 29, 2013, 2:48:55 PM (10 years ago)
Author:
mistic100
Message:

feature 2999 : Documentation of multisize classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/derivative.inc.php

    r25504 r25754  
    2020// +-----------------------------------------------------------------------+
    2121
    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 */
    2432final class SrcImage
    2533{
     
    2836  const DIM_NOT_GIVEN = 0x04;
    2937
     38  /** @var int */
    3039  public $id;
     40  /** @var string */
    3141  public $rel_path;
     42  /** @var int */
    3243  public $rotation = 0;
    33 
     44  /** @var int[] */
    3445  private $size=null;
     46  /** @var int */
    3547  private $flags=0;
    3648
    37   /*@param infos assoc array of data from images table*/
     49  /**
     50   * @param array $infos assoc array of data from images table
     51   */
    3852  function __construct($infos)
    3953  {
     
    89103  }
    90104
     105  /**
     106   * @return bool
     107   */
    91108  function is_original()
    92109  {
     
    94111  }
    95112
     113  /**
     114   * @return bool
     115   */
    96116  function is_mimetype()
    97117  {
     
    99119  }
    100120
     121  /**
     122   * @return string
     123   */
    101124  function get_path()
    102125  {
     
    104127  }
    105128
     129  /**
     130   * @return string
     131   */
    106132  function get_url()
    107133  {
     
    114140  }
    115141
     142  /**
     143   * @return bool
     144   */
    116145  function has_size()
    117146  {
     
    119148  }
    120149
    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   */
    122153  function get_size()
    123154  {
     
    138169
    139170
    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 */
    143176final class DerivativeImage
    144177{
     178  /** @var SrcImage */
    145179  public $src_image;
    146 
     180  /** @var array */
    147181  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   */
    153194  function __construct($type, SrcImage $src_image)
    154195  {
     
    166207  }
    167208
     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   */
    168215  static function thumb_url($infos)
    169216  {
     
    172219
    173220  /**
    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   */
    178228  static function url($type, $infos)
    179229  {
     
    194244  /**
    195245   * Return associative an array of all DerivativeImage for a specific image.
    196    * Disabled derivative types can be still found in the return mapped to an
     246   * Disabled derivative types can be still found in the return, mapped to an
    197247   * enabled derivative (e.g. the values are not unique in the return array).
    198248   * This is useful for any plugin/theme to just use $deriv[IMG_XLARGE] even if
     
    229279   * Disabled derivatives fallback to an enabled derivative.
    230280   *
    231    * @param string $type
     281   * @param string $type standard derivative param type (e.g. IMG_*)
    232282   * @param array|SrcImage $src_image array of info from db or SrcImage
    233283   * @return DerivativeImage|null null if $type not found
     
    255305  }
    256306
     307  /**
     308   * @todo : documentation of DerivativeImage::build
     309   */
    257310  private static function build($src, &$params, &$rel_path, &$rel_url, &$is_cached=null)
    258311  {
     
    335388  }
    336389
     390  /**
     391   * @return string
     392   */
    337393  function get_path()
    338394  {
     
    340396  }
    341397
     398  /**
     399   * @return string
     400   */
    342401  function get_url()
    343402  {
     
    353412  }
    354413
     414  /**
     415   * @return bool
     416   */
    355417  function same_as_source()
    356418  {
     
    358420  }
    359421
    360 
     422  /**
     423   * @return string one if IMG_* or 'Original'
     424   */
    361425  function get_type()
    362426  {
     
    366430  }
    367431
    368   /* returns the size of the derivative image*/
     432  /**
     433   * @return int[]
     434   */
    369435  function get_size()
    370436  {
     
    376442  }
    377443
     444  /**
     445   * Returns the size as CSS rule.
     446   *
     447   * @return string
     448   */
    378449  function get_size_css()
    379450  {
     
    385456  }
    386457
     458  /**
     459   * Returns the size as HTML attributes.
     460   *
     461   * @return string
     462   */
    387463  function get_size_htm()
    388464  {
     
    394470  }
    395471
     472  /**
     473   * Returns literal size: $widthx$height.
     474   *
     475   * @return string
     476   */
    396477  function get_size_hr()
    397478  {
     
    403484  }
    404485
     486  /**
     487   * @param int $maxw
     488   * @param int $mawh
     489   * @return int[]
     490   */
    405491  function get_scaled_size($maxw, $maxh)
    406492  {
     
    427513  }
    428514
     515  /**
     516   * Returns the scaled size as HTML attributes.
     517   *
     518   * @param int $maxw
     519   * @param int $mawh
     520   * @return string
     521   */
    429522  function get_scaled_size_htm($maxw=9999, $maxh=9999)
    430523  {
     
    436529  }
    437530
     531  /**
     532   * @return bool
     533   */
    438534  function is_cached()
    439535  {
Note: See TracChangeset for help on using the changeset viewer.