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