function word_link_exchange_import_from_taxonomy in Word Link 7
Same name and namespace in other branches
- 8 modules/word_link_exchange/word_link_exchange.module \word_link_exchange_import_from_taxonomy()
- 7.2 modules/word_link_exchange/word_link_exchange.module \word_link_exchange_import_from_taxonomy()
Import links from taxonomy terms to DB.
1 string reference to 'word_link_exchange_import_from_taxonomy'
- word_link_exchange_import_form_submit in modules/
word_link_exchange/ word_link_exchange.module - Submit for word_link_exchange_import_form.
File
- modules/
word_link_exchange/ word_link_exchange.module, line 299 - Code for the Word link exchange module.
Code
function word_link_exchange_import_from_taxonomy($vid, $limit, &$context) {
if (empty($context['sandbox'])) {
$context['sandbox']['progress'] = 0;
$context['sandbox']['max'] = word_link_exchange_get_count_taxonomy_terms($vid);
}
if (empty($context['results'])) {
$context['results']['processed'] = 0;
$context['results']['created'] = 0;
}
$tree = word_link_exchange_get_taxonomy_terms($vid, $context['sandbox']['progress'], $limit);
foreach ($tree as $term) {
$exist = word_link_word_exist($term->name);
if (!$exist) {
$value = array(
'text' => $term->name,
'case_sensitive' => 1,
'url' => 'taxonomy/term/' . $term->tid,
'url_title' => $term->name,
'visibility' => 0,
'except' => NULL,
);
word_link_add_update_link('insert', $value);
$context['results']['created']++;
}
$context['results']['processed']++;
$context['sandbox']['progress']++;
$context['message'] = t('Created @created items. Processed @processed items.', array(
'@created' => $context['results']['created'],
'@processed' => $context['results']['processed'],
));
}
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
}
}