Ignore:
Timestamp:
Jul 28, 2012, 8:48:54 PM (12 years ago)
Author:
cljosse
Message:

[extensions] Autosize fix compatibility with 2.4, new options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Autosize/autosize.inc.php

    r16931 r17192  
    2727 static public function cl_autosize_script_1()
    2828        {
    29                 global  $template,$user,$conf,$picture ,$page, $cl_plugin ;
    30  
     29  global $user,$page,$template,$cl_plugin;
     30
     31 
    3132 // header ('X-UA-Compatible: n=7')  ;
    3233 // header ('X-UA-Compatible: IE=Edge')  ;
     
    5859        'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH)  ,
    5960        'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS,
    60         'Version_pwg' => PHPWG_VERSION       
     61        'Version_pwg' => PHPWG_VERSION       ,
     62            'loading' => AUTOSIZE_PATH . 'images/loading.gif'
    6163         )
    6264    );
     
    7173 {
    7274           global  $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ;
     75
     76                global  $template,$user,$conf,$picture ,$page, $cl_plugin ;
     77
    7378   if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ;
    74 
     79   if (!isset($PAMOORAMICS_PATH)) return ;   
    7580                        $AUTOSIZE_PATH = dirname(__FILE__).'/';
    7681//================================================================
     
    155160
    156161  // this is the default handler that generates the display for the element
    157  static public function autosize_RenderContent($content, $element_info)
     162 static public function autosize_calcContent($content)
    158163{
    159   global $conf; 
    160   if ( !empty($content) )
    161   {// someone hooked us - so we skip;
    162     return $content;
    163   }
    164   if (isset($_COOKIE['picture_deriv']))
    165   {
    166     if ( array_key_exists($_COOKIE['picture_deriv'], ImageStdParams::get_defined_type_map()) )
    167     {
    168       pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']);
     164  global $conf;
     165   
     166 global $page, $template,$picture;
     167
     168
     169  $current = $template->get_template_vars('current');
     170  $defined_types = array_keys(ImageStdParams::get_defined_type_map()); 
     171if (isset($current)){
     172    if (!isset($current['selected_derivative'])){ 
     173      $model= $defined_types[count($defined_types)-1];
     174      $selected_derivative =      $current['derivatives'][$model];
     175      $template->append('current', array(
     176      'selected_derivative' => $selected_derivative
     177    ), true);
     178
     179
     180    $current = $template->get_template_vars('current');
     181        }
     182
     183         $derivative=$current['selected_derivative'] ;
     184          $imgScaledWH=$derivative->src_image->get_size();
     185          $imgSizeWH  =  $derivative->get_size();       
     186          $img_type  =  $derivative->get_type();       
     187          $img_url  = $derivative->get_url();
     188          $img_all= $derivative->get_all($derivative->src_image);
     189          $scaled_size=$derivative->get_size_hr(); //792 x 441
     190          $scaled_size=$derivative->get_scaled_size_htm(); // width="792" height="441"
     191         //================= taille mis a l'échelle
     192          $scaled_size=$derivative->get_scaled_size(100,100); // array([0]=>100,[1]=>55)
     193          $src= $derivative->src_image ;
     194       
    169195    }
    170     setcookie('picture_deriv', false, 0, cookie_path() );
    171   }
    172   $deriv_type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']);
    173   $selected_derivative = $element_info['derivatives'][$deriv_type];
    174 
    175   $unique_derivatives = array();
    176   $show_original = isset($element_info['element_url']);
    177   $added = array();
    178   foreach($element_info['derivatives'] as $type => $derivative)
    179    $element_info['derivatives']['Autosize']=$derivative; // last
    180 
    181   foreach($element_info['derivatives'] as $type => $derivative) {     
    182   if ($type=='Autosize'){   
    183        
    184     $url = $derivative->get_url();
    185     if (isset($added[$url]))
    186       continue;
    187     $added[$url] = 1;
    188     $show_original &= !($derivative->same_as_source());
    189     $unique_derivatives[$type]= $derivative;
    190      }
    191 
    192   }
    193 
    194   global $page, $template;
    195 
    196   if ($show_original)
    197   {
    198     $template->assign( 'U_ORIGINAL', $element_info['element_url'] );
    199   }
    200 
    201   $template->append('current', array(
    202       'selected_derivative' => $selected_derivative,
    203       'unique_derivatives' => $unique_derivatives,
    204     ), true);   
    205       $file =AUTOSIZE_PATH_ABS.'template/picture_content.tpl' ;
    206   $template->set_filenames(
    207     array('autosize_content'=> $file)
    208     );
    209 
    210   $template->assign( array(
    211       'ALT_IMG' => $element_info['file'],
    212       'COOKIE_PATH' => cookie_path(),
    213       )
    214     );
    215    return $template->parse( 'autosize_content', false);
     196 
     197    $img_scaled_width=isset($imgScaledWH)?$imgScaledWH[0]:"480";
     198    $img_scaled_height=isset($imgScaledWH)?$imgScaledWH[1]:"320";
     199    $current = $template->get_template_vars('picture');
     200    $picture['current']['scaled_width']=$img_scaled_width;
     201    $picture['current']['scaled_height']= $img_scaled_height;
     202    $picture['current']['image_url']=$src->rel_path;
     203   
    216204 }
    217205
     
    228216 if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ;
    229217                load_language('plugin.lang', AUTOSIZE_PATH);
     218
    230219                $AUTOSIZE_PATH = dirname(__FILE__).'/';
    231220                 if (isset( $page['body_id']) && $page['body_id']=='thePicturePage'  ) {
     
    271260        $template->parse('mes_script');
    272261      }     
    273        
     262           
    274263        return $template->parse( 'autosize_content', false);
    275264                                  }
Note: See TracChangeset for help on using the changeset viewer.