function _node_types($op = '', $node = NULL, $reset = FALSE) { static $node_types = array(), $node_labels = array(); $field_exists = module_exist('field'); if ($reset || empty($node_types)) { if ($field_exists && ($cached = cache_get('node_types'))) { $node_types = unserialize($cached->data); $cached = cache_get('node_labels'); $node_labels = unserialize($cached->data); } else { $node_types = array(); $type_result = db_query('SELECT * FROM {node_type} nt ORDER BY nt.name ASC'); while ($type_object = db_fetch_object($type_result)) { $type_object->fields = module_invoke('field', 'load_type', $type_object->name); $node_types[$type->name] = $type_object; $node_labels[$type->name] = $type_object->label; } if ($field_exists) { cache_set('node_types', serialize($node_types), CACHE_PERMANENT); cache_set('node_labels', serialize($node_labels), CACHE_PERMANENT); } } } 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[$node]; case 'base': return $node_types[$type]->base; case 'list': return $node_labels; case 'label': return $node_labels[$type]; } }