- Patch #922824 by plach: no way to specify the language to view entities in.
parent
69e9e3e3a2
commit
8ec40cc27a
|
@ -64,10 +64,12 @@ function hook_comment_load($comments) {
|
|||
*
|
||||
* @param $comment
|
||||
* Passes in the comment the action is being performed on.
|
||||
* @return
|
||||
* Nothing.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $langcode
|
||||
* The language code used for rendering.
|
||||
*/
|
||||
function hook_comment_view($comment) {
|
||||
function hook_comment_view($comment, $view_mode, $langcode) {
|
||||
// how old is the comment
|
||||
$comment->time_ago = time() - $comment->changed;
|
||||
}
|
||||
|
|
|
@ -887,13 +887,20 @@ function comment_prepare_thread(&$comments) {
|
|||
* The node the comment is attached to.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*
|
||||
* @return
|
||||
* An array as expected by drupal_render().
|
||||
*/
|
||||
function comment_view($comment, $node, $view_mode = 'full') {
|
||||
function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->language;
|
||||
}
|
||||
|
||||
// Populate $comment->content with a render() array.
|
||||
comment_build_content($comment, $node, $view_mode);
|
||||
comment_build_content($comment, $node, $view_mode, $langcode);
|
||||
|
||||
$build = $comment->content;
|
||||
// We don't need duplicate rendering info in comment->content.
|
||||
|
@ -904,6 +911,7 @@ function comment_view($comment, $node, $view_mode = 'full') {
|
|||
'#comment' => $comment,
|
||||
'#node' => $node,
|
||||
'#view_mode' => $view_mode,
|
||||
'#language' => $langcode,
|
||||
);
|
||||
|
||||
if (empty($comment->in_preview)) {
|
||||
|
@ -948,15 +956,22 @@ function comment_view($comment, $node, $view_mode = 'full') {
|
|||
* The node the comment is attached to.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*/
|
||||
function comment_build_content($comment, $node, $view_mode = 'full') {
|
||||
function comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->language;
|
||||
}
|
||||
|
||||
// Remove previously built content, if exists.
|
||||
$comment->content = array();
|
||||
|
||||
// Build fields content.
|
||||
field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode);
|
||||
entity_prepare_view('comment', array($comment->cid => $comment));
|
||||
$comment->content += field_attach_view('comment', $comment, $view_mode);
|
||||
$comment->content += field_attach_view('comment', $comment, $view_mode, $langcode);
|
||||
|
||||
if (empty($comment->in_preview)) {
|
||||
$comment->content['links']['comment'] = array(
|
||||
|
@ -967,7 +982,7 @@ function comment_build_content($comment, $node, $view_mode = 'full') {
|
|||
}
|
||||
|
||||
// Allow modules to make their own additions to the comment.
|
||||
module_invoke_all('comment_view', $comment, $view_mode);
|
||||
module_invoke_all('comment_view', $comment, $view_mode, $langcode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1043,10 +1058,14 @@ function comment_links($comment, $node) {
|
|||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $weight
|
||||
* An integer representing the weight of the first comment in the list.
|
||||
* @param $langcode
|
||||
* A string indicating the language field values are to be shown in. If no
|
||||
* language is provided the current content language is used.
|
||||
*
|
||||
* @return
|
||||
* An array in the format expected by drupal_render().
|
||||
*/
|
||||
function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0) {
|
||||
function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0, $langcode = NULL) {
|
||||
field_attach_prepare_view('comment', $comments, $view_mode);
|
||||
entity_prepare_view('comment', $comments);
|
||||
|
||||
|
@ -1054,7 +1073,7 @@ function comment_view_multiple($comments, $node, $view_mode = 'full', $weight =
|
|||
'#sorted' => TRUE,
|
||||
);
|
||||
foreach ($comments as $comment) {
|
||||
$build[$comment->cid] = comment_view($comment, $node, $view_mode);
|
||||
$build[$comment->cid] = comment_view($comment, $node, $view_mode, $langcode);
|
||||
$build[$comment->cid]['#weight'] = $weight;
|
||||
$weight++;
|
||||
}
|
||||
|
|
|
@ -1236,6 +1236,7 @@ function hook_field_attach_purge($entity_type, $entity, $field, $instance) {
|
|||
* - entity_type: The type of $entity; for example, 'node' or 'user'.
|
||||
* - entity: The entity with fields to render.
|
||||
* - view_mode: View mode, for example, 'full' or 'teaser'.
|
||||
* - language: The language code used for rendering.
|
||||
*/
|
||||
function hook_field_attach_view_alter(&$output, $context) {
|
||||
// Append RDF term mappings on displayed taxonomy links.
|
||||
|
|
|
@ -1146,6 +1146,7 @@ function field_attach_view($entity_type, $entity, $view_mode, $langcode = NULL)
|
|||
'entity_type' => $entity_type,
|
||||
'entity' => $entity,
|
||||
'view_mode' => $view_mode,
|
||||
'language' => $langcode,
|
||||
);
|
||||
drupal_alter('field_attach_view', $output, $context);
|
||||
|
||||
|
|
|
@ -756,10 +756,12 @@ function hook_node_submit($node, $form, &$form_state) {
|
|||
* The node that is being assembled for rendering.
|
||||
* @param $view_mode
|
||||
* The $view_mode parameter from node_view().
|
||||
* @param $langcode
|
||||
* The language code used for rendering.
|
||||
*
|
||||
* @ingroup node_api_hooks
|
||||
*/
|
||||
function hook_node_view($node, $view_mode) {
|
||||
function hook_node_view($node, $view_mode, $langcode) {
|
||||
$node->content['my_additional_field'] = array(
|
||||
'#markup' => $additional_field,
|
||||
'#weight' => 10,
|
||||
|
|
|
@ -1208,13 +1208,20 @@ function node_revision_delete($revision_id) {
|
|||
* A node object.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*
|
||||
* @return
|
||||
* An array as expected by drupal_render().
|
||||
*/
|
||||
function node_view($node, $view_mode = 'full') {
|
||||
function node_view($node, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->language;
|
||||
}
|
||||
|
||||
// Populate $node->content with a render() array.
|
||||
node_build_content($node, $view_mode);
|
||||
node_build_content($node, $view_mode, $langcode);
|
||||
|
||||
$build = $node->content;
|
||||
// We don't need duplicate rendering info in node->content.
|
||||
|
@ -1224,7 +1231,9 @@ function node_view($node, $view_mode = 'full') {
|
|||
'#theme' => 'node',
|
||||
'#node' => $node,
|
||||
'#view_mode' => $view_mode,
|
||||
'#language' => $langcode,
|
||||
);
|
||||
|
||||
// Add contextual links for this node, except when the node is already being
|
||||
// displayed on its own page. Modules may alter this behavior (for example,
|
||||
// to restrict contextual links to certain view modes) by implementing
|
||||
|
@ -1263,8 +1272,15 @@ function node_view($node, $view_mode = 'full') {
|
|||
* A node object.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*/
|
||||
function node_build_content($node, $view_mode = 'full') {
|
||||
function node_build_content($node, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->language;
|
||||
}
|
||||
|
||||
// Remove previously built content, if exists.
|
||||
$node->content = array();
|
||||
|
||||
|
@ -1280,7 +1296,7 @@ function node_build_content($node, $view_mode = 'full') {
|
|||
// twice.
|
||||
field_attach_prepare_view('node', array($node->nid => $node), $view_mode);
|
||||
entity_prepare_view('node', array($node->nid => $node));
|
||||
$node->content += field_attach_view('node', $node, $view_mode);
|
||||
$node->content += field_attach_view('node', $node, $view_mode, $langcode);
|
||||
|
||||
// Always display a read more link on teasers because we have no way
|
||||
// to know when a teaser view is different than a full view.
|
||||
|
@ -1299,7 +1315,7 @@ function node_build_content($node, $view_mode = 'full') {
|
|||
);
|
||||
|
||||
// Allow modules to make their own additions to the node.
|
||||
module_invoke_all('node_view', $node, $view_mode);
|
||||
module_invoke_all('node_view', $node, $view_mode, $langcode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2434,15 +2450,19 @@ function node_feed($nids = FALSE, $channel = array()) {
|
|||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $weight
|
||||
* An integer representing the weight of the first node in the list.
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*
|
||||
* @return
|
||||
* An array in the format expected by drupal_render().
|
||||
*/
|
||||
function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0) {
|
||||
function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL) {
|
||||
field_attach_prepare_view('node', $nodes, $view_mode);
|
||||
entity_prepare_view('node', $nodes);
|
||||
$build = array();
|
||||
foreach ($nodes as $node) {
|
||||
$build['nodes'][$node->nid] = node_view($node, $view_mode);
|
||||
$build['nodes'][$node->nid] = node_view($node, $view_mode, $langcode);
|
||||
$build['nodes'][$node->nid]['#weight'] = $weight;
|
||||
$weight++;
|
||||
}
|
||||
|
|
|
@ -599,11 +599,18 @@ function taxonomy_term_delete($tid) {
|
|||
* A term object.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*
|
||||
* @return
|
||||
* An array as expected by drupal_render().
|
||||
*/
|
||||
function taxonomy_term_view($term, $view_mode = 'full') {
|
||||
function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->language;
|
||||
}
|
||||
|
||||
field_attach_prepare_view('taxonomy_term', array($term->tid => $term), $view_mode);
|
||||
entity_prepare_view('taxonomy_term', array($term->tid => $term));
|
||||
|
||||
|
@ -611,9 +618,10 @@ function taxonomy_term_view($term, $view_mode = 'full') {
|
|||
'#theme' => 'taxonomy_term',
|
||||
'#term' => $term,
|
||||
'#view_mode' => $view_mode,
|
||||
'#language' => $langcode,
|
||||
);
|
||||
|
||||
$build += field_attach_view('taxonomy_term', $term, $view_mode);
|
||||
$build += field_attach_view('taxonomy_term', $term, $view_mode, $langcode);
|
||||
|
||||
$build['description'] = array(
|
||||
'#markup' => check_markup($term->description, $term->format, '', TRUE),
|
||||
|
|
|
@ -314,8 +314,10 @@ function hook_user_logout($account) {
|
|||
* The user object on which the operation is being performed.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full'.
|
||||
* @param $langcode
|
||||
* The language code used for rendering.
|
||||
*/
|
||||
function hook_user_view($account, $view_mode) {
|
||||
function hook_user_view($account, $view_mode, $langcode) {
|
||||
if (user_access('create blog content', $account)) {
|
||||
$account->content['summary']['blog'] = array(
|
||||
'#type' => 'user_profile_item',
|
||||
|
|
|
@ -2389,13 +2389,20 @@ function user_view_page($uid) {
|
|||
* A user object.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full'.
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*
|
||||
* @return
|
||||
* An array as expected by drupal_render().
|
||||
*/
|
||||
function user_view($account, $view_mode = 'full') {
|
||||
function user_view($account, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->language;
|
||||
}
|
||||
|
||||
// Retrieve all profile fields and attach to $account->content.
|
||||
user_build_content($account, $view_mode);
|
||||
user_build_content($account, $view_mode, $langcode);
|
||||
|
||||
$build = $account->content;
|
||||
// We don't need duplicate rendering info in account->content.
|
||||
|
@ -2405,6 +2412,7 @@ function user_view($account, $view_mode = 'full') {
|
|||
'#theme' => 'user_profile',
|
||||
'#account' => $account,
|
||||
'#view_mode' => $view_mode,
|
||||
'#language' => $langcode,
|
||||
);
|
||||
|
||||
// Allow modules to modify the structured user.
|
||||
|
@ -2420,18 +2428,25 @@ function user_view($account, $view_mode = 'full') {
|
|||
* A user object.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full'.
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*/
|
||||
function user_build_content($account, $view_mode = 'full') {
|
||||
function user_build_content($account, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->language;
|
||||
}
|
||||
|
||||
// Remove previously built content, if exists.
|
||||
$account->content = array();
|
||||
|
||||
// Build fields content.
|
||||
field_attach_prepare_view('user', array($account->uid => $account), $view_mode);
|
||||
entity_prepare_view('user', array($account->uid => $account));
|
||||
$account->content += field_attach_view('user', $account, $view_mode);
|
||||
$account->content += field_attach_view('user', $account, $view_mode, $langcode);
|
||||
|
||||
// Populate $account->content with a render() array.
|
||||
module_invoke_all('user_view', $account, $view_mode);
|
||||
module_invoke_all('user_view', $account, $view_mode, $langcode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue