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

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

[Autosize][beta]fix bugs with rv_gmaps, option show icon.


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