Esempio n. 1
0
function _rootcandy_besturlmatch($needle, $menuitems)
{
    $lastmatch = null;
    $lastmatchlen = 0;
    $urlparts = explode('/', $needle);
    $partcount = count($urlparts);
    foreach ($menuitems as $key => $menuitem) {
        $href = $menuitem['href'];
        $menuurlparts = explode('/', $href);
        $matches = _rootcandy_countmatches($urlparts, $menuurlparts);
        if ($matches > $lastmatchlen || $matches == $lastmatchlen && ($lastmatch && strlen($menuitems[$lastmatch]['href'])) > strlen($href)) {
            $lastmatchlen = $matches;
            $lastmatch = $key;
        }
    }
    return $lastmatch;
}
Esempio n. 2
0
function _rootcandy_besturlmatch($needle, $menuitems) {
  $needle = drupal_get_path_alias($needle);
  $lastmatch = NULL;
  $lastmatchlen = 0;
  $urlparts = explode('/', $needle);
  $partcount = count($urlparts);

  foreach ($menuitems as $key => $menuitem) {
    $href = $menuitem['href'];
    $menuurlparts = explode('/', $href);
    $matches = _rootcandy_countmatches($urlparts, $menuurlparts);
    if (($matches > $lastmatchlen) || (($matches == $lastmatchlen) && (($lastmatch && drupal_strlen($menuitems[$lastmatch]['href'])) > drupal_strlen($href)) )) {
      $lastmatchlen = $matches;
      $lastmatch = $key;
    }
  }
  return $lastmatch;
}