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 | // +-----------------------------------------------------------------------+ |
---|
22 | if (!defined('AUTOSIZE_PATH')) |
---|
23 | define('AUTOSIZE_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
24 | |
---|
25 | class 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($pictures) |
---|
117 | { $my_path = dirname(__FILE__).'/'; |
---|
118 | global $template,$user,$conf ; |
---|
119 | $template->set_filenames( |
---|
120 | array('autosize_cl_init'=> $my_path.'template/cl_conflit.tpl') |
---|
121 | ); |
---|
122 | |
---|
123 | $template->assign( |
---|
124 | array( |
---|
125 | 'AUTOSIZE_PATH' => $my_path, |
---|
126 | |
---|
127 | ) |
---|
128 | ); |
---|
129 | |
---|
130 | $template->parse( 'autosize_cl_init', false); |
---|
131 | |
---|
132 | return $pictures; |
---|
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 | */ |
---|
204 | function 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 | |
---|
231 | if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') ) { |
---|
232 | $autosize_parametres->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_icon_v'] : "off" ; |
---|
233 | $autosize_parametres->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ; |
---|
234 | $autosize_parametres->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : "off" ; |
---|
235 | }else{ |
---|
236 | $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') ; |
---|
237 | $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') ; |
---|
238 | $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') ; |
---|
239 | } |
---|
240 | |
---|
241 | |
---|
242 | return $autosize_parametres; |
---|
243 | } |
---|
244 | /* |
---|
245 | * |
---|
246 | */ |
---|
247 | function cl_autosize_sauve_options_inf() |
---|
248 | { |
---|
249 | global $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 | ?> |
---|