mathjax.install in MathJax: LaTeX for Drupal 6
Same filename and directory in other branches
MathJax module install.
File
mathjax.installView source
<?php
/**
* @file
* MathJax module install.
*/
/**
* Implements hook_uninstall().
*/
function mathjax_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'mathjax_%'");
cache_clear_all('variables', 'cache_bootstrap');
}
/**
* Implements hook_requirements().
*
* This hook will issue warnings if:
* - MathJax relies on local files and the source files are not found
*/
function mathjax_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time.
$t = get_t();
if ($phase == 'runtime' && !variable_get('mathjax_use_cdn', TRUE)) {
$requirements['mathjax'] = array(
'title' => $t('MathJax'),
'value' => $t('Installed correctly'),
'severity' => REQUIREMENT_OK,
);
if (!_mathjax_requirements_isinstalled()) {
$requirements['mathjax']['value'] = $t('Third party MathJax software not properly installed');
$requirements['mathjax']['description'] = $t('MathJax was not found in the \'libraries\' folder (e.g. sites/all/libraries).');
$requirements['mathjax']['severity'] = REQUIREMENT_ERROR;
}
}
return $requirements;
}
/**
* Determines whether the MathJax sources are present.
*
* It checks if MathJax.js is present.
* This function is used by mathjax_requirements()
*
* @return bool
* True if MathJax is installed
*/
function _mathjax_requirements_isinstalled() {
$mathjax_path = 'sites/all/libraries/mathjax/';
$jspath = $mathjax_path . '/MathJax.js';
$jsp = file_exists($jspath);
return $jsp;
}
Functions
Name | Description |
---|---|
mathjax_requirements | Implements hook_requirements(). |
mathjax_uninstall | Implements hook_uninstall(). |
_mathjax_requirements_isinstalled | Determines whether the MathJax sources are present. |