function _select2_current_path_is_admin in Select 2 7
Determines whether a current path is in the administrative section of the site.
By default, paths are considered to be non-administrative. If a path does not match any of the patterns in path_get_admin_paths(), or if it matches both administrative and non-administrative patterns, it is considered non-administrative.
Return value
TRUE if the path is administrative, FALSE otherwise.
See also
2 calls to _select2_current_path_is_admin()
- select2_preprocess_page in ./
select2.module - Implements hook_preprocess_page().
- select2_select_element_process in ./
select2.module - Select element process.
File
- ./
select2.module, line 1335 - Main file for Select2 module.
Code
function _select2_current_path_is_admin() {
$result =& drupal_static(__FUNCTION__, NULL);
if ($result !== NULL) {
return $result;
}
if (path_is_admin(current_path())) {
$result = TRUE;
return TRUE;
}
// AJAX check
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && !empty($_SERVER['HTTP_REFERER'])) {
// Need to check request refferer url for admin path
$referrer_url = $_SERVER['HTTP_REFERER'];
$site_url_prefix = url(NULL, array(
'absolute' => TRUE,
)) . (variable_get('clean_url', 0) ? '' : '?q=');
$prefix_pos = strpos($referrer_url, $site_url_prefix);
if ($prefix_pos === FALSE || $prefix_pos > 0) {
$result = FALSE;
return FALSE;
}
$referrer_url_path = str_replace($site_url_prefix, '', $referrer_url);
if (path_is_admin($referrer_url_path)) {
$result = TRUE;
return TRUE;
}
}
$result = FALSE;
return FALSE;
}