You are here

function _admin_language_match_path in Administration Language 7

Check if a path matches any pattern in a set of patterns.

This is a clone of drupal_match_path(), this is necessary because the function isn't available at the bootstrap level where the language switch is done.

Parameters

string $path: The path to match.

string $patterns: String containing a set of patterns separated by \n, \r or \r\n.

Return value

bool Boolean value: TRUE if the path matches a pattern, FALSE otherwise.

See also

drupal_match_path()

2 calls to _admin_language_match_path()
hook_admin_language_switch_alter in ./admin_language.api.php
Alters the decision of admin language switch to change language.
_admin_language_switch_language in ./admin_language.module
Determine whether the language needs to be switched on the current path.

File

./admin_language.module, line 910
Makes admin pages be displayed in the administrator's preferred language.

Code

function _admin_language_match_path($path, $patterns) {
  $regexps =& drupal_static(__FUNCTION__);
  if (!isset($regexps[$patterns])) {

    // Convert path settings to a regular expression. Therefore replace newlines
    // with a logical or, /* with asterisks and the <front> with the frontpage.
    $to_replace = array(
      // Newlines.
      '/(\\r\\n?|\\n)/',
      // Asterisks.
      '/\\\\\\*/',
      // <front>.
      '/(^|\\|)\\\\<front\\\\>($|\\|)/',
    );
    $replacements = array(
      '|',
      '.*',
      '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
    );
    $patterns_quoted = preg_quote($patterns, '/');
    $regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
  }
  return (bool) preg_match($regexps[$patterns], $path);
}