Commit 277c7f7b authored by catch's avatar catch

Issue #1564832 by sun, dcam: Remove _node_extract_type() and node_type_get_name().

parent 1b927f54
......@@ -180,7 +180,7 @@ function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) {
$links[$type] = array(
'#theme' => 'menu_local_action',
'#link' => array(
'title' => t('Add new @node_type', array('@node_type' => node_type_get_name($type))),
'title' => t('Add new @node_type', array('@node_type' => node_type_get_label($type))),
'href' => 'node/add/' . $type . '/' . $forum_term->tid,
),
);
......
......@@ -88,8 +88,8 @@ public function form(array $form, array &$form_state, EntityInterface $node) {
// because hook_form() needs to be able to receive $form_state by reference.
// @todo hook_form() implementations are unable to add #validate or #submit
// handlers to the form buttons below. Remove hook_form() entirely.
$function = node_type_get_base($node) . '_form';
if (function_exists($function) && ($extra = $function($node, $form_state))) {
$function = node_hook($node->type, 'form');
if ($function && ($extra = $function($node, $form_state))) {
$form = array_merge_recursive($form, $extra);
}
// If the node type has a title, and the node type form defined no special
......@@ -295,8 +295,7 @@ public function validate(array $form, array &$form_state) {
// hook_node_validate() for miscellaneous validation needed by modules.
// Can't use node_invoke() or module_invoke_all(), because $form_state must
// be receivable by reference.
$function = node_type_get_base($node) . '_validate';
if (function_exists($function)) {
if ($function = node_hook($node->type, 'validate')) {
$function($node, $form, $form_state);
}
foreach (module_implements('node_validate') as $module) {
......@@ -384,7 +383,7 @@ public function save(array $form, array &$form_state) {
$node->save();
$node_link = l(t('view'), 'node/' . $node->nid);
$watchdog_args = array('@type' => $node->type, '%title' => $node->label());
$t_args = array('@type' => node_type_get_name($node), '%title' => $node->label());
$t_args = array('@type' => node_get_type_label($node), '%title' => $node->label());
if ($insert) {
watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
......
......@@ -176,8 +176,9 @@ protected function attachLoad(&$nodes, $load_revision = FALSE) {
// Call object type specific callbacks on each typed array of nodes.
foreach ($typed_nodes as $node_type => $nodes_of_type) {
if (node_hook($node_type, 'load')) {
$function = node_type_get_base($node_type) . '_load';
// Retrieve the node type 'base' hook implementation based on a Node in
// the type-specific stack.
if ($function = node_hook($node_type, 'load')) {
$function($nodes_of_type);
}
}
......
......@@ -42,7 +42,7 @@ function testNodeTypeGetFunctions() {
$this->assertEqual($node_types['article']->name, $node_names['article'], t('Correct node type base has been returned.'));
$this->assertEqual($node_types['article'], node_type_load('article'), t('Correct node type has been returned.'));
$this->assertEqual($node_types['article']->name, node_type_get_name('article'), t('Correct node type name has been returned.'));
$this->assertEqual($node_types['article']->name, node_type_get_label('article'), t('Correct node type name has been returned.'));
$this->assertEqual($node_types['page']->base, node_type_get_base('page'), t('Correct node type base has been returned.'));
}
......
......@@ -492,7 +492,7 @@ function node_admin_nodes() {
'#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
),
),
'type' => check_plain(node_type_get_name($node)),
'type' => check_plain(node_get_type_label($node)),
'author' => theme('username', array('account' => $node)),
'status' => $node->status ? t('published') : t('not published'),
'changed' => format_date($node->changed, 'short'),
......
This diff is collapsed.
......@@ -17,8 +17,7 @@
* @see node_menu()
*/
function node_page_edit($node) {
$type_name = node_type_get_name($node);
drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => $type_name, '@title' => $node->label())), PASS_THROUGH);
drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => node_get_type_label($node), '@title' => $node->label())), PASS_THROUGH);
return entity_get_form($node);
}
......@@ -210,7 +209,7 @@ function node_delete_confirm_submit($form, &$form_state) {
$node = node_load($form_state['values']['nid']);
node_delete($form_state['values']['nid']);
watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->label()));
drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->label())));
drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_type_label($node), '%title' => $node->label())));
}
$form_state['redirect'] = '<front>';
......@@ -303,7 +302,7 @@ function node_revision_revert_confirm_submit($form, &$form_state) {
$node_revision->save();
watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->label(), '%revision' => $node_revision->vid));
drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_type_get_name($node_revision), '%title' => $node_revision->label(), '%revision-date' => format_date($original_revision_timestamp))));
drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_get_type_label($node_revision), '%title' => $node_revision->label(), '%revision-date' => format_date($original_revision_timestamp))));
$form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions';
}
......@@ -328,7 +327,7 @@ function node_revision_delete_confirm_submit($form, &$form_state) {
node_revision_delete($node_revision->vid);
watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->label(), '%revision' => $node_revision->vid));
drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_type_get_name($node_revision), '%title' => $node_revision->label())));
drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_get_type_label($node_revision), '%title' => $node_revision->label())));
$form_state['redirect'] = 'node/' . $node_revision->nid;
if (db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node_revision->nid))->fetchField() > 1) {
$form_state['redirect'] .= '/revisions';
......
......@@ -125,7 +125,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
break;
case 'type-name':
$type_name = node_type_get_name($node);
$type_name = node_get_type_label($node);
$replacements[$original] = $sanitize ? check_plain($type_name) : $type_name;
break;
......
......@@ -74,7 +74,7 @@ function pollCreate($title, $choices, $preview = TRUE) {
$this->drupalPost(NULL, $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($title);
$this->assertText(t('@type @title has been created.', array('@type' => node_type_get_name('poll'), '@title' => $title)), 'Poll has been created.');
$this->assertText(t('@type @title has been created.', array('@type' => node_type_get_label('poll'), '@title' => $title)), 'Poll has been created.');
$this->assertTrue($node->nid, t('Poll has been found in the database.'));
return isset($node->nid) ? $node->nid : FALSE;
......@@ -188,6 +188,6 @@ function assertPollChoiceOrder(array $choices, $index = 0, $preview = FALSE) {
function pollUpdate($nid, $title, $edit) {
// Edit the poll node.
$this->drupalPost('node/' . $nid . '/edit', $edit, t('Save'));
$this->assertText(t('@type @title has been updated.', array('@type' => node_type_get_name('poll'), '@title' => $title)), 'Poll has been updated.');
$this->assertText(t('@type @title has been updated.', array('@type' => node_type_get_label('poll'), '@title' => $title)), 'Poll has been updated.');
}
}
......@@ -239,7 +239,7 @@ function hook_search_execute($keys = NULL, $conditions = NULL) {
$uri = $node->uri();
$results[] = array(
'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))),
'type' => check_plain(node_type_get_name($node)),
'type' => check_plain(node_get_type_label($node)),
'title' => $node->label($item->langcode),
'user' => theme('username', array('account' => $node)),
'date' => $node->get('changed', $item->langcode),
......
......@@ -2003,7 +2003,7 @@ function hook_mail($key, &$message, $params) {
$variables += array(
'%uid' => $node->uid,
'%node_url' => url('node/' . $node->nid, array('absolute' => TRUE)),
'%node_type' => node_type_get_name($node),
'%node_type' => node_get_type_label($node),
'%title' => $node->title,
'%teaser' => $node->teaser,
'%body' => $node->body,
......
......@@ -70,7 +70,7 @@ function tracker_page($account = NULL, $set_title = FALSE) {
}
$row = array(
'type' => check_plain(node_type_get_name($node->type)),
'type' => check_plain(node_get_type_label($node)),
// Do not use $node->label(), because $node comes from the database.
'title' => array('data' => l($node->title, 'node/' . $node->nid) . ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed)))),
'author' => array('data' => theme('username', array('account' => $node))),
......
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