You are here

function themekey_redirect_match_rules in ThemeKey 7.3

1 call to themekey_redirect_match_rules()
themekey_redirect_callback in themekey_redirect/themekey_redirect.module

File

themekey_redirect/themekey_redirect.module, line 173
Define rules to redirect the user to a different domain. The common use-case is to setup sub-domains for mobile sites. In this case you can configure ThemeKey Redirect to detect mobile clients and redirect the user accordingly. In ThemeKey itself you…

Code

function themekey_redirect_match_rules() {
  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'themekey') . '/themekey_base.inc';
  $parameters = themekey_get_global_parameters();
  $result = themekey_match_rule_childs($parameters, array(
    'table' => 'themekey_redirect_rules',
    'format_rule_as_string_callback' => 'themekey_redirect_format_rule_as_string',
    'check_enabled_callback' => 'themekey_redirect_check_different_url',
    'stop_on_check_enabled_false' => TRUE,
  ));
  if (is_array($result) && 'default' != $result['theme']) {
    drupal_alter('themekey_redirect', $result['theme'], $result['rules_matched']);
    $last_rule = array_pop($result['rules_matched']);
    $query_string = themekey_query_string();
    return url($result['theme'] . ($last_rule->append_path ? variable_get('themekey_redirect_compatible_path', FALSE) ? '/index.php?q=' . $_GET['q'] . ($query_string ? '&' . $query_string : '') : request_uri() : ''), array(
      'query' => array(
        'themekey_redirect' => 'active',
      ),
    ));
  }
  return FALSE;
}