You are here

function drush_metatag_import_export_csv_metatag_import in Metatag Import Export CSV 7

Drush callback for import operatioon.

File

./metatag_import_export_csv.drush.inc, line 105
Drush command for the module.

Code

function drush_metatag_import_export_csv_metatag_import($filepath, $delimeter) {
  if (empty($filepath)) {
    $filepath = drush_prompt(dt('Enter the path you want the CSV to be imported form'));
  }
  if (empty($delimeter)) {
    $delimeter = drush_choice(metatag_import_export_csv_delimiter_list_drush(), 'Select the delemeter for CSV');
  }
  if (file_exists($filepath)) {
    $file_info = pathinfo($filepath);
    $file_extension = $file_info['extension'];
    if ($file_extension == 'csv') {
      if (drush_confirm('Are you sure you want to import metatags this will replace your old metatags ?')) {
        module_load_include('inc', 'metatag_import_export_csv', 'metatag_import_export_csv_upload_admin');
        metatag_import_export_csv_read_file($filepath, $delimeter);
      }
    }
    else {
      drush_set_error(dt('File type is not CSV .'));
    }
  }
  else {
    drush_set_error(dt('File with the given path does not exists.'));
  }
}