Same name and namespace in other branches
  1. 5.x modules/node/node.module \_node_types_build()
  2. 7.x modules/node/node.module \_node_types_build()

Builds and returns the list of available node types.

The list of types is built by querying hook_node_info() in all modules, and by comparing this information with the node types in the {node_type} table.

2 calls to _node_types_build()
node_get_types in modules/node/node.module
Builds a list of available node types, and returns all or part of this list.
node_types_rebuild in modules/node/node.module
Resets the database cache of node types, and saves all new or non-modified module-defined node types to the database.

File

modules/node/node.module, line 553
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_types_build() {
  $_node_types = array();
  $_node_names = array();
  $info_array = module_invoke_all('node_info');
  foreach ($info_array as $type => $info) {
    $info['type'] = $type;
    $_node_types[$type] = (object) _node_type_set_defaults($info);
    $_node_names[$type] = $info['name'];
  }
  $type_result = db_query(db_rewrite_sql('SELECT nt.type, nt.* FROM {node_type} nt ORDER BY nt.type ASC', 'nt', 'type'));
  while ($type_object = db_fetch_object($type_result)) {

    // Check for node types from disabled modules and mark their types for removal.
    // Types defined by the node module in the database (rather than by a separate
    // module using hook_node_info) have a module value of 'node'.
    if ($type_object->module != 'node' && empty($info_array[$type_object->type])) {
      $type_object->disabled = TRUE;
    }
    if (!isset($_node_types[$type_object->type]) || $type_object->modified) {
      $_node_types[$type_object->type] = $type_object;
      $_node_names[$type_object->type] = $type_object->name;
      if ($type_object->type != $type_object->orig_type) {
        unset($_node_types[$type_object->orig_type]);
        unset($_node_names[$type_object->orig_type]);
      }
    }
  }
  asort($_node_names);
  return array(
    $_node_types,
    $_node_names,
  );
}