[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 | ); |
---|
[8911] | 27 | if (!defined('ROOT_URL')) |
---|
| 28 | define( 'ROOT_URL', get_root_url().'/' ); |
---|
[8940] | 29 | |
---|
| 30 | $AUTOSIZE_PATH_ABS=str_replace('\\','/',dirname(__FILE__) ); |
---|
[8911] | 31 | if (!defined('AUTOSIZE_PATH_ABS')) |
---|
| 32 | define( |
---|
[8940] | 33 | 'AUTOSIZE_PATH_ABS', $AUTOSIZE_PATH_ABS."/" |
---|
[8911] | 34 | ); |
---|
[7375] | 35 | |
---|
[8911] | 36 | |
---|
| 37 | |
---|
[7375] | 38 | class autosize_controler { |
---|
[8627] | 39 | //============================================================ |
---|
| 40 | /* |
---|
| 41 | * cl_autosize_script_1 |
---|
| 42 | */ |
---|
| 43 | static public function cl_autosize_script_1() |
---|
| 44 | { |
---|
| 45 | global $template,$user,$conf,$picture ,$page, $cl_plugin ; |
---|
| 46 | if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; |
---|
| 47 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
| 48 | if ($ma_page=='thePiwiShackControllerPage') return ; |
---|
[8911] | 49 | |
---|
[8627] | 50 | $my_path = dirname(__FILE__).'/'; |
---|
| 51 | $template->set_filenames(array('autosize_init'=>$my_path. "template/conflit.tpl" ) ); |
---|
| 52 | $DEBUG = isset($conf['cl_debug']) ? $conf['cl_debug'] : "false" ; |
---|
| 53 | $autosize_parametres = cl_autosize_Get_Options() ; |
---|
| 54 | $theme=$user['theme']; |
---|
[8911] | 55 | $url = get_root_url(); |
---|
| 56 | $AUTOSIZE_PATH=AUTOSIZE_PATH; |
---|
| 57 | |
---|
| 58 | |
---|
[8627] | 59 | $template->assign( |
---|
| 60 | array( |
---|
| 61 | 'autosize_parametres' => $autosize_parametres , |
---|
| 62 | 'cl_plugins' => $cl_plugin , |
---|
| 63 | 'cl_version' => $cl_plugin['version'] , |
---|
| 64 | 'name' => $cl_plugin['name'] , |
---|
| 65 | 'theme' => $theme , |
---|
| 66 | 'DEBUG' => $DEBUG , |
---|
[8911] | 67 | 'AUTOSIZE_PATH' => AUTOSIZE_PATH , |
---|
| 68 | 'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS, |
---|
| 69 | 'ROOT_URL' => $url , |
---|
| 70 | ) |
---|
[8627] | 71 | ); |
---|
| 72 | |
---|
| 73 | return $template->parse( 'autosize_init', false); |
---|
| 74 | }// function cl_autosize_script_1 |
---|
| 75 | //=========================================================== |
---|
| 76 | /* |
---|
| 77 | * cl_autosize_script_2 |
---|
| 78 | */ |
---|
| 79 | static public function cl_autosize_script_2() |
---|
| 80 | { |
---|
[8911] | 81 | global $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ; |
---|
[8627] | 82 | $my_path = dirname(__FILE__).'/'; |
---|
| 83 | $DEBUG = isset($conf['cl_debug']) ? $conf['cl_debug'] : "false" ; |
---|
| 84 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
| 85 | $theme=$user['theme']; |
---|
| 86 | if ($ma_page=='thePiwiShackControllerPage') return ; |
---|
| 87 | |
---|
| 88 | $template->assign( |
---|
| 89 | array( |
---|
| 90 | 'cl_version' => $cl_plugin['version'] , |
---|
| 91 | 'name' => $cl_plugin['name'] , |
---|
| 92 | 'ma_page' => $ma_page, |
---|
| 93 | |
---|
| 94 | 'theme' => $theme , |
---|
| 95 | 'DEBUG' => $DEBUG , |
---|
| 96 | 'AUTOSIZE_PATH' => AUTOSIZE_PATH |
---|
| 97 | ) |
---|
| 98 | ); |
---|
| 99 | |
---|
| 100 | $autoscript="<script type='text/javascript'> |
---|
| 101 | /* cl_autosize_script_2 */ |
---|
| 102 | if (typeof (save_framework) == 'function') |
---|
| 103 | save_framework('".$ma_page."'); |
---|
| 104 | </script>"; |
---|
[8940] | 105 | $autoscript .="<input id='ret_autosize' type='hidden' value='' />"; |
---|
| 106 | $autoscript .="<input id='src_img_h' type='hidden' value='' />"; |
---|
| 107 | $autoscript .="<input id='src_img_w' type='hidden' value='' />"; |
---|
[8627] | 108 | $template->append('footer_elements',$autoscript); |
---|
| 109 | return ; |
---|
| 110 | }// function cl_autosize_script_2 |
---|
| 111 | |
---|
| 112 | //================================================================ |
---|
[7375] | 113 | /* |
---|
[8627] | 114 | * cl_autosize_admin |
---|
| 115 | */ |
---|
| 116 | static public function cl_autosize_admin($menu) |
---|
| 117 | { |
---|
| 118 | global $lang ; |
---|
| 119 | array_push($menu, array('NAME' => 'Autosize', |
---|
| 120 | 'URL' => get_admin_plugin_menu_link(AUTOSIZE_PATH . 'admin/admin_autosize.php'))); |
---|
| 121 | return $menu; |
---|
| 122 | } //function cl_autosize_admin |
---|
| 123 | |
---|
| 124 | //=============================================================== |
---|
| 125 | /* |
---|
[7375] | 126 | * |
---|
[8627] | 127 | */ |
---|
[7375] | 128 | static public function cl_autosize_affiche() |
---|
[7193] | 129 | { |
---|
[8911] | 130 | global $user, $picture, $template,$page,$known_script; |
---|
[7193] | 131 | global $content, $element_info; |
---|
| 132 | global $infos_message,$erreur_message; |
---|
| 133 | global $conf,$lang ,$user,$userdata; |
---|
| 134 | |
---|
| 135 | load_language('lang', AUTOSIZE_PATH); |
---|
| 136 | $my_path = dirname(__FILE__).'/'; |
---|
[8070] | 137 | if (isset( $page['body_id']) && $page['body_id']=='thePicturePage' ) { |
---|
| 138 | if ( isset($picture['current'])){ |
---|
[7193] | 139 | $autosize_parametres = cl_autosize_Get_Options(); |
---|
[8911] | 140 | include (AUTOSIZE_PATH."include/affiche.php"); |
---|
| 141 | |
---|
[8057] | 142 | if($autosize_parametres->check_icon_v == 'on'){ |
---|
| 143 | $template->assign('cl_autosize_button', |
---|
| 144 | array( 'cl_autosize_info' => 'cl_autosize_info' , |
---|
| 145 | 'cl_autosize_info_2' => 'cl_autosize_info_2' , |
---|
| 146 | 'URL' => $_SERVER['REQUEST_URI'] , |
---|
| 147 | 'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png', |
---|
| 148 | 'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png' |
---|
| 149 | ) |
---|
[7536] | 150 | |
---|
[8627] | 151 | ); |
---|
[8057] | 152 | $template->set_filenames(array('cl_bp' => $my_path. 'template/picture.tpl')); |
---|
| 153 | $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true)); |
---|
[7229] | 154 | } |
---|
[8057] | 155 | $template->set_filenames( |
---|
[7193] | 156 | array('autosize_content'=> $my_path.'template/autosize.tpl') |
---|
| 157 | ); |
---|
[8057] | 158 | |
---|
[7193] | 159 | return $template->parse( 'autosize_content', false); |
---|
[8070] | 160 | } |
---|
[7375] | 161 | } |
---|
[8070] | 162 | |
---|
[7375] | 163 | } //public function cl_autosize_affiche |
---|
[8627] | 164 | //=============================================================== |
---|
| 165 | /* |
---|
[7375] | 166 | * |
---|
| 167 | */ |
---|
[7193] | 168 | static public function cl_autosize_aff_infos_plus() |
---|
| 169 | { |
---|
| 170 | global $template,$infos_message,$erreur_message, $user ; |
---|
[8627] | 171 | global $conf,$lang ; |
---|
[7669] | 172 | |
---|
[7193] | 173 | //============================================================== |
---|
| 174 | if (isset($erreur_message)) |
---|
| 175 | { |
---|
| 176 | if ($erreur_message <> "") |
---|
| 177 | { |
---|
| 178 | $erreur_message=str_replace("\n",'<br />',$erreur_message) ; |
---|
| 179 | $template->assign('errors',$erreur_message); |
---|
| 180 | $erreur_message=""; |
---|
| 181 | } |
---|
| 182 | } |
---|
| 183 | if (isset($infos_message)) |
---|
| 184 | { |
---|
| 185 | |
---|
| 186 | if ($infos_message <> "") |
---|
| 187 | { |
---|
| 188 | $infos_message=str_replace("\n",'<br />',$infos_message) ; |
---|
| 189 | $template->assign('infos',$infos_message); |
---|
| 190 | $infos_message=""; |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | //============================================================= |
---|
| 194 | return; |
---|
| 195 | |
---|
[7375] | 196 | } // function cl_autosize_aff_infos_plus |
---|
[8627] | 197 | //=============================================================== |
---|
| 198 | /* |
---|
| 199 | * |
---|
| 200 | */ |
---|
| 201 | static public function cl_ajuste_data($content){ |
---|
| 202 | global $template,$user,$conf,$picture ; |
---|
| 203 | $my_path = realpath(AUTOSIZE_PATH .'/'); |
---|
| 204 | $userdata=$user; |
---|
| 205 | $fields = array( 'maxwidth', 'maxheight' ); |
---|
[8070] | 206 | |
---|
[8627] | 207 | $ThePicture = $template->get_template_vars('current'); |
---|
| 208 | $data = array(); |
---|
| 209 | return $content; |
---|
[7816] | 210 | |
---|
[8627] | 211 | $data['maxwidth'] = '1200'; |
---|
| 212 | $data['maxheight'] ='250'; |
---|
| 213 | $data['user_id'] = $userdata['id']; |
---|
| 214 | foreach ($fields as $field) |
---|
[7943] | 215 | { |
---|
[8627] | 216 | if (isset($_POST[$field])) |
---|
| 217 | { |
---|
| 218 | $data[$field] = $_POST[$field]; |
---|
| 219 | } |
---|
[7943] | 220 | } |
---|
[7193] | 221 | |
---|
[8627] | 222 | if($data['maxwidth'] != "" ) |
---|
| 223 | { |
---|
| 224 | $picture['current']['scaled_width']=$data['maxwidth']; |
---|
| 225 | $picture['current']['scaled_height']=$data['maxheight']; |
---|
| 226 | mass_updates(USER_INFOS_TABLE, |
---|
| 227 | array('primary' => array('user_id'), 'update' => $fields), |
---|
| 228 | array($data)); |
---|
| 229 | } |
---|
[7943] | 230 | |
---|
[8627] | 231 | return $content; |
---|
| 232 | } |
---|
[7375] | 233 | |
---|
| 234 | } // class |
---|
| 235 | |
---|
| 236 | |
---|
| 237 | /* |
---|
| 238 | * |
---|
| 239 | */ |
---|
[7193] | 240 | function cl_autosize_Get_Options() |
---|
| 241 | { |
---|
[7394] | 242 | global $conf,$autosize_parametres; |
---|
| 243 | $autosize_parametres = unserialize($conf['cl_autosize']); |
---|
| 244 | $autosize_parametres = cl_autosize_Set_Options(); |
---|
| 245 | return $autosize_parametres; |
---|
[7375] | 246 | } |
---|
| 247 | /* |
---|
| 248 | * |
---|
[7193] | 249 | */ |
---|
| 250 | function cl_autosize_Set_Options() |
---|
| 251 | { |
---|
[7394] | 252 | |
---|
[7193] | 253 | global $autosize_parametres; |
---|
| 254 | //============================================================================= |
---|
[7962] | 255 | $my_para=$autosize_parametres; |
---|
[7193] | 256 | |
---|
[7962] | 257 | $my_para->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($my_para->query )) ? $my_para->query : 'Qt' ) ; |
---|
| 258 | $my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type: 'Ty') ; |
---|
[7193] | 259 | |
---|
[7962] | 260 | $my_para->webmaster_height =(isset($_POST['webmaster_height'])) ? $_POST['webmaster_height'] : ((isset($my_para->webmaster_height )) ? $my_para->webmaster_height : '100%' ) ; |
---|
| 261 | $my_para->webmaster_width=(isset($_POST['webmaster_width']))? $_POST['webmaster_width']: ((isset($my_para->webmaster_width)) ? $my_para->webmaster_width: '90%') ; |
---|
[7193] | 262 | |
---|
[7962] | 263 | $my_para->admin_height =(isset($_POST['admin_height'])) ? $_POST['admin_height'] : ((isset($my_para->admin_height )) ? $my_para->admin_height : '90%' ) ; |
---|
| 264 | $my_para->admin_width=(isset($_POST['admin_width']))? $_POST['admin_width']: ((isset($my_para->admin_width)) ? $my_para->admin_width: '90%') ; |
---|
[7193] | 265 | |
---|
[7962] | 266 | $my_para->generic_height =(isset($_POST['generic_height'])) ? $_POST['generic_height'] : ((isset($my_para->generic_height )) ? $my_para->generic_height : '100%' ) ; |
---|
| 267 | $my_para->generic_width=(isset($_POST['generic_width']))? $_POST['generic_width']: ((isset($my_para->generic_width)) ? $my_para->generic_width: '90%') ; |
---|
[7193] | 268 | |
---|
[7962] | 269 | $my_para->guest_height =(isset($_POST['guest_height'])) ? $_POST['guest_height'] : ((isset($my_para->guest_height )) ? $my_para->guest_height : '100%' ) ; |
---|
| 270 | $my_para->guest_width=(isset($_POST['guest_width']))? $_POST['guest_width']: ((isset($my_para->guest_width)) ? $my_para->guest_width: '90%') ; |
---|
[7193] | 271 | |
---|
[7962] | 272 | $my_para->normal_height =(isset($_POST['normal_height'])) ? $_POST['normal_height'] : ((isset($my_para->normal_height )) ? $my_para->normal_height : '100%' ) ; |
---|
| 273 | $my_para->normal_width=(isset($_POST['normal_width']))? $_POST['normal_width']: ((isset($my_para->normal_width)) ? $my_para->normal_width: '90%') ; |
---|
[7193] | 274 | |
---|
[7725] | 275 | |
---|
[7962] | 276 | $my_para->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($my_para->mini_height )) ? $my_para->mini_height : '150' ) ; |
---|
| 277 | $my_para->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($my_para->mini_width)) ? $my_para->mini_width: '300') ; |
---|
| 278 | |
---|
| 279 | $my_para->mini_height2 =(isset($_POST['mini_height2'])) ? $_POST['mini_height2'] : ((isset($my_para->mini_height2 )) ? $my_para->mini_height2 : '150' ) ; |
---|
| 280 | $my_para->mini_width2=(isset($_POST['mini_width2']))? $_POST['mini_width2']: ((isset($my_para->mini_width2)) ? $my_para->mini_width2: '300') ; |
---|
| 281 | |
---|
| 282 | $my_para->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($my_para->echelle_max)) ? $my_para->echelle_max : '1.2'); |
---|
| 283 | $my_para->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($my_para->marge_basse)) ? $my_para->marge_basse : '50'); |
---|
| 284 | $my_para->fade_in=(isset($_POST['fade_in']))? $_POST['fade_in']: ((isset($my_para->fade_in)) ? $my_para->fade_in : '200'); |
---|
| 285 | |
---|
[7193] | 286 | //=============================================================================== |
---|
| 287 | |
---|
| 288 | if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') ) { |
---|
[7962] | 289 | $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ; |
---|
| 290 | $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ; |
---|
| 291 | $my_para->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : "off" ; |
---|
[7394] | 292 | |
---|
[7962] | 293 | $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ; |
---|
| 294 | $my_para->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ; |
---|
| 295 | $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ; |
---|
| 296 | $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ; |
---|
| 297 | $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ; |
---|
[7394] | 298 | |
---|
[7193] | 299 | }else{ |
---|
[7962] | 300 | $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : ( ( isset($my_para->check_desc_v) ) ? $my_para->check_desc_v : 'off') ; |
---|
| 301 | $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : ( ( isset($my_para->check_icon_v) ) ? $my_para->check_icon_v : 'off') ; |
---|
| 302 | $my_para->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : ( ( isset($my_para->check_auto_w) ) ? $my_para->check_auto_w : 'off') ; |
---|
[7394] | 303 | |
---|
| 304 | |
---|
[7962] | 305 | $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($my_para->webmaster_enabled) ) ? $my_para->webmaster_enabled : 'on') ; |
---|
| 306 | $my_para->admin_enabled = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($my_para->admin_enabled ) ) ? $my_para->admin_enabled : 'on') ; |
---|
| 307 | $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($my_para->generic_enabled) ) ? $my_para->generic_enabled : 'on') ; |
---|
| 308 | $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($my_para->guest_enabled) ) ? $my_para->guest_enabled : 'on') ; |
---|
| 309 | $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($my_para->normal_enabled) ) ? $my_para->normal_enabled : 'on') ; |
---|
[7394] | 310 | |
---|
| 311 | |
---|
[7193] | 312 | } |
---|
[7316] | 313 | |
---|
[7962] | 314 | return $my_para; |
---|
[7193] | 315 | } |
---|
[7375] | 316 | /* |
---|
| 317 | * |
---|
[7193] | 318 | */ |
---|
| 319 | function cl_autosize_sauve_options_inf() |
---|
| 320 | { |
---|
| 321 | global $options,$infos_message,$conf,$autosize_parametres ; |
---|
| 322 | $infos_message .=l10n("cl_autosize_save_config")."<br>"; |
---|
| 323 | $autosize_parametres=cl_autosize_Set_Options(); |
---|
| 324 | |
---|
| 325 | if ( isset($autosize_parametres) ) |
---|
| 326 | { |
---|
| 327 | |
---|
| 328 | $query = ' |
---|
| 329 | UPDATE '.CONFIG_TABLE.' |
---|
| 330 | SET value="'.addslashes(serialize($autosize_parametres)).'" |
---|
| 331 | WHERE param = "cl_autosize" |
---|
| 332 | LIMIT 1'; |
---|
| 333 | pwg_query($query); |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | } |
---|
[7375] | 337 | |
---|
[8729] | 338 | function auto_memo_var($variables) |
---|
| 339 | { |
---|
| 340 | ob_start(); |
---|
| 341 | echo '<pre>'; |
---|
| 342 | print_r($variables); |
---|
| 343 | echo '</pre>'; |
---|
| 344 | $m= ob_get_contents(); |
---|
| 345 | ob_end_clean(); |
---|
| 346 | return $m; |
---|
| 347 | } |
---|
| 348 | |
---|
[7375] | 349 | |
---|
[7193] | 350 | ?> |
---|