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

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

[extensions] Autosize fix bug init pictureMap

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