function _syntaxhighlighter_setup_autoloader_script in Syntax Highlighter 7
Same name and namespace in other branches
- 8 syntaxhighlighter.module \_syntaxhighlighter_setup_autoloader_script()
- 6.2 syntaxhighlighter.module \_syntaxhighlighter_setup_autoloader_script()
- 6 syntaxhighlighter.module \_syntaxhighlighter_setup_autoloader_script()
- 7.2 syntaxhighlighter.module \_syntaxhighlighter_setup_autoloader_script()
Create the autoload setup script file. Must call this whenever lib location and/or the enable brushes change. Make sure never call this if the js lib is not found
1 call to _syntaxhighlighter_setup_autoloader_script()
1 string reference to '_syntaxhighlighter_setup_autoloader_script'
- syntaxhighlighter_settings_form in ./
syntaxhighlighter.admin.inc - An admin form to specify which language to support for highlighting
File
- ./
syntaxhighlighter.module, line 397 - Syntax highlight code using the Syntaxhighlighter javascript library. See http://alexgorbatchev.com/wiki/SyntaxHighlighter
Code
function _syntaxhighlighter_setup_autoloader_script() {
$path = 'public://syntaxhighlighter.autoloader.js';
if (variable_get('syntaxhighlighter_use_autoloader', FALSE)) {
// use variable_get() instead of _syntaxhighlighter_get_lib_location()
// because this function is called only if the lib location is found
$script_path = base_path() . variable_get('syntaxhighlighter_lib_location', NULL) . '/scripts/';
$script_data = <<<__HERE__
/*
* This file is generated by the Syntaxhighlighter module
*/
__HERE__;
$script_data .= "\nfunction syntaxhighlighterAutoloaderSetup() {\n SyntaxHighlighter.autoloader(\n";
$need_ending = FALSE;
$brushes = variable_get('syntaxhighlighter_enabled_languages', array(
'shBrushPhp.js',
));
foreach ($brushes as $b) {
if ($b) {
if ($need_ending) {
$script_data .= ",\n";
}
$alias = strtolower(substr(substr($b, 7), 0, -3));
$script_data .= " '{$alias} {$script_path}{$b}'";
$need_ending = TRUE;
}
}
$script_data .= "\n);\n}\n";
file_unmanaged_save_data($script_data, $path, FILE_EXISTS_REPLACE);
}
else {
file_unmanaged_delete($path);
}
}