You are here

function rb_misc_action_get_url_alias in Rules Bonus Pack 6

The 'rb_misc_action_get_url_alias' action.

File

./rb_misc.module, line 391
Miscellaneous conditions and actions for Rules.

Code

function rb_misc_action_get_url_alias($settings) {
  $alias = url($settings['path']);

  // Trim any starting base path in the alias.
  global $base_path;
  if (strpos($alias, $base_path) === 0) {
    $alias = substr($alias, strlen($base_path));
  }

  // Trim any starting '/' in the alias.
  if (strpos($alias, '/') === 0) {
    $alias = substr($alias, 1);
  }

  // URL aliases are URL encoded, so we decode it before returning it. (If we
  // use it as a new URL alias it would be URL encoded anyway. No worries.)
  return array(
    'alias' => urldecode($alias),
  );
}