/** * {@inheritdoc} */ public function execute($comment = NULL) { $build = comment_view($comment); $text = drupal_render($build); foreach ($this->configuration['keywords'] as $keyword) { if (strpos($text, $keyword) !== FALSE) { $comment->setPublished(FALSE); $comment->save(); break; } } }
public function render($row) { global $base_url; $cid = $row->{$this->field_alias}; if (!is_numeric($cid)) { return; } $view_mode = $this->options['view_mode']; if ($view_mode == 'default') { $view_mode = \Drupal::config('system.rss')->get('items.view_mode'); } // Load the specified comment and its associated node: /** @var $comment \Drupal\comment\CommentInterface */ $comment = $this->comments[$cid]; if (empty($comment)) { return; } $description_build = []; $comment->link = $comment->url('canonical', array('absolute' => TRUE)); $comment->rss_namespaces = array(); $comment->rss_elements = array(array('key' => 'pubDate', 'value' => gmdate('r', $comment->getCreatedTime())), array('key' => 'dc:creator', 'value' => $comment->getAuthorName()), array('key' => 'guid', 'value' => 'comment ' . $comment->id() . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))); // The comment gets built and modules add to or modify // $comment->rss_elements and $comment->rss_namespaces. $build = comment_view($comment, 'rss'); unset($build['#theme']); if (!empty($comment->rss_namespaces)) { $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $comment->rss_namespaces); } if ($view_mode != 'title') { // We render comment contents. $description_build = $build; } $item = new \stdClass(); $item->description = $description_build; $item->title = $comment->label(); $item->link = $comment->link; // Provide a reference so that the render call in // template_preprocess_views_view_row_rss() can still access it. $item->elements =& $comment->rss_elements; $item->cid = $comment->id(); $build = array('#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item); return $build; }
public function render($row) { global $base_url; $cid = $row->{$this->field_alias}; if (!is_numeric($cid)) { return; } $view_mode = $this->options['view_mode']; if ($view_mode == 'default') { $view_mode = \Drupal::config('system.rss')->get('items.view_mode'); } // Load the specified comment and its associated node: /** @var $comment \Drupal\comment\CommentInterface */ $comment = $this->comments[$cid]; if (empty($comment)) { return; } $item_text = ''; $comment->link = $comment->url('canonical', array('absolute' => TRUE)); $comment->rss_namespaces = array(); $comment->rss_elements = array(array('key' => 'pubDate', 'value' => gmdate('r', $comment->getCreatedTime())), array('key' => 'dc:creator', 'value' => $comment->getAuthorName()), array('key' => 'guid', 'value' => 'comment ' . $comment->id() . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))); // The comment gets built and modules add to or modify // $comment->rss_elements and $comment->rss_namespaces. $build = comment_view($comment, 'rss'); unset($build['#theme']); if (!empty($comment->rss_namespaces)) { $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $comment->rss_namespaces); } // Hide the links if desired. if (!$this->options['links']) { hide($build['links']); } if ($view_mode != 'title') { // We render comment contents and force links to be last. $build['links']['#weight'] = 1000; $item_text .= drupal_render($build); } $item = new \stdClass(); $item->description = $item_text; $item->title = $comment->label(); $item->link = $comment->link; $item->elements = $comment->rss_elements; $item->cid = $comment->id(); $build = array('#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item); return drupal_render($build); }
//comment count if ($comment_count > 0) { $comment_count = $comment_count . ' comment' . ($comment_count == 1 ? '' : 's'); } else { $comment_count = ''; } //most recent comment $query = db_select('comment', 'comment'); $query->innerJoin('node', 'node', 'comment.nid=node.nid'); $query->leftJoin('flag_counts', 'counts', 'comment.cid=counts.entity_id AND counts.fid=3'); $query->fields('comment', array('cid'))->condition('node.nid', $node->nid, '=')->orderBy('counts.count, comment.created', 'DESC')->range(0, 1); $result = $query->execute(); $cid = $result->fetchColumn(); if ($cid > 0) { $comment = comment_load($cid); $comment_rendered = comment_view($comment, $node); $comment_rendered = render($comment_rendered); //$comment_rendered='<div class="top-comment">'.$comment_body.'</div>'; } //comment form $new_comment = new stdClass(); $new_comment->nid = $node->nid; $comment_form = drupal_get_form('comment_form', $new_comment); $path = '/ajax-lb-node' . url('node/' . $node->nid); if ($comment_count > 1) { $link = l(t('View ' . ($comment_count - 1) . ' more comment' . ($comment_count == 2 ? '' : 's')), 'ajax/fetch/comments/' . $node->nid, array('attributes' => array('class' => 'use-ajax'))); /*$more_link=array( '#type' => 'link', '#title' => 'View '.($comment_count-1).' more comment'.($comment_count==2?'':'s'), '#href' => $path, '#ajax' => array(