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

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

[extensions] Autosize fix compatibility with 2.4 (fix bugs)

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