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

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

[Autosize][beta]Improvement frame work mootools,prototype,jquery compatibility.


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