Moderators: jmacgreg, michael, John
function callback($hookName, $args) {
$jaxScript = '<script type="text/javascript" src="path-to-MathJax/MathJax.js">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "mml2jax.js"],
jax: ["input/TeX", "input/MathML", "output/HTML-CSS"],
});
</script>'
$templateManager->assign('additionalHeadData', $additionalHeadData."\n".$jaxScript);
}<?php
/**
* @file plugins/generic/mathjax/MathJaxPlugin.inc.php
*
* Copyright (c) 2003-2010 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class MathJaxPlugin
* @ingroup plugins_generic_mathjax
*
* @brief MathJax plugin for rendering LaTeX and MathML
*/
import('lib.pkp.classes.plugins.GenericPlugin');
class MathJaxPlugin extends GenericPlugin {
/**
* Register the plugin, if enabled
* @param $category string
* @param $path string
* @return boolean
*/
function register($category, $path) {
if (parent::register($category, $path)) {
if ($this->getEnabled()) {
HookRegistry::register('TemplateManager::display',array(&$this, 'callback'));
}
return true;
}
return false;
}
/**
* Hook callback function for TemplateManager::display
* @param $hookName string
* @param $args array
* @return boolean
*/
function callback($hookName, $args) {
// Only pages requests interest us here
if ($this->getEnabled()) {
$templateManager =& $args[0];
$baseUrl = $templateManager->get_template_vars('baseUrl');
$additionalHeadData = $templateManager->get_template_vars('additionalHeadData');
$mathjaxScript = ' <!-- MathJax plugin -->
<script type="text/javascript" src="'.$baseUrl.'/plugins/generic/mathjax/MathJax/MathJax.js">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "mml2jax.js"],
jax: ["input/TeX", "input/MathML", "output/HTML-CSS"],
});
</script>
<!-- / MathJax plugin -->';
$templateManager->assign('additionalHeadData', $additionalHeadData."\n".$mathjaxScript);
}
return false;
}
/**
* Get the display name of this plugin
* @return string
*/
function getDisplayName() {
return Locale::translate('plugins.generic.mathjax.name');
}
/**
* Get the description of this plugin
* @return string
*/
function getDescription() {
return Locale::translate('plugins.generic.mathjax.description');
}
/**
* Get a list of available management verbs for this plugin
* @return array
*/
function getManagementVerbs() {
$verbs = array();
$verbs = parent::getManagementVerbs();
return $verbs;
}
}
?>
Users browsing this forum: Exabot [Bot] and 0 guests