function createMediaObject ($pagename, $fname, $attribs=false) { if (trim($fname) == '') return false; $type = MediaObjectFactory::type($fname); $ext = strtolower(file_extension($fname)); // special case: RealAudio/-Video switch ($ext) { case 'smi' : case 'smil': case 'rm': if ($attribs->attribs['media'] == 'audio') return new RealAudioObject($pagename, $fname, $attribs); else return new RealVideoObject($pagename, $fname, $attribs); case 'htm' : case 'html': return new IFrameObject($pagename, $fname, $attribs); } switch ($type) { case 'image' : return MediaObjectFactory::createImageObject($pagename, $fname, $attribs); case 'audio' : return MediaObjectFactory::createAudioObject($pagename, $fname, $attribs); case 'video' : return MediaObjectFactory::createVideoObject($pagename, $fname, $attribs); } // try to create a ScriptObject if ($so = ScriptObjectFactory::createScriptObjectFromFilename($pagename, $fname, $attribs)) return $so; if (is_object($attribs)) { $attr = $attribs->getAttribs(); if (isset($attr['url'])) return new IFrameObject($pagename, $fname, $attribs); } $co = new CodeObject($pagename, $fname, $attribs); return $co->isBinary() ? false : $co; }
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); }