function apachesolr_commentsearch_node_to_comments in Apache Solr Search 6.2
1 string reference to 'apachesolr_commentsearch_node_to_comments'
- apachesolr_commentsearch_apachesolr_document_handlers in contrib/apachesolr_commentsearch/apachesolr_commentsearch.module
- Implementation of hook_apachesolr_document_handlers().
File
- contrib/apachesolr_commentsearch/apachesolr_commentsearch.module, line 23
Code
function apachesolr_commentsearch_node_to_comments($node, $namespace) {
$documents = array();
$result = db_query("SELECT c.*, u.name AS registered_name FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d", $node->nid);
while ($comment = db_fetch_object($result)) {
$text = check_markup($comment->comment, $comment->format, FALSE);
$document = new Apache_Solr_Document();
$document->status = $node->status ? $comment->status == COMMENT_PUBLISHED ? 1 : 0 : 0;
if ($document->status == 0) {
continue;
}
$document->id = apachesolr_document_id($comment->cid, 'comment');
$document->is_cid = $comment->cid;
$document->ss_thread = $comment->thread;
$document->site = url(NULL, array(
'absolute' => TRUE,
));
$document->hash = apachesolr_site_hash();
$document->entity = 'comment';
$document->nid = $comment->nid;
$document->uid = $comment->uid;
$title = empty($comment->subject) ? $node->title : $comment->subject;
$document->title = apachesolr_clean_text($title);
if (empty($node->language)) {
$document->language = 'und';
}
else {
$document->language = $node->language;
}
$document->body = apachesolr_clean_text($text);
$document->type = 'comment';
$document->type_name = 'Comment';
$timestamp = apachesolr_date_iso($comment->timestamp);
$document->created = $timestamp;
$document->changed = $timestamp;
$last_change = isset($node->last_comment_timestamp) && $node->last_comment_timestamp > $node->changed ? $node->last_comment_timestamp : $node->changed;
$document->last_comment_or_change = apachesolr_date_iso($last_change);
$document->name = $comment->name;
$path = "node/{$node->nid}";
$document->url = url($path, array(
'absolute' => TRUE,
'fragment' => "comment-{$comment->cid}",
));
$document->path = $path;
$documents[] = $document;
}
return $documents;
}