Commit d1c01766 authored by Dries's avatar Dries

- Patch #658364 by effulgentsia: made the build/view/formatter terminology more consistent.

parent ef10abde
......@@ -44,7 +44,7 @@ function blog_page_user($account) {
if (!empty($nids)) {
$nodes = node_load_multiple($nids);
$build += node_build_multiple($nodes);
$build += node_view_multiple($nodes);
$build['pager'] = array(
'#theme' => 'pager',
'#weight' => 5,
......@@ -84,7 +84,7 @@ function blog_page_last() {
if (!empty($nids)) {
$nodes = node_load_multiple($nids);
$build += node_build_multiple($nodes);
$build += node_view_multiple($nodes);
$build['pager'] = array(
'#theme' => 'pager',
'#weight' => 5,
......
......@@ -1110,7 +1110,7 @@ function book_export_traverse($tree, $visit_func) {
* The HTML generated for the given node.
*/
function book_node_export($node, $children = '') {
$build = node_build($node, 'print');
$build = node_view($node, 'print');
unset($build['#theme']);
// @todo Rendering should happen in the template using render().
$node->rendered = drupal_render($build);
......
......@@ -87,9 +87,9 @@ function hook_comment_view($comment) {
* @param $build
* A renderable array representing the comment.
*
* @see comment_build()
* @see comment_view()
*/
function hook_comment_build_alter($build) {
function hook_comment_view_alter($build) {
// Check for the existence of a field added by another module.
if ($build['#build_mode'] == 'full' && isset($build['an_additional_field'])) {
// Change its weight.
......
......@@ -602,7 +602,7 @@ function comment_node_page_additions($node) {
if ($cids = comment_get_thread($node, $mode, $comments_per_page)) {
$comments = comment_load_multiple($cids);
comment_prepare_thread($comments);
$build = comment_build_multiple($comments, $node);
$build = comment_view_multiple($comments, $node);
$build['#attached']['css'][] = drupal_get_path('module', 'comment') . '/comment.css';
$build['pager']['#theme'] = 'pager';
$additions['comments'] = $build;
......@@ -785,7 +785,7 @@ function comment_prepare_thread(&$comments) {
* @return
* An array as expected by drupal_render().
*/
function comment_build($comment, $node, $build_mode = 'full') {
function comment_view($comment, $node, $build_mode = 'full') {
// Populate $comment->content with a render() array.
comment_build_content($comment, $node, $build_mode);
......@@ -823,7 +823,7 @@ function comment_build($comment, $node, $build_mode = 'full') {
}
// Allow modules to modify the structured comment.
drupal_alter('comment_build', $build);
drupal_alter('comment_view', $build);
return $build;
}
......@@ -941,14 +941,14 @@ function comment_links($comment, $node) {
* @return
* An array in the format expected by drupal_render().
*/
function comment_build_multiple($comments, $node, $build_mode = 'full', $weight = 0) {
function comment_view_multiple($comments, $node, $build_mode = 'full', $weight = 0) {
field_attach_prepare_view('comment', $comments, $build_mode);
$build = array(
'#sorted' => TRUE,
);
foreach ($comments as $comment) {
$build[$comment->cid] = comment_build($comment, $node, $build_mode);
$build[$comment->cid] = comment_view($comment, $node, $build_mode);
$build[$comment->cid]['#weight'] = $weight;
$weight++;
}
......@@ -1315,7 +1315,7 @@ function comment_save($comment) {
}
else {
// Add the comment to database. This next section builds the thread field.
// Also see the documentation for comment_build().
// Also see the documentation for comment_view().
if ($comment->pid == 0) {
// This is a comment with no parent comment (depth 0): we start
// by retrieving the maximum thread level.
......@@ -1628,7 +1628,7 @@ function comment_get_display_ordinal($cid, $node_type) {
else {
// For threaded comments, the c.thread column is used for ordering. We can
// use the vancode for comparison, but must remove the trailing slash.
// @see comment_build_multiple().
// @see comment_view_multiple().
$query->where('SUBSTRING(c1.thread, 1, (LENGTH(c1.thread) -1)) < SUBSTRING(c2.thread, 1, (LENGTH(c2.thread) -1))');
}
......@@ -1904,7 +1904,7 @@ function comment_preview($comment) {
$comment->created = !empty($comment->created) ? $comment->created : REQUEST_TIME;
$comment->changed = REQUEST_TIME;
$comment->in_preview = TRUE;
$comment_build = comment_build($comment, $node);
$comment_build = comment_view($comment, $node);
$comment_build += array(
'#weight' => -100,
'#prefix' => '<div class="preview">',
......@@ -1918,11 +1918,11 @@ function comment_preview($comment) {
$build = array();
if ($comments = comment_load_multiple(array($comment->pid), array('status' => COMMENT_PUBLISHED))) {
$parent_comment = $comments[$comment->pid];
$build = comment_build($parent_comment, $node);
$build = comment_view($parent_comment, $node);
}
}
else {
$build = node_build($node);
$build = node_view($node);
}
$form['comment_output_below'] = $build;
......
......@@ -65,7 +65,7 @@ function comment_reply($node, $pid = NULL) {
$comment->node_type = 'comment_node_' . $node->type;
field_attach_load('comment', array($comment->cid => $comment));
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$build['comment_parent'] = comment_build($comment, $node);
$build['comment_parent'] = comment_view($comment, $node);
}
else {
drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
......@@ -74,7 +74,7 @@ function comment_reply($node, $pid = NULL) {
}
// This is the case where the comment is in response to a node. Display the node.
elseif (user_access('access content')) {
$build['comment_node'] = node_build($node);
$build['comment_node'] = node_view($node);
}
// Should we show the reply box?
......
......@@ -59,7 +59,7 @@ function contextual_library() {
/**
* Template variable preprocessor for contextual links.
*
* @see contextual_links_build()
* @see contextual_links_view()
*/
function contextual_preprocess(&$variables, $hook) {
static $hooks;
......@@ -89,7 +89,7 @@ function contextual_preprocess(&$variables, $hook) {
}
if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
$variables['contextual_links'] = contextual_links_build($element);
$variables['contextual_links'] = contextual_links_view($element);
if (!empty($variables['contextual_links'])) {
$variables['classes_array'][] = 'contextual-links-region';
}
......@@ -116,7 +116,7 @@ function contextual_preprocess(&$variables, $hook) {
*
* @see menu_contextual_links()
*/
function contextual_links_build($element) {
function contextual_links_view($element) {
static $destination;
// Retrieve contextual menu links.
......
......@@ -525,7 +525,7 @@ function hook_field_is_empty($item, $field) {
* Widget hooks are typically called by the Field Attach API during the
* creation of the field form structure with field_attach_form().
* @see hook_field_widget_info_alter().
* @see hook_field_widget().
* @see hook_field_widget_form().
* @see hook_field_widget_error().
*
* @return
......@@ -649,7 +649,7 @@ function hook_field_widget_info_alter(&$info) {
* @return
* The form elements for a single widget for this field.
*/
function hook_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
function hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$element += array(
'#type' => $instance['widget']['type'],
'#default_value' => isset($items[$delta]) ? $items[$delta] : '',
......@@ -684,7 +684,7 @@ function hook_field_widget_error($element, $error) {
*
* @see hook_field_formatter_info().
* @see hook_field_formatter_info_alter().
* @see hook_field_formatter().
* @see hook_field_formatter_view().
* @see hook_field_formatter_prepare_view().
*
* @return
......@@ -816,7 +816,7 @@ function hook_field_formatter_prepare_view($obj_type, $objects, $field, $instanc
* A renderable array for the $items, as an array of child elements keyed
* by numeric indexes starting from 0.
*/
function hook_field_formatter($obj_type, $object, $field, $instance, $langcode, $items, $display) {
function hook_field_formatter_view($obj_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
$settings = $display['settings'];
......
......@@ -1144,7 +1144,7 @@ function field_attach_prepare_view($obj_type, $objects, $build_mode = 'full') {
* '#formatter' => the name of the formatter,
* '#items' => the field values being displayed,
* // The element's children are the formatted values returned by
* // hook_field_formatter().
* // hook_field_formatter_view().
* ),
* );
* @endcode
......
......@@ -187,7 +187,7 @@ function field_default_view($obj_type, $object, $field, $instance, $langcode, $i
// Calling the formatter function through module_invoke() can have a
// performance impact on pages with many fields and values.
$function = $display['module'] . '_field_formatter';
$function = $display['module'] . '_field_formatter_view';
if (function_exists($function)) {
$elements = $function($obj_type, $object, $field, $instance, $langcode, $items, $display);
}
......
......@@ -47,7 +47,7 @@ function field_default_form($obj_type, $object, $field, $instance, $langcode, $i
// make it the $delta value.
else {
$delta = isset($get_delta) ? $get_delta : 0;
$function = $instance['widget']['module'] . '_field_widget';
$function = $instance['widget']['module'] . '_field_widget_form';
if (function_exists($function)) {
$element = array(
'#object_type' => $instance['object_type'],
......@@ -161,7 +161,7 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form,
$wrapper_id = drupal_html_class($field_name) . '-wrapper';
$field_elements = array();
$function = $instance['widget']['module'] . '_field_widget';
$function = $instance['widget']['module'] . '_field_widget_form';
if (function_exists($function)) {
for ($delta = 0; $delta <= $max; $delta++) {
$multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
......
......@@ -330,9 +330,9 @@ function list_field_formatter_info() {
}
/**
* Implements hook_field_formatter().
* Implements hook_field_formatter_view().
*/
function list_field_formatter($object_type, $object, $field, $instance, $langcode, $items, $display) {
function list_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
......
......@@ -253,9 +253,9 @@ function number_field_formatter_info() {
}
/**
* Implements hook_field_formatter().
* Implements hook_field_formatter_view().
*/
function number_field_formatter($object_type, $object, $field, $instance, $langcode, $items, $display) {
function number_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
$settings = $display['settings'];
......@@ -298,9 +298,9 @@ function number_field_widget_info() {
}
/**
* Implements hook_field_widget().
* Implements hook_field_widget_form().
*/
function number_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
function number_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$value = isset($items[$delta]['value']) ? $items[$delta]['value'] : '';
// Substitute the decimal separator.
if ($field['type'] == 'number_decimal' || $field['type'] == 'number_float') {
......
......@@ -66,9 +66,9 @@ function options_field_widget_info() {
}
/**
* Implements hook_field_widget().
* Implements hook_field_widget_form().
*/
function options_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
function options_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
// Abstract over the actual field columns, to allow different field types to
// reuse those widgets.
$value_key = key($field['columns']);
......
......@@ -199,7 +199,7 @@ function text_field_validate($obj_type, $object, $field, $instance, $langcode, $
* Where possible, generate the sanitized version of each field early so that
* it is cached in the field cache. This avoids looking up from the filter cache
* separately.
* @see text_field_formatter().
* @see text_field_formatter_view().
*/
function text_field_load($obj_type, $objects, $field, $instances, $langcode, &$items) {
foreach ($objects as $id => $object) {
......@@ -262,9 +262,9 @@ function text_field_formatter_info() {
}
/**
* Implements hook_field_formatter().
* Implements hook_field_formatter_view().
*/
function text_field_formatter($object_type, $object, $field, $instance, $langcode, $items, $display) {
function text_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
......@@ -508,9 +508,9 @@ function text_field_widget_settings_form($field, $instance) {
}
/**
* Implements hook_field_widget().
* Implements hook_field_widget_form().
*/
function text_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
function text_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
$element = $base;
switch ($instance['widget']['type']) {
......
......@@ -154,9 +154,9 @@ function field_test_field_widget_info() {
}
/**
* Implements hook_field_widget().
* Implements hook_field_widget_form().
*/
function field_test_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
function field_test_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
switch ($instance['widget']['type']) {
case 'test_field_widget':
$element += array(
......@@ -277,9 +277,9 @@ function field_test_field_formatter_prepare_view($obj_type, $objects, $field, $i
}
/**
* Implements hook_field_formatter().
* Implements hook_field_formatter_view().
*/
function field_test_field_formatter($object_type, $object, $field, $instance, $langcode, $items, $display) {
function field_test_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
$settings = $display['settings'];
......
......@@ -425,9 +425,9 @@ function file_field_widget_settings_form($field, $instance) {
}
/**
* Implements hook_field_widget().
* Implements hook_field_widget_form().
*/
function file_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
function file_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$form['#attributes'] = array('enctype' => 'multipart/form-data');
$defaults = array(
......@@ -842,9 +842,9 @@ function theme_file_upload_help($variables) {
}
/**
* Implements hook_field_formatter().
* Implements hook_field_formatter_view().
*/
function file_field_formatter($obj_type, $object, $field, $instance, $langcode, $items, $display) {
function file_field_formatter_view($obj_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
......
......@@ -305,10 +305,10 @@ function image_field_widget_settings_form($field, $instance) {
}
/**
* Implements hook_field_widget().
* Implements hook_field_widget_form().
*/
function image_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$elements = file_field_widget($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
function image_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$elements = file_field_widget_form($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
$settings = $instance['settings'];
foreach (element_children($elements) as $delta) {
......@@ -450,9 +450,9 @@ function image_field_formatter_info() {
}
/**
* Implements hook_field_formatter().
* Implements hook_field_formatter_view().
*/
function image_field_formatter($obj_type, $object, $field, $instance, $langcode, $items, $display) {
function image_field_formatter_view($obj_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
// Check if the formatter involves a particular image style.
......
......@@ -445,7 +445,7 @@ function hook_node_prepare_translation($node) {
* Act on a node being displayed as a search result.
*
* This hook is invoked from node_search_execute(), after node_load()
* and node_build() have been called.
* and node_view() have been called.
*
* @param $node
* The node being displayed in a search result.
......@@ -497,7 +497,7 @@ function hook_node_update($node) {
* Act on a node being indexed for searching.
*
* This hook is invoked during search indexing, after node_load(), and after
* the result of node_build() is added as $node->rendered to the node object.
* the result of node_view() is added as $node->rendered to the node object.
*
* @param $node
* The node being indexed.
......@@ -563,7 +563,7 @@ function hook_node_validate($node, $form) {
* @param $node
* The node that is being assembled for rendering.
* @param $build_mode
* The $build_mode parameter from node_build().
* The $build_mode parameter from node_view().
*/
function hook_node_view($node, $build_mode) {
$node->content['my_additional_field'] = array(
......@@ -574,7 +574,7 @@ function hook_node_view($node, $build_mode) {
}
/**
* Alter the results of node_build().
* Alter the results of node_view().
*
* This hook is called after the content has been assembled in a structured
* array and may be used for doing processing which requires that the complete
......@@ -588,9 +588,9 @@ function hook_node_view($node, $build_mode) {
* @param $build
* A renderable array representing the node content.
*
* @see node_build()
* @see node_view()
*/
function hook_node_build_alter($build) {
function hook_node_view_alter($build) {
if ($build['#build_mode'] == 'full' && isset($build['an_additional_field'])) {
// Change its weight.
$build['an_additional_field']['#weight'] = -10;
......@@ -990,9 +990,9 @@ function hook_validate($node, &$form) {
* by assembling a structured array, formatted as in the Form API, in
* $node->content. As with Form API arrays, the #weight property can be
* used to control the relative positions of added elements. After this
* hook is invoked, node_build() calls field_attach_view() to add field
* hook is invoked, node_view() calls field_attach_view() to add field
* views to $node->content, and then invokes hook_node_view() and
* hook_node_build_alter(), so if you want to affect the final
* hook_node_view_alter(), so if you want to affect the final
* view of the node, you might consider implementing one of these hooks
* instead.
*
......
......@@ -1173,7 +1173,7 @@ function node_revision_delete($revision_id) {
* @return
* An array as expected by drupal_render().
*/
function node_build($node, $build_mode = 'full') {
function node_view($node, $build_mode = 'full') {
// Populate $node->content with a render() array.
node_build_content($node, $build_mode);
......@@ -1191,7 +1191,7 @@ function node_build($node, $build_mode = 'full') {
$build['#contextual_links']['node'] = array('node', array($node->nid));
// Allow modules to modify the structured node.
drupal_alter('node_build', $build);
drupal_alter('node_view', $build);
return $build;
}
......@@ -1232,7 +1232,7 @@ function node_build_content($node, $build_mode = 'full') {
}
// Build fields content.
// @todo field_attach_prepare_view() is only invoked by node_build_multiple(),
// @todo field_attach_prepare_view() is only invoked by node_view_multiple(),
// all other entities invoke it _here_.
//field_attach_prepare_view('node', array($node->nid => $node), $build_mode);
$node->content += field_attach_view('node', $node, $build_mode);
......@@ -1321,8 +1321,8 @@ function node_show($node, $message = FALSE) {
// Update the history table, stating that this user viewed this node.
node_tag_new($node->nid);
// For markup consistency with other pages, use node_build_multiple() rather than node_build().
return node_build_multiple(array($node->nid => $node), 'full');
// For markup consistency with other pages, use node_view_multiple() rather than node_view().
return node_view_multiple(array($node->nid => $node), 'full');
}
/**
......@@ -1582,7 +1582,7 @@ function node_search_execute($keys = NULL) {
foreach ($find as $item) {
// Render the node.
$node = node_load($item->sid);
$build = node_build($node, 'search_result');
$build = node_view($node, 'search_result');
unset($build['#theme']);
$node->rendered = drupal_render($build);
......@@ -2089,7 +2089,7 @@ function node_feed($nids = FALSE, $channel = array()) {
// The node gets built and modules add to or modify $node->rss_elements
// and $node->rss_namespaces.
$build = node_build($node, 'rss');
$build = node_view($node, 'rss');
unset($build['#theme']);
if (!empty($node->rss_namespaces)) {
......@@ -2136,11 +2136,11 @@ function node_feed($nids = FALSE, $channel = array()) {
* @return
* An array in the format expected by drupal_render().
*/
function node_build_multiple($nodes, $build_mode = 'teaser', $weight = 0) {
function node_view_multiple($nodes, $build_mode = 'teaser', $weight = 0) {
field_attach_prepare_view('node', $nodes, $build_mode);
$build = array();
foreach ($nodes as $node) {
$build['nodes'][$node->nid] = node_build($node, $build_mode);
$build['nodes'][$node->nid] = node_view($node, $build_mode);
$build['nodes'][$node->nid]['#weight'] = $weight;
$weight++;
}
......@@ -2166,7 +2166,7 @@ function node_page_default() {
if (!empty($nids)) {
$nodes = node_load_multiple($nids);
$build = node_build_multiple($nodes);
$build = node_view_multiple($nodes);
$feed_url = url('rss.xml', array('absolute' => TRUE));
drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') . ' ' . t('RSS'));
......@@ -2247,7 +2247,7 @@ function _node_index_node($node) {
variable_set('node_cron_last', $node->changed);
// Render the node.
$build = node_build($node, 'search_index');
$build = node_view($node, 'search_index');
unset($build['#theme']);
$node->rendered = drupal_render($build);
......@@ -3215,7 +3215,7 @@ function node_unpublish_by_keyword_action_submit($form, $form_state) {
*/
function node_unpublish_by_keyword_action($node, $context) {
foreach ($context['keywords'] as $keyword) {
if (strpos(drupal_render(node_build(clone $node)), $keyword) !== FALSE || strpos($node->title, $keyword) !== FALSE) {
if (strpos(drupal_render(node_view(clone $node)), $keyword) !== FALSE || strpos($node->title, $keyword) !== FALSE) {
$node->status = NODE_NOT_PUBLISHED;
watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title[LANGUAGE_NONE][0]['value']));
break;
......
......@@ -397,8 +397,8 @@ function theme_node_preview($variables) {
$preview_trimmed_version = FALSE;
$trimmed = drupal_render(node_build(clone $node, 'teaser'));
$full = drupal_render(node_build($node, 'full'));
$trimmed = drupal_render(node_view(clone $node, 'teaser'));
$full = drupal_render(node_view($node, 'full'));
// Do we need to preview trimmed version of post as well as full version?
if ($trimmed != $full) {
......
......@@ -584,7 +584,7 @@ function rdf_field_attach_view_alter(&$output, $context) {
$element = &$output[$field_name];
if ($element['#field_type'] == 'taxonomy_term' && $element['#formatter'] == 'taxonomy_term_link') {
foreach ($element['#items'] as $delta => $item) {
// @todo Remove this when "node_build() does not call
// @todo Remove this when "node_view() does not call
// field_attach_prepare_view()" bug is fixed.
// See http://drupal.org/node/493314.
if (!isset($item['taxonomy_term'])) {
......
......@@ -1080,15 +1080,15 @@ function taxonomy_field_formatter_info() {
}
/**
* Implements hook_field_formatter().
* Implements hook_field_formatter_view().
*/
function taxonomy_field_formatter($object_type, $object, $field, $instance, $langcode, $items, $display) {
function taxonomy_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'taxonomy_term_link':
foreach ($items as $delta => $item) {
// @todo Remove this when "node_build() does not call
// @todo Remove this when "node_view() does not call
// field_attach_prepare_view()" bug is fixed.
// See http://drupal.org/node/493314.
if (!isset($item['taxonomy_term'])) {
......@@ -1228,9 +1228,9 @@ function taxonomy_term_title($term) {
}
/**
* Implements hook_field_widget().
* Implements hook_field_widget_form().
*/
function taxonomy_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
function taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$tags = array();
foreach ($items as $item) {
$tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']);
......
......@@ -41,7 +41,7 @@ function taxonomy_term_page($term) {
);