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

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

[extensions] Autosize fix compatibility with 2.4 (compatible gvideo)

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