function doCode ($pagename, $code, $attrstr) { $code = trim(html_entity_decode($code)); $attribs = new Attributes($attrstr, array('print'=>'fo')); $attr = $attribs->getAttribs('fo'); if ($code == '') { if ($attr['file'] != '') { $co = new CodeObject($pagename, $attr['file']); $co->linkUploadedFile($attr['file']); if ($co->exists()) $code = $co->getCode(); } else return ''; } $tabwidth = (isset($attr['tab']) && $attr['tab'] >= 0 && $attr['tab'] <= 10) ? $attr['tab'] : 4; $code = str_replace('\"', '"', html_entity_decode($code)); // replace already created entities $code = str_replace('<:vspace>', '', $code); $code = str_replace("\t", substr(' ', 0, $tabwidth), $code); $co = new CodeObject($pagename, $code, false); $html = $co->getWikiXML('fo', $attr); $co->cleanup(); // remove temporary files return Keep($html); }
function doCode ($pagename, $code, $attrstr) { $code = trim($code); $attribs = new Attributes($attrstr); $attr = $attribs->getAttribs('html'); if ($code == '') { if ($attr['file'] != '') { $co = new CodeObject($pagename, $attr['file']); $co->linkUploadedFile($attr['file']); if ($co->exists()) $code = $co->getCode(); else { global $ScriptUrl; $msg = "code file <i>$attr[file]</i> not found<br>"; $msg.= "<a href='$ScriptUrl?n=$pagename/?action=upload&upname=$attr[file]'>upload now</a>"; return Keep(errorHTML($msg)); } } else return ''; } $tabwidth = (isset($attr['tab']) && $attr['tab'] >= 0 && $attr['tab'] <= 10) ? $attr['tab'] : 4; $code = str_replace('\"', '"', html_entity_decode($code)); // replace already created entities $code = str_replace('<:vspace>', '', $code); $code = str_replace("\t", substr(' ', 0, $tabwidth), $code); $co = new CodeObject($pagename, $code, false); $html = $co->getHTML($attr); $co->cleanup(); // remove temporary files return Keep($html); }