node_get_module_name

Versions
4.6
node_get_module_name($node)

Determine the module that defines the node type of the given node.

Parameters

&$node Either a node object, a node array, or a string containing the node type.

Return value

A string containing the name of the defining module.

▾ 4 functions call node_get_module_name()

node_access in modules/node.module
Determine whether the current user may perform the given operation on the specified node.
node_form in modules/node.module
Generate the node editing form.
node_hook in modules/node.module
Determine whether a node hook exists.
node_invoke in modules/node.module
Invoke a node hook.

Code

modules/node.module, line 213

<?php
function node_get_module_name($node) {
  if (is_array($node)) {
    if ($pos = strpos($node['type'], '-')) {
      return substr($node['type'], 0, $pos);
    }
    else {
      return $node['type'];
    }
  }
  else if (is_object($node)) {
    if ($pos = strpos($node->type, '-')) {
      return substr($node->type, 0, $pos);
    }
    else {
      return $node->type;
    }
  }
  else if (is_string($node)) {
    if ($pos = strpos($node, '-')) {
      return substr($node, 0, $pos);
    }
    else {
      return $node;
    }
  }
}
?>
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.