You are here

function sheetnode_html_import_form_submit in Sheetnode 6

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

Submit handler for import form.

File

modules/sheetnode_html/sheetnode_html.module, line 42

Code

function sheetnode_html_import_form_submit($form, &$form_state) {
  module_load_include('inc', 'node', 'node.pages');
  global $user;
  $url = $form_state['values']['url'];
  $querypath = $form_state['values']['querypath'];
  $options = array(
    'ignore_spans' => variable_get('sheetnode_html_ignore_spans', FALSE),
  );
  list($title, $sc) = sheetnode_html_import($url, $querypath, $options);
  $node = new StdClass();
  $node->type = 'sheetnode';
  node_object_prepare($node);
  $node->title = $title;
  $node->name = $user->name;
  $node->sheetnode['value'] = $sc;
  $node->sheetnode['template'] = NULL;

  // Let other modules alter the sheetnode or do other work.
  drupal_alter('sheetnode_import', $node, array(), array(
    'url' => $url,
    'querypath' => $querypath,
    'options' => $options,
  ));

  // Save the sheetnode.
  $node = node_submit($node);
  node_save($node);
  if (!empty($node->nid)) {
    $form_state['redirect'] = 'node/' . $node->nid;
  }
}