You are here

function _context_ui_node_links in Context 5

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_ui_node_links()
theme_context_ui_node_links in context_ui/context_ui.module
Generates a themed set of links for node types associated with the current active contexts.

File

context_ui/context_ui.module, line 944

Code

function _context_ui_node_links($resest = false) {
  static $links;
  if (!$links || $reset) {
    $links = array();
    if ($cids = context_get('context_ui', 'cid')) {

      // Collect types
      $types = node_get_types();

      // Iterate over active contexts
      foreach ($cids as $cid) {
        $context = context_ui_context('load', $cid);
        if (is_array($context->node)) {
          foreach ($context->node as $type) {
            if (isset($types[$type]) && node_access('create', $type)) {
              $links[$type] = array(
                'title' => $types[$type]->name,
                'href' => 'node/add/' . $type,
              );
            }
          }
        }
      }
    }
  }
  return $links;
}