From c9fc300b1f8fcb00de78aca77bc85d79f4bab5b1 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 28 Aug 2005 15:29:34 +0000 Subject: - Patch #29785 by Chx: multiple node types were broken so we refactored part of the node system! If you have a module that implements node types, you'll have to udpate its CVS HEAD version. We replaced _node_name() and _node_types() by _node(). The new _node() hook let's you define one or more node types, including their names. The implementation of the _node() hook needs to: return array($type1 => array('name' => $name1, 'base' => $base1), $type2 => array('name' => $name2, 'base' => $base2)); where $type is the node type, $name is the human readable name of the type and $base is used instead of for _load, _view, etc. For example, the story module's node hook looks like this: function story_node() { return array('story' => array('name' => t('story'), 'base' => 'story')); } The page module's node hook module like: function page_node() { return array('page' => array('name' => t('page'), 'base' => 'page')); } However, more complex node modules like the project module and the flexinode module can use the 'base' parameter to specify a different base. The project module implements two node types, proejcts and issues, so it can do: function project_node() { return array( array('project_project' => array('name' => t('project'), 'base' => 'project'), array('project_issue' => array('name' => t('issue'), 'base' => 'project_issue')); } In the flexinode module's case there can only one base ... This hook will simplify the CCK, and will make it easy (or easier) to merge the story and page module. In addition, node_list() became node_get_types(). In addition, we created the following functions: node_get_name($type) and node_get_base($type). --- modules/taxonomy/taxonomy.module | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'modules/taxonomy/taxonomy.module') diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 1dbde4f81..4bbfbe36c 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -107,17 +107,12 @@ function taxonomy_menu($may_cache) { } function taxonomy_form_vocabulary($edit = array()) { - foreach (node_list() as $type => $module) { - $node_type = node_invoke($type, 'node_name'); - $nodes[$type] = $node_type ? $node_type : $type; - } - $form .= form_textfield(t('Vocabulary name'), 'name', $edit['name'], 60, 64, t('The name for this vocabulary. Example: "Topic".'), NULL, TRUE); // Prepend extra vocabulary form elements. $form .= implode('', module_invoke_all('taxonomy', 'form pre', 'vocabulary', $edit)); $form .= form_textarea(t('Description'), 'description', $edit['description'], 60, 5, t('Description of the vocabulary; can be used by modules.')); $form .= form_textfield(t('Help text'), 'help', $edit['help'], 60, 255, t('Instructions to present to the user when choosing a term.')); - $form .= form_checkboxes(t('Types'), 'nodes', $edit['nodes'], $nodes, t('A list of node types you want to associate with this vocabulary.'), NULL, TRUE); + $form .= form_checkboxes(t('Types'), 'nodes', $edit['nodes'], node_get_types(), t('A list of node types you want to associate with this vocabulary.'), NULL, TRUE); $form .= form_radios(t('Hierarchy'), 'hierarchy', $edit['hierarchy'], array(t('Disabled'), t('Single'), t('Multiple')), t('Allows a tree-like hierarchy between terms of this vocabulary.', array('%help-url' => url('admin/help/taxonomy', NULL, NULL, 'hierarchy')))); $form .= form_checkbox(t('Related terms'), 'relations', 1, $edit['relations'], t('Allows related terms in this vocabulary.', array('%help-url' => url('admin/help/taxonomy', NULL, NULL, 'related-terms')))); $form .= form_checkbox(t('Free tagging'), 'tags', 1, $edit['tags'], t('Content is categorized by typing terms instead of choosing from a list.')); @@ -374,7 +369,7 @@ function taxonomy_overview() { foreach ($vocabularies as $vocabulary) { $types = array(); foreach ($vocabulary->nodes as $type) { - $node_type = node_invoke($type, 'node_name'); + $node_type = node_get_name($type); $types[] = $node_type ? $node_type : $type; } $rows[] = array(check_plain($vocabulary->name), implode(', ', $types), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('edit terms'), "admin/taxonomy/$vocabulary->vid")); -- cgit v1.2.3