function i18n_select_page in Internationalization 7
Check current path to enable selection.
This works pretty much like block visibility.
Return value
bool TRUE if content selection should be enabled for this page.
1 call to i18n_select_page()
- i18n_select_init in i18n_select/
i18n_select.module - Implements hook_init().
File
- i18n_select/
i18n_select.module, line 92 - Multilingual content selection module.
Code
function i18n_select_page() {
static $mode;
if (!isset($mode)) {
$mode =& drupal_static(__FUNCTION__);
$visibility = variable_get('i18n_select_page_mode', I18N_SELECT_PAGE_NOTLISTED);
if ($pages = variable_get('i18n_select_page_list', 'admin/*')) {
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = drupal_strtolower($pages);
if ($visibility < I18N_SELECT_PAGE_PHP) {
// @see views_ajax()
// @see I18NSelectAdminViewsAjax::testViewsAjaxWithoutSkippingTags()
$path = isset($_REQUEST['view_path']) ? $_REQUEST['view_path'] : $_GET['q'];
// Convert the Drupal path to lowercase.
$path = drupal_strtolower(drupal_get_path_alias($path));
// Compare the lowercase internal and lowercase path alias (if any).
$page_match = drupal_match_path($path, $pages);
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], $pages);
}
// When $visibility has a value of 0 (I18N_SELECT_PAGE_NOTLISTED),
// the block is displayed on all pages except those listed in $pages.
// When set to 1 (I18N_SELECT_PAGE_LISTED), it is displayed only on
// those pages listed in $pages.
$mode = !($visibility xor $page_match);
}
elseif (module_exists('php')) {
$mode = php_eval($pages);
}
else {
$mode = FALSE;
}
}
else {
// No pages defined, still respect the setting (unlike blocks).
$mode = $visibility == I18N_SELECT_PAGE_NOTLISTED;
}
}
return $mode;
}