source: code/Website/php-ofc-library/open-flash-chart-object.php

Last change on this file was 7849, checked in by dennisw, 15 years ago
File size: 3.4 KB
Line 
1<?php
2
3function open_flash_chart_object_str( $width, $height, $url, $use_swfobject=true, $base='' )
4{
5 //
6 // return the HTML as a string
7 //
8 return _ofc( $width, $height, $url, $use_swfobject, $base );
9}
10
11function open_flash_chart_object( $width, $height, $url, $use_swfobject=true, $base='' )
12{
13 //
14 // stream the HTML into the page
15 //
16 echo _ofc( $width, $height, $url, $use_swfobject, $base );
17}
18
19function _ofc( $width, $height, $url, $use_swfobject, $base )
20{
21 //
22 // I think we may use swfobject for all browsers,
23 // not JUST for IE...
24 //
25 //$ie = strstr(getenv('HTTP_USER_AGENT'), 'MSIE');
26
27 //
28 // escape the & and stuff:
29 //
30 $url = urlencode($url);
31
32 //
33 // output buffer
34 //
35 $out = array();
36
37 //
38 // check for http or https:
39 //
40 if (isset ($_SERVER['HTTPS']))
41 {
42 if (strtoupper ($_SERVER['HTTPS']) == 'ON')
43 {
44 $protocol = 'https';
45 }
46 else
47 {
48 $protocol = 'http';
49 }
50 }
51 else
52 {
53 $protocol = 'http';
54 }
55
56 //
57 // if there are more than one charts on the
58 // page, give each a different ID
59 //
60 global $open_flash_chart_seqno;
61 $obj_id = 'chart';
62 $div_name = 'flashcontent';
63
64 //$out[] = '<script type="text/javascript" src="'. $base .'js/ofc.js"></script>';
65
66 if( !isset( $open_flash_chart_seqno ) )
67 {
68 $open_flash_chart_seqno = 1;
69 $out[] = '<script type="text/javascript" src="'. $base .'js/swfobject.js"></script>';
70 }
71 else
72 {
73 $open_flash_chart_seqno++;
74 $obj_id .= '_'. $open_flash_chart_seqno;
75 $div_name .= '_'. $open_flash_chart_seqno;
76 }
77
78 if( $use_swfobject )
79 {
80 // Using library for auto-enabling Flash object on IE, disabled-Javascript proof
81 $out[] = '<div id="'. $div_name .'"></div>';
82 $out[] = '<script type="text/javascript">';
83 $out[] = 'var so = new SWFObject("'. $base .'open-flash-chart.swf", "'. $obj_id .'", "'. $width . '", "' . $height . '", "9", "#FFFFFF");';
84
85 $out[] = 'so.addVariable("data-file", "'. $url . '");';
86
87 $out[] = 'so.addParam("allowScriptAccess", "always" );//"sameDomain");';
88 $out[] = 'so.write("'. $div_name .'");';
89 $out[] = '</script>';
90 $out[] = '<noscript>';
91 }
92
93 $out[] = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' . $protocol . '://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
94 $out[] = 'width="' . $width . '" height="' . $height . '" id="ie_'. $obj_id .'" align="middle">';
95 $out[] = '<param name="allowScriptAccess" value="sameDomain" />';
96 $out[] = '<param name="movie" value="'. $base .'open-flash-chart.swf?data='. $url .'" />';
97 $out[] = '<param name="quality" value="high" />';
98 $out[] = '<param name="bgcolor" value="#FFFFFF" />';
99 $out[] = '<embed src="'. $base .'open-flash-chart.swf?data=' . $url .'" quality="high" bgcolor="#FFFFFF" width="'. $width .'" height="'. $height .'" name="'. $obj_id .'" align="middle" allowScriptAccess="sameDomain" ';
100 $out[] = 'type="application/x-shockwave-flash" pluginspage="' . $protocol . '://www.macromedia.com/go/getflashplayer" id="'. $obj_id .'"/>';
101 $out[] = '</object>';
102
103 if ( $use_swfobject ) {
104 $out[] = '</noscript>';
105 }
106
107 return implode("\n",$out);
108}
109?>
Note: See TracBrowser for help on using the repository browser.