You are here

function _me_create_menu_items in me aliases 5

Helper function to create our menu items.

1 call to _me_create_menu_items()
me_menu in ./me.module
Implementation of hook_menu().

File

./me.module, line 35

Code

function _me_create_menu_items($may_cache) {
  $items = array();
  $aliases = explode("\n", variable_get('me_aliases', 'user/me'));
  foreach ($aliases as $alias) {

    // check to see if there's a 'me' to replace;
    // either '.../me/...', 'me/...' or '.../me' but eg 'readme/...' does not count
    $alias = preg_split('/[\\?\\#]/', $alias);
    $alias = trim(check_url($alias[0]), "/ \t\n\r\0");
    $path = drupal_get_normal_path($_GET['q']);
    if (preg_match('/(\\/m|^m)(e$|e\\/)/', $alias, $matches) > 0 && ($may_cache || 0 === strpos($path, $alias))) {
      $items[] = array(
        'path' => $may_cache ? $alias : $path,
        'type' => MENU_CALLBACK,
        'callback' => 'me_relay',
        'access' => true,
      );
      if (!$may_cache) {
        break;
      }
    }
  }
  return $items;
}