コード例 #1
0
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);
}