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