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

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

[Autosize][beta] fix warning on jquery


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