You are here

function word_link_exchange_import_from_file in Word Link 7

Same name and namespace in other branches
  1. 8 modules/word_link_exchange/word_link_exchange.module \word_link_exchange_import_from_file()
  2. 7.2 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 266
Code for the Word link exchange module.

Code

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