function _sheetnode_phpexcel_import_callback in Sheetnode 6
Same name and namespace in other branches
- 7.2 modules/sheetnode_phpexcel/sheetnode_phpexcel.import.inc \_sheetnode_phpexcel_import_callback()
- 7 modules/sheetnode_phpexcel/sheetnode_phpexcel.import.inc \_sheetnode_phpexcel_import_callback()
1 string reference to '_sheetnode_phpexcel_import_callback'
- _sheetnode_phpexcel_import_form_submit in modules/
sheetnode_phpexcel/ sheetnode_phpexcel.import.inc
File
- modules/
sheetnode_phpexcel/ sheetnode_phpexcel.import.inc, line 62
Code
function _sheetnode_phpexcel_import_callback($node, $params, &$context) {
$workbook = $context['sandbox']['workbook'];
if ($workbook
->getSheetCount() > 1 && module_exists('book')) {
// Create book if none present.
if (empty($context['sandbox']['book'])) {
global $user;
$book = new StdClass();
$book->type = 'book';
node_object_prepare($book);
$book->title = $workbook
->getProperties()
->getTitle();
if (empty($book->title)) {
$book->title = t('Untitled Workbook');
}
$book->name = $user->name;
$book->book['bid'] = 'new';
$book->book['plid'] = $book->book['mlid'] = NULL;
// Let other modules alter the book or do other work.
drupal_alter('sheetnode_import', $book, $params, $context);
$book = node_submit($book);
node_save($book);
if ($book->nid) {
$context['results'][] = $book->nid;
$context['sandbox']['book'] = $book;
}
}
// Mark the book as parent to the sheetnode.
$book = $context['sandbox']['book'];
$node->book['bid'] = $book->nid;
$node->book['plid'] = $book->book['mlid'];
$node->book['module'] = 'book';
$node->book['weight'] = $context['sandbox']['current'] - 1;
}
}