function siteimprove_init in Siteimprove 7
Implements hook_init().
File
- ./
siteimprove.module, line 114 - Drupal Module: Siteimprove Plugin.
Code
function siteimprove_init() {
// Check if user has access and ignore some paths.
if (user_access(SITEIMPROVE_PERMISSION_USE) && (empty($_SERVER['REDIRECT_QUERY_STRING']) || $_SERVER['REDIRECT_QUERY_STRING'] != 'render=overlay' || path_is_admin(current_path())) && current_path() != 'batch') {
// If exist siteimprove_url in SESSION, send to Siteimprove.
if (!empty($_SESSION['siteimprove_url'])) {
if (count($_SESSION['siteimprove_url']) > 1) {
$url = url('<front>', array(
'absolute' => TRUE,
));
$method = 'recrawl';
}
else {
$url = array_pop($_SESSION['siteimprove_url']);
$method = 'recheck';
}
// Include all Siteimprove js scripts.
SiteimproveUtils::includeJs($url, $method);
unset($_SESSION['siteimprove_url']);
}
// Find the "siteimprove" path of the current page.
$siteimprove_path = siteimprove_is_frontpage() ? '<front>' : current_path();
// If node page or taxonomy term page, add input method, else domain method.
if (preg_match('/(^node\\/\\d*$)|(^taxonomy\\/term\\/\\d*$)/', current_path())) {
SiteimproveUtils::includeJs(url($siteimprove_path, array(
'absolute' => TRUE,
)), 'input');
}
elseif (preg_match('/(^node\\/\\d*(\\/edit)?$)|(^taxonomy\\/term\\/\\d*(\\/edit)?$)/', current_path())) {
SiteimproveUtils::includeJs(url($siteimprove_path, array(
'absolute' => TRUE,
)), 'input');
SiteimproveUtils::includeJs(url($siteimprove_path, array(
'absolute' => TRUE,
)), 'recheck', FALSE);
}
else {
SiteimproveUtils::includeJs(url($siteimprove_path, array(
'absolute' => TRUE,
)), 'domain');
}
}
}