You are here

function word_link_exchange_import_from_file in Word Link 8

Same name and namespace in other branches
  1. 7.2 modules/word_link_exchange/word_link_exchange.module \word_link_exchange_import_from_file()
  2. 7 modules/word_link_exchange/word_link_exchange.module \word_link_exchange_import_from_file()

Import links from file to DB.

1 string reference to 'word_link_exchange_import_from_file'
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 247
Code for the Word link exchange module.

Code

function word_link_exchange_import_from_file($values, &$context) {
  if (empty($context['results'])) {
    $context['results']['created'] = 0;
    $context['results']['processed'] = 0;
  }
  foreach ($values as $value) {
    $exist = word_link_get_link_text($value['text']);
    if (!$exist) {
      $value['except'] = str_replace('|', "\n", str_replace('"', '', trim($value['except'])));
      drupal_write_record('word_link', $value);
      $context['results']['created']++;
    }
    $context['results']['processed']++;
    $context['message'] = t('Created @created items. Processed @processed items.', array(
      '@created' => $context['results']['created'],
      '@processed' => $context['results']['processed'],
    ));
  }
}