node_get_types
Definition
node_get_types($op = 'types', $node = NULL, $reset = FALSE)
modules/node/node.module, line 266
Description
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.
Code
<?php
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];
}
}
?> 