/** * Create output */ function render($mode, Doku_Renderer $renderer, $data) { global $INFO; global $ACT; global $conf; if ($mode == 'xhtml' && strlen($data[0]) > 1) { $src = $data[0]; $origSrc = $src; $trans = "0 " . $data[1]; // "0" includes the original key $debug = $conf['allowdebug']; $error = $this->_checkExecs(); if ($this->getConf('abcok') && (!$INFO['rev'] || $INFO['rev'] && $ACT == 'preview') && !$error) { //do not create/show files if an old revision is viewed, but always if the page is previewed and never when there is an error $entitiesFile = dirname(__FILE__) . '/conf/entities.conf'; if (@file_exists($entitiesFile)) { $entities = confToHash($entitiesFile); $src = strtr($src, $entities); } $fileBase = $this->_getFileBase($origSrc); $srcFile = $fileBase . '.abc'; $srcChanged = !file_exists($srcFile) || file_exists($srcFile) && $src != io_readFile($srcFile); if ($srcChanged) { io_saveFile($srcFile, $src); } if ($this->getConf('abc2abc') && is_executable($this->getConf('abc2abc'))) { $transSrc = $this->_getTransSrc($trans); $transNew = $this->_getTransNew($fileBase, $transSrc); } else { $transSrc = array(0); $transNew = array(); } $renderList = $srcChanged ? $transSrc : $transNew; if ($debug || $_REQUEST['purge']) { $renderList = $transSrc; } // create files foreach ($renderList as $transMode) { // if no transposition is allowed and the tune shall be transposed // by 0 semitones (= not at all), then nothing is appended to the fileBase; // else append the amount of semitiones to the fileBase $curFileBase = $transMode == 0 ? $fileBase : $fileBase . "_" . $transMode; $abcFile = $curFileBase . '.abc'; io_saveFile($abcFile, $src); ob_start(); if ($transMode != 0) { $this->_transpose($abcFile, $srcFile, $transMode); } $debugLog = $this->_createImgFile($abcFile, $curFileBase); if ($this->getConf('displayType') == 1 || $this->getConf('displayType') == 2) { $this->_createMidiFile($abcFile, $curFileBase); } if ($this->getConf('displayType') == 2) { $this->_createPsFile($abcFile, $curFileBase); if ($this->getConf('ps2pdf')) { $this->_createPdfFile($abcFile, $curFileBase); } } $errorLog = ob_get_contents(); ob_end_clean(); } if (($this->getConf('displayErrorlog') || $debug) && $errorLog) { $errorLog = str_replace($this->_getAbc2psVersion(), "abc2ps", $errorLog); //hide abc2ps version for security reasons //TODO: hide lines starting with "writing MIDI file", "File", "Output written on", ... for boring reasons msg(nl2br($errorLog), 2); } if ($debugLog) { msg($debugLog); } // display files foreach ($transSrc as $transMode) { $curFileBase = $transMode == 0 ? $fileBase : $fileBase . "_" . $transMode; $renderer->doc .= $this->_showFiles($curFileBase); } // always have the abc source in the html source (for search engine optimization) // only per css visible when displaySource = 1 if ($this->getConf('displaySource')) { $visible = " visible"; } $renderer->doc .= '<div class="abc_src' . $visible . '">' . NL; $renderer->doc .= $renderer->file($origSrc); $renderer->doc .= '</div>' . NL; } else { if ($error && $this->getConf('abcok')) { msg($error, -1); } $renderer->doc .= $renderer->file($origSrc); } return true; } return false; }