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