source: extensions/Panoramas/AS_Panorama.php @ 19541

Last change on this file since 19541 was 19535, checked in by Klarsfeld, 11 years ago
File size: 2.9 KB
Line 
1<?php
2/* A simple panorama */
3if (!defined('PHPWG_ROOT_PATH') or !defined('ASP_DIR')) die('Hacking attempt!');
4global $conf;
5include_once( ASP_PATH . 'AS_Panorama_default.php');
6
7if ( !function_exists( 'AS_panorama_content' ) ) {
8        if ( !defined('IN_ADMIN') or !IN_ADMIN ) {
9    add_event_handler('render_element_content', 'AS_panorama_content', 41, 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        if ($image['height'] > $asp['viewport_height']) {
23                $ratio = $image['width'] / $image['height'];
24                $image['height'] = $asp['viewport_height'];
25                $image['width'] = $asp['viewport_height'] * $ratio;
26        }
27
28        $content = "<img src=\"".str_replace( "./", "", $image['path'])."\" width=\"".$image['width']."\" height=\"".$image['height']."\" alt=\"".$image['file']."\" id=\"theMainImage\"></img>";
29
30       
31        $asp['image_name'] = $image['name'];
32        $asp['width'] = $image['width'];
33        $asp['height'] = $image['height'];
34        if (stristr($image['name'], $asp['in_mode_180'])) {
35                $asp['mode_360'] = 'false';
36                $asp['name'] = str_replace($asp['in_mode_180'],'', $image['name']);
37        }
38        else  {
39                $asp['name'] = str_replace($asp['in_mode_360'],'', $image['name']);
40        }
41        $asp['footer_view'] = 'false';
42       
43        $template->set_filenames(
44        array('AS_panorama_content' => dirname(__FILE__) . '/template/AS_panorama_content.tpl') );
45        $asp['Path'] = embellish_url($template->get_template_vars('ROOT_URL').ASP_PATH);
46        $asp['content'] = $content;
47        $template->assign( array( 'ASP' => $asp, ) );
48        return $template->parse('AS_panorama_content', true);
49}
50}
51}
52
53if ( !function_exists( 'AS_panorama_title' ) ) {
54        if ( $conf['AS_panorama']['In_name_display_removal'] ) {
55                add_event_handler('loc_end_picture', 'AS_panorama_title');
56                function AS_panorama_title()
57                {
58                        global $conf, $template;
59                        $asp = & $conf['AS_panorama'];
60                        $picture = $template->get_template_vars('current');
61                        if ( isset($asp['name']) ) {
62                        $picture['TITLE'] = $asp['name'];
63                        $template->assign('current', $picture);
64                        $template->assign( array( 'ASP' => $asp, ) );
65                        }
66                }
67        }
68}
69
70if ( !function_exists( 'AS_panorama_menu' ) ) {
71        if ( defined('IN_ADMIN') and IN_ADMIN ) {
72                add_event_handler('get_admin_plugin_menu_links', 'AS_panorama_menu');
73                function AS_panorama_menu($menu)
74                {
75                        array_push($menu,
76                                array(
77                                        'NAME' => 'Panoramas',
78                                        'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/AS_Panorama_admin.php')
79                                        )
80                        );
81                return $menu;
82                }
83        }
84}
85?>
Note: See TracBrowser for help on using the repository browser.