source: extensions/Autosize/autosize.inc.php @ 18234

Last change on this file since 18234 was 18234, checked in by cljosse, 12 years ago

[extensions] Autosize fix compatibility with 2.4, store typesize

File size: 28.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// | Autosize                                                              |
5// +-----------------------------------------------------------------------+
6// | Copyright(C) 2010      cljosse                                        |
7// +-----------------------------------------------------------------------+
8// | This program is free software; you can redistribute it and/or modify  |
9// | it under the terms of the GNU General Public License as published by  |
10// | the Free Software Foundation                                          |
11// |                                                                       |
12// | This program is distributed in the hope that it will be useful, but   |
13// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
14// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
15// | General Public License for more details.                              |
16// |                                                                       |
17// | You should have received a copy of the GNU General Public License     |
18// | along with this program; if not, write to the Free Software           |
19// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
20// | USA.                                                                  |
21// +-----------------------------------------------------------------------+
22class autosize_controler {
23        /*********************************
24        * cl_autosize_admin
25        **********************************/
26        static public function cl_autosize_admin($menu)         {
27                global  $lang ;
28                array_push($menu, array('NAME' => 'Autosize',
29                'URL' => get_admin_plugin_menu_link(AUTOSIZE_PATH . 'admin/admin_autosize.php')));
30                return $menu;
31        } //function cl_autosize_admin
32/*********************
33* INIT
34*********************/
35static public function init($content){
36  // header ('X-UA-Compatible: n=7')  ;
37 // header ('X-UA-Compatible: IE=Edge')  ;
38 global  $template,$version,$icon_path,$page,$picture,$conf;
39 
40  $current = $template->get_template_vars('current'); 
41  $has_pamoorama=isset($template->files['pamooramics_content']);
42//====================================================================   
43  $pictureDeriv = pwg_get_session_var('picture_deriv',$conf['derivative_default_size']); 
44  $default_size =  $conf['derivative_default_size'];
45  $SRC_IMG=""; 
46//=====================================================================
47if(!isset($_COOKIE['picture_deriv']))
48    if(isset($current['derivatives']['Autosize']))
49        $_COOKIE['picture_deriv']="Autosize";
50
51if(isset( $_COOKIE['picture_deriv']))
52  $model=  $_COOKIE['picture_deriv'] ;
53else
54  $model= $pictureDeriv ;
55
56 if(!isset($current['derivatives'][$model]))
57   $model=$default_size ;
58
59$selected_derivative =  $current['derivatives'][$model];
60
61
62if (!isset($current['selected_derivative'])){ 
63
64  $current['SelMaxi'] = ImageStdParams::get_custom(900,900); 
65  $selected_derivative = ImageStdParams::get_custom($_COOKIE['theImageWidth'], $_COOKIE['theImageHeight']); 
66 
67  $selected_derivative->type=$model;
68  $template->append('current', array(
69                                'selected_derivative' => $selected_derivative
70                                    ), 
71                      true);
72  $current = $template->get_template_vars('current');
73   
74  }
75 
76  if(isset($current['derivatives'][$model])) {
77    $selected_derivative =  $current['derivatives'][$model];
78    $template->assign('current[selected_derivative]', $selected_derivative , true);
79    $current = $template->get_template_vars('current'); 
80  }
81
82return $content;
83
84}//INIT
85/**************************
86*  autosize_calcContent   *
87**************************/
88 static public function autosize_calcContent($content){
89  global $conf,$page, $template,$picture,$user; 
90  global $defined_types,$maxi_img ,$pictureDeriv ,$liste_type,$SRC_IMG,$select_type;
91  global  $has_pamoorama;
92  global $autosize_parametres,$user_status;
93$defined_types = array_keys(ImageStdParams::get_defined_type_map());   
94//===============================================================
95 if(isset($page['body_id']) &&  $page['body_id'] == 'theAdminPage' ) return ;   
96    if (!isset($_COOKIE['autosize_reload'])){   
97            $autoscript="<script type='text/javascript' src='themes/default/js/jquery.min.js'></script>                        <script type='text/javascript' src='plugins/Autosize/js/autosizeDetect.js'></script>
98      <script type='text/javascript' src='plugins/Autosize/js/autosize.cookie.js'></script>
99      <body onload=on_load() style='background-color:black;color :white;font-size:30px '  > 
100     please wait, loading...
101      </body>";   
102                  echo $autoscript; 
103      die();
104    } 
105  $current = $template->get_template_vars('current'); 
106  if (!isset($current)) return ;
107//===============================================================
108    $derivative = $current['src_image'] ;
109    $imgScaledWH = $derivative->get_size();
110    $SRC_IMG    = $derivative->get_url(); 
111    $picture['current']['scaled_width']=$imgScaledWH[0];
112    $picture['current']['scaled_height']= $imgScaledWH[1];
113    $picture['current']['high_url']= $SRC_IMG;   
114    $picture['current']['image_url']=$SRC_IMG; 
115//===============================================================
116 
117    $user_status = $user['status'] ;
118    $autosize_parametres = cl_autosize_Get_Options();
119    $user_type= get_user_status($user_status)."_type";
120    $select_type=$autosize_parametres->$user_type ;
121 
122
123  if (isset($_COOKIE['theImageHeight'])){   
124      pwg_set_session_var('theImageWidtht',$_COOKIE['theImageWidth']); 
125      pwg_set_session_var('theImageHeight',$_COOKIE['theImageHeight']);   
126  } 
127if (isset($_COOKIE['theMainImageHeight']))  pwg_set_session_var('theMainImageHeight',$_COOKIE['theMainImageHeight']); 
128if (isset($_COOKIE['theMainImageWidth']))  pwg_set_session_var('theImageWidth',$_COOKIE['theMainImageWidth']); 
129
130
131if (isset($_COOKIE['picture_deriv'])) 
132    pwg_set_session_var('picture_deriv',$_COOKIE['picture_deriv']); 
133else 
134  pwg_set_session_var('picture_deriv',$select_type); 
135
136 
137$model=   $conf['derivative_default_size'] ; // par defaut
138  $pictureDeriv = pwg_get_session_var('picture_deriv',  $model); 
139
140 
141 $model=$pictureDeriv ;
142
143    $value=0;
144    $liste_type="";
145    $maxi_info="";
146    if($model!="Autosize" & $model!="SelMaxi"){
147     
148    }else{
149        $model=$conf['derivative_default_size'] ;  // format par défaut
150    }
151    $derivative=$current['derivatives'][$model] ; 
152    $img_all= $derivative->get_all($derivative->src_image);
153    $maxi_img="";
154    $mini_img="";
155    $maxi_url="";
156    $imgSizeWH  = $derivative->get_size();     
157    //==== valeur taille image ====
158   
159     $window_width=$imgSizeWH[0];
160     $window_height=$imgSizeWH[1];
161
162
163   
164   $window_width = pwg_get_session_var('theMainImageWidth',$imgSizeWH[0]); 
165 $window_height =  pwg_get_session_var('theMainImageHeight',$imgSizeWH[1]);
166
167if (!isset($_COOKIE['theMainImageHeight']))    setcookie('theMainImageHeight', $window_height ); 
168if (!isset($_COOKIE['theMainImageWidth']))  setcookie('theMainImageWidth',$window_width); 
169
170//
171
172    $last_defined=ImageStdParams::get_defined_type_map(); 
173    foreach ($img_all as $img_select){
174            $img_type  =  $img_select->get_type();     
175            if ($img_type=="square" || $img_type=="thumb" ) continue ;
176            if (!isset($last_img)) $last_img = $img_select; 
177           
178            $img_url  = $img_select->get_url();
179            $imgSizeWH  =  $img_select->get_size();     
180       
181
182            if($img_type=="Autosize" || $img_type=="SelMaxi"){
183                $img_url = $img_select->src_image->get_url();
184                $imgSizeWH  =  $img_select->src_image->get_size();
185                $liste_type[$img_type]=$img_type.",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ;
186
187            } 
188              $liste_type[$img_type]=$img_type.",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ;
189 
190              if($window_height < $imgSizeWH[0] ){
191                          $maxi_img=  $img_type;
192                          $maxi_url= $img_url;
193                          $maxi_i=$img_select;
194              }
195
196              if($window_height < $imgSizeWH[0] && $mini_img==""){ 
197                      $mini_img=  $img_type;
198                      $mini_url= $img_url;
199                      $mini_i=$img_select;
200                 }
201
202               if($select_type == $img_type){ 
203                  if($maxi_img==""){
204                      $maxi_img =  $img_type;
205                      $maxi_url =  $img_url;
206                      $maxi_i   = $img_select;
207                  } 
208                  if($mini_img==""){
209                      $mini_img=  $img_type;
210                      $mini_url= $img_url;
211                      $mini_i=$img_select;
212                  }                   
213               break ;
214                }
215      }
216//==============================================================   
217  //==== Réécriture selection ====
218  if( $img_type=="SelMaxi"){
219      $maxi_img= $mini_img;
220      $maxi_url= $mini_img;
221  }
222  if ( !array_key_exists($maxi_img, $last_defined) ){
223   
224            $maxi_img = $last_img->get_type();   
225            $maxi_url  = $last_img->get_url();
226            $imgSizeWH  =  $last_img->get_size();       
227 
228  }
229 $model= $maxi_img;
230   
231  /*  $_COOKIE['picture_deriv']=$maxi_img ;
232    $_COOKIE['picture_map']=  $maxi_img ;
233    $_COOKIE['imgSrc']=       $maxi_url;
234   */
235  if (isset($_COOKIE['picture_deriv'])){   
236      if ( array_key_exists($_COOKIE['picture_deriv'], ImageStdParams::get_defined_type_map()) ){
237   //         pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']);
238        }else{
239     //       pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']);
240        }
241  //  setcookie('picture_deriv', false, 0, cookie_path() );
242  } 
243
244 
245return false ;
246
247 }
248
249/************************
250* cl_autosize_affiche
251*************************/     
252        static public function cl_autosize_affiche(){
253    global $user, $picture, $template,$page,$known_script;
254    global $content, $element_info;   
255    global $infos_message,$erreur_message;
256    global  $conf,$lang ,$user,$userdata;
257    global $defined_types,$maxi_img ,$pictureDeriv ,$liste_type,$SRC_IMG,$select_type;
258    global  $has_pamoorama;
259    global $autosize_parametres,$user_status;
260 
261
262    if(isset($page['body_id']) &&       $page['body_id'] == 'theAdminPage' ) return ;   
263
264 if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ;
265     if ('stripped' == $user['theme'] ) return ;
266
267                load_language('plugin.lang', AUTOSIZE_PATH);
268                $AUTOSIZE_PATH = dirname(__FILE__).'/';
269                 if (isset( $page['body_id']) && $page['body_id']=='thePicturePage'  ) {
270                        if ( isset($picture['current'])){       
271                                include (AUTOSIZE_PATH."include/affiche.php"); 
272
273        $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ;
274        $template->set_filenames(array('autosize_content_header'=> $file )); 
275        $template->assign(
276                                        array( 
277            'select_type' =>$select_type,
278            ));
279
280        $template->concat('autosize_content', $template->parse('autosize_content_header', true)); 
281
282        $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ;
283        $template->set_filenames(array('autosize_init_header'=> $file ));
284        $template->parse( 'autosize_init_header', false); 
285        $theme=$user['theme']; 
286                               
287                                if($autosize_parametres->check_icon_v == 'on'){                         
288                                                $template->assign('cl_autosize_button', 
289                                                array(  'cl_autosize_info' => 'cl_autosize_info' ,
290                    'cl_autosize_info_1' => 'cl_autosize_info_' , 
291                                                                    'cl_autosize_info_2' => 'cl_autosize_info_2' ,   
292                                                                    'URL' => $_SERVER['REQUEST_URI'] ,
293                                                                    'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png',
294                                                                    'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png',
295                    'ICON1' => AUTOSIZE_PATH . 'icons/button-no.png'
296                                                                )
297
298                                                        ); 
299                                        $template->set_filenames(array('cl_bp' => $AUTOSIZE_PATH. 'template/picture.tpl'));
300                                        $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true));
301                                }
302                                 $template->set_filenames(
303                                                array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl',
304             'theme' => $theme   )
305                                        );
306                        $template->concat('autosize_content', $template->parse('autosize_content_header', true));               
307      if(isset($conf['go_up_down']) && ($conf['go_up_down']==true) ){
308        $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') );
309        $template->func_combine_script(array('id'=>'my_script_2',
310        'path'=> AUTOSIZE_PATH.'/js/JScript.js',
311        'require' => 'jquery'),
312        $template->smarty);
313        $template->assign(array( 
314                          'MY_FOOTER_PATH' =>AUTOSIZE_PATH
315                          ));                                   
316        $template->parse('mes_script');
317      }   
318        return $template->parse( 'autosize_content', false);
319                                  }
320                } 
321
322        } //public function cl_autosize_affiche
323
324   /************************
325 *  cl_autosize_script_1
326 *************************/
327 static public function cl_autosize_script_1(){
328  global $user,$page,$template,$cl_plugin;
329    if(isset($page['body_id']) &&       $page['body_id'] == 'theAdminPage' ) return ;   
330 
331    $ma_page=isset($page['body_id'])?$page['body_id']:"" ;
332    if ($ma_page=='thePiwiShackControllerPage') return ;   
333    if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ;
334    global  $has_pamoorama;
335    $has_pamoorama=isset($template->files['pamooramics_content']);
336  if (!$has_pamoorama) return ; 
337      if ('stripped' == $user['theme'] ) return ;
338
339    $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) );
340    $autosize_parametres =       cl_autosize_Get_Options() ;                   
341    $theme=$user['theme'];
342    //==============================================================================
343    $DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ;
344    $DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] :  $DEBUG_autosize ;
345    $DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ;
346    //==============================================================================
347    $template->assign(
348      array(   
349          'autosize_parametres' => $autosize_parametres ,
350          'cl_plugins' => $cl_plugin ,
351          'cl_version' => $cl_plugin['version'] ,
352          'name' => $cl_plugin['name'] ,
353          'pamoorama' =>  $has_pamoorama,                                                               
354          'theme' => $theme  , 
355          'DEBUG_autosize' => $DEBUG_autosize,
356          'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH)  ,
357          'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS,
358          'Version_pwg' => PHPWG_VERSION           )
359    );
360    return $template->parse( 'autosize_init', false);
361        }// function cl_autosize_script_1
362
363 /*************************************
364 * cl_autosize_script_2()
365 **************************************/
366 static public function cl_autosize_script_2()
367 {
368           global  $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ;
369                global  $template,$user,$conf,$picture ,$page, $cl_plugin ;
370            if(isset($page['body_id']) &&       $page['body_id'] == 'theAdminPage' ) return ;   
371   
372   if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ;
373     global  $has_pamoorama;
374       if (!$has_pamoorama) return ; 
375       if ('stripped' == $user['theme'] ) return ;
376
377                        $AUTOSIZE_PATH = dirname(__FILE__).'/';
378//================================================================
379$DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ;
380$DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ;
381$DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ; 
382//=====================================================================
383    $ma_page=isset($page['body_id'])?$page['body_id']:"" ;
384    $theme=$user['theme'];
385    if ($ma_page=='thePiwiShackControllerPage') return ;
386    $img_width=isset($picture['current']['width'])?$picture['current']['width']:480;
387    $img_height=isset($picture['current']['height'])?$picture['current']['height']:320;
388    $img_scaled_width=isset($picture['current']['scaled_width'])?$picture['current']['scaled_width']:480;
389    $img_scaled_height=isset($picture['current']['scaled_height'])?$picture['current']['scaled_height']:320;
390    $src_img_h=isset($_POST['src_img_h'])?$_POST['src_img_h']: $img_width               ;
391    $src_img_w= isset($_POST['src_img_w'])?$_POST['src_img_w']:$img_height              ;
392
393
394  include_once (PHPWG_ROOT_PATH.'include/functions_cookie.inc.php') ;
395if(isset($_COOKIE['img_w'])){
396    $src_img_w=$_COOKIE['img_w'];
397    $src_img_h=$_COOKIE['img_h'];
398}
399
400$window_height= isset($_SESSION['height'])?$_SESSION['height']: $img_scaled_height ;
401$window_width= isset($_SESSION['width'])?$_SESSION['width']: $img_scaled_width    ;
402
403
404$size=array(
405            'src_img_h' => $src_img_h,
406            'src_img_w' => $src_img_w,
407            'window_height' =>$window_height,
408            'window_width' => $window_width
409
410          );
411
412                        $template->assign(
413                                        array(
414                                        'cl_version' => $cl_plugin['version'] ,
415                                        'name' => $cl_plugin['name'] ,
416                                        'ma_page' =>    $ma_page,
417                                       
418                                        'theme' => $theme  ,
419                                        'DEBUG_autosize' => $DEBUG_autosize   ,
420                                        'AUTOSIZE_PATH' => AUTOSIZE_PATH,
421          'Size' => $size
422           
423                                        )
424                                                );
425
426                        $autoscript="<script type='text/javascript'>
427                        /* cl_autosize_script_2 */
428                        if (typeof (save_framework) == 'function')
429                           save_framework('".$ma_page."'); 
430       var cookie_path   ='". cookie_path() ."'
431                        </script>";
432                $template->append('footer_elements',$autoscript); 
433                return ; 
434 }// function cl_autosize_script_2
435  /*************************************
436 * cl_autosize_script_3()
437 **************************************/
438 static public function cl_autosize_script_3() {
439           global  $template,$page;
440    if(isset($page['body_id']) &&       $page['body_id'] == 'theAdminPage' ) return ;   
441          global  $has_pamoorama;
442       if (!$has_pamoorama) return ; 
443
444                        $autoscript="<script type='text/javascript'>                   
445                        if (typeof (Ajout_Ajax) == 'function')
446                           Ajout_Ajax(); 
447                        </script>";
448                $template->append('footer_elements',$autoscript); 
449                return ; 
450 }// function cl_autosize_script_3
451
452        //===============================================================
453                /*
454        *
455        */
456        static public function cl_autosize_aff_infos_plus()
457                {
458                 global $template,$infos_message,$erreur_message, $user ;
459                 global  $conf,$lang ;
460       
461                 //==============================================================
462                  if (isset($erreur_message))
463                                {       
464                                if ($erreur_message <> "")
465                                        {
466                                                $erreur_message=str_replace("\n",'<br />',$erreur_message) ;
467                                                $template->assign('errors',$erreur_message);
468                                                $erreur_message="";
469                                        }
470                                }
471                  if (isset($infos_message))
472                                {       
473               
474                                if ($infos_message <> "")
475                                        {
476                                                $infos_message=str_replace("\n",'<br />',$infos_message) ;
477                                                $template->assign('infos',$infos_message);
478                                                $infos_message="";
479                                        }
480                                }
481                                //=============================================================
482                return;         
483               
484                } // function cl_autosize_aff_infos_plus
485        //===============================================================
486        /*
487         *
488        */
489        static public function cl_ajuste_data($content){
490                global  $template,$user,$conf,$picture ;
491      global $size;
492                $AUTOSIZE_PATH = realpath(AUTOSIZE_PATH .'/');
493                $userdata=$user;
494                $fields = array( 'maxwidth', 'maxheight' );
495         
496                $ThePicture = $template->get_template_vars('current'); 
497                $data = array();
498         return $content;
499
500                $data['maxwidth'] = $size['src_img_w'];
501                $data['maxheight'] =$size['src_img_h'];
502                $data['user_id'] = $userdata['id'];
503                foreach ($fields as $field)
504                {
505                        if (isset($_POST[$field]))
506                        {
507                                $data[$field] = $_POST[$field];
508                        }
509                }
510       
511                if($data['maxwidth'] != "" )
512                        {
513                        $picture['current']['scaled_width']=$data['maxwidth'];
514                        $picture['current']['scaled_height']=$data['maxheight'];
515                        mass_updates(USER_INFOS_TABLE,
516                                        array('primary' => array('user_id'), 'update' => $fields),
517                                        array($data)); 
518                        }
519                 
520                        return $content;                                                                                 
521                 }
522
523
524/****************************************
525*
526****************************************/
527function Get_Options(&$parametres,$str_index){
528    global $conf ;
529     if (!isset( $conf[$str_index]))  {   
530      $conf[$str_index]="";
531     }
532    $m_options=  $conf[$str_index];
533     if(isset($m_options))
534       if ( preg_match("|s:(.*)|", $m_options, $val) )
535        $parametres =  unserialize($conf[$str_index]);
536       else{
537         $parametres=explode(",",$_options);
538        }     
539        //====== par defaut =======================
540         $new_val=false;
541         $def_para=Array();
542
543    $def_para['query'] = 'Qt'  ;
544    $def_para['type'] = 'Ty' ;
545
546    $def_para['webmaster_type'] = 'Autosize' ; 
547    $def_para['admin_type'] = 'Autosize'  ; 
548    $def_para['generic_type'] = 'Autosize'  ;
549    $def_para['guest_type'] = 'Autosize'  ;
550    $def_para['normal_type']  =  'Autosize'  ;
551 
552
553
554    $def_para['mini_height'] =  '150' ;
555    $def_para['mini_width'] = '300' ;
556
557    $def_para['mini_height2'] =  '150' ;
558    $def_para['mini_width2'] =   '300' ;
559
560    $def_para['echelle_max'] =  '1.0'; 
561    $def_para['marge_basse'] =  '0';
562    $def_para['fade_in'] =   '0';
563    //==================================================
564    $def_para['check_desc_v'] =  "off" ;
565    $def_para['check_icon_v'] =  "off" ;
566   
567    $def_para['webmaster_enabled'] =   "off" ;
568    $def_para['admin_enabled'] =   "off" ;
569    $def_para['generic_enabled'] =   "off" ;
570    $def_para['guest_enabled'] =   "off" ;
571    $def_para['normal_enabled'] =   "off" ;
572    //===================================================
573   $para=$def_para;   
574    foreach ($para as $key => $value) {   
575      if( isset($parametres->$key) ){
576         $value=$parametres->$key;         
577      } 
578    if($def_para[$key] =="on" ||$def_para[$key] =="off" ){
579       $val_pg=(isset($_POST[$key]))? ($_POST[$key]=="off"||$_POST[$key]=="on")?$_POST[$key]:"on" : "off" ;
580       $value =(isset($_POST[$key]))? $val_pg : $value ; 
581       $val_pg=(isset($_GET[$key]))? ($_GET[$key]=="off"||$_GET[$key]=="on")?$_GET[$key]:"on" : "off" ;
582       $value =(isset($_GET[$key]))? $val_pg  : $value ; 
583     }else{
584        $value =(isset($_POST[$key]))? $_POST[$key] : $value ; 
585        $value =(isset($_GET[$key]))? $_GET[$key] : $value ; 
586      }
587        unset( $parametres->$key) ;
588        $parametres->$key = $value ;           
589     }   
590    return $parametres ;
591  }
592} // class
593
594/*************************************
595        *
596 *************************************/
597 function cl_autosize_Get_Options()
598  {
599                global $conf,$autosize_parametres; 
600    $autosize_parametres ="";
601 
602 if (!isset($conf['cl_autosize']))  {   
603  $conf['cl_autosize']="";
604  $q = '
605   INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
606   VALUES ("cl_autosize","","Parametres du plugin Autosize")
607  ;';
608  pwg_query($q);
609  }
610 
611 
612
613                $autosize_parametres =  unserialize($conf['cl_autosize']);
614      // $autosize_parametres = autosize_controler::Get_Options($autosize_parametres,'cl_autosize');
615                $autosize_parametres =  cl_autosize_Set_Options();
616                return $autosize_parametres;
617  }
618        /*
619        *
620        */
621function cl_autosize_Set_Options() {
622  global $autosize_parametres;
623//=============================================================================
624$my_para=$autosize_parametres;
625  if (empty($my_para))
626$my_para = (object) '';
627
628$my_para->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($my_para->query )) ? $my_para->query : 'Qt' ) ;
629$my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type:  'Ty') ;
630
631$my_para->webmaster_type =(isset($_POST['webmaster_type'])) ? $_POST['webmaster_type'] : ((isset($my_para->webmaster_type )) ? $my_para->webmaster_type : 'Autosize' ) ;
632
633$my_para->admin_type =(isset($_POST['admin_type'])) ? $_POST['admin_type'] : ((isset($my_para->admin_type )) ? $my_para->admin_type : 'Autosize' ) ;
634
635$my_para->generic_type =(isset($_POST['generic_type'])) ? $_POST['generic_type'] : ((isset($my_para->generic_type )) ? $my_para->generic_type : 'Autosize' ) ;
636
637
638$my_para->guest_type =(isset($_POST['guest_type'])) ? $_POST['guest_type'] : ((isset($my_para->guest_type )) ? $my_para->guest_type : 'Autosize' ) ;
639
640
641$my_para->normal_type =(isset($_POST['normal_type'])) ? $_POST['normal_type'] : ((isset($my_para->normal_type )) ? $my_para->normal_type : 'Autosize' ) ;
642
643
644
645$my_para->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($my_para->mini_height )) ? $my_para->mini_height : '150' ) ;
646$my_para->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($my_para->mini_width)) ? $my_para->mini_width:  '300') ;
647
648$my_para->mini_height2 =(isset($_POST['mini_height2'])) ? $_POST['mini_height2'] : ((isset($my_para->mini_height2 )) ? $my_para->mini_height2 : '150' ) ;
649$my_para->mini_width2=(isset($_POST['mini_width2']))? $_POST['mini_width2']: ((isset($my_para->mini_width2)) ? $my_para->mini_width2:  '300') ;
650
651$my_para->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($my_para->echelle_max)) ? $my_para->echelle_max :  '1.0'); 
652$my_para->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($my_para->marge_basse)) ? $my_para->marge_basse :  '0');
653$my_para->fade_in=(isset($_POST['fade_in']))? $_POST['fade_in']: ((isset($my_para->fade_in)) ? $my_para->fade_in :  '0');
654
655//===============================================================================       
656
657if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') )  { 
658                $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ;
659                $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ;
660       
661
662                $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ;
663                $my_para->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ;
664                $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ;
665                $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ;
666                $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ;
667
668         }else{
669                $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') ; 
670                $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') ; 
671
672
673
674$my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($my_para->webmaster_enabled) ) ? $my_para->webmaster_enabled :   'on') ; 
675$my_para->admin_enabled  = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($my_para->admin_enabled ) ) ? $my_para->admin_enabled :   'on') ; 
676$my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($my_para->generic_enabled) ) ? $my_para->generic_enabled :   'on') ; 
677$my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($my_para->guest_enabled) ) ? $my_para->guest_enabled :   'on') ;
678$my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($my_para->normal_enabled) ) ? $my_para->normal_enabled :   'on') ; 
679
680
681   }
682
683return $my_para;
684}
685        /*
686        *
687        */
688function cl_autosize_sauve_options_inf()
689{
690global $options,$infos_message,$conf,$autosize_parametres  ;
691$infos_message .=l10n("cl_autosize_save_config")."<br>";
692 $autosize_parametres=cl_autosize_Set_Options();
693 if ( isset($autosize_parametres) )     { 
694                $query = '
695                UPDATE '.CONFIG_TABLE.'
696                SET value="'.addslashes(serialize($autosize_parametres)).'"
697                WHERE param = "cl_autosize"
698                LIMIT 1';
699                        pwg_query($query);
700          }
701    if (!isset($conf['cl_derivatives_sav']))  {   
702      $q = '
703        INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
704        VALUES ("cl_derivatives_sav","","sauvegarde derivatives")
705      ;';
706      pwg_query($q);     
707      }
708 }
709
710 function print_var($variables)
711{
712  ob_start();
713  echo '<pre>';
714  print_r($variables);
715  echo '</pre>';
716  $m= ob_get_contents();
717  ob_end_clean();
718  return $m;           
719}
720   
721
722?>
Note: See TracBrowser for help on using the repository browser.