node_get_types
- Versions
- 4.7
node_get_types()- 5 – 6
node_get_types($op = 'types', $node = NULL, $reset = FALSE)
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. Returns FALSE if the node type is not found.
Code
modules/node/node.module, line 412
<?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 isset($_node_types[$type]) ? $_node_types[$type] : FALSE;
case 'module':
return isset($_node_types[$type]->module) ? $_node_types[$type]->module : FALSE;
case 'names':
return $_node_names;
case 'name':
return isset($_node_names[$type]) ? $_node_names[$type] : FALSE;
}
}
?>Login or register to post comments 