You are here

function globallink_upload_translation_all_form_submit in GlobalLink Connect for Drupal 7.7

File

./globallink_workbench_all_active_submissions.inc, line 878

Code

function globallink_upload_translation_all_form_submit($form, &$form_state) {
  module_load_include('inc', 'globallink', 'globallink_node');
  module_load_include('inc', 'globallink_entity', 'globallink_entity');
  module_load_include('inc', 'globallink', 'globallink');
  $num_files = '';
  if (isset($form_state['values']['upload_data'])) {
    $num_files = count($form_state['values']['upload_data']);
  }
  for ($i = 0; $i < $num_files; $i++) {
    $globallink = array();
    $type = $form_state['values']['upload_data'][$i]['type'];
    $file_path = $form_state['values']['upload_data'][$i]['file']->uri;
    $file_name = $form_state['values']['upload_data'][$i]['file']->filename;
    $contents = file_get_contents($file_path);
    $globallink = $form_state['values']['upload_data'][$i]['data'];
    $globallink->targetXML = $contents;
    if ($type == GLOBALLINK_ENTITY_TYPE_NODE) {
      globallink_import_node($globallink);
      globallink_update_status($globallink);
      drupal_set_message(t($file_name . ' file uploaded and published successfully.'));
    }
    else {
      if ($type == GLOBALLINK_ENTITY_TYPE_ENTITY) {
        globallink_entity_update_entity($globallink);
        globallink_entity_update_status($globallink);
        drupal_set_message(t($file_name . ' file uploaded and published successfully.'));
      }
      else {
        if ($type == GLOBALLINK_ENTITY_TYPE_BLOCK) {
          module_load_include('inc', 'globallink_block', 'globallink_block');
          publish_block($globallink);
          drupal_set_message(t($file_name . ' file uploaded and published successfully.'));
        }
        else {
          if ($type == GLOBALLINK_ENTITY_TYPE_FPP) {
            module_load_include('inc', 'globallink_fieldable_panels', 'globallink_fieldable_panels');
            publish_fpanels($globallink);
            drupal_set_message(t($file_name . ' file uploaded and published successfully.'));
          }
          else {
            if ($type == GLOBALLINK_ENTITY_TYPE_INTERFACE) {
              module_load_include('inc', 'globallink_interface', 'globallink_interface');
              publish_interface($globallink);
              drupal_set_message(t($file_name . ' file uploaded and published successfully.'));
            }
            else {
              if ($type == GLOBALLINK_ENTITY_TYPE_MENU) {
                module_load_include('inc', 'globallink_menu', 'globallink_menu');
                publish_menu($globallink);
                drupal_set_message(t($file_name . ' file uploaded and published successfully.'));
              }
              else {
                if ($type == GLOBALLINK_ENTITY_TYPE_TAXONOMY) {
                  module_load_include('inc', 'globallink_taxonomy', 'globallink_taxonomy');
                  publish_taxonomy($globallink);
                  drupal_set_message(t($file_name . ' file uploaded and published successfully.'));
                }
                else {
                  if ($type == GLOBALLINK_ENTITY_TYPE_WEBFORM) {
                    module_load_include('inc', 'globallink_webform', 'globallink_webform');
                    publish_webform($globallink);
                    drupal_set_message(t($file_name . ' file uploaded and published successfully.'));
                  }
                  else {
                    if ($type == GLOBALLINK_ENTITY_TYPE_BEAN) {
                      module_load_include('inc', 'globallink_beans', 'globallink_beans');
                      publish_bean($globallink);
                      drupal_set_message(t($file_name . 'file uploaded and published successfully'));
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}