enable = $this->_requirements_ok();
}
/**
* return some info
*/
function getInfo(){
return array(
'author' => 'Olivier Delrieu',
'email' => 'olivier@delrieu.org',
'date' => '2010 March 10',
'name' => 'Mathtran Plugin'.(!$this->enable ? ' (disabled)' : ''),
'desc' => 'Add mathematical formulae to dokuwiki
using the MathTran TeX engine
Syntax: math formulae'.
(!$this->enable ? "\n(".$this->msg_disable.")" : ''),
'url' => 'http://www.delrieu.org',
);
}
function getType(){ return 'protected'; }
function getPType(){ return 'normal'; }
function getSort(){ return 208; }
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addEntryPattern('.*?',$mode,'plugin_mathtran');
}
function postConnect() {
$this->Lexer->addExitPattern('','plugin_mathtran');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
if ( $state == DOKU_LEXER_UNMATCHED ) {
$math = $match;
return (array(trim($math), $align));
}
return false;
}
/**
* Create output
*/
function render($mode, &$renderer, $data) {
global $mathtranplugin_js;
if (!$data) return; // skip rendering for the enter and exit patterns
list($math, $align) = $data;
if($mode == 'xhtml'){
if ($this->enable) {
if($mathtranplugin_js == true) {
// this is ugly but I can't make any local script.js file work.
$math_html = '' ;
$mathtranplugin_js = false;
} else {
$math_html = '';
}
$math_html .= '';
$renderer->doc .= $math_html;
} else {
$this->_msg($this->msg_disable, -1);
}
return true;
}
return false;
}
// return true if php installation has required libraries/functions for mathpublisher
function _requirements_ok() {
return true;
}
// used to avoid multiple messages
function _msg($str, $lvl=0) {
if ($this->msg_sent) return;
msg($str, $lvl);
$this->msg_sent = true;
}
// would like to see this function in io.php :)
function _mkdir($d) {
global $conf;
umask($conf['dmask']);
$ok = io_mkdir_p($d);
umask($conf['umask']);
return $ok;
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :