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

Last change on this file since 8194 was 8070, checked in by cljosse, 13 years ago

[Autosize][beta] fix bug whith pamooramic


File size: 14.3 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// +-----------------------------------------------------------------------+
22if (!defined('AUTOSIZE_PATH')) 
23define(
24  'AUTOSIZE_PATH',
25   PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'
26);
27
28class autosize_controler {
29        /*
30        *
31        */
32       
33        static public function cl_autosize_affiche()
34        {
35                global $user, $picture, $template,$page;
36                global $content, $element_info;   
37                global $infos_message,$erreur_message;
38                global  $conf,$lang ,$user,$userdata;
39
40                load_language('lang', AUTOSIZE_PATH);
41                $my_path = dirname(__FILE__).'/';
42
43
44
45                 if (isset( $page['body_id']) && $page['body_id']=='thePicturePage'  ) {
46                        if ( isset($picture['current'])){       
47                                       
48                       
49       
50                               
51                                $autosize_parametres = cl_autosize_Get_Options();
52                                include (AUTOSIZE_PATH."include/affiche.php"); 
53                               
54                               
55                                if($autosize_parametres->check_icon_v == 'on'){                         
56                                                $template->assign('cl_autosize_button', 
57                                                array(  'cl_autosize_info' => 'cl_autosize_info' ,
58                                                                'cl_autosize_info_2' => 'cl_autosize_info_2' ,   
59                                                                'URL' => $_SERVER['REQUEST_URI'] ,
60                                                                'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png',
61                                                                'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png'
62                                                                )
63
64                                                        );
65 
66                                        $template->set_filenames(array('cl_bp' => $my_path. 'template/picture.tpl'));
67                                        $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true));
68                                }
69                                 $template->set_filenames(
70                                                array('autosize_content'=> $my_path.'template/autosize.tpl')
71                                        );
72                                                                                                       
73                                return $template->parse( 'autosize_content', false);
74                                  }
75                }
76
77        } //public function cl_autosize_affiche
78        /*
79        *
80        */
81        static public function cl_autosize_admin($menu)
82                {
83                global  $lang ;
84                array_push($menu, array('NAME' => 'Autosize',
85                'URL' => get_admin_plugin_menu_link(AUTOSIZE_PATH . 'admin/admin_autosize.php')));
86                return $menu;
87        } //function cl_autosize_admin
88        /*
89        *
90        */
91        static public function cl_autosize_aff_infos_plus()
92                {
93                 global $template,$infos_message,$erreur_message, $user ;
94                global  $conf,$lang ;
95       
96                 //==============================================================
97                  if (isset($erreur_message))
98                                {       
99                                if ($erreur_message <> "")
100                                        {
101                                                $erreur_message=str_replace("\n",'<br />',$erreur_message) ;
102                                                $template->assign('errors',$erreur_message);
103                                                $erreur_message="";
104                                        }
105                                }
106                  if (isset($infos_message))
107                                {       
108               
109                                if ($infos_message <> "")
110                                        {
111                                                $infos_message=str_replace("\n",'<br />',$infos_message) ;
112                                                $template->assign('infos',$infos_message);
113                                                $infos_message="";
114                                        }
115                                }
116                                //=============================================================
117                return;         
118               
119                } // function cl_autosize_aff_infos_plus
120
121
122
123 /*
124 * conflit =============================================
125 */
126 static public function cl_autosize_script_3($content)
127 {
128                global  $template,$user,$conf,$picture ,$page,$cl_plugin;
129 
130                $my_path =  basename(dirname(__FILE__)).'/' ;
131                $my_path = dirname(__FILE__).'/';
132                $DEBUG = isset($conf['cl_debug']) ? $conf['cl_debug'] : "false" ; 
133               
134                $ThePicture = $template->get_template_vars('current');
135                $tpl_name =   $user['theme'] ;
136
137 $autosizejs ='<!--- cl_autosize_script_3 -->';
138                $autosizejs = $autosizejs.'<script type="text/javascript" id="jquery" charset="utf-8"  src="';
139                $autocss =   $autosizejs.'themes/default/js/jquery.packed.js"></script>'."\n"; 
140        //      $template->append('head_elements',$autocss);
141 
142                $autocss="<script type='text/javascript'>
143                /* cl_autosize_script_3 */
144                var DEBUG=\"".$DEBUG."\" ;
145                if (fade_in !=0) jQuery('#theImage').css({opacity:'0.0'});
146                if (fade_in !=0) jQuery('#theImage').css({opacity:'1.0'});
147         
148</script>";
149
150        //      $template->append('footer_elements',"\n".$autocss);
151 
152                if ( !empty($content) )   {  return $content;  }       
153                if ($ThePicture['is_picture'] <> 1 )    { 
154                 return $content;  ; 
155                 }     
156
157
158                return $content ;
159
160 }// function cl_autosize_script_3
161 //=================================================================================
162 static public function cl_autosize_script_2()
163 {
164           global  $template,$user,$conf,$picture ,$page, $cl_plugin ;
165         
166                        $my_path =  basename(dirname(__FILE__)).'/' ;
167                        $my_path = dirname(__FILE__).'/';
168                        $DEBUG =  isset($conf['cl_debug']) ? $conf['cl_debug'] : "false"  ; 
169                        $ma_page=isset($page['body_id'])?$page['body_id']:"" ;
170                        $theme=$user['theme'];
171                        $template->assign(
172                                        array(
173                                        'cl_version' => $cl_plugin['version'] ,
174                                        'name' => $cl_plugin['name'] ,
175                                        'ma_page' =>    $ma_page,
176                                       
177                                        'theme' => $theme  ,
178                                        'DEBUG' => $DEBUG   ,
179                                        'AUTOSIZE_PATH' => AUTOSIZE_PATH
180                                        )
181                                                );
182                                                 
183$autoscript="<script type='text/javascript'>
184/* cl_autosize_script_2 */
185var DEBUG=\"".$DEBUG."\" ;
186if (typeof (save_framework) == 'function')
187   save_framework('".$ma_page."');
188</script>";
189                         $template->append('footer_elements',$autoscript); 
190                         return ; 
191
192 }// function cl_autosize_script_2
193 //============================================================
194 /*
195  *  cl_autosize_script
196 */
197 static public function cl_autosize_script()
198        {
199           global  $template,$user,$conf,$picture ,$page, $cl_plugin ;
200                if(isset($page['body_id']) &&   $page['body_id'] == 'theAdminPage' ) return ; 
201
202            $my_path = dirname(__FILE__).'/';
203                $template->set_filenames(array('autosize_init'=>$my_path. "template/conflit.tpl" ) );   
204                $DEBUG = isset($conf['cl_debug']) ? $conf['cl_debug'] : "false" ; 
205                $autosize_parametres =   cl_autosize_Get_Options() ;                   
206                $theme=$user['theme'];
207                $url = get_root_url();   
208                 
209                $template->assign(
210                                                array(   
211                                                'autosize_parametres' => $autosize_parametres ,
212                                                'cl_plugins' => $cl_plugin ,
213                                                'cl_version' => $cl_plugin['version'] ,
214                                                'name' => $cl_plugin['name'] ,
215                                                 
216                                                 'MY_ROOT' => get_root_url(),
217                                                'theme' => $theme  ,
218                                                'DEBUG' => $DEBUG   ,
219                                                'AUTOSIZE_PATH' => AUTOSIZE_PATH)
220                                                 );
221 
222                return $template->parse( 'autosize_init', false);
223        }// function cl_autosize_script
224//===============================================================
225/*
226 *
227*/
228static public function cl_ajuste_data($content){
229        global  $template,$user,$conf,$picture ;
230        $my_path = realpath(AUTOSIZE_PATH .'/');
231        $userdata=$user;
232        $fields = array( 'maxwidth', 'maxheight' );
233         
234        $ThePicture = $template->get_template_vars('current'); 
235        $data = array();
236 return $content;
237
238        $data['maxwidth'] = '1200';
239        $data['maxheight'] ='250';
240        $data['user_id'] = $userdata['id'];
241        foreach ($fields as $field)
242        {
243                if (isset($_POST[$field]))
244                {
245                        $data[$field] = $_POST[$field];
246                }
247        }
248       
249        if($data['maxwidth'] != "" )
250                {
251                $picture['current']['scaled_width']=$data['maxwidth'];
252                $picture['current']['scaled_height']=$data['maxheight'];
253                mass_updates(USER_INFOS_TABLE,
254                                array('primary' => array('user_id'), 'update' => $fields),
255                                array($data)); 
256                }
257                 
258                return $content;                                                                                 
259         }
260
261} // class
262
263
264        /*
265        *
266        */
267 function cl_autosize_Get_Options()
268  {
269                global $conf,$autosize_parametres; 
270                $autosize_parametres =  unserialize($conf['cl_autosize']);
271                $autosize_parametres =  cl_autosize_Set_Options();
272                return $autosize_parametres;
273  }
274        /*
275        *
276        */
277function cl_autosize_Set_Options()
278  {
279
280  global $autosize_parametres;
281//=============================================================================
282$my_para=$autosize_parametres;
283
284$my_para->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($my_para->query )) ? $my_para->query : 'Qt' ) ;
285$my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type:  'Ty') ;
286
287$my_para->webmaster_height =(isset($_POST['webmaster_height'])) ? $_POST['webmaster_height'] : ((isset($my_para->webmaster_height )) ? $my_para->webmaster_height : '100%' ) ;
288$my_para->webmaster_width=(isset($_POST['webmaster_width']))? $_POST['webmaster_width']: ((isset($my_para->webmaster_width)) ? $my_para->webmaster_width:  '90%') ;
289
290$my_para->admin_height =(isset($_POST['admin_height'])) ? $_POST['admin_height'] : ((isset($my_para->admin_height )) ? $my_para->admin_height : '90%' ) ;
291$my_para->admin_width=(isset($_POST['admin_width']))? $_POST['admin_width']: ((isset($my_para->admin_width)) ? $my_para->admin_width:  '90%') ;
292
293$my_para->generic_height =(isset($_POST['generic_height'])) ? $_POST['generic_height'] : ((isset($my_para->generic_height )) ? $my_para->generic_height : '100%' ) ;
294$my_para->generic_width=(isset($_POST['generic_width']))? $_POST['generic_width']: ((isset($my_para->generic_width)) ? $my_para->generic_width:  '90%') ;
295
296$my_para->guest_height =(isset($_POST['guest_height'])) ? $_POST['guest_height'] : ((isset($my_para->guest_height )) ? $my_para->guest_height : '100%' ) ;
297$my_para->guest_width=(isset($_POST['guest_width']))? $_POST['guest_width']: ((isset($my_para->guest_width)) ? $my_para->guest_width:  '90%') ;
298
299$my_para->normal_height =(isset($_POST['normal_height'])) ? $_POST['normal_height'] : ((isset($my_para->normal_height )) ? $my_para->normal_height : '100%' ) ;
300$my_para->normal_width=(isset($_POST['normal_width']))? $_POST['normal_width']: ((isset($my_para->normal_width)) ? $my_para->normal_width:  '90%') ;
301
302
303$my_para->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($my_para->mini_height )) ? $my_para->mini_height : '150' ) ;
304$my_para->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($my_para->mini_width)) ? $my_para->mini_width:  '300') ;
305
306$my_para->mini_height2 =(isset($_POST['mini_height2'])) ? $_POST['mini_height2'] : ((isset($my_para->mini_height2 )) ? $my_para->mini_height2 : '150' ) ;
307$my_para->mini_width2=(isset($_POST['mini_width2']))? $_POST['mini_width2']: ((isset($my_para->mini_width2)) ? $my_para->mini_width2:  '300') ;
308
309$my_para->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($my_para->echelle_max)) ? $my_para->echelle_max :  '1.2'); 
310$my_para->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($my_para->marge_basse)) ? $my_para->marge_basse :  '50');
311$my_para->fade_in=(isset($_POST['fade_in']))? $_POST['fade_in']: ((isset($my_para->fade_in)) ? $my_para->fade_in :  '200');
312
313//===============================================================================       
314
315if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') )  { 
316                $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ;
317                $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ;
318                $my_para->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : "off" ;
319
320                $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ;
321                $my_para->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ;
322                $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ;
323                $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ;
324                $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ;
325
326         }else{
327                $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') ; 
328                $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') ; 
329                $my_para->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : ( ( isset($my_para->check_auto_w) ) ? $my_para->check_auto_w :   'off') ; 
330
331
332$my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($my_para->webmaster_enabled) ) ? $my_para->webmaster_enabled :   'on') ; 
333$my_para->admin_enabled  = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($my_para->admin_enabled ) ) ? $my_para->admin_enabled :   'on') ; 
334$my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($my_para->generic_enabled) ) ? $my_para->generic_enabled :   'on') ; 
335$my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($my_para->guest_enabled) ) ? $my_para->guest_enabled :   'on') ;
336$my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($my_para->normal_enabled) ) ? $my_para->normal_enabled :   'on') ; 
337
338
339   }
340
341return $my_para;
342}
343        /*
344        *
345        */
346function cl_autosize_sauve_options_inf()
347{
348global $options,$infos_message,$conf,$autosize_parametres  ;
349$infos_message .=l10n("cl_autosize_save_config")."<br>";
350 $autosize_parametres=cl_autosize_Set_Options();
351
352 if ( isset($autosize_parametres) )
353        {
354 
355                $query = '
356                UPDATE '.CONFIG_TABLE.'
357                SET value="'.addslashes(serialize($autosize_parametres)).'"
358                WHERE param = "cl_autosize"
359                LIMIT 1';
360                        pwg_query($query);
361          }
362         
363 }
364
365
366
367?>
Note: See TracBrowser for help on using the repository browser.