alchemy_tagging_suggest.module in Alchemy 6
File
modules/alchemy_tagging_suggest/alchemy_tagging_suggest.module
View source
<?php
function alchemy_tagging_suggest_menu() {
$items = array();
$items['admin/settings/alchemy/tagging'] = array(
'title' => t('Alchemy tagging'),
'description' => 'Settings for Alchemy tagging.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'alchemy_tagging_suggest_admin_settings',
),
'access callback' => 'user_access',
'access arguments' => array(
'admin content analysis',
),
'type' => MENU_LOCAL_TASK,
'file' => 'alchemy_tagging_suggest.admin.inc',
);
return $items;
}
function alchemy_tagging_suggest_tagging_suggestions($vid, $node) {
$result = db_query('select * from {term_data} where vid=%d', $vid);
$suggestions = array();
$usecache = variable_get('alchemy_tagging_suggest_usecache', FALSE);
$types = variable_get('alchemy_tagging_suggest_types', alchemy_tagging_suggest_get_types(TRUE));
$terms = array();
$r_min = variable_get('alchemy_tagging_suggest_relevance_min', 50) / 100;
foreach ($types as $type) {
$t = alchemy_get_elements_from_node($node, $type, 'normalized', ALCHEMY_DEBUG || $usecache);
if (is_array($t)) {
foreach ($t as $k => $v) {
if ($v['relevance'] >= $r_min) {
$terms[$k] = $v;
}
}
}
}
foreach ($terms as $v) {
$suggestions[] = array(
'#name' => $v['term'],
);
}
return $suggestions;
}
function alchemy_tagging_suggest_get_types($defaults = FALSE) {
if ($defaults) {
$types = array(
'concepts',
'entities',
'keywords',
);
}
else {
$types = array(
'concepts' => t('Concepts'),
'entities' => t('Entities'),
'keywords' => t('Keywords'),
);
}
return $types;
}