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