You are here

function context_links in Context 6

Same name and namespace in other branches
  1. 6.3 context.core.inc \context_links()
  2. 6.2 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 478

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) {
        $type_url = str_replace('_', '-', $type);
        $add_url = 'node/add/' . $type_url;
        if (isset($types[$type]) && strpos($_GET['q'], $add_url) === FALSE && node_access('create', $type)) {
          $links[$type_url] = array(
            'title' => $types[$type]->name,
            'href' => $add_url,
          );
        }
      }
    }
    drupal_alter('context_links', $links);
  }
  return $links;
}