You are here

function entityconnect_entityconnect_add_info in Entity connect 7.2

Same name and namespace in other branches
  1. 8.2 entityconnect.module \entityconnect_entityconnect_add_info()

Implements hook_entityconnect_add_info().

File

includes/entityconnect.menu.inc, line 94
Handles all entityconnect menu item page callbacks.

Code

function entityconnect_entityconnect_add_info($cache_id, $entity_type, $acceptable_types) {
  if (!isset($entity_type)) {
    throw new \Exception(t('Entity type can not be empty'));
  }
  switch ($entity_type) {
    case 'node':
      if (count($acceptable_types) > 0) {
        foreach (node_type_get_types() as $key => $item) {
          if (isset($acceptable_types[$key]) && $acceptable_types[$key]) {
            $type = str_replace("_", '-', $key);
            $content[$key] = array(
              'href' => "node/add/{$type}/{$cache_id}",
              'label' => $item->name,
              'description' => $item->description,
            );
          }
        }
      }
      else {
        foreach (node_type_get_types() as $key => $item) {
          $type = str_replace("_", '-', $key);
          $content[$key] = array(
            'href' => "node/add/{$type}/{$cache_id}",
            'label' => $item->name,
            'description' => $item->description,
          );
        }
      }
      break;
    case 'user':
      $content[$entity_type]['href'] = "admin/people/create/{$cache_id}";
      break;
    case 'taxonomy_term':
      if (count($acceptable_types) > 0) {
        foreach (taxonomy_get_vocabularies() as $key => $item) {
          $type = $item->machine_name;
          if (isset($acceptable_types[$type]) && $acceptable_types[$type]) {
            $item->href = "admin/structure/taxonomy/{$type}/add/{$cache_id}";
            $content[$key] = $item;
          }
        }
      }
      else {
        foreach (taxonomy_get_vocabularies() as $key => $item) {
          !isset($item->href) ? $item->href = NULL : $item->href;
          $type = $item->machine_name;
          $item->href = "admin/structure/taxonomy/{$type}/add/{$cache_id}";
          $content[$key] = $item;
        }
      }
      $theme_callback = 'entityconnect_taxonomy_term_add_list';
      break;
    case 'taxonomy_vocabulary':
      $content[$entity_type]['href'] = "admin/structure/taxonomy/add/{$cache_id}";
      break;
    default:
      break;
  }
  if (isset($content)) {
    if (isset($theme_callback)) {
      return array(
        'content' => $content,
        'theme_callback' => $theme_callback,
      );
    }
    else {
      return array(
        'content' => $content,
      );
    }
  }
}