4 * Copyright 2009 $ThePhpWikiProgrammingTeam
6 * This file is part of PhpWiki.
8 * PhpWiki is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * PhpWiki is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with PhpWiki; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Interface to http://ejohn.org/blog/processingjs/
25 * Syntax: http://ejohn.org/blog/overview-of-processing/
27 class WikiPlugin_Processing
31 return _("Processing");
34 function getDescription() {
35 return _("Render inline Processing");
38 function getDefaultArguments() {
39 return array('width' => 200,
41 'script' => false, // one line script. not very likely
42 'onmousemove' => false
45 function handle_plugin_args_cruft(&$argstr, &$args) {
46 $this->source = $argstr;
49 function run($dbi, $argstr, &$request, $basepage) {
51 $args = $this->getArgs($argstr, $request);
52 if (empty($this->source))
55 if (empty($WikiTheme->_asciiSVG)) {
56 $js = JavaScript('', array
57 ('src' => $WikiTheme->_findData('Processing.js')));
58 if (empty($WikiTheme->_headers_printed))
59 $WikiTheme->addMoreHeaders($js);
61 $html->pushContent($js);
62 $WikiTheme->_processing = 1; // prevent duplicates
65 if (preg_match("/^(.*)<script>(.*)<\/script>/ism", $this->source, $m)) {
66 $this->source = $m[1];
67 $args['script'] = $m[2];
69 $embedargs = array('width' => $args['width'],
70 'height' => $args['height'],
72 'script' => $this->source);
73 // additional onmousemove argument
74 if ($args['onmousemove']) $embedargs['onmousemove'] = $args['onmousemove'];
75 // we need script='data' and not script="data"
76 $embed = new Processing_HTML("embed", $embedargs);
77 $html->pushContent($embed);
78 if ($args['script']) $html->pushContent(JavaScript($args['script']));
83 class Processing_HTML extends HtmlElement {
85 $start = "<" . $this->_tag;
87 foreach ($this->_attr as $attr => $val) {
93 $qval = str_replace("\"", '"', $this->_quote((string)$val));
94 if ($attr == 'script')
96 $start .= " $attr='$qval'";
98 $start .= " $attr=\"$qval\"";
109 // c-hanging-comment-ender-p: nil
110 // indent-tabs-mode: nil