You are here

function node_get_types in Drupal 5

Same name and namespace in other branches
  1. 4 modules/node.module \node_get_types()
  2. 6 modules/node/node.module \node_get_types()

Builds a list of available node types, and returns all of part of this list in the specified format.

Parameters

$op: The format in which to return the list. When this is set to 'type', 'module', or 'name', only the specified node type is returned. When set to 'types' or 'names', all node types are returned.

$node: A node object, array, or string that indicates the node type to return. Leave at default value (NULL) to return a list of all node types.

$reset: Whether or not to reset this function's internal cache (defaults to FALSE).

Return value

Either an array of all available node types, or a single node type, in a variable format.

34 calls to node_get_types()
blogapi_admin_settings in modules/blogapi/blogapi.module
blog_form in modules/blog/blog.module
Implementation of hook_form().
book_form in modules/book/book.module
Implementation of hook_form().
book_help in modules/book/book.module
Implementation of hook_help().
forum_form in modules/forum/forum.module
Implementation of hook_form().

... See full list

File

modules/node/node.module, line 266
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

function node_get_types($op = 'types', $node = NULL, $reset = FALSE) {
  static $_node_types, $_node_names;
  if ($reset || !isset($_node_types)) {
    list($_node_types, $_node_names) = _node_types_build();
  }
  if ($node) {
    if (is_array($node)) {
      $type = $node['type'];
    }
    elseif (is_object($node)) {
      $type = $node->type;
    }
    elseif (is_string($node)) {
      $type = $node;
    }
    if (!isset($_node_types[$type])) {
      return FALSE;
    }
  }
  switch ($op) {
    case 'types':
      return $_node_types;
    case 'type':
      return $_node_types[$type];
    case 'module':
      return $_node_types[$type]->module;
    case 'names':
      return $_node_names;
    case 'name':
      return $_node_names[$type];
  }
}