drupal_match_path

Versions
6 – 7
drupal_match_path($path, $patterns)

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

Parameters

$path The path to match.

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

Return value

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

▾ 2 functions call drupal_match_path()

block_block_info_alter in modules/block/block.module
Implements hook_block_info_alter().
path_is_admin in includes/path.inc
Determine whether a path is in the administrative section of the site.

Code

includes/path.inc, line 354

<?php
function drupal_match_path($path, $patterns) {
  $regexps = &drupal_static(__FUNCTION__);

  if (!isset($regexps[$patterns])) {
    $regexps[$patterns] = '/^(' . preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2'), preg_quote($patterns, '/')) . ')$/';
  }
  return (bool)preg_match($regexps[$patterns], $path);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.