node_type_set_defaults

Versions
7
node_type_set_defaults($info = array())

Set the default values for a node type.

The defaults are for a type defined through hook_node_info(). When populating a custom node type $info should have the 'custom' key set to 1.

Parameters

$info An object or array containing values to override the defaults.

Return value

A node type object.

▾ 7 functions call node_type_set_defaults()

default_install in profiles/default/default.install
Implement hook_install().
node_type_form in modules/node/content_types.inc
Generates the node type editing form.
node_type_form_submit in modules/node/content_types.inc
Implement hook_form_submit().
node_type_reset in modules/node/content_types.inc
Resets all of the relevant fields of a module-defined node type to their default values.
node_type_save in modules/node/node.module
Saves a node type to the database.
_book_install_type_create in modules/book/book.install
_node_types_build in modules/node/node.module
Builds and returns the list of available node types.

Code

modules/node/node.module, line 745

<?php
function node_type_set_defaults($info = array()) {
  static $type;

  if (!isset($type)) {
    $type = new stdClass();
    $type->type = '';
    $type->name = '';
    $type->base = '';
    $type->description = '';
    $type->help = '';
    $type->has_title = 1;
    $type->has_body = 1;
    $type->title_label = t('Title');
    $type->body_label = t('Body');
    $type->custom = 0;
    $type->modified = 0;
    $type->locked = 1;
    $type->is_new = 1;
  }

  $new_type = clone $type;
  $info = (array) $info;
  foreach ($info as $key => $data) {
    $new_type->$key = $data;
  }
  // If the type has no title or body, set an empty label.
  if (!$new_type->has_title) {
    $new_type->title_label = '';
  }
  if (!$new_type->has_body) {
    $new_type->body_label = '';
  }
  $new_type->orig_type = isset($info['type']) ? $info['type'] : '';

  return $new_type;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.