Commit 2895357d authored by Dries's avatar Dries

- Modified patch #25031 by chx: modified node_list() so one has both the module and its type.

  TODO: update migration page in handbook.
parent 28c72cd8
......@@ -535,7 +535,7 @@ function blogapi_blogger_title(&$contents) {
function blogapi_settings() {
$output = form_select(t('XML-RPC Engine'), 'blogapi_engine', variable_get('blogapi_engine', 0), array(0 => 'Blogger', 1 => 'MetaWeblog', 2 => 'Movabletype'), t('RSD or Really-Simple-Discovery is a mechanism which allows external blogger tools to discover the APIs they can use to interact with Drupal. Here you can set the preferred method for blogger tools to interact with your site. The common XML-RPC engines are Blogger, MetaWeblog and Movabletype. If you are not sure which is the correct setting, choose Blogger.'));
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
$node_types[$type] = node_invoke($type, 'node_name');
if (in_array($type, array('blog'))) {
$defaults[] = $type;
......@@ -707,7 +707,7 @@ function _blogapi_blogid($id) {
function _blogapi_get_node_types() {
$available_types = variable_get('blogapi_node_types', array('blog'));
$types = array();
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
if (node_access('create', $type) && in_array($type, $available_types)) {
$types[] = $type;
}
......
......@@ -535,7 +535,7 @@ function blogapi_blogger_title(&$contents) {
function blogapi_settings() {
$output = form_select(t('XML-RPC Engine'), 'blogapi_engine', variable_get('blogapi_engine', 0), array(0 => 'Blogger', 1 => 'MetaWeblog', 2 => 'Movabletype'), t('RSD or Really-Simple-Discovery is a mechanism which allows external blogger tools to discover the APIs they can use to interact with Drupal. Here you can set the preferred method for blogger tools to interact with your site. The common XML-RPC engines are Blogger, MetaWeblog and Movabletype. If you are not sure which is the correct setting, choose Blogger.'));
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
$node_types[$type] = node_invoke($type, 'node_name');
if (in_array($type, array('blog'))) {
$defaults[] = $type;
......@@ -707,7 +707,7 @@ function _blogapi_blogid($id) {
function _blogapi_get_node_types() {
$available_types = variable_get('blogapi_node_types', array('blog'));
$types = array();
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
if (node_access('create', $type) && in_array($type, $available_types)) {
$types[] = $type;
}
......
......@@ -32,7 +32,7 @@ function node_help($section) {
<dt>Published</dt><dd>When using Drupal's moderation system a node remains unpublished -- unavailable to non-moderators -- until it is marked Published.</dd></dl>
<p>Now that you know what is in a node, here are some of the types of nodes available.</p>", array("%teaser" => url("admin/node/configure/settings")));
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
$output .= '<h3>'. t('Node type: %module', array('%module' => node_invoke($type, 'node_name'))). '</h3>';
$output .= implode("\n", module_invoke_all('help', 'node/add#'. $type));
}
......@@ -212,49 +212,41 @@ function node_teaser($body, $format = NULL) {
*/
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'];
}
$type = $node['type'];
}
else if (is_object($node)) {
if ($pos = strpos($node->type, '-')) {
return substr($node->type, 0, $pos);
}
else {
return $node->type;
}
$type = $node->type;
}
else if (is_string($node)) {
if ($pos = strpos($node, '-')) {
return substr($node, 0, $pos);
}
else {
return $node;
}
$type = $node;
}
$modules = node_list();
return $modules[$type];
}
/**
* Get a list of all the defined node types.
*
* @return
* A list of all node types.
* An associate array of consisting of (node type, modulename) pairs for all node types.
*/
function node_list() {
$types = array();
foreach (module_list() as $module) {
if (module_hook($module, 'node_name')) {
$module_types = module_invoke($module, 'node_types');
if (is_array($module_types)) {
foreach ($module_types as $type) {
$types[] = $type;
static $types = array();
if (empty($types)) {
foreach (module_list() as $module) {
if (module_hook($module, 'node_name')) {
$module_types = module_invoke($module, 'node_types');
if (is_array($module_types)) {
foreach ($module_types as $type) {
$types[$type] = $module;
}
}
else {
$types[$module] = $module;
}
}
else {
$types[] = $module;
}
}
}
......@@ -781,7 +773,7 @@ function node_admin_nodes() {
/*
** Filters
*/
$node_types = drupal_map_assoc(node_list());
$node_types = drupal_map_assoc(array_keys(node_list()));
foreach ($node_types as $k => $v) {
$node_types[$k] = node_invoke($v, 'node_name');
}
......@@ -955,7 +947,7 @@ function node_types_configure($type = NULL) {
$header = array(t('Type'), t('Operations'));
$rows = array();
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
$rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/settings/content-types/'. $type));
}
......@@ -1388,7 +1380,7 @@ function node_add($type) {
$edit = $_POST['edit'];
// If a node type has been specified, validate its existence.
if (in_array($type, node_list()) && node_access('create', $type)) {
if (array_key_exists($type, node_list()) && node_access('create', $type)) {
// Initialize settings:
$node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);
......@@ -1404,7 +1396,7 @@ function node_add($type) {
}
else {
// If no (valid) node type has been provided, display a node type overview.
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
if (node_access('create', $type)) {
$out = '<dt>'. l(node_invoke($type, 'node_name'), "node/add/$type", array('title' => t('Add a new %s.', array('%s' => node_invoke($type, 'node_name'))))) .'</dt>';
$out .= '<dd>'. implode("\n", module_invoke_all('help', 'node/add#'. $type)) .'</dd>';
......@@ -1984,4 +1976,4 @@ function node_db_rewrite_sql($query, $primary_table, $primary_field) {
* @} End of "defgroup node_access".
*/
?>
\ No newline at end of file
?>
......@@ -32,7 +32,7 @@ function node_help($section) {
<dt>Published</dt><dd>When using Drupal's moderation system a node remains unpublished -- unavailable to non-moderators -- until it is marked Published.</dd></dl>
<p>Now that you know what is in a node, here are some of the types of nodes available.</p>", array("%teaser" => url("admin/node/configure/settings")));
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
$output .= '<h3>'. t('Node type: %module', array('%module' => node_invoke($type, 'node_name'))). '</h3>';
$output .= implode("\n", module_invoke_all('help', 'node/add#'. $type));
}
......@@ -212,49 +212,41 @@ function node_teaser($body, $format = NULL) {
*/
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'];
}
$type = $node['type'];
}
else if (is_object($node)) {
if ($pos = strpos($node->type, '-')) {
return substr($node->type, 0, $pos);
}
else {
return $node->type;
}
$type = $node->type;
}
else if (is_string($node)) {
if ($pos = strpos($node, '-')) {
return substr($node, 0, $pos);
}
else {
return $node;
}
$type = $node;
}
$modules = node_list();
return $modules[$type];
}
/**
* Get a list of all the defined node types.
*
* @return
* A list of all node types.
* An associate array of consisting of (node type, modulename) pairs for all node types.
*/
function node_list() {
$types = array();
foreach (module_list() as $module) {
if (module_hook($module, 'node_name')) {
$module_types = module_invoke($module, 'node_types');
if (is_array($module_types)) {
foreach ($module_types as $type) {
$types[] = $type;
static $types = array();
if (empty($types)) {
foreach (module_list() as $module) {
if (module_hook($module, 'node_name')) {
$module_types = module_invoke($module, 'node_types');
if (is_array($module_types)) {
foreach ($module_types as $type) {
$types[$type] = $module;
}
}
else {
$types[$module] = $module;
}
}
else {
$types[] = $module;
}
}
}
......@@ -781,7 +773,7 @@ function node_admin_nodes() {
/*
** Filters
*/
$node_types = drupal_map_assoc(node_list());
$node_types = drupal_map_assoc(array_keys(node_list()));
foreach ($node_types as $k => $v) {
$node_types[$k] = node_invoke($v, 'node_name');
}
......@@ -955,7 +947,7 @@ function node_types_configure($type = NULL) {
$header = array(t('Type'), t('Operations'));
$rows = array();
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
$rows[] = array(node_invoke($type, 'node_name'), l(t('configure'), 'admin/settings/content-types/'. $type));
}
......@@ -1388,7 +1380,7 @@ function node_add($type) {
$edit = $_POST['edit'];
// If a node type has been specified, validate its existence.
if (in_array($type, node_list()) && node_access('create', $type)) {
if (array_key_exists($type, node_list()) && node_access('create', $type)) {
// Initialize settings:
$node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);
......@@ -1404,7 +1396,7 @@ function node_add($type) {
}
else {
// If no (valid) node type has been provided, display a node type overview.
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
if (node_access('create', $type)) {
$out = '<dt>'. l(node_invoke($type, 'node_name'), "node/add/$type", array('title' => t('Add a new %s.', array('%s' => node_invoke($type, 'node_name'))))) .'</dt>';
$out .= '<dd>'. implode("\n", module_invoke_all('help', 'node/add#'. $type)) .'</dd>';
......@@ -1984,4 +1976,4 @@ function node_db_rewrite_sql($query, $primary_table, $primary_field) {
* @} End of "defgroup node_access".
*/
?>
\ No newline at end of file
?>
......@@ -716,7 +716,7 @@ function system_theme_settings($key = '') {
$node_list = module_invoke('node', 'list');
if ($node_list) {
$group = '';
foreach (node_list() as $type) {
foreach ($node_list as $type => $module) {
$group .= form_checkbox(node_invoke($type, 'node_name'), "$var][toggle_node_info_$type", 1, $settings["toggle_node_info_$type"]);
}
$form .= form_group(t('Display post information on'), $group, t('Enable or disable the "submitted by Username on date" text when displaying posts of the above type'));
......
......@@ -716,7 +716,7 @@ function system_theme_settings($key = '') {
$node_list = module_invoke('node', 'list');
if ($node_list) {
$group = '';
foreach (node_list() as $type) {
foreach ($node_list as $type => $module) {
$group .= form_checkbox(node_invoke($type, 'node_name'), "$var][toggle_node_info_$type", 1, $settings["toggle_node_info_$type"]);
}
$form .= form_group(t('Display post information on'), $group, t('Enable or disable the "submitted by Username on date" text when displaying posts of the above type'));
......
......@@ -109,7 +109,7 @@ function taxonomy_menu($may_cache) {
}
function taxonomy_form_vocabulary($edit = array()) {
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
$node_type = node_invoke($type, 'node_name');
$nodes[$type] = $node_type ? $node_type : $type;
}
......
......@@ -109,7 +109,7 @@ function taxonomy_menu($may_cache) {
}
function taxonomy_form_vocabulary($edit = array()) {
foreach (node_list() as $type) {
foreach (node_list() as $type => $module) {
$node_type = node_invoke($type, 'node_name');
$nodes[$type] = $node_type ? $node_type : $type;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment