Changeset 12796


Ignore:
Timestamp:
12/27/11 06:26:44 (8 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
Files:
4 added
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager_global.php

    r12748 r12796  
    712712 
    713713  $query = ' 
    714 SELECT id,path,tn_ext,file,filesize,level,name 
     714SELECT id,path,representative_ext,file,filesize,level,name 
    715715  FROM '.IMAGES_TABLE; 
    716716   
     
    748748  { 
    749749    $nb_thumbs_page++; 
    750     $src = get_thumbnail_url($row); 
     750    $src = DerivativeImage::thumb_url($row); 
    751751 
    752752    $title = $row['name']; 
  • trunk/admin/batch_manager_unit.php

    r11853 r12796  
    202202 
    203203  $query = ' 
    204 SELECT id,path,tn_ext,name,date_creation,comment,author,level,file 
     204SELECT id,path,representative_ext,name,date_creation,comment,author,level,file 
    205205  FROM '.IMAGES_TABLE; 
    206206   
     
    238238    array_push($element_ids, $row['id']); 
    239239 
    240     $src = get_thumbnail_url($row); 
     240    $src = DerivativeImage::thumb_url($row); 
    241241 
    242242    // creation date 
  • trunk/admin/cat_modify.php

    r12591 r12796  
    302302  { 
    303303    $query = ' 
    304 SELECT id,tn_ext,path 
     304SELECT id,representative_ext,path 
    305305  FROM '.IMAGES_TABLE.' 
    306306  WHERE id = '.$category['representative_picture_id'].' 
    307307;'; 
    308308    $row = pwg_db_fetch_assoc(pwg_query($query)); 
    309     $src = get_thumbnail_url($row); 
     309    $src = DerivativeImage::thumb_url($row); 
    310310    $url = get_root_url().'admin.php?page=picture_modify'; 
    311311    $url.= '&image_id='.$category['representative_picture_id']; 
     
    388388  { 
    389389    $query = ' 
    390 SELECT id, file, path, tn_ext 
     390SELECT id, file, path, representative_ext 
    391391  FROM '.IMAGES_TABLE.' 
    392392  WHERE id = '.$category['representative_picture_id'].' 
     
    404404                          'category' => $category 
    405405                        )) 
    406                       .'" class="thumblnk"><img src="'.get_thumbnail_url($element).'"></a>'; 
     406                      .'" class="thumblnk"><img src="'.DerivativeImage::thumb_url($element).'"></a>'; 
    407407    } 
    408408  } 
  • trunk/admin/comments.php

    r12596 r12796  
    100100$query = ' 
    101101SELECT c.id, c.image_id, c.date, c.author, '. 
    102 $conf['user_fields']['username'].' AS username, c.content, i.path, i.tn_ext 
     102$conf['user_fields']['username'].' AS username, c.content, i.path, i.representative_ext 
    103103  FROM '.COMMENTS_TABLE.' AS c 
    104104    INNER JOIN '.IMAGES_TABLE.' AS i 
     
    112112while ($row = pwg_db_fetch_assoc($result)) 
    113113{ 
    114   $thumb = get_thumbnail_url( 
     114  $thumb = DerivativeImage::thumb_url( 
    115115      array( 
    116116        'id'=>$row['image_id'], 
  • trunk/admin/element_set_ranks.php

    r12782 r12796  
    200200    file, 
    201201    path, 
    202     tn_ext, 
     202    representative_ext, 
     203    width, height, 
    203204    name, 
    204205    rank 
     
    215216        $thumbnail_info=array(); 
    216217        $clipping=array(); 
     218  $derivativeParams = ImageStdParams::get_by_type(IMG_SQUARE); 
    217219        while ($row = pwg_db_fetch_assoc($result)) 
    218220        { 
    219                 $src = get_thumbnail_url($row); 
    220  
    221                 $thumbnail_size = getimagesize($src); 
     221    $derivative = new DerivativeImage($derivativeParams, new SrcImage($row)); 
     222 
     223                $thumbnail_size = $derivative->get_size(); 
    222224                if ( !empty( $row['name'] ) ) 
    223225                { 
     
    234236                        'height'        => $thumbnail_size[1], 
    235237                        'id'    => $row['id'], 
    236                         'tn_src'        => $src, 
     238                        'tn_src'        => $derivative->get_url(), 
    237239                        'rank'  => $current_rank * 10, 
    238240                        ); 
  • trunk/admin/history.php

    r9808 r12796  
    304304    file, 
    305305    path, 
    306     tn_ext 
     306    representative_ext 
    307307  FROM '.IMAGES_TABLE.' 
    308308  WHERE id IN ('.implode(',', array_keys($image_ids)).') 
     
    314314    $file_of_image = array(); 
    315315    $path_of_image = array(); 
    316     $tn_ext_of_image = array(); 
     316    $representative_ext_of_image = array(); 
    317317 
    318318    $result = pwg_query($query); 
     
    333333      $file_of_image[ $row['id'] ] = $row['file']; 
    334334      $path_of_image[ $row['id'] ] = $row['path']; 
    335       $tn_ext_of_image[ $row['id'] ] = $row['tn_ext']; 
     335      $representative_ext_of_image[ $row['id'] ] = $row['representative_ext']; 
    336336    } 
    337337 
     
    455455          'file' => $file_of_image[$line['image_id']], 
    456456          'path' => $path_of_image[$line['image_id']], 
    457           'tn_ext' => $tn_ext_of_image[$line['image_id']], 
     457          'representative_ext' => $representative_ext_of_image[$line['image_id']], 
    458458          ); 
    459459        $thumbnail_display = $page['search']['fields']['display_thumbnail']; 
     
    488488          $image_string = 
    489489            '<a class="thumbnail" href="'.$picture_url.'">' 
    490             .'<span><img src="'.get_thumbnail_url($element) 
     490            .'<span><img src="'.DerivativeImage::thumb_url($element) 
    491491            .'" alt="'.$image_title.'" title="'.$image_title.'">' 
    492492            .'</span></a>'; 
     
    497497          $image_string = 
    498498            '<a class="over" href="'.$picture_url.'">' 
    499             .'<span><img src="'.get_thumbnail_url($element) 
     499            .'<span><img src="'.DerivativeImage::thumb_url($element) 
    500500            .'" alt="'.$image_title.'" title="'.$image_title.'">' 
    501501            .'</span>'.$image_title.'</a>'; 
  • trunk/admin/picture_modify.php

    r12612 r12796  
    283283    'PATH'=>$row['path'], 
    284284 
    285     'TN_SRC' => get_thumbnail_url($row), 
     285    'TN_SRC' => DerivativeImage::thumb_url($row), 
    286286 
    287287    'NAME' => 
  • trunk/admin/rating.php

    r12624 r12796  
    185185        i.path, 
    186186        i.file, 
    187         i.tn_ext, 
     187        i.representative_ext, 
    188188        i.rating_score, 
    189189        r.element_id 
     
    202202foreach ($images as $image) 
    203203{ 
    204   $thumbnail_src = get_thumbnail_url($image); 
     204  $thumbnail_src = DerivativeImage::thumb_url($image); 
    205205 
    206206  $image_url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'. 
  • trunk/admin/rating_user.php

    r12650 r12796  
    102102if (count($image_ids) > 0 ) 
    103103{ 
    104   $query = 'SELECT id, name, file, path, tn_ext 
     104  $query = 'SELECT id, name, file, path, representative_ext 
    105105  FROM '.IMAGES_TABLE.' 
    106106  WHERE id IN ('.implode(',', array_keys($image_ids)).')'; 
     
    109109  { 
    110110    $image_urls[ $row['id'] ] = array( 
    111       'tn' => get_thumbnail_url($row), 
     111      'tn' => DerivativeImage::thumb_url($row), 
    112112      'page' => make_picture_url( array('image_id'=>$row['id'], 'image_file'=>$row['file']) ), 
    113113    ); 
     
    218218  'ratings' => $by_user_ratings, 
    219219  'image_urls' => $image_urls, 
    220   'TN_WIDTH' => 20+2*$conf['upload_form_thumb_maxwidth'], 
     220  'TN_WIDTH' => 28+2*ImageStdParams::get_by_type(IMG_THUMB)->sizing->ideal_size[0], 
    221221  ) ); 
    222222$template->set_filename('rating', 'rating_user.tpl'); 
  • trunk/admin/themes/default/template/rating_user.tpl

    r12650 r12796  
    6060                {capture assign=rate_over}{foreach from=$rates item=rate_arr}<img src="{$image_urls[$rate_arr.id].tn}" alt="thumb-{$rate_arr.id}" title="{$rate_arr.date}"></img> 
    6161                {/foreach}{/capture} 
    62                 <a class="cluetip" title="{$rate_over|@htmlspecialchars}">{$rates|@count}</a> 
     62                <a class="cluetip" title="|{$rate_over|@htmlspecialchars}">{$rates|@count}</a> 
    6363                {/if}</td> 
    6464        {/foreach} 
     
    7272jQuery(document).ready(function(){ldelim} 
    7373        jQuery('.cluetip').cluetip({ldelim} 
    74                 width: {$TN_WIDTH}, splitTitle: '|' 
     74                width: {$TN_WIDTH}, showTitle:false, splitTitle: '|' 
    7575        }); 
    7676}) 
  • trunk/comments.php

    r12765 r12796  
    409409  $elements = array(); 
    410410  $query = ' 
    411 SELECT id, name, file, path, tn_ext 
     411SELECT id, name, file, path, representative_ext 
    412412  FROM '.IMAGES_TABLE.' 
    413413  WHERE id IN ('.implode(',', $element_ids).') 
     
    451451 
    452452    // source of the thumbnail picture 
    453     $thumbnail_src = get_thumbnail_url( $elements[$comment['image_id']] ); 
     453    $thumbnail_src = DerivativeImage::thumb_url( $elements[$comment['image_id']] ); 
    454454 
    455455    // link to the full size picture 
  • 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 
  • trunk/picture.php

    r12767 r12796  
    2222// +-----------------------------------------------------------------------+ 
    2323 
    24 define('PHPWG_ROOT_PATH','./'); 
     24define('PHPWG_ROOT_PATH',''); 
    2525include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); 
    2626include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); 
     
    154154    return $content; 
    155155  } 
    156   if (!isset($element_info['image_url'])) 
    157   { // nothing to do 
    158     return $content; 
     156 
     157  if (isset($_COOKIE['picture_deriv'])) 
     158  { 
     159    pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']); 
     160    setcookie('picture_deriv', false, 0); 
     161  } 
     162  $deriv_type = pwg_get_session_var('picture_deriv', IMG_LARGE); 
     163  $selected_derivative = $element_info['derivatives'][$deriv_type]; 
     164 
     165  $available_derivatives = array(); 
     166  $added = array(); 
     167  foreach($element_info['derivatives'] as $type => $derivative) 
     168  { 
     169    $url = $derivative->get_url(); 
     170    if (isset($added[$url])) 
     171      continue; 
     172    $added[$url] = 1; 
     173    $available_derivatives[] = $type; 
    159174  } 
    160175 
    161176  global $user, $page, $template; 
     177   
     178  $template->append('current', array( 
     179      'selected_derivative' => $selected_derivative, 
     180      'available_derivative_types' => $available_derivatives, 
     181    ), true); 
     182 
    162183 
    163184  $template->set_filenames( 
     
    165186    ); 
    166187 
    167   if ( !$page['slideshow'] and isset($element_info['high_url']) ) 
    168   { 
    169     $uuid = uniqid(rand()); 
    170     $template->assign( 
    171       'high', 
    172       array( 
    173         'U_HIGH' => $element_info['high_url'], 
    174         'UUID'   => $uuid, 
    175         ) 
    176       ); 
    177   } 
    178188  $template->assign( array( 
    179       'SRC_IMG' => $element_info['image_url'], 
    180189      'ALT_IMG' => $element_info['file'], 
    181       'WIDTH_IMG' => @$element_info['scaled_width'], 
    182       'HEIGHT_IMG' => @$element_info['scaled_height'], 
    183190      ) 
    184191    ); 
     
    404411} 
    405412 
    406 // incrementation of the number of hits, we do this only if no action 
     413//---------- incrementation of the number of hits, we do this only if no action 
    407414if (trigger_event('allow_increment_element_hit_count', !isset($_POST['content']) ) ) 
    408415{ 
     
    493500  } 
    494501 
     502  $picture[$i]['derivatives'] = DerivativeImage::get_all($row); 
     503  $picture[$i]['src_image'] = $picture[$i]['derivatives'][IMG_THUMB]->src_image; 
     504  $picture[$i]['thumbnail'] = $picture[$i]['derivatives'][IMG_THUMB]->get_url(); 
     505   
    495506  // ------ build element_path and element_url 
    496507  $picture[$i]['element_path'] = get_element_path($picture[$i]); 
     
    510521      if ( $user['enabled_high']=='true' ) 
    511522      { 
    512         $hi_url=get_high_url($picture[$i]); 
    513         if ( !empty($hi_url) ) 
    514         { 
    515           $picture[$i]['high_url'] = $hi_url; 
    516           $picture[$i]['download_url'] = get_download_url('h',$picture[$i]); 
    517         } 
     523        $picture[$i]['download_url'] = get_download_url('e',$picture[$i]); 
    518524      } 
    519525    } 
     
    524530  } 
    525531 
    526   $picture[$i]['thumbnail'] = get_thumbnail_url($row); 
    527532 
    528533  if ( !empty( $row['name'] ) ) 
     
    567572    $picture['current']['height']= $taille_image[1]; 
    568573  } 
    569 } 
    570  
    571 if (!empty($picture['current']['width'])) 
    572 { 
    573   list( 
    574     $picture['current']['scaled_width'], 
    575     $picture['current']['scaled_height'] 
    576     ) = get_picture_size( 
    577       $picture['current']['width'], 
    578       $picture['current']['height'], 
    579       @$user['maxwidth'], 
    580       @$user['maxheight'] 
    581     ); 
    582574} 
    583575 
     
    897889 
    898890// size in pixels 
    899 if ($picture['current']['is_picture'] AND $picture['current']['has_high']) 
    900 { 
    901   if (!empty($picture['current']['high_width'])) 
    902   { 
    903     $infos['INFO_DIMENSIONS'] = $picture['current']['high_width'].'*'.$picture['current']['high_height']; 
    904   } 
    905   else if ($hi_size = @getimagesize($hi_url)) 
    906   { 
    907     pwg_query(' 
    908       UPDATE ' . IMAGES_TABLE . ' 
    909       SET  
    910         high_width = \'' . $hi_size[0].'\', 
    911         high_height = \''.$hi_size[1] .'\' 
    912       WHERE id = ' . $picture['current']['id'] . '; 
    913     '); 
    914      
    915     $infos['INFO_DIMENSIONS'] = $hi_size[0].'*'.$hi_size[1]; 
    916   } 
    917 } 
    918 else if ($picture['current']['is_picture'] and isset($picture['current']['width']) ) 
    919 { 
    920   if ($picture['current']['scaled_width'] !== $picture['current']['width'] ) 
    921   { 
    922     $infos['INFO_DIMENSIONS'] = 
    923       '<a href="'.$picture['current']['image_url'].'" title="'. 
    924       l10n('Original dimensions').'">'. 
    925       $picture['current']['width'].'*'.$picture['current']['height'].'</a>'; 
    926   } 
    927   else 
    928   { 
    929     $infos['INFO_DIMENSIONS'] = 
    930       $picture['current']['width'].'*'.$picture['current']['height']; 
    931   } 
     891if ($picture['current']['is_picture'] and isset($picture['current']['width']) ) 
     892{ 
     893  $infos['INFO_DIMENSIONS'] = 
     894    $picture['current']['width'].'*'.$picture['current']['height']; 
    932895} 
    933896 
    934897// filesize 
    935 if ($picture['current']['has_high'] and !empty($picture['current']['high_filesize'])) 
    936 { 
    937   $infos['INFO_FILESIZE'] = 
    938     sprintf(l10n('%d Kb'), $picture['current']['high_filesize']); 
    939 } 
    940 else if (!empty($picture['current']['filesize'])) 
     898if (!empty($picture['current']['filesize'])) 
    941899{ 
    942900  $infos['INFO_FILESIZE'] = 
  • trunk/themes/default/template/picture_content.tpl

    r11062 r12796  
    1 {if isset($high)} 
    2 {combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'} 
    3 <a href="javascript:phpWGOpenWindow('{$high.U_HIGH}','{$high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')"> 
     1<img src="{$current.selected_derivative->get_url()}" {$current.selected_derivative->get_size_htm()} alt="{$ALT_IMG}" id="theMainImage" 
     2{if isset($COMMENT_IMG)} 
     3        title="{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}" {else} title="{$current.TITLE|@replace:'"':' '} - {$ALT_IMG}" 
     4{/if}> 
     5{if count($current.available_derivative_types)>1} 
     6{footer_script}{literal} 
     7function changeImgSrc(url,type) 
     8{ 
     9        var theImg = document.getElementById("theMainImage"); 
     10        if (theImg) 
     11        { 
     12                theImg.removeAttribute("width");theImg.removeAttribute("height"); 
     13                theImg.src = url; 
     14        } 
     15        document.cookie = 'picture_deriv=' + type; 
     16} 
     17{/literal}{/footer_script} 
     18<p> 
     19{foreach from=$current.available_derivative_types item=derivative_type} 
     20<a onclick="changeImgSrc('{$current.derivatives[$derivative_type]->get_url()|@escape:javascript}', '{$derivative_type}')" title="{$current.derivatives[$derivative_type]->get_size_hr()}">{$derivative_type}</a> 
     21{/foreach} 
     22</p> 
    423{/if} 
    5         <img src="{$SRC_IMG}" style="width:{$WIDTH_IMG}px;height:{$HEIGHT_IMG}px;" alt="{$ALT_IMG}" id="theMainImage" 
    6         {if isset($COMMENT_IMG)} 
    7                 title="{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}" {else} title="{$current.TITLE|@replace:'"':' '} - {$ALT_IMG}" 
    8         {/if}> 
    9 {if isset($high) } 
    10 </a> 
    11         <p>{'Click on the photo to see it in high definition'|@translate}</p> 
    12 {/if} 
Note: See TracChangeset for help on using the changeset viewer.