Changeset 12796 for trunk/include


Ignore:
Timestamp:
Dec 27, 2011, 6:26:44 AM (12 years ago)
Author:
rvelices
Message:

feature 2541 multisize

  • core implementation + usage on most public/admin pages
  • still to do: sync process, upload, gui/persistence for size parameters, migration script, center of interest ...
Location:
trunk/include
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/calendar_monthly.class.php

    r12118 r12796  
    351351    $page['chronology_date'][CDAY]=$day;
    352352    $query = '
    353 SELECT id, file,tn_ext,path, width, height, '.pwg_db_get_dayofweek($this->date_field).'-1 as dow';
     353SELECT id, file,representative_ext,path,width, height, '.pwg_db_get_dayofweek($this->date_field).'-1 as dow';
    354354    $query.= $this->inner_sql;
    355355    $query.= $this->get_date_where();
     
    360360
    361361    $row = pwg_db_fetch_assoc(pwg_query($query));
    362     $items[$day]['tn_url'] = get_thumbnail_url($row);
     362    $derivative = new DerivativeImage(IMG_SQUARE, new SrcImage($row));
     363    $items[$day]['derivative'] = $derivative;
    363364    $items[$day]['file'] = $row['file'];
    364     $items[$day]['path'] = $row['path'];
    365     $items[$day]['tn_ext'] = @$row['tn_ext'];
    366     $items[$day]['width'] = $row['width'];
    367     $items[$day]['height'] = $row['height'];
    368365    $items[$day]['dow'] = $row['dow'];
    369366  }
    370367
    371   if ( !empty($items)
    372       and $conf['calendar_month_cell_width']>0
    373       and $conf['calendar_month_cell_height']>0)
     368  if ( !empty($items) )
    374369  {
    375370    list($known_day) = array_keys($items);
     
    397392    }
    398393
    399     $cell_width = $conf['calendar_month_cell_width'];
    400     $cell_height = $conf['calendar_month_cell_height'];
     394    list($cell_width, $cell_height) = ImageStdParams::get_by_type(IMG_SQUARE)->sizing->ideal_size;
    401395
    402396    $tpl_weeks    = array();
     
    431425      else
    432426      {
    433         $thumb = get_thumbnail_path($items[$day]);
    434         $tn_size = @getimagesize($thumb);
    435 
    436         $tn_width = $tn_size[0];
    437         $tn_height = $tn_size[1];
     427        list($tn_width,$tn_height) = $items[$day]['derivative']->get_size();
    438428
    439429        // now need to fit the thumbnail of size tn_size within
     
    492482              'DOW'         => $dow,
    493483              'NB_ELEMENTS' => $items[$day]['nb_images'],
    494               'IMAGE'       => $items[$day]['tn_url'],
     484              'IMAGE'       => $items[$day]['derivative']->get_url(),
    495485              'U_IMG_LINK'  => $url,
    496486              'IMAGE_STYLE' => $css_style,
  • trunk/include/category_cats.inc.php

    r12546 r12796  
    190190    if ($row['level'] <= $user['level'])
    191191    {
    192       $row['tn_src'] = get_thumbnail_url($row);
     192      $row['tn_src'] = DerivativeImage::thumb_url($row);
    193193      $infos_of_image[$row['id']] = $row;
    194194    }
     
    237237    while ($row = pwg_db_fetch_assoc($result))
    238238    {
    239       $row['tn_src'] = get_thumbnail_url($row);
     239      $row['tn_src'] =  DerivativeImage::thumb_url($row);
    240240      $infos_of_image[$row['id']] = $row;
    241241    }
  • trunk/include/category_default.inc.php

    r12546 r12796  
    114114  $tpl_var = array(
    115115    'ID' => $row['id'],
    116     'TN_SRC' => get_thumbnail_url($row),
     116    'TN_SRC' => DerivativeImage::thumb_url($row),
    117117    'TN_ALT' => htmlspecialchars(strip_tags($name)),
    118118    'TN_TITLE' => get_thumbnail_title($row),
  • trunk/include/common.inc.php

    r12768 r12796  
    108108include(PHPWG_ROOT_PATH . 'include/constants.php');
    109109include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
    110 include( PHPWG_ROOT_PATH .'include/template.class.php');
     110include(PHPWG_ROOT_PATH .'include/template.class.php');
    111111
    112112// Database connection
     
    132132  }
    133133}
     134
     135ImageStdParams::load_from_db();
    134136
    135137load_plugins();
  • trunk/include/config_default.inc.php

    r12768 r12796  
    8989//no elements for these
    9090$conf['calendar_show_empty'] = true;
    91 
    92 // calendar_month_cell_width, calendar_month_cell_height : define the
    93 // width and the height of a cell in the monthly calendar when viewing a
    94 // given month. a value of 0 means that the pretty view is not shown.
    95 // a good suggestion would be to have the width and the height equal
    96 // and smaller than upload thumbnails configuration size.
    97 $conf['calendar_month_cell_width'] =80;
    98 $conf['calendar_month_cell_height']=80;
    9991
    10092// newcat_default_commentable : at creation, must a category be commentable
     
    761753// upload form or through pwg.images.addSimple web API method?
    762754$conf['upload_form_automatic_rotation'] = true;
     755
     756// 0-'auto', 1-'derivative' 2-'script'
     757$conf['derivative_url_style']=0;
     758
     759$conf['chmod_value']=0777;
     760
    763761?>
  • trunk/include/constants.php

    r12768 r12796  
    2828
    2929define('PHPWG_THEMES_PATH', $conf['themes_dir'].'/');
    30 define('PWG_COMBINED_DIR', PWG_LOCAL_DIR.'combined/');
     30defined('PWG_COMBINED_DIR') or define('PWG_COMBINED_DIR', PWG_LOCAL_DIR.'combined/');
     31defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', PWG_LOCAL_DIR.'i/');
    3132
    3233// Required versions
  • trunk/include/functions.inc.php

    r12541 r12796  
    3131include_once( PHPWG_ROOT_PATH .'include/functions_url.inc.php' );
    3232include_once( PHPWG_ROOT_PATH .'include/functions_plugins.inc.php' );
     33include_once( PHPWG_ROOT_PATH .'/include/derivative_params.inc.php');
     34include_once( PHPWG_ROOT_PATH .'/include/derivative_std_params.inc.php');
     35include_once( PHPWG_ROOT_PATH .'/include/derivative.inc.php');
    3336
    3437//----------------------------------------------------------- generic functions
     
    168171  if ( !is_dir($dir) )
    169172  {
     173    global $conf;
    170174    if (substr(PHP_OS, 0, 3) == 'WIN')
    171175    {
     
    173177    }
    174178    $umask = umask(0);
    175     $mkd = @mkdir($dir, 0755, ($flags&MKGETDIR_RECURSIVE) ? true:false );
     179    $mkd = @mkdir($dir, $conf['chmod_value'], ($flags&MKGETDIR_RECURSIVE) ? true:false );
    176180    umask($umask);
    177181    if ($mkd==false)
  • trunk/include/functions_notification.inc.php

    r8728 r12796  
    459459    { // get some thumbnails ...
    460460      $query = '
    461 SELECT DISTINCT id, path, name, tn_ext, file
     461SELECT DISTINCT id, path, name, representative_ext, file
    462462  FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
    463463  '.$where_sql.'
     
    536536  foreach($date_detail['elements'] as $element)
    537537  {
    538     $tn_src = get_thumbnail_url($element);
     538    $tn_src = DerivativeImage::thumb_url($element);
    539539    $description .= '<a href="'.
    540540                    make_picture_url(array(
  • trunk/include/picture_metadata.inc.php

    r12131 r12796  
    2727 */
    2828
    29 // $picture['current']['high_url'] may not be set if the user has no access
    30 // to the high definition, but we may want to display metadata and read the
    31 // high definition is available
    32 $high_url = null;
    33 if (isset($picture['current']['high_url']))
    34 {
    35   $high_url = $picture['current']['high_url'];
    36 }
    37 else
    38 {
    39   $high_url = get_high_url($picture['current']);
    40 }
    4129
    4230include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');
     
    5038
    5139  $exif = get_exif_data($picture['current']['image_path'], $exif_mapping);
    52   if (count($exif) == 0 and $picture['current']['has_high'])
    53   {
    54     $exif = get_exif_data($high_url, $exif_mapping);
    55   }
    5640 
    5741  if (count($exif) > 0)
     
    9781{
    9882  $iptc = get_iptc_data($picture['current']['image_path'], $conf['show_iptc_mapping']);
    99   if (count($iptc) == 0 and $picture['current']['has_high'])
    100   {
    101     $iptc = get_iptc_data($high_url, $conf['show_iptc_mapping']);
    102   }
    10383
    10484  if (count($iptc) > 0)
  • trunk/include/ws_functions.inc.php

    r12749 r12796  
    147147function ws_std_get_urls($image_row)
    148148{
    149   $ret = array(
    150     'tn_url' => get_thumbnail_url($image_row),
    151     'element_url' => get_element_url($image_row)
    152   );
     149  $ret = array();
    153150  global $user;
    154   if ($user['enabled_high'] and $image_row['has_high'] )
    155   {
    156     $ret['high_url'] = get_high_url($image_row);
    157   }
     151  if ($user['enabled_high'])
     152  {
     153    $ret['element_url'] = get_element_url($image_row);
     154  }
     155 
     156  $derivatives = DerivativeImage::get_all($image_row);
     157  $derivatives_arr = array();
     158  foreach($derivatives as $type=>$derivative)
     159  {
     160    $size = $derivative->get_size();
     161    $size != null or $size=array(null,null);
     162    $derivatives_arr[$type] = array('url' => $derivative->get_url(), 'width'=>$size[0], 'height'=>$size[1] );
     163  }
     164  $ret['derivatives'] = $derivatives_arr;;
    158165  return $ret;
    159166}
     
    166173{
    167174  return array(
    168     'id','tn_url','element_url','high_url', 'file','width','height','hit','date_available','date_creation'
     175    'id','element_url', 'file','width','height','hit','date_available','date_creation'
    169176    );
    170177}
     
    621628
    622629    $query = '
    623 SELECT id, path, tn_ext, level
     630SELECT id, path, representative_ext, level
    624631  FROM '.IMAGES_TABLE.'
    625632  WHERE id IN ('.implode(',', $image_ids).')
     
    630637      if ($row['level'] <= $user['level'])
    631638      {
    632         $thumbnail_src_of[$row['id']] = get_thumbnail_url($row);
     639        $thumbnail_src_of[$row['id']] = DerivativeImage::thumb_url($row);
    633640      }
    634641      else
     
    669676    {
    670677      $query = '
    671 SELECT id, path, tn_ext
     678SELECT id, path, representative_ext
    672679  FROM '.IMAGES_TABLE.'
    673680  WHERE id IN ('.implode(',', $new_image_ids).')
     
    676683      while ($row = pwg_db_fetch_assoc($result))
    677684      {
    678         $thumbnail_src_of[$row['id']] = get_thumbnail_url($row);
     685        $thumbnail_src_of[$row['id']] = DerivativeImage::thumb_url($row);
    679686      }
    680687    }
     
    13711378  if (!is_dir($upload_dir)) {
    13721379    umask(0000);
    1373     $recursive = true;
    1374     if (!@mkdir($upload_dir, 0777, $recursive))
     1380    if (!@mkdir($upload_dir, 0777, true))
    13751381    {
    13761382      return new PwgError(500, 'error during buffer directory creation');
     
    14251431    if (is_file($output_filepath))
    14261432    {
    1427       new PwgError(500, '[merge_chunks] error while trying to remove existing '.$output_filepath);
    1428       exit();
     1433      return new PwgError(500, '[merge_chunks] error while trying to remove existing '.$output_filepath);
    14291434    }
    14301435  }
     
    14651470    if (!file_put_contents($output_filepath, $string, FILE_APPEND))
    14661471    {
    1467       new PwgError(500, '[merge_chunks] error while writting chunks for '.$output_filepath);
    1468       exit();
     1472      return new PwgError(500, '[merge_chunks] error while writting chunks for '.$output_filepath);
    14691473    }
    14701474
     
    15011505    if (!@mkdir($upload_dir, 0777, $recursive))
    15021506    {
    1503       new PwgError(500, '[add_file] error during '.$type.' directory creation');
    1504       exit();
     1507      return new PwgError(500, '[add_file] error during '.$type.' directory creation');
    15051508    }
    15061509  }
     
    15131516    if (!is_writable($upload_dir))
    15141517    {
    1515       new PwgError(500, '[add_file] '.$type.' directory has no write access');
    1516       exit();
     1518      return new PwgError(500, '[add_file] '.$type.' directory has no write access');
    15171519    }
    15181520  }
     
    15261528  // check dumped thumbnail md5
    15271529  $dumped_md5 = md5_file($file_path);
    1528   if ($dumped_md5 != $file_sum) {
    1529     new PwgError(500, '[add_file] '.$type.' transfer failed');
    1530     exit();
     1530  if ($dumped_md5 != $file_sum)
     1531  {
     1532    return new PwgError(500, '[add_file] '.$type.' transfer failed');
    15311533  }
    15321534
     
    24522454      else
    24532455      {
    2454         new PwgError(
     2456        return new PwgError(
    24552457          500,
    24562458          '[ws_images_setInfo]'
     
    24582460          .', possible values are {fill_if_empty, replace}.'
    24592461          );
    2460         exit();
    24612462      }
    24622463    }
     
    24672468    if (!empty($image_row['storage_category_id']))
    24682469    {
    2469       new PwgError(500, '[ws_images_setInfo] updating "file" is forbidden on photos added by synchronization');
    2470       exit();
     2470      return new PwgError(500, '[ws_images_setInfo] updating "file" is forbidden on photos added by synchronization');
    24712471    }
    24722472
     
    25182518    else
    25192519    {
    2520       new PwgError(
     2520      return new PwgError(
    25212521        500,
    25222522        '[ws_images_setInfo]'
     
    25242524        .', possible values are {replace, append}.'
    25252525        );
    2526       exit();
    25272526    }
    25282527  }
     
    26112610  if (count($cat_ids) == 0)
    26122611  {
    2613     new PwgError(
     2612    return new PwgError(
    26142613      500,
    26152614      '[ws_add_image_category_relations] there is no category defined in "'.$categories_string.'"'
    26162615      );
    2617     exit();
    26182616  }
    26192617
     
    26292627  if (count($unknown_cat_ids) != 0)
    26302628  {
    2631     new PwgError(
     2629    return new PwgError(
    26322630      500,
    26332631      '[ws_add_image_category_relations] the following categories are unknown: '.implode(', ', $unknown_cat_ids)
    26342632      );
    2635     exit();
    26362633  }
    26372634
Note: See TracChangeset for help on using the changeset viewer.