1 | <?php |
---|
2 | /* A simple panorama */ |
---|
3 | if (!defined('PHPWG_ROOT_PATH') or !defined('ASP_DIR')) die('Hacking attempt!'); |
---|
4 | global $conf; |
---|
5 | include_once( ASP_PATH . 'AS_Panorama_default.php'); |
---|
6 | |
---|
7 | if ( !function_exists( 'AS_panorama_content' ) ) { |
---|
8 | if ( !defined('IN_ADMIN') or !IN_ADMIN ) { |
---|
9 | add_event_handler('render_element_content', 'AS_panorama_content', 99, 2 ); |
---|
10 | function AS_panorama_content($content, $image) |
---|
11 | { |
---|
12 | global $conf, $template, $page; |
---|
13 | $asp = & $conf['AS_panorama']; |
---|
14 | //echo "<pre>"; print_r($template); echo "</pre>"; exit; |
---|
15 | |
---|
16 | if (isset($template->files['slideshow'])) return $content; |
---|
17 | if ( !stristr($image['name'], $asp['in_mode_360']) and !stristr($image['name'], $asp['in_mode_180']) ) return $content; |
---|
18 | if (!isset($image['path'])) return $content; |
---|
19 | if ( isset($page['slideshow']) and $page['slideshow'] ) return $content; |
---|
20 | if (isset($image['width']) and $image['width'] < $asp['min_viewport_width']) return $content; |
---|
21 | |
---|
22 | $divtag = "<img src=\""; |
---|
23 | $divtag.= str_replace( "./", "", $image['path'])."\" width=\"".$image['width']."\" "; |
---|
24 | $divtag.= "height=\"".$image['height']."\" "; |
---|
25 | $divtag.= "alt=\"".$image['file']."\" id=\"theMainImage\" "; |
---|
26 | |
---|
27 | if ($image['height'] > $asp['viewport_height']) { |
---|
28 | $ratio = $image['width'] / $image['height']; |
---|
29 | $image['height'] = $asp['viewport_height']; |
---|
30 | $image['width'] = $asp['viewport_height'] * $ratio; |
---|
31 | } |
---|
32 | |
---|
33 | $asp['image_name'] = $image['name']; |
---|
34 | $asp['width'] = $image['width']; |
---|
35 | $asp['height'] = $image['height']; |
---|
36 | if (stristr($image['name'], $asp['in_mode_180'])) { |
---|
37 | $asp['mode_360'] = 'false'; |
---|
38 | $asp['name'] = str_replace($asp['in_mode_180'],'', $image['name']); |
---|
39 | } |
---|
40 | else { |
---|
41 | $asp['name'] = str_replace($asp['in_mode_360'],'', $image['name']); |
---|
42 | } |
---|
43 | |
---|
44 | $template->set_filenames( |
---|
45 | array('AS_panorama_content' => dirname(__FILE__) . '/template/AS_panorama_content.tpl') ); |
---|
46 | $asp['Path'] = embellish_url($template->get_template_vars('ROOT_URL').ASP_PATH); |
---|
47 | $asp['content'] = $divtag; |
---|
48 | $template->assign( array( 'ASP' => $asp, ) ); |
---|
49 | return $template->parse('AS_panorama_content', true); |
---|
50 | } |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | if ( !function_exists( 'AS_panorama_title' ) ) { |
---|
55 | if ( $conf['AS_panorama']['In_name_display_removal'] ) { |
---|
56 | add_event_handler('loc_end_picture', 'AS_panorama_title'); |
---|
57 | function AS_panorama_title() |
---|
58 | { |
---|
59 | global $conf, $template; |
---|
60 | $asp = & $conf['AS_panorama']; |
---|
61 | $picture = $template->get_template_vars('current'); |
---|
62 | if ( isset($asp['name']) ) { |
---|
63 | $picture['TITLE'] = $asp['name']; |
---|
64 | $template->assign('current', $picture); |
---|
65 | $template->assign( array( 'ASP' => $asp, ) ); |
---|
66 | } |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | if ( !function_exists( 'AS_panorama_menu' ) ) { |
---|
72 | if ( defined('IN_ADMIN') and IN_ADMIN ) { |
---|
73 | add_event_handler('get_admin_plugin_menu_links', 'AS_panorama_menu'); |
---|
74 | function AS_panorama_menu($menu) |
---|
75 | { |
---|
76 | array_push($menu, |
---|
77 | array( |
---|
78 | 'NAME' => 'Panoramas', |
---|
79 | 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/AS_Panorama_admin.php') |
---|
80 | ) |
---|
81 | ); |
---|
82 | return $menu; |
---|
83 | } |
---|
84 | } |
---|
85 | } |
---|
86 | ?> |
---|