Commit 39cc830a authored by alexpott's avatar alexpott

Issue #2008980 by jeroen12345, hussainweb: Replace theme() with drupal_render() in comment module.

parent 0453593c
...@@ -114,6 +114,10 @@ function comment_admin_overview($form, &$form_state, $arg) { ...@@ -114,6 +114,10 @@ function comment_admin_overview($form, &$form_state, $arg) {
// Remove the first node title from the node_titles array and attach to // Remove the first node title from the node_titles array and attach to
// the comment. // the comment.
$node_title = $comment->nid->entity->label(); $node_title = $comment->nid->entity->label();
$username = array(
'#theme' => 'username',
'#account' => comment_prepare_author($comment),
);
$options[$comment->id()] = array( $options[$comment->id()] = array(
'subject' => array( 'subject' => array(
'data' => array( 'data' => array(
...@@ -123,7 +127,7 @@ function comment_admin_overview($form, &$form_state, $arg) { ...@@ -123,7 +127,7 @@ function comment_admin_overview($form, &$form_state, $arg) {
'#options' => array('attributes' => array('title' => truncate_utf8($comment->comment_body->value, 128)), 'fragment' => 'comment-' . $comment->id()), '#options' => array('attributes' => array('title' => truncate_utf8($comment->comment_body->value, 128)), 'fragment' => 'comment-' . $comment->id()),
), ),
), ),
'author' => theme('username', array('account' => comment_prepare_author($comment))), 'author' => drupal_render($username),
'posted_in' => array( 'posted_in' => array(
'data' => array( 'data' => array(
'#type' => 'link', '#type' => 'link',
......
...@@ -535,7 +535,11 @@ function theme_comment_block($variables) { ...@@ -535,7 +535,11 @@ function theme_comment_block($variables) {
} }
if ($items) { if ($items) {
return theme('item_list', array('items' => $items)); $item_list = array(
'#theme' => 'item_list',
'#items' => $items,
);
return drupal_render($item_list);
} }
else { else {
return t('No comments available.'); return t('No comments available.');
...@@ -596,8 +600,12 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_ ...@@ -596,8 +600,12 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_
} }
} }
else { else {
$comment_post_forbidden = array(
'#theme' => 'comment_post_forbidden',
'#node' => $node,
);
$links['comment-forbidden'] = array( $links['comment-forbidden'] = array(
'title' => theme('comment_post_forbidden', array('node' => $node)), 'title' => drupal_render($comment_post_forbidden),
'html' => TRUE, 'html' => TRUE,
); );
} }
...@@ -626,8 +634,12 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_ ...@@ -626,8 +634,12 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_
} }
} }
else { else {
$comment_post_forbidden = array(
'#theme' => 'comment_post_forbidden',
'#node' => $node,
);
$links['comment-forbidden'] = array( $links['comment-forbidden'] = array(
'title' => theme('comment_post_forbidden', array('node' => $node)), 'title' => drupal_render($comment_post_forbidden),
'html' => TRUE, 'html' => TRUE,
); );
} }
...@@ -929,7 +941,11 @@ function comment_links(Comment $comment, EntityInterface $node) { ...@@ -929,7 +941,11 @@ function comment_links(Comment $comment, EntityInterface $node) {
); );
} }
if (empty($links)) { if (empty($links)) {
$links['comment-forbidden']['title'] = theme('comment_post_forbidden', array('node' => $node)); $comment_post_forbidden = array(
'#theme' => 'comment_post_forbidden',
'#node' => $node,
);
$links['comment-forbidden']['title'] = drupal_render($comment_post_forbidden);
$links['comment-forbidden']['html'] = TRUE; $links['comment-forbidden']['html'] = TRUE;
} }
} }
...@@ -1526,7 +1542,11 @@ function template_preprocess_comment(&$variables) { ...@@ -1526,7 +1542,11 @@ function template_preprocess_comment(&$variables) {
$account = comment_prepare_author($comment); $account = comment_prepare_author($comment);
// @todo Do not call theme() here. We do this for purposes of t(). // @todo Do not call theme() here. We do this for purposes of t().
$variables['author'] = theme('username', array('account' => $account)); $username = array(
'#theme' => 'username',
'#account' => $account,
);
$variables['author'] = drupal_render($username);
$variables['new'] = $comment->new->value ? t('new') : ''; $variables['new'] = $comment->new->value ? t('new') : '';
$variables['created'] = format_date($comment->created->value); $variables['created'] = format_date($comment->created->value);
// Avoid calling format_date() twice on the same timestamp. // Avoid calling format_date() twice on the same timestamp.
...@@ -1567,7 +1587,11 @@ function template_preprocess_comment(&$variables) { ...@@ -1567,7 +1587,11 @@ function template_preprocess_comment(&$variables) {
$account_parent = comment_prepare_author($comment_parent); $account_parent = comment_prepare_author($comment_parent);
$variables['parent_comment'] = $comment_parent; $variables['parent_comment'] = $comment_parent;
// @todo Do not call theme() here. We do this for purposes of t(). // @todo Do not call theme() here. We do this for purposes of t().
$variables['parent_author'] = theme('username', array('account' => $account_parent)); $username = array(
'#theme' => 'username',
'#account' => $account_parent,
);
$variables['parent_author'] = drupal_render($username);
$variables['parent_created'] = format_date($comment_parent->created->value); $variables['parent_created'] = format_date($comment_parent->created->value);
// Avoid calling format_date() twice on the same timestamp. // Avoid calling format_date() twice on the same timestamp.
if ($comment_parent->changed->value == $comment_parent->created->value) { if ($comment_parent->changed->value == $comment_parent->created->value) {
......
...@@ -92,7 +92,11 @@ public function form(array $form, array &$form_state) { ...@@ -92,7 +92,11 @@ public function form(array $form, array &$form_state) {
elseif ($user->uid) { elseif ($user->uid) {
$form['author']['name']['#type'] = 'item'; $form['author']['name']['#type'] = 'item';
$form['author']['name']['#value'] = $form['author']['name']['#default_value']; $form['author']['name']['#value'] = $form['author']['name']['#default_value'];
$form['author']['name']['#markup'] = theme('username', array('account' => $user)); $username = array(
'#theme' => 'username',
'#account' => $user,
);
$form['author']['name']['#markup'] = drupal_render($username);
} }
// Add author e-mail and homepage fields depending on the current user. // Add author e-mail and homepage fields depending on the current user.
......
...@@ -61,9 +61,11 @@ function render($values) { ...@@ -61,9 +61,11 @@ function render($values) {
$account = entity_create('user', array()); $account = entity_create('user', array());
$account->name = $this->getValue($values); $account->name = $this->getValue($values);
$account->uid = $values->{$this->uid}; $account->uid = $values->{$this->uid};
return theme('username', array( $username = array(
'account' => $account '#theme' => 'username',
)); '#account' => $account,
);
return drupal_render($username);
} }
else { else {
return $this->sanitizeValue($this->getValue($values)); return $this->sanitizeValue($this->getValue($values));
......
...@@ -54,10 +54,11 @@ function render_link($data, $values) { ...@@ -54,10 +54,11 @@ function render_link($data, $values) {
$account->uid = $this->getValue($values, 'uid'); $account->uid = $this->getValue($values, 'uid');
$account->name = $this->getValue($values); $account->name = $this->getValue($values);
$account->homepage = $this->getValue($values, 'homepage'); $account->homepage = $this->getValue($values, 'homepage');
$username = array(
return theme('username', array( '#theme' => 'username',
'account' => $account '#account' => $account,
)); );
return drupal_render($username);
} }
else { else {
return $data; return $data;
......
...@@ -154,11 +154,13 @@ function render($row) { ...@@ -154,11 +154,13 @@ function render($row) {
$item->elements = $comment->rss_elements; $item->elements = $comment->rss_elements;
$item->cid = $comment->id(); $item->cid = $comment->id();
return theme($this->themeFunctions(), array( $build = array(
'view' => $this->view, '#theme' => $this->themeFunctions(),
'options' => $this->options, '#view' => $this->view,
'row' => $item '#options' => $this->options,
)); '#row' => $item,
);
return drupal_render($build);
} }
} }
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