| 28 |
$text = apachesolr_strip_ctl_chars($text); |
$text = apachesolr_strip_ctl_chars($text); |
| 29 |
|
|
| 30 |
$document = new Apache_Solr_Document(); |
$document = new Apache_Solr_Document(); |
| 31 |
|
// Comments have their status integers backwards compared to nodes. |
| 32 |
|
// Here we use the logic that the status of the comment is dependent both on the node and |
| 33 |
|
// the comment. If the node is published, we look to see if the comment is published, too. |
| 34 |
|
// If either the node or the comment are not published, the status of the comment |
| 35 |
|
// will get published as 0. |
| 36 |
|
$document->status = $node->status ? $document->status == COMMENT_PUBLISHED ? 1 : 0 : 0; |
| 37 |
|
if ($document->status == 0) { |
| 38 |
|
// don't index unpublished comments. |
| 39 |
|
continue; |
| 40 |
|
} |
| 41 |
$document->id = apachesolr_document_id($comment->cid, 'comment'); |
$document->id = apachesolr_document_id($comment->cid, 'comment'); |
| 42 |
$document->is_cid = $comment->cid; |
$document->is_cid = $comment->cid; |
| 43 |
$document->site = url(NULL, array('absolute' => TRUE)); |
$document->site = url(NULL, array('absolute' => TRUE)); |
| 44 |
$document->hash = apachesolr_site_hash(); |
$document->hash = apachesolr_site_hash(); |
| 45 |
|
|
| 46 |
|
// Since the nid of this comment is set, when the node gets deleted, |
| 47 |
|
// the comment will also get removed from the index. See apachesolr_delete_node_from_index() |
| 48 |
$document->nid = $comment->nid; |
$document->nid = $comment->nid; |
| 49 |
$document->uid = $comment->uid; |
$document->uid = $comment->uid; |
| 50 |
$document->title = apachesolr_clean_text($comment->subject); |
$document->title = apachesolr_clean_text($comment->subject); |
|
$document->status = $node->status; |
|
| 51 |
if (!empty($node->language)) { |
if (!empty($node->language)) { |
| 52 |
$document->language = $node->language; |
$document->language = $node->language; |
| 53 |
} |
} |
| 96 |
$breadcrumb_name = 'apachesolr_commentsearch_breadcrumb_type'; |
$breadcrumb_name = 'apachesolr_commentsearch_breadcrumb_type'; |
| 97 |
} |
} |
| 98 |
|
|
| 99 |
|
function apachesolr_commentsearch_comment(&$a1, $op) { |
| 100 |
|
switch ($op) { |
| 101 |
|
case 'delete': |
| 102 |
|
case 'unpublish': |
| 103 |
|
case 'publish': |
| 104 |
|
case 'update': |
| 105 |
|
// Make sure this comment gets reindexed any time it changes. |
| 106 |
|
$comment = (array) $a1; |
| 107 |
|
$node = node_load($comment['nid']); |
| 108 |
|
apachesolr_nodeapi_update($node); |
| 109 |
|
break; |
| 110 |
|
} |
| 111 |
|
} |
| 112 |
|
|
| 113 |
/** |
/** |
| 114 |
* Return the human readable text for a content type. |
* Return the human readable text for a content type. |
| 115 |
*/ |
*/ |