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

Last change on this file since 7394 was 7394, checked in by cljosse, 14 years ago

[Autosize][beta] Add the option validation of the autosize according to the status

File size: 11.9 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('AUTOSIZE_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
24
25class autosize_controler {
26        /*
27        *
28        */
29        static public function cl_autosize_affiche()
30        {
31                global $user, $picture, $template,$page;
32                global $content, $element_info;   
33                global $infos_message,$erreur_message;
34                global  $conf,$lang ,$user,$userdata;
35
36                load_language('lang', AUTOSIZE_PATH);
37                $my_path = dirname(__FILE__).'/';
38                if (isset( $page['body_id'])  ) {
39                if ( $page['body_id']=='thePicturePage'  ) {
40                        if ( isset($picture['current'])){
41                               
42                                $autosize_parametres = cl_autosize_Get_Options();
43                                include (AUTOSIZE_PATH."include/affiche.php");   
44                                if($autosize_parametres->check_icon_v == 'on'){
45                                $template->assign('cl_autosize_button', 
46                                 array(
47                                                'cl_autosize_info' => 'cl_autosize_info' ,
48                                                'cl_autosize_info_2' => 'cl_autosize_info_2' ,   
49                                                'URL' => $_SERVER['REQUEST_URI'] ,
50                                                'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png',
51                                                'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png'
52                                        )
53                                        );
54 
55                                $template->set_filenames(array('cl_bp' => $my_path. 'template/picture.tpl'));
56                                $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true));
57                                }
58                                $template->set_filenames(
59                                                array('autosize_content'=> $my_path.'template/autosize.tpl')
60                                        );
61                                       
62                                return $template->parse( 'autosize_content', false);
63                        }
64     
65                }
66                }
67        } //public function cl_autosize_affiche
68        /*
69        *
70        */
71        static public function cl_autosize_admin($menu)
72                {
73                global  $lang ;
74                array_push($menu, array('NAME' => 'Autosize',
75                'URL' => get_admin_plugin_menu_link(AUTOSIZE_PATH . 'admin/admin_autosize.php')));
76                return $menu;
77        } //function cl_autosize_admin
78        /*
79        *
80        */
81        static public function cl_autosize_aff_infos_plus()
82                {
83                 global $template,$infos_message,$erreur_message, $user ;
84                global  $conf,$lang ;
85
86                 //==============================================================
87                  if (isset($erreur_message))
88                                {       
89                                if ($erreur_message <> "")
90                                        {
91                                                $erreur_message=str_replace("\n",'<br />',$erreur_message) ;
92                                                $template->assign('errors',$erreur_message);
93                                                $erreur_message="";
94                                        }
95                                }
96                  if (isset($infos_message))
97                                {       
98               
99                                if ($infos_message <> "")
100                                        {
101                                                $infos_message=str_replace("\n",'<br />',$infos_message) ;
102                                                $template->assign('infos',$infos_message);
103                                                $infos_message="";
104                                        }
105                                }
106                                //=============================================================
107                return;         
108               
109                } // function cl_autosize_aff_infos_plus
110
111
112
113 /*
114 * conflit =============================================
115 */
116        static public function cl_autosize_script()
117        {
118           global  $template,$user,$conf ;
119
120 
121                $my_path = dirname(__FILE__).'/';
122                $template->set_filenames(
123                     array('autosize_cl_init'=> $my_path.'template/cl_conflit.tpl')
124                      );
125                 
126                $template->assign(
127                                                array(
128                                                'AUTOSIZE_PATH' => $my_path,
129
130                                                                                        )
131                                                 );
132
133                   return $template->parse( 'autosize_cl_init', false);
134
135       
136        }// function cl_autosize_script
137        /*
138        *
139        */
140        static public function cl_ajuste_data($content, $image){
141 
142           global  $template,$user,$conf ;
143                        $my_path = dirname(__FILE__).'/';
144                        $template->set_filenames(
145                     array('autosize_cl_init'=> $my_path.'template/cl_conflit.tpl')
146                      );
147 /*
148         $userdata=$user;
149         $fields = array( 'maxwidth', 'maxheight' );
150         $ThePicture = $template->get_template_vars('current');
151
152                        $data = array();
153                        $data['maxheight'] = $ThePicture['scaled_height'];
154                        $data['maxwidth'] = $ThePicture['scaled_width'];
155                        $data['user_id'] = $userdata['id'];
156           foreach ($fields as $field)
157      {
158        if (isset($_POST[$field]))
159        {
160          $data[$field] = $_POST[$field];
161        }
162      }
163       
164        if($data['maxwidth'] != "" )
165{
166       
167       mass_updates(USER_INFOS_TABLE,
168                   array('primary' => array('user_id'), 'update' => $fields),
169                   array($data));
170       
171}
172
173   */
174
175 $template->assign(
176                                                array(
177                                                'AUTOSIZE_PATH' => $my_path,
178
179                                                                                        )
180                                                 );
181 
182                $template->parse( 'autosize_cl_init', false);
183        return $content;
184
185
186                                                                                 
187         }
188
189} // class
190
191
192        /*
193        *
194        */
195 function cl_autosize_Get_Options()
196  {
197                global $conf,$autosize_parametres; 
198                $autosize_parametres =  unserialize($conf['cl_autosize']);
199                $autosize_parametres =  cl_autosize_Set_Options();
200                return $autosize_parametres;
201  }
202        /*
203        *
204        */
205function cl_autosize_Set_Options()
206  {
207
208  global $autosize_parametres;
209//=============================================================================
210$autosize_parametres->webmaster_height =(isset($_POST['webmaster_height'])) ? $_POST['webmaster_height'] : ((isset($autosize_parametres->webmaster_height )) ? $autosize_parametres->webmaster_height : '100%' ) ;
211$autosize_parametres->webmaster_width=(isset($_POST['webmaster_width']))? $_POST['webmaster_width']: ((isset($autosize_parametres->webmaster_width)) ? $autosize_parametres->webmaster_width:  '90%') ;
212
213$autosize_parametres->admin_height =(isset($_POST['admin_height'])) ? $_POST['admin_height'] : ((isset($autosize_parametres->admin_height )) ? $autosize_parametres->admin_height : '90%' ) ;
214$autosize_parametres->admin_width=(isset($_POST['admin_width']))? $_POST['admin_width']: ((isset($autosize_parametres->admin_width)) ? $autosize_parametres->admin_width:  '90%') ;
215
216$autosize_parametres->generic_height =(isset($_POST['generic_height'])) ? $_POST['generic_height'] : ((isset($autosize_parametres->generic_height )) ? $autosize_parametres->generic_height : '100%' ) ;
217$autosize_parametres->generic_width=(isset($_POST['generic_width']))? $_POST['generic_width']: ((isset($autosize_parametres->generic_width)) ? $autosize_parametres->generic_width:  '90%') ;
218
219$autosize_parametres->guest_height =(isset($_POST['guest_height'])) ? $_POST['guest_height'] : ((isset($autosize_parametres->guest_height )) ? $autosize_parametres->guest_height : '100%' ) ;
220$autosize_parametres->guest_width=(isset($_POST['guest_width']))? $_POST['guest_width']: ((isset($autosize_parametres->guest_width)) ? $autosize_parametres->guest_width:  '90%') ;
221
222$autosize_parametres->normal_height =(isset($_POST['normal_height'])) ? $_POST['normal_height'] : ((isset($autosize_parametres->normal_height )) ? $autosize_parametres->normal_height : '100%' ) ;
223$autosize_parametres->normal_width=(isset($_POST['normal_width']))? $_POST['normal_width']: ((isset($autosize_parametres->normal_width)) ? $autosize_parametres->normal_width:  '90%') ;
224
225
226$autosize_parametres->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($autosize_parametres->mini_height )) ? $autosize_parametres->mini_height : '150' ) ;
227$autosize_parametres->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($autosize_parametres->mini_width)) ? $autosize_parametres->mini_width:  '300') ;
228
229$autosize_parametres->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($autosize_parametres->echelle_max)) ? $autosize_parametres->echelle_max :  '1.2'); 
230$autosize_parametres->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($autosize_parametres->marge_basse)) ? $autosize_parametres->marge_basse :  '50');
231//===============================================================================       
232
233if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') )  { 
234                $autosize_parametres->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ;
235                $autosize_parametres->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ;
236                $autosize_parametres->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : "off" ;
237
238                $autosize_parametres->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ;
239                $autosize_parametres->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ;
240                $autosize_parametres->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ;
241                $autosize_parametres->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ;
242                $autosize_parametres->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ;
243
244         }else{
245                $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') ; 
246                $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') ; 
247                $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') ; 
248
249
250$autosize_parametres->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($autosize_parametres->webmaster_enabled) ) ? $autosize_parametres->webmaster_enabled :   'on') ; 
251$autosize_parametres->admin_enabled  = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($autosize_parametres->admin_enabled ) ) ? $autosize_parametres->admin_enabled :   'on') ; 
252$autosize_parametres->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($autosize_parametres->generic_enabled) ) ? $autosize_parametres->generic_enabled :   'on') ; 
253$autosize_parametres->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($autosize_parametres->guest_enabled) ) ? $autosize_parametres->guest_enabled :   'on') ;
254$autosize_parametres->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($autosize_parametres->normal_enabled) ) ? $autosize_parametres->normal_enabled :   'on') ; 
255
256
257   }
258
259return $autosize_parametres;
260}
261        /*
262        *
263        */
264function cl_autosize_sauve_options_inf()
265{
266global $options,$infos_message,$conf,$autosize_parametres  ;
267$infos_message .=l10n("cl_autosize_save_config")."<br>";
268 $autosize_parametres=cl_autosize_Set_Options();
269
270 if ( isset($autosize_parametres) )
271        {
272 
273                $query = '
274                UPDATE '.CONFIG_TABLE.'
275                SET value="'.addslashes(serialize($autosize_parametres)).'"
276                WHERE param = "cl_autosize"
277                LIMIT 1';
278                        pwg_query($query);
279          }
280         
281 }
282
283
284
285?>
Note: See TracBrowser for help on using the repository browser.