function _glossify_content_process in Glossify 7.4
Content filter process callback for the glossify filter.
1 string reference to '_glossify_content_process'
- glossify_filter_info in ./
glossify.module - Implements hook_filter_info().
File
- ./
glossify.module, line 220 - Glossify module.
Code
function _glossify_content_process($text, $filter, $format, $langcode, $cache, $cache_id) {
//get content types
$types = array_filter($filter->settings['glossify_content_types']);
if (!$types) {
return $text;
}
//get titles
if (!$filter->settings['glossify_content_tooltips']) {
$result = db_query("SELECT nid AS id, title AS name, LOWER(title) AS name_norm FROM {node} WHERE status = 1 AND type IN (:types)", array(
':types' => $types,
));
}
else {
$field_name = $filter->settings['glossify_content_tooltip_field'];
$result = db_query("SELECT n.nid AS id, n.title AS name, LOWER(title) AS name_norm, f." . $field_name . "_value AS tip, f." . $field_name . "_format AS format FROM {node n} LEFT OUTER JOIN {field_data_" . $field_name . " f} ON n.vid = f.revision_id WHERE n.status = 1 AND n.type IN (:types) AND (f.delta = 0 OR f.delta IS NULL)", array(
':types' => $types,
));
}
$terms = $result
->fetchAllAssoc('name_norm');
//process text
if (count($terms) > 0) {
return _glossify_to_links($text, $terms, 'content', $filter->settings['glossify_content_case_sensitivity'], $filter->settings['glossify_content_first_only'], $filter->settings['glossify_content_tooltips']);
}
else {
return $text;
}
}