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

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

[Autosize][beta] save

File size: 14.6 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// | Autosize                                                              |
5// +-----------------------------------------------------------------------+
6// | Copyright(C) 2010      cljosse                                        |
7// +-----------------------------------------------------------------------+
8// | This program is free software; you can redistribute it and/or modify  |
9// | it under the terms of the GNU General Public License as published by  |
10// | the Free Software Foundation                                          |
11// |                                                                       |
12// | This program is distributed in the hope that it will be useful, but   |
13// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
14// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
15// | General Public License for more details.                              |
16// |                                                                       |
17// | You should have received a copy of the GNU General Public License     |
18// | along with this program; if not, write to the Free Software           |
19// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
20// | USA.                                                                  |
21// +-----------------------------------------------------------------------+
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                if (isset( $page['body_id'])  ) {
44                if ( $page['body_id']=='thePicturePage'  ) {
45                        if ( isset($picture['current'])){
46                               
47                                $autosize_parametres = cl_autosize_Get_Options();
48                                include (AUTOSIZE_PATH."include/affiche.php"); 
49                                $debug = isset($conf['debug']) ? $conf['debug'] : false ; 
50                                $cl_visible=isset($conf['cl_auto']) ? $conf['cl_auto'] : 'true' ; 
51                               
52                                if($autosize_parametres->check_icon_v == 'on'){
53                                 
54                                $template->assign('cl_autosize_button', 
55                                 array( 
56                                                'cl_autosize_info' => 'cl_autosize_info' ,
57                                                'cl_autosize_info_2' => 'cl_autosize_info_2' ,   
58                                                'URL' => $_SERVER['REQUEST_URI'] ,
59                                                'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png',
60                                                'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png'
61                                        )
62
63                                        );
64 
65                                $template->set_filenames(array('cl_bp' => $my_path. 'template/picture.tpl'));
66                                $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true));
67                                }
68                                 
69
70                                $template->set_filenames(
71                                                array('autosize_content'=> $my_path.'template/autosize.tpl')
72                                        );
73                   $template->assign(
74                                                array('DEBUG' => $debug   ,
75                                                'cl_visible' =>  $cl_visible
76                                                )
77                                                 );             
78                                                                       
79                                return $template->parse( 'autosize_content', false);
80                        }
81     
82                }
83                }
84        } //public function cl_autosize_affiche
85        /*
86        *
87        */
88        static public function cl_autosize_admin($menu)
89                {
90                global  $lang ;
91                array_push($menu, array('NAME' => 'Autosize',
92                'URL' => get_admin_plugin_menu_link(AUTOSIZE_PATH . 'admin/admin_autosize.php')));
93                return $menu;
94        } //function cl_autosize_admin
95        /*
96        *
97        */
98        static public function cl_autosize_aff_infos_plus()
99                {
100                 global $template,$infos_message,$erreur_message, $user ;
101                global  $conf,$lang ;
102       
103                 //==============================================================
104                  if (isset($erreur_message))
105                                {       
106                                if ($erreur_message <> "")
107                                        {
108                                                $erreur_message=str_replace("\n",'<br />',$erreur_message) ;
109                                                $template->assign('errors',$erreur_message);
110                                                $erreur_message="";
111                                        }
112                                }
113                  if (isset($infos_message))
114                                {       
115               
116                                if ($infos_message <> "")
117                                        {
118                                                $infos_message=str_replace("\n",'<br />',$infos_message) ;
119                                                $template->assign('infos',$infos_message);
120                                                $infos_message="";
121                                        }
122                                }
123                                //=============================================================
124                return;         
125               
126                } // function cl_autosize_aff_infos_plus
127
128
129
130 /*
131 * conflit =============================================
132 */
133 static public function cl_autosize_script_3()
134 {
135           global  $template,$user,$conf,$picture ,$page;
136           //userDefManage ??
137                $my_path =  basename(dirname(__FILE__)).'/' ;
138            $my_path = dirname(__FILE__).'/';
139                        $debug = isset($conf['debug']) ? $conf['debug'] : false ; 
140                        $cl_conflit =  isset($conf['cl_conflit']) ? $conf['cl_conflit'] : 'false' ;
141                        $template->set_filenames(
142                     array('autosize_init'=>$my_path. "template/cl_conflit3.tpl" 
143                         )
144                      );               
145                         
146                       
147                          $theme=$user['theme'];
148                         
149                $template->assign(
150                                                array(
151                                                'cl_conflit' => $cl_conflit  ,
152                                                'theme' => $theme  ,
153                                                'DEBUG' => $debug   ,
154                                                'AUTOSIZE_PATH' => AUTOSIZE_PATH)
155                                                 );
156
157if(     $page['body_id'] == 'theAdminPage' ) return ;
158
159                   return $template->parse( 'autosize_init', false);
160
161 }// function cl_autosize_script_3
162
163 static public function cl_autosize_script_2()
164 {
165           global  $template,$user,$conf,$picture ,$page;
166           //userDefManage ??
167                $my_path =  basename(dirname(__FILE__)).'/' ;
168            $my_path = dirname(__FILE__).'/';
169                        $debug = isset($conf['debug']) ? $conf['debug'] : false ; 
170                        $cl_conflit =  isset($conf['cl_conflit']) ? $conf['cl_conflit'] : 'false' ;
171                        $template->set_filenames(
172                     array('autosize_init'=>$my_path. "template/cl_conflit.tpl" 
173                         )
174                      );               
175                         
176                       
177                          $theme=$user['theme'];
178                         
179                $template->assign(
180                                                array('ma_page' =>      $page['body_id'],
181                                                'cl_conflit' => $cl_conflit  ,
182                                                'theme' => $theme  ,
183                                                'DEBUG' => $debug   ,
184                                                'AUTOSIZE_PATH' => AUTOSIZE_PATH)
185                                                 );
186
187if(     $page['body_id'] == 'theAdminPage' ) return ;
188
189                   return $template->parse( 'autosize_init', false);
190
191 }// function cl_autosize_script_2
192 //============================================================
193        static public function cl_autosize_script()
194        {
195           global  $template,$user,$conf,$picture ,$page;
196           //userDefManage ??
197                $my_path =  basename(dirname(__FILE__)).'/' ;
198            $my_path = dirname(__FILE__).'/';
199                        $debug = isset($conf['debug']) ? $conf['debug'] : false ; 
200                        $cl_conflit =  isset($conf['cl_conflit']) ? $conf['cl_conflit'] : 'false' ;
201                        $template->set_filenames(
202                     array('autosize_init'=>$my_path. "template/conflit.tpl" 
203                         )
204                      );               
205                         
206                       
207                          $theme=$user['theme'];
208                         
209                $template->assign(
210                                                array(
211                                                'cl_conflit' => $cl_conflit  ,
212                                                'theme' => $theme  ,
213                                                'DEBUG' => $debug   ,
214                                                'AUTOSIZE_PATH' => AUTOSIZE_PATH)
215                                                 );
216
217if(     $page['body_id'] == 'theAdminPage' ) return ;
218
219                   return $template->parse( 'autosize_init', false);
220
221       
222        }// function cl_autosize_script
223        /*
224        *
225    */
226        static public function cl_ajuste_data($content){
227           global  $template,$user,$conf,$picture ;
228                        $my_path = realpath(AUTOSIZE_PATH .'/');
229         $userdata=$user;
230         $fields = array( 'maxwidth', 'maxheight' );
231         
232         $ThePicture = $template->get_template_vars('current'); 
233                        $data = array();
234                       
235                         
236
237 return $content;
238
239                        $data['maxwidth'] = '1200';
240$data['maxheight'] ='250';
241                        $data['user_id'] = $userdata['id'];
242           foreach ($fields as $field)
243      {
244        if (isset($_POST[$field]))
245        {
246          $data[$field] = $_POST[$field];
247        }
248      }
249       
250        if($data['maxwidth'] != "" )
251{
252        $picture['current']['scaled_width']=$data['maxwidth'];
253                 $picture['current']['scaled_height']=$data['maxheight'];
254       mass_updates(USER_INFOS_TABLE,
255                   array('primary' => array('user_id'), 'update' => $fields),
256                   array($data));
257       
258}
259
260 
261   return $content;
262   /*
263 $template->assign(
264                                                array(
265                                                'AUTOSIZE_PATH' => $my_path,
266
267                                                                                        )
268                                                 );
269 
270                $template->parse( 'autosize_cl_init', false);
271        return $content;
272        */
273
274                                                                                 
275         }
276
277} // class
278
279
280        /*
281        *
282        */
283 function cl_autosize_Get_Options()
284  {
285                global $conf,$autosize_parametres; 
286                $autosize_parametres =  unserialize($conf['cl_autosize']);
287                $autosize_parametres =  cl_autosize_Set_Options();
288                return $autosize_parametres;
289  }
290        /*
291        *
292        */
293function cl_autosize_Set_Options()
294  {
295
296  global $autosize_parametres;
297//=============================================================================
298$autosize_parametres->webmaster_height =(isset($_POST['webmaster_height'])) ? $_POST['webmaster_height'] : ((isset($autosize_parametres->webmaster_height )) ? $autosize_parametres->webmaster_height : '100%' ) ;
299$autosize_parametres->webmaster_width=(isset($_POST['webmaster_width']))? $_POST['webmaster_width']: ((isset($autosize_parametres->webmaster_width)) ? $autosize_parametres->webmaster_width:  '90%') ;
300
301$autosize_parametres->admin_height =(isset($_POST['admin_height'])) ? $_POST['admin_height'] : ((isset($autosize_parametres->admin_height )) ? $autosize_parametres->admin_height : '90%' ) ;
302$autosize_parametres->admin_width=(isset($_POST['admin_width']))? $_POST['admin_width']: ((isset($autosize_parametres->admin_width)) ? $autosize_parametres->admin_width:  '90%') ;
303
304$autosize_parametres->generic_height =(isset($_POST['generic_height'])) ? $_POST['generic_height'] : ((isset($autosize_parametres->generic_height )) ? $autosize_parametres->generic_height : '100%' ) ;
305$autosize_parametres->generic_width=(isset($_POST['generic_width']))? $_POST['generic_width']: ((isset($autosize_parametres->generic_width)) ? $autosize_parametres->generic_width:  '90%') ;
306
307$autosize_parametres->guest_height =(isset($_POST['guest_height'])) ? $_POST['guest_height'] : ((isset($autosize_parametres->guest_height )) ? $autosize_parametres->guest_height : '100%' ) ;
308$autosize_parametres->guest_width=(isset($_POST['guest_width']))? $_POST['guest_width']: ((isset($autosize_parametres->guest_width)) ? $autosize_parametres->guest_width:  '90%') ;
309
310$autosize_parametres->normal_height =(isset($_POST['normal_height'])) ? $_POST['normal_height'] : ((isset($autosize_parametres->normal_height )) ? $autosize_parametres->normal_height : '100%' ) ;
311$autosize_parametres->normal_width=(isset($_POST['normal_width']))? $_POST['normal_width']: ((isset($autosize_parametres->normal_width)) ? $autosize_parametres->normal_width:  '90%') ;
312
313
314$autosize_parametres->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($autosize_parametres->mini_height )) ? $autosize_parametres->mini_height : '150' ) ;
315$autosize_parametres->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($autosize_parametres->mini_width)) ? $autosize_parametres->mini_width:  '300') ;
316
317$autosize_parametres->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($autosize_parametres->echelle_max)) ? $autosize_parametres->echelle_max :  '1.2'); 
318$autosize_parametres->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($autosize_parametres->marge_basse)) ? $autosize_parametres->marge_basse :  '50');
319$autosize_parametres->fade_in=(isset($_POST['fade_in']))? $_POST['fade_in']: ((isset($autosize_parametres->fade_in)) ? $autosize_parametres->fade_in :  '200');
320
321//===============================================================================       
322
323if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') )  { 
324                $autosize_parametres->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ;
325                $autosize_parametres->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ;
326                $autosize_parametres->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : "off" ;
327
328                $autosize_parametres->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ;
329                $autosize_parametres->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ;
330                $autosize_parametres->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ;
331                $autosize_parametres->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ;
332                $autosize_parametres->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ;
333
334         }else{
335                $autosize_parametres->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : ( ( isset($autosize_parametres->check_desc_v) ) ? $autosize_parametres->check_desc_v :   'off') ; 
336                $autosize_parametres->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : ( ( isset($autosize_parametres->check_icon_v) ) ? $autosize_parametres->check_icon_v :   'off') ; 
337                $autosize_parametres->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : ( ( isset($autosize_parametres->check_auto_w) ) ? $autosize_parametres->check_auto_w :   'off') ; 
338
339
340$autosize_parametres->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($autosize_parametres->webmaster_enabled) ) ? $autosize_parametres->webmaster_enabled :   'on') ; 
341$autosize_parametres->admin_enabled  = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($autosize_parametres->admin_enabled ) ) ? $autosize_parametres->admin_enabled :   'on') ; 
342$autosize_parametres->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($autosize_parametres->generic_enabled) ) ? $autosize_parametres->generic_enabled :   'on') ; 
343$autosize_parametres->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($autosize_parametres->guest_enabled) ) ? $autosize_parametres->guest_enabled :   'on') ;
344$autosize_parametres->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($autosize_parametres->normal_enabled) ) ? $autosize_parametres->normal_enabled :   'on') ; 
345
346
347   }
348
349return $autosize_parametres;
350}
351        /*
352        *
353        */
354function cl_autosize_sauve_options_inf()
355{
356global $options,$infos_message,$conf,$autosize_parametres  ;
357$infos_message .=l10n("cl_autosize_save_config")."<br>";
358 $autosize_parametres=cl_autosize_Set_Options();
359
360 if ( isset($autosize_parametres) )
361        {
362 
363                $query = '
364                UPDATE '.CONFIG_TABLE.'
365                SET value="'.addslashes(serialize($autosize_parametres)).'"
366                WHERE param = "cl_autosize"
367                LIMIT 1';
368                        pwg_query($query);
369          }
370         
371 }
372
373
374
375?>
Note: See TracBrowser for help on using the repository browser.