/** * * Renders a token into text matching the requested format. * * @access public * * @param array $options The "options" portion of the token (second * element). * * @return string The text rendered from the token options. * */ function token($options) { $content = $options['content']; $hashcode = md5($content); $runData = Ozone::getRunData(); $site = $runData->getTemp('site'); $dir = $site->getLocalFilesPath() . '/math/inline'; if (!file_exists($dir)) { mkdirfull($dir); } $tmpDir = WIKIDOT_ROOT . '/tmp/math'; if (!file_exists($tmpDir)) { mkdirfull($tmpDir); } $imgFile = $hashcode . '.png'; if (!file_exists($dir . '/' . $imgFile)) { $renderer = new LatexRenderer(); $renderer->setTmpDir($tmpDir); $renderer->setOutputDir($dir); $renderer->setDensity(110); $content2 = '$' . $content . '$'; $renderer->render($content2, $hashcode); } if (!file_exists($dir . '/' . $imgFile)) { return '<span class="error-inline">' . _('The equation has not been processed correctly. Most prabably it has syntax error(s).') . ' </span>'; } $out = '<img class="math-inline" src="/local--math/inline/' . $imgFile . '" alt="' . htmlentities($content) . '" />'; return $out; $content = $options['content']; $hashcode = md5($content); $runData = Ozone::getRunData(); $site = $runData->getTemp('site'); $dir = $site->getLocalFilesPath() . '/math/inline'; if (!file_exists($dir)) { mkdirfull($dir); } $imgFile = $hashcode . '.png'; $imgFile = $hashcode . '.png'; $out = '<img src="http://' . $site->getDomain() . '/local--math/inline/' . $imgFile . '" alt="' . htmlentities($content) . '" />'; return $out; }
/** * * Renders a token into text matching the requested format. * * @access public * * @param array $options The "options" portion of the token (second * element). * * @return string The text rendered from the token options. * */ function token($options) { $content = $options['content']; $type = $options['type']; $hashcode = md5($content . '..' . $type); $runData = Ozone::getRunData(); $site = $runData->getTemp('site'); $dir = $site->getLocalFilesPath() . '/math/eqs'; if (!file_exists($dir)) { mkdirfull($dir); } $tmpDir = WIKIDOT_ROOT . '/tmp/math'; if (!file_exists($tmpDir)) { mkdirfull($tmpDir); } $imgFile = $hashcode . '.png'; if (!file_exists($dir . '/' . $imgFile)) { $renderer = new LatexRenderer(); $renderer->setTmpDir($tmpDir); $renderer->setOutputDir($dir); if ($type == 'eqnarray') { $content2 = "\\begin{eqnarray*}\n" . $content . "\n\\end{eqnarray*}"; } else { $content2 = "\\begin{equation*}\n" . $content . "\n\\end{equation}"; } $renderer->render($content2, $hashcode); } if (!file_exists($dir . '/' . $imgFile)) { return '<div class="error-block">' . _('The equation has not been processed correctly. Most prabably it has syntax error(s).') . '</div>'; } $label = $options['label']; $idPrefix = $this->getConf("id_prefix"); $idString = ' id="equation-' . $idPrefix . $options['id'] . '" '; $equationNumberLabel = '<span class="equation-number">(' . $options['id'] . ')</span>'; $out = '<div class="math-equation"' . $idString . '><img src="/local--math/eqs/' . $imgFile . '" alt="' . htmlentities($content) . '" /></div>'; return $equationNumberLabel . $out; }