Ignore:
Timestamp:
Jul 23, 2012, 3:01:09 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

    r16579 r16931  
    3737    $ma_page=isset($page['body_id'])?$page['body_id']:"" ;
    3838    if ($ma_page=='thePiwiShackControllerPage') return ;
    39 
    40 
    41     if (PHPWG_VERSION < 2.2 )
    42       $file =AUTOSIZE_PATH_ABS.'template/header_2_1.tpl' ;
    43     else
    44       $file =AUTOSIZE_PATH_ABS.'template/header_2_2.tpl' ;
     39      $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ;
    4540    $template->set_filenames(array('autosize_init_header'=> $file ));
    4641    $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) );
    47 //=================================================================================================
     42//================================================================
    4843$DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ;
    4944$DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ;
    5045$DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ;
    51 //=================================================================================================
     46//======================================================================
    5247    $autosize_parametres =       cl_autosize_Get_Options() ;                   
    5348    $theme=$user['theme'];
     
    6964                return $template->parse( 'autosize_init', false);
    7065        }// function cl_autosize_script_1
    71  //===========================================================
    72  /*
    73   * cl_autosize_script_2()
    74  */
     66
     67 /*************************************
     68 * cl_autosize_script_2()
     69 **************************************/
    7570 static public function cl_autosize_script_2()
    7671 {
     
    7974
    8075                        $AUTOSIZE_PATH = dirname(__FILE__).'/';
    81 //=================================================================================================
     76//================================================================
    8277$DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ;
    8378$DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ;
    8479$DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ;
    85 //=================================================================================================
     80//=====================================================================
    8681
    8782
     
    156151                return $menu;
    157152        } //function cl_autosize_admin
     153  //=====================================
     154
     155
     156  // this is the default handler that generates the display for the element
     157 static public function autosize_RenderContent($content, $element_info)
     158{
     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']);
     169    }
     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);
     216 }
    158217
    159218    //===============================================================
     
    174233                                $autosize_parametres = cl_autosize_Get_Options();
    175234                                include (AUTOSIZE_PATH."include/affiche.php");
    176 
    177        if (PHPWG_VERSION < 2.2 )
    178                 $file =AUTOSIZE_PATH_ABS.'template/picture_2_1.tpl' ;
    179         else
    180                 $file =AUTOSIZE_PATH_ABS.'template/picture_2_2.tpl' ;
    181 
    182 
    183 
    184         $template->set_filenames(array('autosize_content_header'=> $file )); 
    185         $template->concat('autosize_content', $template->parse('autosize_content_header', true));   
    186                        
     235        $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ;
     236        $template->set_filenames(array('autosize_content_header'=> $file ));
     237        $template->concat('autosize_content', $template->parse('autosize_content_header', true));                           
    187238        $template->set_filenames(array('autosize_init_header'=> $file ));
    188                                        
     239                $theme=$user['theme'];   
     240          $deriv_type = pwg_get_session_var('picture_deriv', IMG_LARGE);                               
    189241                                if($autosize_parametres->check_icon_v == 'on'){                         
    190242                                                $template->assign('cl_autosize_button',
    191243                                                array(  'cl_autosize_info' => 'cl_autosize_info' ,
    192             'cl_autosize_info_1' => 'cl_autosize_info_' , 
     244                    'cl_autosize_info_1' => 'cl_autosize_info_' , 
    193245                                                                    'cl_autosize_info_2' => 'cl_autosize_info_2' ,   
    194246                                                                    'URL' => $_SERVER['REQUEST_URI'] ,
    195247                                                                    'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png',
    196                                                                     'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png'
     248                                                                    'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png',
     249                    'ICON1' => AUTOSIZE_PATH . 'icons/button-no.png'
    197250                                                                )
    198251
     
    202255                                }
    203256                                 $template->set_filenames(
    204                                                 array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl')
     257                                                array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl',
     258             'theme' => $theme   )
    205259                                        );
    206260                        $template->concat('autosize_content', $template->parse('autosize_content_header', true));               
     
    216270                                       
    217271        $template->parse('mes_script');
    218       }     
    219        
    220        
     272      }     
    221273       
    222274        return $template->parse( 'autosize_content', false);
     
    318370    $def_para['query'] = 'Qt'  ;
    319371    $def_para['type'] = 'Ty' ;
    320     $def_para['webmaster_height'] = '100%' ;
    321     $def_para['webmaster_width'] = '100%' ;
    322     $def_para['admin_height'] = '100%'  ;
    323     $def_para['admin_width'] =  '100%' ;
    324     $def_para['generic_height'] = '100%'  ;
    325     $def_para['generic_width'] =  '100%' ;
    326 
    327     $def_para['guest_height'] = '100%'  ;
    328     $def_para['guest_width'] =  '100%' ;
    329 
    330     $def_para['normal_height']  =  '100%'  ;
    331     $def_para['normal_width'] =  '100%' ;
     372
     373    $def_para['webmaster_type'] = 'Autosize' ;
     374    $def_para['admin_type'] = 'Autosize'  ;
     375    $def_para['generic_type'] = 'Autosize'  ;
     376    $def_para['guest_type'] = 'Autosize'  ;
     377    $def_para['normal_type']  =  'Autosize'  ;
     378 
    332379
    333380
     
    344391    $def_para['check_desc_v'] =  "off" ;
    345392    $def_para['check_icon_v'] =  "off" ;
    346     $def_para['check_auto_w'] =   "off" ;
     393   
    347394    $def_para['webmaster_enabled'] =   "off" ;
    348395    $def_para['admin_enabled'] =   "off" ;
     
    403450//=============================================================================
    404451$my_para=$autosize_parametres;
    405 
    406 
    407452  if (empty($my_para))
    408453$my_para = (object) '';
     
    411456$my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type:  'Ty') ;
    412457
    413 $my_para->webmaster_height =(isset($_POST['webmaster_height'])) ? $_POST['webmaster_height'] : ((isset($my_para->webmaster_height )) ? $my_para->webmaster_height : '100%' ) ;
    414 $my_para->webmaster_width=(isset($_POST['webmaster_width']))? $_POST['webmaster_width']: ((isset($my_para->webmaster_width)) ? $my_para->webmaster_width:  '100%') ;
    415 
    416 $my_para->admin_height =(isset($_POST['admin_height'])) ? $_POST['admin_height'] : ((isset($my_para->admin_height )) ? $my_para->admin_height : '100%' ) ;
    417 $my_para->admin_width=(isset($_POST['admin_width']))? $_POST['admin_width']: ((isset($my_para->admin_width)) ? $my_para->admin_width:  '100%') ;
    418 
    419 $my_para->generic_height =(isset($_POST['generic_height'])) ? $_POST['generic_height'] : ((isset($my_para->generic_height )) ? $my_para->generic_height : '100%' ) ;
    420 $my_para->generic_width=(isset($_POST['generic_width']))? $_POST['generic_width']: ((isset($my_para->generic_width)) ? $my_para->generic_width:  '100%') ;
    421 
    422 $my_para->guest_height =(isset($_POST['guest_height'])) ? $_POST['guest_height'] : ((isset($my_para->guest_height )) ? $my_para->guest_height : '100%' ) ;
    423 $my_para->guest_width=(isset($_POST['guest_width']))? $_POST['guest_width']: ((isset($my_para->guest_width)) ? $my_para->guest_width:  '100%') ;
    424 
    425 $my_para->normal_height =(isset($_POST['normal_height'])) ? $_POST['normal_height'] : ((isset($my_para->normal_height )) ? $my_para->normal_height : '100%' ) ;
    426 $my_para->normal_width=(isset($_POST['normal_width']))? $_POST['normal_width']: ((isset($my_para->normal_width)) ? $my_para->normal_width:  '100%') ;
     458$my_para->webmaster_type =(isset($_POST['webmaster_type'])) ? $_POST['webmaster_type'] : ((isset($my_para->webmaster_type )) ? $my_para->webmaster_type : 'Autosize' ) ;
     459
     460$my_para->admin_type =(isset($_POST['admin_type'])) ? $_POST['admin_type'] : ((isset($my_para->admin_type )) ? $my_para->admin_type : 'Autosize' ) ;
     461
     462$my_para->generic_type =(isset($_POST['generic_type'])) ? $_POST['generic_type'] : ((isset($my_para->generic_type )) ? $my_para->generic_type : 'Autosize' ) ;
     463
     464
     465$my_para->guest_type =(isset($_POST['guest_type'])) ? $_POST['guest_type'] : ((isset($my_para->guest_type )) ? $my_para->guest_type : 'Autosize' ) ;
     466
     467
     468$my_para->normal_type =(isset($_POST['normal_type'])) ? $_POST['normal_type'] : ((isset($my_para->normal_type )) ? $my_para->normal_type : 'Autosize' ) ;
     469
    427470
    428471
     
    442485                $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ;
    443486                $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ;
    444                 $my_para->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : "off" ;
     487       
    445488
    446489                $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ;
     
    453496                $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : ( ( isset($my_para->check_desc_v) ) ? $my_para->check_desc_v :   'off') ; 
    454497                $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : ( ( isset($my_para->check_icon_v) ) ? $my_para->check_icon_v :   'off') ; 
    455                 $my_para->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : ( ( isset($my_para->check_auto_w) ) ? $my_para->check_auto_w :   'off') ; 
     498
    456499
    457500
Note: See TracChangeset for help on using the changeset viewer.