You are here

function context_links in Context 6.2

Same name and namespace in other branches
  1. 6.3 context.core.inc \context_links()
  2. 6 context.core.inc \context_links()
  3. 7.3 context.core.inc \context_links()

Generates an array of links (suitable for use with theme_links) to the node forms of types associated with current active contexts.

1 call to context_links()
context_preprocess_page in ./context.core.inc
Implementation of preprocess_page().

File

./context.core.inc, line 656

Code

function context_links($reset = FALSE) {
  static $links;
  if (!$links || $reset) {
    $links = array();
    $active_types = context_active_values('node');
    if (!empty($active_types)) {

      // Collect types
      $types = node_get_types();

      // Iterate over active contexts
      foreach ($active_types as $type) {
        $add_url = 'node/add/' . str_replace('_', '-', $type);
        $item = menu_get_item($add_url);
        if ($item && $item['access'] && strpos($_GET['q'], $add_url) !== 0) {
          $links[$type] = array(
            'title' => $types[$type]->name,
            'href' => $add_url,
          );
        }
      }
    }
    drupal_alter('context_links', $links);
  }
  return $links;
}