[3700] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: paMOOramics |
---|
| 4 | Version: 2.0 |
---|
| 5 | Description: Display panoramics images using pamoorama script by silvertab (powered by mootools) |
---|
| 6 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=213 |
---|
| 7 | Author: Repié38 |
---|
| 8 | Author URI: http://www.pierre-b.com |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | /* |
---|
| 12 | Changelog : |
---|
| 13 | since 0.2.b: |
---|
| 14 | - smarty compatible (Dont use it with PhpWebGallery 1.7.x) |
---|
| 15 | - fix bug on image name with quotes |
---|
| 16 | - fully multilingual (even in javascript) |
---|
| 17 | - jQuery color picker in admin panel |
---|
| 18 | - checkbox instead of field for true/false |
---|
| 19 | - impossible to check "start autoscroll onload" when "allow autoscroll" isnt checked (ie:not logic, and cause a bug) |
---|
| 20 | - compatibility with panoramas 2.0.b (priority to panoramas when an image is interpreted as panoramic by the 2 plugins |
---|
| 21 | - paMOOramics can be activated on 2 modes : on name (as panoramas), or on width/height ration (as on previous version) |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 25 | define('PAMOORAMICS_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | class paMOOramics |
---|
| 29 | { |
---|
| 30 | function paMOOramics_menu($menu) |
---|
| 31 | { |
---|
| 32 | array_push($menu, |
---|
| 33 | array( |
---|
| 34 | 'NAME' => 'paMOOramics', |
---|
| 35 | 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/paMOOramics_admin.php') |
---|
| 36 | ) |
---|
| 37 | ); |
---|
| 38 | return $menu; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | var $my_config; |
---|
| 43 | function load_config() |
---|
| 44 | { |
---|
| 45 | $x = @file_get_contents( dirname(__FILE__).'/data.dat' ); |
---|
| 46 | if ($x!==false) |
---|
| 47 | { |
---|
| 48 | $c = unserialize($x); |
---|
| 49 | $this->my_config = $c; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | if ( !isset($this->my_config) |
---|
| 53 | or empty($this->my_config['paMOOramics_ratio']) ) |
---|
| 54 | { |
---|
| 55 | //default values |
---|
| 56 | |
---|
| 57 | $this->my_config['paMOOramics_mode'] = 'moderatio'; |
---|
| 58 | $this->my_config['paMOOramics_name'] = 'paMOOramics'; |
---|
| 59 | $this->my_config['paMOOramics_ratio'] = 2; |
---|
| 60 | $this->my_config['paMOOramics_border'] = 2; |
---|
| 61 | $this->my_config['paMOOramics_bordercolor'] = '#FFFFFF'; |
---|
| 62 | $this->my_config['paMOOramics_width'] = 650; |
---|
| 63 | $this->my_config['paMOOramics_activateSlider'] = 'true'; |
---|
| 64 | $this->my_config['paMOOramics_footercolor'] = '#000000'; |
---|
| 65 | $this->my_config['paMOOramics_captioncolor'] = '#FFFFFF'; |
---|
| 66 | $this->my_config['paMOOramics_enableAutoscroll'] = 'true'; |
---|
| 67 | $this->my_config['paMOOramics_autoscrollSpeed'] = 10000; |
---|
| 68 | $this->my_config['paMOOramics_autoscrollOnLoad'] = 'false'; |
---|
| 69 | $this->my_config['paMOOramics_displayfooter'] = ''; |
---|
| 70 | $this->my_config['pamooramics_Slideshow_displayfooter']= 'display:none;'; |
---|
| 71 | $this->save_config(); |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | function save_config() |
---|
| 75 | { |
---|
| 76 | $file = fopen( dirname(__FILE__).'/data.dat', 'w' ); |
---|
| 77 | fwrite($file, serialize($this->my_config) ); |
---|
| 78 | fclose( $file ); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | function paMOOramics_load ($content) { |
---|
| 84 | global $template,$picture,$page; |
---|
| 85 | |
---|
| 86 | if (isset($picture['current']['scaled_width']) && isset($picture['current']['scaled_height'])) { |
---|
| 87 | $current_ratio=$picture['current']['scaled_width']/$picture['current']['scaled_height']; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | if ((isset($current_ratio))&&(empty($content))) { |
---|
| 91 | if (($this->my_config['paMOOramics_mode']=='modename' && stristr($picture['current']['name'],$this->my_config['paMOOramics_name'])) |
---|
| 92 | or |
---|
| 93 | ($current_ratio >= ($this->my_config['paMOOramics_ratio']) && $this->my_config['paMOOramics_mode']=='moderatio') |
---|
| 94 | ) { |
---|
| 95 | |
---|
| 96 | $template->append('head_elements', |
---|
| 97 | '<script src="plugins/paMOOramics/js/mootools.js" type="text/javascript" charset="utf-8"></script> |
---|
| 98 | <script src="plugins/paMOOramics/js/pamoorama0.3.js" type="text/javascript" charset="utf-8"></script>'); |
---|
| 99 | |
---|
| 100 | $template->set_filenames( |
---|
| 101 | array('pamooramics_content'=> dirname(__FILE__).'/picture_content.tpl') |
---|
| 102 | ); |
---|
| 103 | $template->assign( array( |
---|
| 104 | 'SRC_IMG' => $picture['current']['image_url'], |
---|
| 105 | 'ALT_IMG' => htmlspecialchars($picture['current']['name'], ENT_QUOTES), |
---|
| 106 | 'WIDTH_IMG' => $picture['current']['scaled_width'], |
---|
| 107 | 'HEIGHT_IMG' => $picture['current']['scaled_height'], |
---|
| 108 | 'PANO_BORDER' => $this->my_config['paMOOramics_border'], |
---|
| 109 | 'PANO_BORDERCOLOR' => $this->my_config['paMOOramics_bordercolor'], |
---|
| 110 | 'PANO_WIDTH' => $this->my_config['paMOOramics_width'], |
---|
| 111 | 'PANO_FOOTERCOLOR' => $this->my_config['paMOOramics_footercolor'], |
---|
| 112 | 'PANO_CAPTIONCOLOR' => $this->my_config['paMOOramics_captioncolor'],)); |
---|
| 113 | |
---|
| 114 | $slideshow_paMOOramics_activateSlider = $this->my_config['paMOOramics_activateSlider']; |
---|
| 115 | $slideshow_paMOOramics_enableAutoscroll = $this->my_config['paMOOramics_enableAutoscroll']; |
---|
| 116 | $slideshow_paMOOramics_autoscrollSpeed = $this->my_config['paMOOramics_autoscrollSpeed']; |
---|
| 117 | $slideshow_paMOOramics_autoscrollOnLoad = $this->my_config['paMOOramics_autoscrollOnLoad']; |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | if ( !$page['slideshow'] ){ |
---|
| 121 | if (isset($picture['current']['high_url'])){ |
---|
| 122 | $uuid = uniqid(rand()); |
---|
| 123 | $template->assign('high', array( |
---|
| 124 | 'U_HIGH' => $picture['current']['high_url'] , |
---|
| 125 | 'UUID' => $uuid, )); |
---|
| 126 | } |
---|
| 127 | $display_footer=$this->my_config['paMOOramics_displayfooter']; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | else { |
---|
| 131 | $slideshow_params = decode_slideshow_params($_GET['slideshow']); |
---|
| 132 | $slideshow_paMOOramics_activateSlider = 'true'; |
---|
| 133 | $slideshow_paMOOramics_enableAutoscroll = 'true'; |
---|
| 134 | $slideshow_paMOOramics_autoscrollSpeed = ($slideshow_params['period']-0.5)*1000; |
---|
| 135 | $slideshow_paMOOramics_autoscrollOnLoad = 'true'; |
---|
| 136 | $display_footer=$this->my_config['pamooramics_Slideshow_displayfooter']; |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | $template->assign( array( |
---|
| 140 | 'PANO_ACTIVATESLIDER' => $slideshow_paMOOramics_activateSlider, |
---|
| 141 | 'PANO_ENABLEAUTOSCROLL' => $slideshow_paMOOramics_enableAutoscroll, |
---|
| 142 | 'PANO_AUTOSCROLLSPEED' => $slideshow_paMOOramics_autoscrollSpeed, |
---|
| 143 | 'PANO_AUTOSCROLLONLOAD' => $slideshow_paMOOramics_autoscrollOnLoad, |
---|
| 144 | 'PANO_DISPLAYFOOTER' => $display_footer,)); |
---|
| 145 | |
---|
| 146 | load_language('plugin.lang', PAMOORAMICS_PATH); |
---|
| 147 | |
---|
| 148 | return $template->parse( 'pamooramics_content', true); |
---|
| 149 | |
---|
| 150 | } |
---|
| 151 | else { |
---|
| 152 | return $content; |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | else { |
---|
| 156 | return $content; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | $obj = new paMOOramics(); |
---|
| 168 | $obj->load_config(); |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'paMOOramics_menu') ); |
---|
| 172 | set_plugin_data($plugin['id'], $obj); |
---|
| 173 | |
---|
| 174 | add_event_handler('render_element_content', array(&$obj, 'paMOOramics_load'),41,2); |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | ?> |
---|