Changeset 12820 for trunk/include


Ignore:
Timestamp:
Jan 1, 2012, 10:10:43 PM (12 years ago)
Author:
rvelices
Message:

feature 2541 multisize

  • admin GUI for choosing derivative parameters + persistence
Location:
trunk/include
Files:
2 edited

Legend:

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

    r12797 r12820  
    279279
    280280/*how we generate a derivative image*/
    281 final class ImageParams
     281final class DerivativeParams
    282282{
    283283  public $type = IMG_CUSTOM;
     
    290290  }
    291291
     292  public function __sleep()
     293  {
     294      return array('last_mod_time', 'sizing');
     295  }
     296   
    292297  function add_url_tokens(&$tokens)
    293298  {
     
    298303  {
    299304    $sizing = SizingParams::from_url_tokens($tokens);
    300     $ret = new ImageParams($sizing);
     305    $ret = new DerivativeParams($sizing);
    301306    return $ret;
    302307  }
  • trunk/include/derivative_std_params.inc.php

    r12796 r12820  
    3535  private static $type_map = array();
    3636  private static $undefined_type_map = array();
    37  
     37
    3838  static function get_all_types()
    3939  {
    4040    return self::$all_types;
    4141  }
    42  
     42
    4343  static function get_all_type_map()
    4444  {
     
    5555    return self::$undefined_type_map;
    5656  }
    57  
     57
    5858  static function get_by_type($type)
    5959  {
    6060    return self::$all_type_map[$type];
    6161  }
    62  
     62
    6363  static function load_from_db()
    6464  {
    65     self::make_default();
     65    global $conf;
     66    $arr = @unserialize($conf['derivatives']);
     67    if (false!==$arr)
     68    {
     69      self::$type_map = $arr['d'];
     70    }
     71    else
     72    {
     73      self::make_default();
     74    }
    6675    self::build_maps();
    6776  }
     
    6978  static function load_from_file()
    7079  {
    71     self::make_default();
     80    global $conf;
     81    $arr = @unserialize(@file_get_contents(PHPWG_ROOT_PATH.$conf['data_location'].'derivatives.dat'));
     82    if (false!==$arr)
     83    {
     84      self::$type_map = $arr['d'];
     85    }
     86    else
     87    {
     88      self::make_default();
     89    }
     90    self::build_maps();
     91  }
     92
     93  static function set_and_save($map)
     94  {
     95    global $conf;
     96    self::$type_map = $map;
     97
     98    $ser = serialize( array(
     99      'd' => self::$type_map
     100      ) );
     101    conf_update_param('derivatives', addslashes($ser) );
     102    file_put_contents(PHPWG_ROOT_PATH.$conf['data_location'].'derivatives.dat', $ser);
    72103    self::build_maps();
    73104  }
     
    75106  static function make_default()
    76107  {
    77     //todo
    78     self::$type_map[IMG_SQUARE] = new ImageParams( SizingParams::square(100,100) );
    79     self::$type_map[IMG_THUMB] = new ImageParams( SizingParams::classic(144,144) );
    80     self::$type_map[IMG_SMALL] = new ImageParams( SizingParams::classic(240,240) );
    81     self::$type_map[IMG_MEDIUM] = new ImageParams( SizingParams::classic(432,432) );
    82     self::$type_map[IMG_LARGE] = new ImageParams( SizingParams::classic(648,576) );
    83     self::$type_map[IMG_XLARGE] = new ImageParams( SizingParams::classic(864,648) );
    84     self::$type_map[IMG_XXLARGE] = new ImageParams( SizingParams::classic(1200,900) );
     108    self::$type_map[IMG_SQUARE] = new DerivativeParams( SizingParams::square(100,100) );
     109    self::$type_map[IMG_THUMB] = new DerivativeParams( SizingParams::classic(144,144) );
     110    self::$type_map[IMG_SMALL] = new DerivativeParams( SizingParams::classic(240,240) );
     111    self::$type_map[IMG_MEDIUM] = new DerivativeParams( SizingParams::classic(432,432) );
     112    self::$type_map[IMG_LARGE] = new DerivativeParams( SizingParams::classic(648,576) );
     113    self::$type_map[IMG_XLARGE] = new DerivativeParams( SizingParams::classic(864,648) );
     114    self::$type_map[IMG_XXLARGE] = new DerivativeParams( SizingParams::classic(1200,900) );
    85115  }
    86  
     116
    87117  private static function build_maps()
    88118  {
     
    111141    }
    112142  }
    113  
     143
    114144}
    115145
Note: See TracChangeset for help on using the changeset viewer.