function efABCRender($input, $args, $parser) { global $abcPath, $abcURL, $abc2midi, $abctimidity, $abcOggHandler, $abcDelayedRendering, $wgLang; if ($abcPath == false || $abcURL == false) { return 'Error: $abcPath and $abcURL must be set to use the ABC extension.'; } /** * To avoid re-rendering the same tunes on every view, * use the hash of the ABC content for the filename. * This has the added benefit that rendering the same tune * on different pages will only cause one rendering. */ $float = "left"; if (isset($args['float']) && $args['float'] == 'right') { $float = "right"; } $abc = preg_replace("/^\n+/", "", $input); $hash = sha1($input); $error = ""; $hashbits = array(substr($hash, 0, 2), substr($hash, 2, 2), substr($hash, 4, 2)); $directory = "{$hashbits[0]}/{$hashbits[1]}/{$hashbits[2]}"; $filename = "{$abcPath}/{$directory}/{$hash}"; if (!@file_exists("{$abcPath}/{$directory}")) { if (!@mkdir("{$abcPath}/{$directory}", 0777, true)) { return "Cannot create directory \"{$abcPath}/{$directory}\"."; } } /** * Try to extract the title from the ABC. This is used as the * alt text for the image. */ $title = "Unknown song"; if (preg_match("/^T:\\s*(.*)\$/m", $input, $matches)) { $title = $matches[1]; } if (!abcCreateABC($abc, $filename, $error)) { return str_replace("\n", "<br />", htmlspecialchars($error)); } if (!$abcDelayedRendering) { if (!abcCreatePS($abc, $filename, $error)) { return str_replace("\n", "<br />", htmlspecialchars($error)); } if (!abcCreatePNG($abc, $filename, $error)) { return str_replace("\n", "<br />", htmlspecialchars($error)); } if (!abcCreatePDF($abc, $filename, $error)) { return str_replace("\n", "<br />", htmlspecialchars($error)); } if ($abc2midi) { if (!abcCreateMIDI($abc, $filename, $error)) { return str_replace("\n", "<br />", htmlspecialchars($error)); } } if ($abc2midi && $abctimidity) { if (!abcCreateVorbis($abc, $filename, $error)) { return str_replace("\n", "<br />", htmlspecialchars($error)); } } } /** * Succeeded to create all the output formats, return the * output. We produce an image from the PNG, and include * links to the ABC and PS. */ $e_title = htmlspecialchars($title); $e_imgpath = htmlspecialchars("{$abcURL}/{$directory}/{$hash}.png"); $e_abcpath = htmlspecialchars("{$abcURL}/{$directory}/{$hash}.abc"); $e_pspath = htmlspecialchars("{$abcURL}/{$directory}/{$hash}.ps"); $e_pdfpath = htmlspecialchars("{$abcURL}/{$directory}/{$hash}.pdf"); $e_midipath = htmlspecialchars("{$abcURL}/{$directory}/{$hash}.mid"); $e_vorbispath = htmlspecialchars("{$abcURL}/{$directory}/{$hash}.ogg"); $links = array(); $links[] = "<a href=\"{$e_abcpath}\">" . wfMsg('abcabc') . "</a>"; $links[] = "<a href=\"{$e_pspath}\">" . wfMsg('abcps') . "</a>"; $links[] = "<a href=\"{$e_pdfpath}\">" . wfMsg('abcpdf') . "</a>"; if ($abc2midi) { $links[] = "<a href=\"{$e_midipath}\">" . wfMsg('abcmidi') . "</a>"; } if ($abctimidity) { $links[] = "<a href=\"{$e_vorbispath}\">" . wfMsg('abcvorbis') . "</a>"; } $e_dllinks = wfMsg('abcdownload') . " " . $wgLang->pipeList($links); $ogghtml = ""; if ($abcOggHandler) { $oh = new OggTransformOutput(null, "{$filename}.ogg", false, 250, 0, 0, false, "{$filename}.ogg", false); $ogghtml = $oh->toHtml(array('alt' => $title)); } $output = <<<EOF <div style="float: {$float}; border: solid 1px #aaaaaa; margin: 0.2em;" class="abc-music"> \t<img src="{$e_imgpath}" alt="{$e_title}" /> \t<div style="text-align: center"> \t\t{$e_dllinks} \t</div> \t<div style='margin-left: auto; margin-right: auto;'> \t\t{$ogghtml} \t</div> </div> EOF; return $output; }
function __construct($file, $videoUrl, $width, $height, $length, $path, $noIcon = false) { parent::__construct($file, $videoUrl, false, $width, $height, $length, false, $path, $noIcon); }