function sheetnode_html_import_form_submit in Sheetnode 7
Same name and namespace in other branches
- 6 modules/sheetnode_html/sheetnode_html.module \sheetnode_html_import_form_submit()
- 7.2 modules/sheetnode_html/sheetnode_html.module \sheetnode_html_import_form_submit()
Submit handler for import form.
File
- modules/
sheetnode_html/ sheetnode_html.module, line 47 - Module file for the sheetnode_html module. This extends sheetnodes to enable inmporting of html to sheetnodes.
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->language = LANGUAGE_NONE;
$node->sheetnode['value'] = $sc;
$node->sheetnode['template'] = NULL;
// Let other modules alter the sheetnode or do other work.
$context = array(
'url' => $url,
'querypath' => $querypath,
'options' => $options,
);
$params = array();
drupal_alter('sheetnode_import', $node, $params, $context);
// Save the sheetnode.
$node = node_submit($node);
node_save($node);
if (!empty($node->nid)) {
$form_state['redirect'] = 'node/' . $node->nid;
}
}