* @version 2007-02-22
* heavily based on the graphviz plugin (with the dokutexit extensions) and the gnuplot plugin.
*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
require_once(DOKU_INC.'inc/init.php');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_format extends DokuWiki_Syntax_Plugin {
function getInfo(){
return array(
'author' => 'Jason Grout',
'email' => 'jason-doku@creativetrax.com',
'date' => '2007-02-22',
'name' => 'format Plugin',
'desc' => 'Sends text to external program',
'url' => 'https://www.dokuwiki.org/plugin:format',
);
}
/**
* What kind of syntax are we?
*/
function getType(){
return 'protected';
}
/**
* Where to sort in?
*/
function getSort(){
return 100;
}
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addEntryPattern('
".preg_replace('/@DOKUMEDIA:([^:]*):([^@]*)@/e', "''.\$renderer->internalmedia(\$medians.'$2', '$1').'
'", $renderer->_xmlEntities(file_get_contents($outfilename))).""; */ } else { switch($mode) { case 'xhtml': $renderer->doc .= $renderer->internalmedia($medians.$hashname, $config['name']); break; case 'latex': $renderer->doc .= "\\begin{figure}[h]\n"; $renderer->doc .= "\t\\begin{center}\n"; $renderer->doc .= "\t\t\\includegraphics{"; $renderer->doc .= $medianame; $renderer->doc .= "}\n"; $renderer->doc .= "\t\\end{center}\n"; $renderer->doc .= "\\end{figure}\n"; break; } } return true; } return false; } function createMedia($medianame, $outfilename, $multipart, &$text, $program, $mode='xhtml') { global $conf; $config = $this->getConf($program); if(!$config || !$config[$mode]) return false; $tmpinput = tempnam($this->getConf('tmpdir'), "dokuwiki.format"); $pre = str_replace(array('@INFILE@','@OUTFILE@','@MEDIAFILE@'), array($tmpinput, $outfilename, $medianame), $config[$mode]['pre']); $post = str_replace(array('@INFILE@','@OUTFILE@','@MEDIAFILE@'), array($tmpinput, $outfilename,$medianame), $config[$mode]['post']); $wrappeddata = $pre.$text.$post; //$this->printpre($wrappeddata); io_saveFile($tmpinput, $wrappeddata); //Using dokuwiki framework // TODO: do I need to initialize these variables before passing them to exec? $output=array(); $retval=''; // Replace the variable strings $command=str_replace(array('@INFILE@','@OUTFILE@','@MEDIAFILE@'), array($tmpinput, $outfilename, $medianame), $config[$mode]['command']) //$this->printpre($command); exec($command,$output,$retval); //$this->printpre(print_r($output,true)); unlink($tmpinput); return $retval; } function printpre($data) { print("
".$data.""); } } ?>