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

Last change on this file since 19744 was 19744, checked in by cljosse, 11 years ago

[extensions] Autosize fix bug init with chrome

File size: 54.6 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_ctrl {
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
34/**************************
35*  autosize_calcContent   *
36**************************/
37 static public function autosize_calcContent($content,$element_info){
38   global $conf,$page, $template,$picture,$user; 
39  global $defined_types,$pictureSelType,$pictureMap ,$pictureDeriv ,$liste_type,$SRC_IMG;
40  global $autosize_parametres,$user_status;
41  global $infos_message,$error_message;
42    //==============================================================================
43  global $DEBUG_autosize;
44  if( isset($_GET['cl_debug']) && $_GET['cl_debug'] =='false') {
45      $DEBUG_autosize="";
46  }else{
47    $DEBUG_autosize = isset($_POST['cl_debug']) ? $_POST['cl_debug'] : "" ;
48    $DEBUG_autosize = isset($_GET['cl_debug']) ? $_GET['cl_debug'] :  $DEBUG_autosize ;
49    $DEBUG_autosize = isset($conf['cl_debug']) ? $conf['cl_debug']."," . $DEBUG_autosize : $DEBUG_autosize ;
50 //===============================================================
51}
52 if(preg_match("|event|", $DEBUG_autosize, $val))  $infos_message =  "autosize_calcContent, " ; 
53    $ma_page=isset($page['body_id'])?$page['body_id']:"" ; 
54   if ($ma_page !='thePicturePage') return ; 
55    $default_size =  $conf['derivative_default_size'];
56//============================================================
57self::get_cookies();
58    $types = array_intersect(array_keys(ImageStdParams::get_defined_type_map()), array("Autosize","SelMaxi"));
59    if (count($types)==0){ 
60        include_once (AUTOSIZE_PATH.'maintain.inc.php');
61        if (isset($conf['cl_derivatives_sav']))  {   
62            plugin_deactivate() ;             
63        }   
64          plugin_activate(); 
65          unset (  $_COOKIE['autosize_reload']) ;
66    }
67    if(preg_match("|test|", $DEBUG_autosize, $val)) { 
68    $infos_message .= "#65 autosize_calcContent: <br>";
69       if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
70        $infos_message .=  "SESSION:"  . cl_print_var($_SESSION) ;
71        $infos_message .=  "COOKIE:"  . cl_print_var($_COOKIE) ;
72        $infos_message .=  "GET:"  . cl_print_var($_GET) ;
73        $infos_message .= "POST:"  . cl_print_var($_POST) ;
74        $infos_message .= "$pictureDeriv $pictureSelType $pictureMap ";
75      //  self::Fin_php ("#138: ".$DEBUG_autosize);
76 }
77    if(!isset($_COOKIE['picture_deriv'] )){
78        if(preg_match("|test_1|", $DEBUG_autosize, $val)) { 
79          $infos_message .= "not COOKIE['picture_deriv'] -> reload(): <br>";
80         
81          self::Fin_php("#78 autosize_calcContent:" . $DEBUG_autosize );
82        }
83        self::reload("#80");
84           self::Fin_php("#81 autosize_calcContent:" + $DEBUG_autosize);
85    } 
86
87
88   if (!isset($_COOKIE['autosize_reload'])  ){ 
89           if(preg_match("|test_2|", $DEBUG_autosize, $val)) { 
90          $infos_message .= "not COOKIE['autosize_reload'] -> reload(): <br>";
91           echo $infos_message;
92          self::Fin_php("#89 autosize_calcContent:" . $DEBUG_autosize);
93        }
94          self::reload("#81");
95           self::Fin_php("#92 autosize_calcContent:" + $DEBUG_autosize);
96
97    } 
98//===================================================================
99  $current = $template->get_template_vars('current'); 
100  if (!isset($current)) return ; 
101//===============================================================
102    global $imgSizeWH;
103    $derivative = $current['src_image'] ;
104    $imgSizeWH = $derivative->get_size();
105    $SRC_IMG    = $derivative->get_url(); 
106
107    $picture['current']['scaled_width']=$imgSizeWH[0];
108    $picture['current']['scaled_height']= $imgSizeWH[1];
109    $picture['current']['high_url']= $SRC_IMG;   
110    $picture['current']['image_url']=$SRC_IMG; 
111    $picture['current']['thumbnail']=$SRC_IMG;
112
113//==============================================================
114    $autosize_parametres = cl_autosize_Get_Options();
115   return false ;
116 }//calc_content ;
117
118
119
120/*********************
121* INIT
122*********************/
123static public function init($content,$element_info){
124  global  $template,$version,$icon_path,$page,$picture,$conf;
125  global $user,$Css,$css_slideshow,$css_display,$liste_type;
126  global  $has_pamoorama,$pictureSelType,$pictureDeriv,$pictureMap;
127  global $infos_message,$warnings_message;
128
129  global $set_miniature,$imgSizeWH,$DEBUG_autosize; 
130  global $theImageHeight,$theImageWidth,$theImageLeft,$theImageTop,$windowWidth,$windowHeight,$theMainImageSize;
131//======================================================= 
132global $has_pamoorama ;
133
134  if( isset($_GET['cl_debug']) && $_GET['cl_debug'] =='false') {
135      $DEBUG_autosize="";
136  }else{
137    $DEBUG_autosize = isset($_POST['cl_debug']) ? $_POST['cl_debug'] : "" ;
138    $DEBUG_autosize = isset($_GET['cl_debug']) ? $_GET['cl_debug'] :  $DEBUG_autosize ;
139    $DEBUG_autosize = isset($conf['cl_debug']) ? $conf['cl_debug']."," . $DEBUG_autosize : $DEBUG_autosize ;
140 //===============================================================
141}
142if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .=  "init, ";} ;
143
144  $has_pamoorama = isset($template->files['pamooramics_content'])?"true":"false"; 
145  $theme=$user['theme']; 
146 
147  $Css = self::css($theme."-rules.css"); 
148  $css_slideshow=isset($Css['.Autosize']['slideshow'])?$Css['.Autosize']['slideshow']:"yes"; 
149  $css_display= isset($Css['.Autosize']['display'])?$Css['.Autosize']['display']:"block"; 
150  $default_size =  $conf['derivative_default_size'];
151//============================================================
152self::get_cookies();
153 //==============================================================
154 if(preg_match("|test|", $DEBUG_autosize, $val)) { 
155    $infos_message .= "#133 <br>Init:SESSION:"  . cl_print_var($_SESSION) ;
156       if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
157        $infos_message .=  "GET:"  . cl_print_var($_GET) ;
158        $infos_message .= "POST:"  . cl_print_var($_POST) ;
159        $infos_message .= "$pictureDeriv $pictureSelType $pictureMap ";
160      //  self::Fin_php("#138: ".$DEBUG_autosize);
161 }
162  $autosize_parametres = cl_autosize_Get_Options();
163
164//=====================================================================
165  $current = $template->get_template_vars('current'); 
166   //=== Zone affichage ==       
167      $windowWidth=$_COOKIE['windowWidth'] ;
168      $windowHeight=$_COOKIE['windowHeight'] ;
169
170      $theImageTop= isset($_COOKIE['theImageTop'])?$_COOKIE['theImageTop']:0;
171      $theImageLeft=isset($_COOKIE['theImageLeft'])?$_COOKIE['theImageLeft']:0;
172
173       $theImageRight=isset($_COOKIE['theImageRight'])?$_COOKIE['theImageRight']:0;
174       $theImageBottom=isset($_COOKIE['theImageBottom'])?$_COOKIE['theImageBottom']:0;
175
176
177       $theImageMargeWidth=isset($_COOKIE['theImageMargeWidth']) ? $_COOKIE['theImageMargeWidth']:0;
178       $theImageMargeHeight=isset($_COOKIE['theImageMargeHeight'])?$_COOKIE['theImageMargeHeight']:0;
179
180      $theImageMargeHeight -= 2;
181if(isset($_COOKIE['theImageWidth'])){
182       $theImageWidth=    $_COOKIE['theImageWidth'];
183       $theImageHeight=  $_COOKIE['theImageHeight'] ;
184}
185       $theImageWidth=    $windowWidth -  $theImageLeft - $theImageMargeWidth;
186       $theImageHeight=   $windowHeight - $theImageTop  - $theImageMargeHeight ;
187 
188   if (isset($element_info['is_gvideo']) && $element_info['is_gvideo'] ){
189    $pictureDeriv=$default_size;
190
191   }else{
192
193
194    $retour = self::get_min_max() ; 
195
196    $theMainImageSize = $retour->get_size();
197    $theMainImageWidth=   isset($_COOKIE['theMainImageWidth'])?$_COOKIE['theMainImageWidth']:$theMainImageSize[0];
198    $theMainImageHeight=   isset($_COOKIE['theMainImageHeight'])?$_COOKIE['theMainImageHeight']:$theMainImageSize[1] ;
199
200  if($theImageHeight!=0 && $theImageWidth!=0){
201      $pictureDeriv=$retour->type ;
202   }else{
203      $pictureDeriv=$default_size;
204   }
205}
206 
207 if(preg_match("|test|", $DEBUG_autosize, $val)) { 
208    $infos_message .=  "#187 <br>Init:SESSION:"  . cl_print_var($_SESSION) ;
209   
210    if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
211        $infos_message .=  "Init: COOKIE:"  . cl_print_var($_COOKIE) ;
212        $infos_message .=  "GET:"  . cl_print_var($_GET) ;
213        $infos_message .=  "POST:"  . cl_print_var($_POST) ;     
214        $infos_message .=("#193: ".$DEBUG_autosize);
215 }
216 $pattern = array();
217  if($has_pamoorama=="true"){ 
218  if(preg_match("|c1|", $DEBUG_autosize, $val)) echo  $theImageWidth . "x" . $theImageHeight ;
219      $pattern[0] = '/width\:(.*)(\d+),/';$replacement[0] = 'width:  '.$theImageWidth.' ,'; 
220      if(($theImageWidth!=0)){     
221            $content=  preg_replace($pattern, $replacement, $content);
222        }
223         if(preg_match("|c1|", $DEBUG_autosize, $val)) {
224         echo "<!-- " . $theImageWidth . "x" . $theImageHeight . " " .cl_print_var($content) ." -->";
225         self::Fin_php("#222: " . $DEBUG_autosize);
226    }
227      return  $content;
228  }
229if(isset($_GET['map'])){
230return  $content;
231}
232 $pattern[0] = '/width\:(.*)(\d+)px/';$replacement[0] = 'width:100% '; 
233 $pattern[1] = '/height\:(.*)(\d+)px/';$replacement[1] = 'height:100% '; 
234 $pattern[2] = '/width=\"(\d+)\"/';$replacement[2] = ' ';
235 $pattern[3] = '/height=\"(\d+)\"/';$replacement[3] = ' ';
236
237if ( strstr( $content,"iframe")||strstr($content,"charlie" )){ 
238 
239$pictureSelType="Autosize";
240$pictureDeriv=$conf['derivative_default_size'];
241
242$_COOKIE['picture_sel_type']=$pictureSelType;
243$_COOKIE['picture_deriv']=$pictureDeriv;
244
245  $ncount=1;   
246  if (strstr($content,"charlie" )){   
247      $content=str_replace( "<object" , "<object id='theMainImage_obj' name='theMainImage' "  ,$content,$ncount);
248      $content=str_replace( "<embed" ,  "<embed id='theMainImage_emb' name='theMainImage' "  ,$content,$ncount);
249      $content=str_replace( 'id="video"',"id='theMainImage_vid'  name='theMainImage' " ,$content,$ncount);
250  $content=str_replace( '<video"',"<video id='theMainImage_vid'  name='theMainImage' " ,$content,$ncount);
251  }else{
252      $content=str_replace( "<iframe" ,  "<iframe id='iframe' name='theMainImage' "  ,$content,$ncount);
253  }
254  $content=  preg_replace($pattern, "", $content);
255
256  $content= "<div id='theMainImage' style='height:".$theImageHeight."px  ;width:".$theImageWidth."px '>". $content . "</div>";
257 $content= "<style>#theImageAndInfos{height:auto;width:auto;position:relative}
258  #theImage{height:auto;align:center;text-align:center;position:relative}
259  #theMainImage{height:auto;align:center;text-align:center;position:static} 
260  #charlie{display:none }
261  #iframe{display:none }
262 </style>".$content;
263return  $content;
264 }
265 
266   $content=  preg_replace($pattern, "", $content);
267
268  return  $content;
269}//INIT
270
271/************************
272*  INIT 2
273*************************/
274static public function init2($content,$element_info){
275
276
277global  $template,$version,$icon_path,$page,$picture,$conf;
278global $user,$Css,$css_slideshow,$css_display,$liste_type;
279global $infos_message;
280//content = photo
281
282//=====================================================================
283  global  $has_pamoorama,$pictureSelType,$pictureDeriv;
284  global $DEBUG_autosize;
285  if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "init2, ";} ;
286   global $theImageHeight,$theImageWidth,$theImageLeft,$theImageTop,$windowWidth,$windowHeight,$theMainImageSize;
287  //-- si Autosize correction redim ---------------
288  $current = $template->get_template_vars('current'); 
289  if (!isset($current)) return ;
290  if($pictureSelType!="Autosize") return $content ; 
291    $pattern =Array('/width=\"(\d+)\"/','/height=\"(\d+)\"/');
292    $replacement = Array('',"style='height:".$theImageHeight."px'");
293      $replacement = Array('',"");
294    $content= preg_replace($pattern, $replacement, $content);
295if( $has_pamoorama=="true") return $content ;
296
297if( !preg_match("|c1|", $DEBUG_autosize, $val) ) return $content ;
298//************************  c1 ***************************************
299   echo "theMainImageWidth :" . $theMainImageSize[0] . " X " . $theMainImageSize[1]  . "<br >";
300   echo "theImageWidth :" . $theImageWidth . " X " . $theImageHeight . "<br >";
301   echo $infos_message."<br />";
302   $Ratio = $theMainImageSize[0]/$theMainImageSize[1];
303
304   $nh = intval($theImageWidth / $Ratio)  ;
305   $nw = intval($theImageHeight * $Ratio) ;
306
307   echo $nw . "x " . $nh ."<br />";
308
309if($theMainImageSize[0] < $nw){
310     echo "HEIGHT " .$theImageHeight . "  WIDTH " .  $nw."<br />";
311}
312if($theMainImageSize[1] <  $nh ){
313 echo "HEIGHT " . $nh  . "  WIDTH " .  ($theImageWidth)."<br />";
314}
315
316 $content=  $content . $pictureDeriv . " " .$pictureSelType;
317        echo "<div style='color:white;position:absolute;left:0;top:0;width:".$windowWidth ."px;height:" .$windowHeight."px;background-color:blue'>";
318         echo "left:".$theImageLeft."px;top:".$theImageTop."px;width:".$theImageWidth ."px;height:" .$theImageHeight."px;";
319        echo "<div style='position:absolute;left:".$theImageLeft."px;top:".$theImageTop."px;width:".$theImageWidth ."px;height:" .  $theImageHeight."px;background-color:green;'>";
320 self::Fin_php("#317 : " . $content + $DEBUG_autosize);
321   
322} //INIT2
323/***************************
324*
325***************************/
326static public  function reload($id_ret){
327//=========================================
328include_once ( "include/functions_cookie.inc.php");   
329global $ma_page,$user,$element_info,$infos_message,$DEBUG_autosize;
330global $pictureDeriv,$pictureSelType,$pictureMap;
331      global $conf;
332
333  $set_miniature = "<!DOCTYPE html><html><head>
334   <meta http-equiv='content-type' content='text/html; charset=UTF-8'/>
335    <script type='text/javascript' src='themes/default/js/jquery.min.js'></script>
336    <script type='text/javascript' src='plugins/Autosize/js/autosizeDetect.js'></script>
337    <script type='text/javascript' src='plugins/Autosize/js/autosize.cookie.js'></script>
338    <script type='text/javascript' src='".PHPWG_ROOT_PATH."themes/default/js/plugins/jquery.ajaxmanager.js'></script>";     
339   
340    $set_miniature .= "<script type='text/javascript' src='".PHPWG_ROOT_PATH."plugins/Autosize/js/autosize_ajax.js' id='autosize_ajax' >  </script >";
341
342   $set_var = "<script type='text/javascript'>\n var COOKIE_PATH =  '".cookie_path()."';\n"; 
343   if(preg_match("|noreload|", $DEBUG_autosize, $val)) { 
344   $set_var .= " var reload =  'false';\n"; 
345   } else {
346    $set_var .= " var reload =  'true';\n"; 
347   }
348   $set_var .= " var ret_id =  '". $id_ret . "';\n"; 
349   $set_var .= " var mapage =  '". $ma_page . "';\n"; 
350   $set_var .= " var theme =  '" .$user['theme']. "';\n"; 
351   $set_var .= " var  theMainImageWidth = '" .$element_info['width'] . "';\n"; 
352   $set_var .= " var   theMainImageHeight = '" .$element_info['height'] . "';\n";   
353   $set_var .= " var  theMainImageSrc = '" .$element_info['path']. "';\n"; 
354
355   $set_var .= " </script >";
356   
357$autoscript="
358      </head>
359      <body onload=on_load() style='background-color:black;color :white;font-size:30px '  > 
360     please wait, loading($id_ret)...
361     <div></div>
362      </body></html>";   
363     
364 
365  $default_size =  $conf['derivative_default_size'];
366//=======================================================================
367$pictureSelType = pwg_get_session_var('picture_sel_type',$default_size); 
368$pictureDeriv = pwg_get_session_var('picture_deriv',$default_size); 
369$pictureMap = pwg_get_session_var('picture_map',$default_size); 
370//=======================================================================
371   $autosize_parametres = cl_autosize_Get_Options();
372   $userst= $user['status']."_enabled" ;
373 $userst=$autosize_parametres-> $userst;
374 $usertype= $user['status']."_type" ;
375 $usertype = $autosize_parametres->$usertype;
376if($userst=='off'){
377 
378}else{ 
379      if($usertype!="Autosize" && $usertype!="SelMaxi" ){
380          $pictureSelType = $usertype;
381          $pictureDeriv = $usertype;
382      }else if($autosize_parametres->defaut_type=="off"){
383          $pictureSelType = pwg_get_session_var('picture_sel_type',"SelMaxi"); 
384      }else {
385          $pictureSelType = pwg_get_session_var('picture_sel_type',"Autosize"); 
386      }
387}       
388//============================================================
389  self::save_cookies();
390if( !isset($_COOKIE['picture_deriv'])  ){
391  echo "INIT <pre>";
392  print_r($_COOKIE);
393  self::Fin_php("#385: ".$DEBUG_autosize);
394}
395
396if(preg_match("|vue_init|", $DEBUG_autosize, $val)) {   
397  $infos_message.="Reload: $userst <br> $usertype <br> autosize_parametres:"  . cl_print_var($autosize_parametres) ; 
398        if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
399        echo "Reload: SESSION:"  . cl_print_var($_SESSION) ;
400        echo "Reload: COOKIE:"  . cl_print_var($_COOKIE) ;
401        echo "GET:"  . cl_print_var($_GET) ;
402        echo "POST:"  . cl_print_var($_POST) ;
403        self::Fin_php("#396: ".$DEBUG_autosize);
404    }
405
406     $infos_message.="Reload: $userst <br> $usertype <br> autosize_parametres:"  . cl_print_var($autosize_parametres) ; 
407
408        echo $set_miniature ;
409        echo $set_var ;
410       
411        echo $autoscript;       
412        self::Fin_php("#401: ".$DEBUG_autosize);
413       
414}
415
416 /************************
417 *  cl_autosize_script_1
418 *************************/
419 static public function cl_autosize_script_1(){
420  global $user,$page,$template,$cl_plugin,$cl_version;
421    global  $has_pamoorama,$css_slideshow; 
422    global $pictureSelType,$pictureDeriv,$infos_message,$conf;
423    global $DEBUG_autosize;
424 if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "cl_autosize_script_1, " ;} ;
425    $ma_page=isset($page['body_id'])?$page['body_id']:"" ; 
426    if ($ma_page !='thePicturePage') return ; 
427    if ( $has_pamoorama=="false" ) return ; 
428 if ($page['slideshow']){
429 //==== mise à l'échelle ===
430    $current = $template->get_template_vars('current'); 
431    $default_size =  $conf['derivative_default_size'];
432
433    if(isset($current['selected_derivative'])) {
434        $model=$current['selected_derivative']->get_type() ;
435    }else{
436        $model=$default_size;
437    }
438   
439    $selected_derivative =  $current['derivatives'][$model]; 
440    $template->append('current', array(
441                                'selected_derivative' => $selected_derivative
442                                    ), 
443                      true);
444
445 }
446 
447
448
449    $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) );
450    $autosize_parametres =       cl_autosize_Get_Options() ;                   
451    $theme=$user['theme'];
452    //==============================================================================
453    $template->assign(
454      array(   
455          'autosize_parametres' => $autosize_parametres ,
456          'cl_plugins' => $cl_plugin ,
457          'cl_version' => $cl_version ,
458          'name' => $cl_plugin['name'] ,
459          'has_pamoorama' => $has_pamoorama,                                                             
460          'theme' => $theme  , 
461          'DEBUG_autosize' => $DEBUG_autosize,
462          'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH)  ,
463          'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS,
464          'Version_pwg' => PHPWG_VERSION ,
465          'slide_show' => $page['slideshow']
466         )
467    );
468   if( preg_match("|c2|", $DEBUG_autosize, $val) ){ 
469   self::Fin_php( "446: " . $DEBUG_autosize);
470   return $content ;
471
472   }
473 
474    return $template->parse( 'autosize_init', false);
475
476
477        }// function cl_autosize_script_1
478
479 /*************************************
480 * cl_autosize_script_2()
481 **************************************/
482 static public function cl_autosize_script_2()
483 {  global $css_slideshow;
484   global $pictureSelType,$pictureDeriv,$infos_message;
485           global  $template,$user,$conf,$picture ,$page, $cl_plugin,$cl_version,$known_script ;
486 
487     global  $has_pamoorama; 
488     global $DEBUG_autosize;
489  if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "cl_autosize_script_2, ";} ;
490    $ma_page=isset($page['body_id'])?$page['body_id']:"" ;   
491    if ($ma_page !='thePicturePage') return ; 
492 
493    $theme=$user['theme'];
494    if ($has_pamoorama=="false" ) return ; 
495    if ($css_slideshow == "no" and isset($_GET['slideshow'])) return ;   
496                        $AUTOSIZE_PATH = dirname(__FILE__).'/';
497//=====================================================================
498                        $template->assign(
499                                        array(
500                                        'cl_version' => $cl_version ,
501                                        'name' => $cl_plugin['name'] ,
502                                        'ma_page' =>    $ma_page,
503                                        'theme' => $theme  ,
504                                        'DEBUG_autosize' => $DEBUG_autosize   ,
505                                        'AUTOSIZE_PATH' => AUTOSIZE_PATH         
506                                        )
507                                                );
508                        $autoscript="<script type='text/javascript'>
509                        /* cl_autosize_script_2 */
510                        if (typeof (save_framework) == 'function')
511                           save_framework('".$ma_page."'); 
512     
513                        </script>";
514                $template->append('footer_elements',$autoscript); 
515     
516                return ; 
517 }// function cl_autosize_script_2
518
519  /*************************************
520 * cl_autosize_script_3()
521 **************************************/
522 static public function cl_autosize_script_3() {
523    global  $has_pamoorama,$template,$page,$infos_message;
524     global $DEBUG_autosize;
525      if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "cl_autosize_script_3, ";} ;
526$ma_page=isset($page['body_id'])?$page['body_id']:"" ;
527if ($ma_page !='thePicturePage') return ; 
528
529   
530    $template->func_combine_script(array('id'=>'my_script_2',
531                                    'path'=> AUTOSIZE_PATH.'js/JScript.js',
532                                    'require' => 'jquery'),
533                                $template->smarty);
534
535$template->func_combine_css(array('id'=>'autosize.css',
536                                    'path'=> AUTOSIZE_PATH.'css/autosize.css'
537                            ));
538
539
540                        $autoscript="<script type='text/javascript'>   
541                         var COOKIE_PATH = '".cookie_path()."' ;
542                        </script>"; 
543                    $template->append('footer_elements',$autoscript); 
544        if ($has_pamoorama=="false" ) return ; 
545
546                        $autoscript="<script type='text/javascript'>   
547                        if (typeof (Ajout_Ajax) == 'function')
548                           Ajout_Ajax(); 
549                        </script>";
550                $template->append('footer_elements',$autoscript); 
551
552     
553                return ; 
554 }// function cl_autosize_script_3
555
556/************************
557* cl_autosize_affiche
558*************************/     
559        static public function cl_autosize_affiche(){
560  if (!defined('AUTOSIZE_PATH')) {
561      define(  'AUTOSIZE_PATH',   PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/' );
562      if (!defined('AUTOSIZE_PATH_ABS')) 
563        define(  'AUTOSIZE_PATH_ABS',  realpath(AUTOSIZE_PATH)."/");
564}
565
566    global $user, $picture, $template,$page,$known_script;
567    global $content, $element_info;   
568    global $infos_message,$error_message,$warnings_message;
569    global  $conf,$lang ,$user,$userdata;
570    global $defined_types,  $liste_type,$SRC_IMG;
571    global $set_miniature;
572    global $autosize_parametres,$user_status;   
573    global  $has_pamoorama,$pictureSelType,$pictureDeriv;
574    global $DEBUG_autosize;
575      global $css_slideshow,$css_display; 
576      if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .=  "cl_autosize_affiche, " ;} ;
577$ma_page=isset($page['body_id'])?$page['body_id']:"" ;
578if ($ma_page !='thePicturePage') return ; 
579//============================================================
580 self::save_cookies();
581
582    if(isset($set_miniature)){
583          $set_miniature = self::cl_autosize_nofile($set_miniature) ;
584          $set_miniatures= explode("script",$set_miniature);
585          if(preg_match("|noGen|", $DEBUG_autosize, $val)) { 
586          if(count($set_miniatures)> 1 )
587                $infos_message .= "PictureDeriv:" . $pictureDeriv. ' miniature:' . cl_print_var( $set_miniature); 
588                 
589            }else { 
590               
591               
592          } ; 
593          $template->append('footer_elements',$set_miniature); 
594      }
595 if ($css_slideshow == "no" and isset($_GET['slideshow'])) return ;   
596 
597  $AUTOSIZE_PATH = dirname(__FILE__).'/';
598  $theme=$user['theme']; 
599  load_language('plugin.lang', AUTOSIZE_PATH);
600
601 include_once (AUTOSIZE_PATH."include/affiche.php");   
602
603     $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ;
604     if ($css_display=="none"  &&  $has_pamoorama=="true" ) {   
605            $css_display="block" ;
606         }
607         $file_css=AUTOSIZE_PATH."css/".$theme.".css";
608         if (!file_exists($file_css))  $file_css="no";     
609     if ($css_display=="none" ) {       
610        return ;
611      } 
612     if($pictureSelType == $pictureDeriv ) {
613         if(preg_match("|event|", $DEBUG_autosize, $val)) {  cl_aff_infos_plus();} ;
614   
615     } 
616     
617    if (defined('GMAPS_VERSION')) $gmaps_function="true";
618          else $gmaps_function="false" ;
619
620
621
622        $template->set_filenames(array('autosize_content_header'=> $file )); 
623        $template->assign(      array( AUTOSIZE_PATH,$AUTOSIZE_PATH,
624                                  'file_css' =>$file_css,
625                                  'css_display' => $css_display,                                 
626                                  'theme' =>$theme,
627                                   'gmaps_function' => $gmaps_function
628                          ));
629        $template->concat('autosize_content', $template->parse('autosize_content_header', true)); 
630
631        $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ;
632        $template->set_filenames(array('autosize_init_header'=> $file ));
633        $template->parse( 'autosize_init_header', false); 
634        $theme=$user['theme']; 
635                               
636                                if($autosize_parametres->check_icon_v == 'on'){                         
637                                                $template->assign('cl_autosize_button', 
638                                                array(  'cl_autosize_info' => 'cl_autosize_info' ,
639                    'cl_autosize_info_1' => 'cl_autosize_info_' , 
640                                                                    'cl_autosize_info_2' => 'cl_autosize_info_2' ,   
641                                                                    'URL' => $_SERVER['REQUEST_URI'] ,
642                                                                    'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png',
643                                                                    'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png',
644                    'ICON1' => AUTOSIZE_PATH . 'icons/button-no.png'
645                                                                )
646
647                                                        ); 
648                                        $template->set_filenames(array('cl_bp' => $AUTOSIZE_PATH. 'template/picture.tpl'));
649                                        $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true));
650                                }
651
652                                 $template->set_filenames(
653                                                array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl',
654             'theme' => $theme   )
655                                        );
656
657                        $template->concat('autosize_content', $template->parse('autosize_content_header', true));               
658      if(isset($conf['go_up_down']) && ($conf['go_up_down']==true) ){
659        $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') );
660
661        $template->func_combine_script(array('id'=>'my_script_2',
662                                             'path'=> AUTOSIZE_PATH.'/js/JScript.js',
663                                             'require' => 'jquery'),
664                                              $template->smarty
665                                              );
666
667        $template->assign(array( 
668                          'MY_FOOTER_PATH' =>AUTOSIZE_PATH
669                          ));                                   
670        $template->parse('mes_script');
671      }   
672     
673
674if(preg_match("|vue_cookies|", $DEBUG_autosize, $val)) { 
675
676  $pictureSelType=$_COOKIE['picture_sel_type'];
677  $pictureDeriv=$_COOKIE['picture_deriv'];
678  $infos_message .= "cl_autosize_affiche: $pictureSelType  <--> $pictureDeriv \n" ;
679
680}
681 
682   if(preg_match("|test|", $DEBUG_autosize, $val)) { 
683    $infos_message .= "#653 <br>cl_autosize_affiche:_COOKIE:"  . cl_print_var($_COOKIE) ;   
684    $pictureMap=$_COOKIE['picture_map'];
685    $infos_message .= "<br />SelType:" . $pictureSelType."; pictureDeriv:".$pictureDeriv ."; pictureMap:".$pictureMap;
686   
687    self::Fin_php("#677: ".$DEBUG_autosize);
688 } 
689       cl_aff_infos_plus();
690        return $template->parse( 'autosize_content', false);
691        } //public function cl_autosize_affiche
692
693
694/****************************************
695*
696****************************************/
697function Get_Options(&$parametres,$str_index){
698    global $conf ;
699     if (!isset( $conf[$str_index]))  {   
700      $conf[$str_index]="";
701     }
702    $m_options=  $conf[$str_index];
703     if(isset($m_options))
704       if ( preg_match("|s:(.*)|", $m_options, $val) )
705        $parametres =  unserialize($conf[$str_index]);
706       else{
707         $parametres=explode(",",$_options);
708        }     
709        //====== par defaut =======================
710         $new_val=false;
711         $def_para=Array();
712
713    $def_para['query'] = 'Qt'  ;
714    $def_para['type'] = 'Ty' ;
715
716    $def_para['webmaster_type'] = 'Autosize' ; 
717    $def_para['admin_type'] = 'Autosize'  ; 
718    $def_para['generic_type'] = 'Autosize'  ;
719    $def_para['guest_type'] = 'Autosize'  ;
720    $def_para['normal_type']  =  'Autosize'  ;
721 
722
723
724    $def_para['mini_height'] =  '150' ;
725    $def_para['mini_width'] = '300' ;
726
727    $def_para['mini_height2'] =  '150' ;
728    $def_para['mini_width2'] =   '300' ;
729
730    $def_para['echelle_max'] =  '1.0'; 
731    $def_para['marge_basse'] =  '0';
732    $def_para['fade_in'] =   '0';
733    //==================================================
734    $def_para['check_desc_v'] =  "off" ;
735    $def_para['check_icon_v'] =  "off" ;
736    $def_para['defaut_type'] =  "off" ;
737
738    $def_para['webmaster_enabled'] =   "off" ;
739    $def_para['admin_enabled'] =   "off" ;
740    $def_para['generic_enabled'] =   "off" ;
741    $def_para['guest_enabled'] =   "off" ;
742    $def_para['normal_enabled'] =   "off" ;
743    //===================================================
744   $para=$def_para;   
745    foreach ($para as $key => $value) {   
746      if( isset($parametres->$key) ){
747         $value=$parametres->$key;         
748      } 
749    if($def_para[$key] =="on" ||$def_para[$key] =="off" ){
750       $val_pg=(isset($_POST[$key]))? ($_POST[$key]=="off"||$_POST[$key]=="on")?$_POST[$key]:"on" : "off" ;
751       $value =(isset($_POST[$key]))? $val_pg : $value ; 
752       $val_pg=(isset($_GET[$key]))? ($_GET[$key]=="off"||$_GET[$key]=="on")?$_GET[$key]:"on" : "off" ;
753       $value =(isset($_GET[$key]))? $val_pg  : $value ; 
754     }else{
755        $value =(isset($_POST[$key]))? $_POST[$key] : $value ; 
756        $value =(isset($_GET[$key]))? $_GET[$key] : $value ; 
757      }
758        unset( $parametres->$key) ;
759        $parametres->$key = $value ;           
760     }   
761    return $parametres ;
762  }
763  /****************************************************/
764 
765function listeFichiers($dir,$theme){
766  global $extensions_allowed;
767  $extensions_allowed = array();
768  $extensions_allowed [] = 'css';
769  if ($handle = opendir($dir)) {   
770    while (false !== ($file = readdir($handle))) {
771      if (($file <>'.') && ($file<>'..')) {
772        if (is_file($dir.'/'.$file)){
773          $extension = pathinfo($dir.'/'.$file, PATHINFO_EXTENSION);
774          if (in_array($extension,$extensions_allowed)){
775            $fileHandle = fopen($dir.'/'.$file, "r");
776           
777            $intro = fread($fileHandle,filesize ($dir.'/'.$file));
778            fclose($fileHandle);
779            if ($file== $theme){       
780              flush();   
781              return $intro ;
782            }
783          }
784      } else {
785        if (is_dir($dir.'/'.$file)){
786          listeFichiers($dir.'/'.$file,$theme);
787        }
788      }
789    }
790   }
791   closedir($handle);
792  }
793}
794//================================================
795static public function css($theme_local) {     
796    $path = $_SERVER['DOCUMENT_ROOT'];
797    if (substr($path,-1)=='/'){
798              $path =  substr($path,0,-1);
799          }
800     if(isset($_GET['path'])) 
801              $path=$_GET['path'];
802          else
803              $path=PHPWG_ROOT_PATH."local/css/";
804
805              $mycssfile=$path.$theme_local;
806
807              if(!file_exists($mycssfile))
808               $mycssfile=$path."default-rules.css";
809
810               if(!file_exists($mycssfile)){             
811              return Array();
812               }
813
814      $ret =   file_get_contents ($mycssfile);
815
816    function remove_comments( & $string ) { 
817       $string = preg_replace('#/\*.*?\*/#s',"",$string); 
818       return $string;
819     }
820
821    $order   = array("\r\n", "\n", "\r"," ");
822    $replace = '';
823    $newstr = str_replace($order, $replace, $ret); 
824
825    $order   = array('"');
826    $replace = "'";
827    $newstr = str_replace($order, $replace, $newstr); 
828
829
830    $order   = array("}");
831    $replace = '}\r\n';
832    $newstr = str_replace($order, $replace, $newstr);
833    remove_comments($newstr);
834
835    $newstr = explode('\r\n',$newstr);
836    $css=Array();
837   
838  foreach ($newstr as $key => $value) {   
839   if($value){
840    $css2=Array();
841      $key=explode("{",$value);   
842      $value = str_replace("}","",$key[1]) ;
843      $value=explode(";",$value); 
844           foreach ($value as $key2 => $value2) {   
845            if($value2){
846              $key2=explode(":",$value2);   
847                $value2 =  $key2[1] ;
848                $css2[$key2[0]] = $value2 ;
849            }
850           }
851      $css[$key[0]]=$css2 ;
852     }   
853}
854
855       
856                    return $css;
857        } 
858
859/***************************
860 *  get_min_max
861 ***************************/
862 static public function get_min_max(){
863 global $liste_type,$img_all,$set_miniature,$template,$infos_message,$error_message,$has_pamoorama ; 
864 global $theImageWidth,$theImageHeight,$pictureSelType,$pictureDeriv ;
865   global $DEBUG_autosize;
866 
867
868    $current = $template->get_template_vars('current'); 
869    $liste_type="";
870    $del_deriv_types = array();
871    $i=0;
872     $defined_types = array_keys(ImageStdParams::get_defined_type_map());     
873    foreach($defined_types as $type){
874   
875      if($type!="Autosize" && $type!="SelMaxi" ){
876            $last_derivative= $type ;
877            $del_deriv_types[$i] =  $last_derivative ; 
878        $i++;
879      }
880     
881    }
882    ;
883    $derivative=$current['derivatives'][$last_derivative] ;   
884    $img_all= $derivative->get_all($derivative->src_image);
885
886    $retour = (object) '';
887    $maxi_image = (object) '';
888    $mini_image = (object) '';
889    $std_image  = (object) '';
890    $default_image=(object) '';
891    $SelType_image=(object) '';
892    $last_image=(object) '';
893
894    global $imgSizeWH ;
895    $imgSizeWH  = $derivative->get_size();     
896    $theImage_maxi=0;
897     $theImage_mini=0;
898     $theImage_def=0;
899     $No_files= array();
900//================= Liste =========================   
901  $ok= 0 ;
902  $nofile=0 ; 
903  //=============================================
904  // Liste mini maxi
905  //=============================================
906    foreach ($img_all as $img_select){
907            $img_type  =  $img_select->get_type();     
908            $img_url  = $img_select->get_path();     
909            $imgWH  =  $img_select->get_size();   
910            if ($img_type=="square" || $img_type=="thumb" ) continue ;   
911            if($img_type=="Autosize" || $img_type=="SelMaxi"){
912            $theImage_def +=1 ;
913             continue;
914             }             
915           if(!file_exists(PHPWG_ROOT_PATH.$img_url)){   
916                  $No_files[$img_type] =   $img_select ;
917                  $nofile++ ;   
918                   if(preg_match("|get_infos|", $DEBUG_autosize, $val)) 
919                  $infos_message .=$nofile ." " ;
920            }         
921             if(preg_match("|get_minfos|", $DEBUG_autosize, $val)) 
922                      $infos_message .=$img_url . " -> " . $img_type ."<br >";
923
924          if(file_exists(PHPWG_ROOT_PATH.$img_url)){    } // if file       
925                             
926                     if ($theImage_def==0){
927                        // Avant Autosize ou Original;
928                        if($img_type=="Original") {
929                            $theImage_def = 1;
930                            $theImage_maxi=1;
931                            $theImage_mini=1;
932                            if($ok==0){
933                                $last_image->type=$img_type;
934                                $last_image->url=$img_url;
935                                $last_image=$img_select;     
936                              }
937                         }else{
938                            $last_derivative=$img_type ;
939                            $last_image=  $img_select; 
940                           } 
941                       }
942                       if ($theImage_maxi==0){                       
943                            $maxi_image=  $img_select; 
944                          }
945                       if ($theImage_mini==0){                     
946                            $mini_image=  $img_select; 
947                          }
948                    $liste_type[$img_type]=$img_type.",".$img_url.",".$imgWH[0] .",".$imgWH[1] ;
949                    if( $img_type==$pictureSelType){
950                     if(preg_match("|get_minfos|", $DEBUG_autosize, $val))     $infos_message .= $pictureSelType . " <--> " . $img_type ."<br >";
951
952                          $SelType_image->type=$img_type;
953                          $SelType_image->url=$img_url;
954                          $SelType_image=$img_select;   
955                    }
956                    if( $img_type=="Original" && $theImage_def==0 ){ 
957                          $theImage_def=1;
958                          $img_type = $last_derivative ;                         
959                          $img_url= $derivative->get_path();
960                          $imgWH = $derivative->get_size();
961
962                          $default_image->type=$img_type;
963                          $default_image->url=$img_url;
964                          $default_image=$img_select;                     
965                       
966                        }
967
968                     if($has_pamoorama==true) 
969                          $test= ($imgWH[1] >  $theImageHeight)  ;
970                    else
971                          $test= ($imgWH[1] >  $theImageHeight  && $imgWH[0] >  $theImageWidth);             
972                    if($theImage_maxi==0)
973                        if( $test  ){ 
974                                $theImage_maxi=1; 
975                                $maxi_image->type =   $img_type;
976                                $img_type=$img_select->get_type();
977                                if($img_type=="Original")
978                                    $maxi_image = $last_image; 
979                                else
980                                    $maxi_image = $img_select;   
981                                                             
982                               $maxi_image->url  =  $maxi_image->get_path();
983
984                            } else { 
985                           
986                                $mini_image->type=$img_type;
987                                $mini_image->url=$img_url;
988                                $mini_image=$img_select; 
989                               $mini_image->url  =  $mini_image->get_path();           
990                            }                         
991       
992      } // for
993      //================================================ 
994 
995      $img_url = $img_select->src_image->get_url();
996                $imgSizeWH  =  $img_select->src_image->get_size();
997                $liste_type["Original"]="Original".",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ;
998     
999 
1000          $retour=(object)'' ;
1001      if ($pictureSelType=="Autosize") $retour= $maxi_image ;
1002      else if ($pictureSelType=="SelMaxi") $retour= $mini_image ;
1003      else{     
1004      $types = array_intersect(array_keys($liste_type), array($pictureSelType));
1005      if(!count($types)){
1006        $pictureSelType="Original";
1007      }
1008        $retours=  explode(",",$liste_type[$pictureSelType]);
1009        $retour=$SelType_image;
1010        $retour->type=$retours[0];
1011        $retour->url=$retours[1];
1012     }
1013
1014  if (!isset( $retour->type)){     
1015                  $retour=$last_image;
1016                  $retour->type =  $retour->get_type();
1017                  $retour->url  =  $retour->get_path();
1018               
1019}
1020if (isset( $retour->type) && $retour->type=="Original" ){     
1021                  $retour=$last_image;
1022                  $retour->type =  $last_derivative;
1023                  $retour->url  =  $retour->get_path();
1024             
1025}
1026      if($nofile > 0){ 
1027        $set_miniature=$No_files ;
1028      }
1029
1030    if(preg_match("|get_infos|", $DEBUG_autosize, $val)) 
1031            $infos_message .=$pictureSelType . " -> " . $retour->type . " : "  . $retour->url  ."<br >";
1032
1033return $retour ;
1034
1035  }
1036//==================================================================
1037static public  function  cl_autosize_nofile($img_all){
1038 //=== verification fichiers absents ===
1039 global $infos_message,$error_message;
1040 global $theImageHeight,$theImageWidth,$theImageLeft,$theImageTop,$windowWidth,$windowHeight,$theMainImageSize;
1041global  $pictureDeriv;
1042  $ok=false ;
1043 $nofiles=array();
1044 $file_no=(object) '';
1045
1046 $nosrc=false ;
1047 $ok=true ;
1048 $listes="";     
1049  foreach ($img_all as $img_select){
1050    $img_url  = $img_select->get_url();
1051    if(!file_exists(PHPWG_ROOT_PATH.$img_url)){   
1052      $img_type  =  $img_select->get_type();     
1053     
1054      $file_id=explode("?",$img_url); 
1055      if(count($file_id) ==1){
1056          $file_id[]=$file_id[0] ;
1057      }   
1058        if ( !preg_match("|".$file_id[1]."|", $listes) ){
1059              $listes  .=  $file_id[1] ."<br />";
1060              $file_no->url= $file_id[1] ;         
1061              $id  =  $img_select->src_image->id;                 
1062              $file_no->id=$id ;
1063              $file_no->type=$img_type ; 
1064              array_push($nofiles,serialize($file_no)) ;   
1065               if( $img_type == $pictureDeriv){
1066         
1067          break ;
1068    }           
1069      }
1070      $ok=false ;     
1071    }
1072  }
1073  $exec_miniatures="";
1074  if(count($nofiles)>0){
1075  //=======================================================================================
1076    if($nosrc!=true  ){
1077      $script_miniatures = "<script type='text/javascript' src='".PHPWG_ROOT_PATH."themes/default/js/plugins/jquery.ajaxmanager.js' ></script>";     
1078      $script_miniatures .= "<script type='text/javascript' src='".PHPWG_ROOT_PATH."plugins/Autosize/js/autosize_ajax.js' id='autosize_ajax' >  </script >";
1079      $nosrc=true ;
1080    } 
1081    $exec_miniatures ="";
1082      $script_miniatures .= "<script type='text/javascript'>
1083        var nofile=Array(";
1084        for ($i=0;$i  <  count($nofiles)-1 ;$i++){       
1085             $file = unserialize($nofiles[$i]);
1086             $exec_miniatures .=  "{id:'".$file->id."',type:'". $file->type."',file:'". $file->url."',width:'".$theMainImageSize[0]."', height:'".$theMainImageSize[1]."'},\n" ;
1087          } 
1088          if($i  <  count($nofiles))
1089          {   $file = unserialize($nofiles[$i]);
1090             $exec_miniatures .=  "{id:'".$file->id."',type:'". $file->type."',file:'". $file->url."',width:'".$theMainImageSize[0]."', height:'".$theMainImageSize[1]."'}" ;
1091             }
1092             /*** Un seul ***********/
1093             $file = unserialize($nofiles[count($nofiles)-1]);
1094             $exec_miniatures =  "{id:'".$file->id."',type:'". $file->type."',file:'". $file->url."',width:'".$theMainImageSize[0]."', height:'".$theMainImageSize[1]."'}" ;
1095
1096          $script_miniatures  .= $exec_miniatures . "); </script>\n" ;                 
1097          $script_miniatures  .= "<script type='text/javascript' >
1098          if(typeof nofile!='undefined')
1099              getDerivativeUrls(nofile);
1100      </script>";
1101      //==================================================================================
1102      return $script_miniatures  ;
1103    }
1104 }
1105 /***************************
1106 *  get_cookies
1107 ****************************/
1108 static public  function  get_cookies(){
1109  global $pictureDeriv,$pictureSelType,$pictureDeriv,$pictureMap;
1110  if(!isset($_COOKIE['picture_deriv'])){
1111      $pictureDeriv= pwg_get_session_var('picture_deriv');
1112      $pictureSelType = pwg_get_session_var('picture_sel_type');
1113      $pictureMap = pwg_get_session_var('picture_map') | $pictureDeriv;
1114  }else{
1115      $pictureDeriv = $_COOKIE['picture_deriv'];
1116      $pictureSelType = isset( $_COOKIE['picture_sel_type'])?$_COOKIE['picture_sel_type']:$pictureDeriv;
1117     
1118      $pictureMap =  isset($_COOKIE['picture_map'])?$_COOKIE['picture_map']:$pictureDeriv;
1119  }
1120  $_COOKIE['picture_sel_type']=$pictureSelType;
1121  $_COOKIE['picture_deriv']=$pictureDeriv;
1122  $_COOKIE['picture_map']=$pictureMap;
1123
1124 }
1125 /***************************
1126 * save_cookies
1127 ****************************/
1128 static public  function  save_cookies(){
1129  global $pictureDeriv,$pictureSelType,$pictureDeriv,$pictureMap;
1130
1131  pwg_set_session_var('picture_deriv',$pictureDeriv);
1132  pwg_set_session_var('picture_sel_type',$pictureSelType);
1133  pwg_set_session_var('picture_map',$pictureDeriv);
1134//============================================================
1135  setcookie( 'picture_sel_type',
1136            $pictureSelType,
1137            time()+5,
1138            cookie_path() 
1139          );
1140//=============================================================
1141  setcookie( 'picture_map',
1142            $pictureDeriv,
1143            time()+5,
1144            cookie_path() 
1145          );
1146//============================================================
1147  setcookie( 'picture_deriv',
1148            $pictureDeriv,
1149            time()+5,
1150            cookie_path() 
1151          );
1152$_COOKIE['picture_sel_type']=$pictureSelType;
1153$_COOKIE['picture_deriv']=$pictureDeriv;
1154$_COOKIE['picture_map']=$pictureDeriv;
1155}
1156
1157static public function Fin_php($message_){
1158global  $infos_message;
1159 echo "End :".$message_."<br>";
1160die($infos_message);
1161}
1162 //==================================================
1163} // class
1164
1165/*************************************
1166        *
1167 *************************************/
1168 function cl_autosize_Get_Options()
1169  {
1170                global $conf,$autosize_parametres; 
1171    $autosize_parametres ="";
1172 
1173 if (!isset($conf['cl_autosize']))  {   
1174  $conf['cl_autosize']="";
1175  $q = '
1176   INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
1177   VALUES ("cl_autosize","","Parametres du plugin Autosize")
1178  ;';
1179  pwg_query($q);
1180  }
1181 
1182 
1183
1184                $autosize_parametres =  unserialize($conf['cl_autosize']);
1185      // $autosize_parametres = self::Get_Options($autosize_parametres,'cl_autosize');
1186                $autosize_parametres =  cl_autosize_Set_Options();
1187                return $autosize_parametres;
1188  }
1189        /*
1190        *
1191        */
1192function cl_autosize_Set_Options() {
1193  global $autosize_parametres;
1194//=============================================================================
1195$my_para=$autosize_parametres;
1196  if (empty($my_para))
1197$my_para = (object) '';
1198
1199$my_para->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($my_para->query )) ? $my_para->query : 'Qt' ) ;
1200$my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type:  'Ty') ;
1201
1202$my_para->webmaster_type =(isset($_POST['webmaster_type'])) ? $_POST['webmaster_type'] : ((isset($my_para->webmaster_type )) ? $my_para->webmaster_type : 'Autosize' ) ;
1203
1204$my_para->admin_type =(isset($_POST['admin_type'])) ? $_POST['admin_type'] : ((isset($my_para->admin_type )) ? $my_para->admin_type : 'Autosize' ) ;
1205
1206$my_para->generic_type =(isset($_POST['generic_type'])) ? $_POST['generic_type'] : ((isset($my_para->generic_type )) ? $my_para->generic_type : 'Autosize' ) ;
1207
1208
1209$my_para->guest_type =(isset($_POST['guest_type'])) ? $_POST['guest_type'] : ((isset($my_para->guest_type )) ? $my_para->guest_type : 'Autosize' ) ;
1210
1211
1212$my_para->normal_type =(isset($_POST['normal_type'])) ? $_POST['normal_type'] : ((isset($my_para->normal_type )) ? $my_para->normal_type : 'Autosize' ) ;
1213
1214
1215
1216$my_para->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($my_para->mini_height )) ? $my_para->mini_height : '150' ) ;
1217$my_para->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($my_para->mini_width)) ? $my_para->mini_width:  '300') ;
1218
1219$my_para->mini_height2 =(isset($_POST['mini_height2'])) ? $_POST['mini_height2'] : ((isset($my_para->mini_height2 )) ? $my_para->mini_height2 : '150' ) ;
1220$my_para->mini_width2=(isset($_POST['mini_width2']))? $_POST['mini_width2']: ((isset($my_para->mini_width2)) ? $my_para->mini_width2:  '300') ;
1221
1222$my_para->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($my_para->echelle_max)) ? $my_para->echelle_max :  '1.0'); 
1223$my_para->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($my_para->marge_basse)) ? $my_para->marge_basse :  '0');
1224$my_para->fade_in=(isset($_POST['fade_in']))? $_POST['fade_in']: ((isset($my_para->fade_in)) ? $my_para->fade_in :  '0');
1225
1226//===============================================================================       
1227
1228if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') )  { 
1229                $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ;
1230                $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ;
1231        $my_para->defaut_type= isset($_POST['defaut_type']) ? $_POST['defaut_type'] : "off" ;
1232
1233                $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ;
1234                $my_para->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ;
1235                $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ;
1236                $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ;
1237                $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ;
1238
1239         }else{
1240                $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') ; 
1241                $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') ; 
1242                $my_para->defaut_type = isset($_POST['defaut_type']) ? $_POST['defaut_type'] : ( ( isset($my_para->defaut_type) ) ? $my_para->defaut_type :   'off') ; 
1243
1244$my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($my_para->webmaster_enabled) ) ? $my_para->webmaster_enabled :   'on') ; 
1245$my_para->admin_enabled  = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($my_para->admin_enabled ) ) ? $my_para->admin_enabled :   'on') ; 
1246$my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($my_para->generic_enabled) ) ? $my_para->generic_enabled :   'on') ; 
1247$my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($my_para->guest_enabled) ) ? $my_para->guest_enabled :   'on') ;
1248$my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($my_para->normal_enabled) ) ? $my_para->normal_enabled :   'on') ; 
1249
1250
1251   }
1252
1253return $my_para;
1254}
1255        /*
1256        *
1257        */
1258function cl_autosize_sauve_options_inf()
1259{
1260global $options,$infos_message,$conf,$autosize_parametres  ;
1261$infos_message .=l10n("cl_autosize_save_config")."<br>";
1262 $autosize_parametres=cl_autosize_Set_Options();
1263 if ( isset($autosize_parametres) )     { 
1264                $query = '
1265                UPDATE '.CONFIG_TABLE.'
1266                SET value="'.addslashes(serialize($autosize_parametres)).'"
1267                WHERE param = "cl_autosize"
1268                LIMIT 1';
1269                        pwg_query($query);
1270          }
1271    if (!isset($conf['cl_derivatives_sav']))  {   
1272      $q = '
1273        INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
1274        VALUES ("cl_derivatives_sav","","sauvegarde derivatives")
1275      ;';
1276      pwg_query($q);     
1277      }
1278 }
1279 /*************************
1280 *
1281 *************************/
1282 if(!function_exists("cl_print_var")){
1283   function cl_print_var($variables){
1284    ob_start();
1285    echo '<pre>';
1286    print_r($variables);
1287    echo '</pre>';
1288    $m= ob_get_contents();
1289    ob_end_clean();
1290    return $m;         
1291  }
1292}
1293/******************
1294*
1295******************/
1296if(!function_exists("cl_aff_infos_plus")){
1297        function cl_aff_infos_plus()
1298                {
1299                 global $template,$infos_message,$error_message,$warnings_message, $user ;
1300                 global  $conf,$lang,$page  ;
1301                 //==============================================================
1302                  if (isset($error_message))    {       
1303                                if ($error_message <> ""){
1304                                                $error_message=str_replace("\n",'<br />',$error_message) ;
1305                                                $template->assign('errors',$error_message);
1306                                                $error_message="";
1307                                        }
1308                        }
1309     //==============================================================
1310                  if (isset($warnings_message)) {       
1311                                if ($warnings_message <> ""){
1312                                                $warnings_message=str_replace("\n",'<br />',$warnings_message) ;
1313                                                $template->assign('warnings',$warnings_message);
1314                                                $warnings_message="";
1315                                        }
1316                        }
1317        //=============================================
1318                  if (isset($infos_message)){                   
1319                                if ($infos_message <> ""){
1320                                                $infos_message=str_replace("\n",'<br />',$infos_message) ;
1321                                                $template->assign('infos',$infos_message);
1322                                                $infos_message="";
1323                                        }
1324                                }
1325                                //=============================================================
1326                return;         
1327               
1328                } // function cl_autosize_aff_infos_plus
1329        //===============================================================
1330}
1331
1332?>
Note: See TracBrowser for help on using the repository browser.