| 7 node.install | _update_7000_node_get_types() |
| 8 node.install | _update_7000_node_get_types() |
Utility function: fetch the node types directly from the database.
This function is valid for a database schema version 7000.
Related topics
10 calls to _update_7000_node_get_types()
File
- modules/
node/ node.install, line 479 - Install, update and uninstall functions for the node module.
Code
function _update_7000_node_get_types() {
$node_types = db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ);
// Create default settings for orphan nodes.
$all_types = db_query('SELECT DISTINCT type FROM {node}')->fetchCol();
$extra_types = array_diff($all_types, array_keys($node_types));
foreach ($extra_types as $type) {
$type_object = new stdClass();
$type_object->type = $type;
// In Drupal 6, whether you have a body field or not is a flag in the node
// type table. If it's enabled, nodes may or may not have an empty string
// for the bodies. As we can't detect what this setting should be in
// Drupal 7 without access to the Drupal 6 node type settings, we assume
// the default, which is to enable the body field.
$type_object->has_body = 1;
$type_object->body_label = 'Body';
$node_types[$type_object->type] = $type_object;
}
return $node_types;
}
Login or register to post comments