3 description : Display XML/SWF Charts ver.5
5 email : i.obataya@gmail.com
6 lastupdate : 2008-10-30
7 license : GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__
).'/../../').'/');
10 require_once(DOKU_INC
.'inc/init.php');
11 if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC
.'lib/plugins/');
12 require_once(DOKU_PLUGIN
.'syntax.php');
14 class syntax_plugin_chart2
extends DokuWiki_Syntax_Plugin
{
19 function syntax_plugin_chart2(){
20 $this->swfLoc
= DOKU_BASE
.'lib/plugins/chart2/maani.us/charts';
21 $this->swfLibLoc
= DOKU_BASE
.'lib/plugins/chart2/maani.us/charts_library';
26 'author' => 'Ikuo Obataya',
27 'email' => 'I.Obataya@gmail.com',
28 'date' => '2008-10-30',
29 'name' => 'XML/SWF Charts Plugin',
30 'desc' => 'Create SWF Charts by www.maani.us
31 <chart2 (filename)> script </chart2>',
32 'url' => 'http://wiki.symplus.co.jp/computer/en/chart2_plugin',
35 function getType(){ return 'protected'; }
36 function getSort(){ return 916; }
37 function connectTo($mode) {$this->Lexer
->addEntryPattern('<chart2(?=.*?>.*?</chart2>)',$mode,'plugin_chart2');}
38 function postConnect(){$this->Lexer
->addExitPattern('</chart2>','plugin_chart2');}
40 function handle($match, $state, $pos) {
42 case DOKU_LEXER_ENTER
: return array($state);
43 case DOKU_LEXER_UNMATCHED
:return array($state,$match,$pos);
44 case DOKU_LEXER_EXIT
: return array($state);
48 function render($mode, &$renderer, $data){
49 if ($mode!='xhtml') return;
52 @list
($state, $match,$pos) = $data;
54 case DOKU_LEXER_ENTER
:break;
55 case DOKU_LEXER_UNMATCHED
:
56 $i = strpos($match,">");
57 if($att_idx<0) return array();
58 $att_str = trim(substr($match,0,$i));
59 $chart_xml = substr($match,$i+
1);
61 $att = explode(" ",$att_str);
62 $tryFN = preg_replace("/({{)?([^|}]+).*(}})?/",'$2',$att[0]);
63 if(strpos($tryFN,"http")!==false){
67 $source = "xml_source=".$tryFN;
73 $filename = mediaFN($tryFN);
74 if(is_dir($filename) ||
!file_exists($filename)){
76 $xml_data= strtr($chart_xml,array("\n"=>"","\t"=>""));
77 $xml_data= preg_replace("/>\s+</","><",$xml_data);
78 $source = "xml_data=".$xml_data;
81 //$source = "xml_source=".ml($tryFN,"",true,"",true);
82 $source = "xml_source=/~kssilveira/site/lib/exe/fetch.php?media=".$tryFN;
86 $width = (!empty($att[$idx])) ?
$att[$idx] : $this->getConf('default_width');$idx++
;
87 $height = (!empty($att[$idx])) ?
$att[$idx] : $this->getConf('default_height');$idx++
;
88 $oid = (!empty($att[$idx])) ?
$att[$idx] : 'chart'.$pos;$idx++
;
89 $bgcolor = (!empty($att[$idx])) ?
$att[$idx] : $this->getConf('default_bgcolor');$idx++
;
90 $align = (!empty($att[$idx])) ?
$att[$idx] : '';
92 $renderer->doc
.=sprintf($this->template
,$width,$height,$this->swfLoc
,$this->swfLoc
,
93 "library_path=".$this->swfLibLoc
."&".$source,$oid,$oid,$bgcolor,$align);
95 case DOKU_LEXER_EXIT
:break;
100 function setTemplate(){
101 $this->template
= <<<EOT
102 <script language="JavaScript" type="text/javascript">
104 var requiredMajorVersion = 9;
105 var requiredMinorVersion = 0;
106 var requiredRevision = 45;
107 if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
108 alert("This page requires AC_RunActiveContent.js.");
110 var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
111 if(hasRightVersion) {
113 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',
127 'allowFullScreen', 'true',
128 'allowScriptAccess','sameDomain',
130 'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
132 'devicefont', 'false'
135 var alternateContent = 'This content requires the Adobe Flash Player. '
136 + '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.';
137 document.write(alternateContent);
142 <noscript><p>This content requires JavaScript.</p></noscript>