function syntaxhighlighter_init in Syntax Highlighter 6
Same name and namespace in other branches
- 6.2 syntaxhighlighter.module \syntaxhighlighter_init()
- 7.2 syntaxhighlighter.module \syntaxhighlighter_init()
- 7 syntaxhighlighter.module \syntaxhighlighter_init()
File
- ./
syntaxhighlighter.module, line 63 - Syntax highlight code using the Syntaxhighlighter javascript library. See http://alexgorbatchev.com/wiki/SyntaxHighlighter
Code
function syntaxhighlighter_init() {
if (!_syntaxhighlighter_page_match()) {
return;
}
$lib_location = _syntaxhighlighter_get_lib_location();
$styles_path = $lib_location . '/styles/';
$scripts_path = $lib_location . '/scripts/';
drupal_add_css($styles_path . 'shCore.css', 'module');
$theme = variable_get('syntaxhighlighter_theme', 'shThemeDefault.css');
drupal_add_css($styles_path . $theme, 'module');
drupal_add_js($scripts_path . 'shCore.js', 'module');
if (variable_get('syntaxhighlighter_legacy_mode', 0)) {
drupal_add_js($scripts_path . 'shLegacy.js', 'module');
}
if (variable_get('syntaxhighlighter_use_autoloader', FALSE)) {
drupal_add_js($scripts_path . 'shAutoloader.js');
drupal_add_js(file_directory_path() . '/syntaxhighlighter.autoloader.js');
$settings['useAutoloader'] = TRUE;
}
else {
$enabled_languages = variable_get('syntaxhighlighter_enabled_languages', array(
'shBrushPhp.js',
));
foreach ($enabled_languages as $lang) {
if (!empty($lang)) {
drupal_add_js($scripts_path . $lang, 'module');
}
}
}
$tag_name = variable_get('syntaxhighlighter_tagname', 'pre');
if ($tag_name !== 'pre') {
$settings['tagName'] = $tag_name;
}
if (file_exists($scripts_path . 'clipboard.swf')) {
$settings['clipboard'] = base_path() . $scripts_path . 'clipboard.swf';
}
if (variable_get('syntaxhighlighter_legacy_mode', 0)) {
$settings['legacyMode'] = TRUE;
}
drupal_add_js(array(
'syntaxhighlighter' => $settings,
), 'setting');
if ($defaultExpression = variable_get('syntaxhighlighter_default_expressions', '')) {
drupal_add_js($defaultExpression, 'inline');
}
drupal_add_js(drupal_get_path('module', 'syntaxhighlighter') . '/syntaxhighlighter.min.js', 'module', 'footer');
}