function jstimer_load_js in Javascript Timer 6
Same name and namespace in other branches
- 7 jstimer.module \jstimer_load_js()
Determine whether or not to to add javascript.
Return value
boolean TRUE if the javascript should be added, FALSE otherwise.
1 call to jstimer_load_js()
- jstimer_init in ./
jstimer.module - Implementation of hook_init
File
- ./
jstimer.module, line 117 - A module which creates javascript timed dhtml things.
Code
function jstimer_load_js() {
$js_load_option = variable_get('jstimer_js_load_option', DEFAULT_JS_LOAD);
if ($js_load_option == 1) {
//every page
return TRUE;
}
else {
if ($js_load_option == 2 || $js_load_option == 0) {
if ($js_load_option == 0) {
// all nodes
$pages = 'node/*';
}
else {
// page list
$pages = variable_get('jstimer_js_load_pages', '');
$exclude = variable_get('jstimer_js_exclude_pages', '');
}
$path = drupal_get_path_alias($_GET['q']);
if ($exclude) {
$regexp = '/^(' . preg_replace(array(
'/(\\r\\n?|\\n)/',
'/\\\\\\*/',
'/(^|\\|)\\\\<front\\\\>($|\\|)/',
), array(
'|',
'.*',
'\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
), preg_quote($exclude, '/')) . ')$/';
$page_match = preg_match($regexp, $path);
if ($path != $_GET['q']) {
$page_match = $page_match || preg_match($regexp, $_GET['q']);
}
if ($page_match) {
return 0;
}
}
$regexp = '/^(' . preg_replace(array(
'/(\\r\\n?|\\n)/',
'/\\\\\\*/',
'/(^|\\|)\\\\<front\\\\>($|\\|)/',
), array(
'|',
'.*',
'\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
), preg_quote($pages, '/')) . ')$/';
// Compare with the internal and path alias (if any).
$page_match = preg_match($regexp, $path);
if ($path != $_GET['q']) {
$page_match = $page_match || preg_match($regexp, $_GET['q']);
}
return $page_match == 1;
}
}
}