You are here

function context_prefix_unprefix in Context 5

Removes any prefixes from a query string. For path prefixes only.

1 call to context_prefix_unprefix()
_context_prefix_init in context_prefix/context_prefix.module
Helper function to initialize, parse + set prefixed contexts.

File

context_prefix/context_prefix.module, line 269

Code

function context_prefix_unprefix($q, $method, $providers = array()) {
  $parsed = context_prefix_parse($method, $q);
  if (is_array($providers) && count($providers)) {
    foreach ($parsed as $prefix => $info) {
      if (!in_array($info['provider'], $providers)) {
        unset($parsed[$prefix]);
      }
    }
  }
  $parsed = array_keys($parsed);
  $args = explode('/', $q);
  switch ($method) {
    case CONTEXT_PREFIX_PATH:
      $args = array_diff($args, $parsed);
      break;
    case CONTEXT_PREFIX_PAIR:
      foreach ($parsed as $v) {
        array_splice($args, array_search($v, $args), 2);
      }
      break;
  }
  return implode('/', $args);
}