You are here

function sheetnode_html_import in Sheetnode 7.2

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

API function to import a URL.

1 call to sheetnode_html_import()
sheetnode_html_import_form_submit in modules/sheetnode_html/sheetnode_html.module
Submit handler for import form.

File

modules/sheetnode_html/sheetnode_html.module, line 91
Module file for the sheetnode_html module.

Code

function sheetnode_html_import($url, $querypath, $options = array()) {
  module_load_include('inc', 'sheetnode', 'socialcalc');
  $doc = new DOMDocument('1.0');
  @$doc
    ->loadHTMLFile($url);
  $qp = htmlqp($doc);
  $title = $qp
    ->top('title')
    ->text();
  $sheet = array();
  foreach ($qp
    ->top($querypath) as $table) {
    sheetnode_html_import_table($table, $sheet, $options);
  }
  $socialcalc = array(
    'sheet' => $sheet,
    'edit' => socialcalc_default_edit($sheet),
    'audit' => socialcalc_default_audit($sheet),
  );
  return array(
    $title,
    socialcalc_save($socialcalc),
  );
}