You are here

function node_export_gui in Node export 7.3

Same name and namespace in other branches
  1. 6.3 node_export.pages.inc \node_export_gui()

Export GUI function.

Parameters

$nodes: A node, an array of nodes, or an array of nids. @param $format The node export format. @param $delivery The code delivery format, if NULL will use settings. @return The node export form or nothing if calling function to serve file.

2 calls to node_export_gui()
node_export_bulk_operation in ./node_export.module
Callback for use with hook_node_operations().
_node_export_book_run_export in modules/node_export_book/node_export_book.module
Helper function to export a book.
1 string reference to 'node_export_gui'
node_export_menu in ./node_export.module
Implements hook_menu().

File

./node_export.pages.inc, line 289
The Node export pages file.

Code

function node_export_gui($nodes = NULL, $format = NULL, $delivery = NULL) {

  // Get the $code_string.
  if ($nodes) {

    // $nodes passed in, get the code_string.
    $result = node_export($nodes, $format);
    if ($result['success']) {
      $code_string = $result['output'];
    }
    else {
      foreach ($result['output'] as $output) {
        drupal_set_message($output, 'error');
      }
      return;
    }
    $nids = node_export_nodes_to_nids($nodes);
    $format = $result['format'];
  }
  elseif (!empty($_SESSION['node_export'])) {

    // Nids and code string supplied from session.
    $session_data = array_shift($_SESSION['node_export']);
    $code_string = $session_data['code_string'];
    $nids = $session_data['nids'];
    $format = $session_data['format'];
  }
  $delivery = $delivery ? $delivery : variable_get('node_export_code', 'all');
  if ($delivery != 'file') {
    if (is_object($nodes)) {

      // Single node, output straight away.
      drupal_set_title(t('Node export of !title', array(
        '!title' => $nodes->title,
      )));
      return drupal_get_form('node_export_form', $nids, $code_string, $format);
    }
    elseif ($nodes) {

      // Node operation, add to session and redirect.
      $_SESSION['node_export'][] = array(
        'code_string' => $code_string,
        'nids' => $nids,
        'format' => $format,
      );
      drupal_goto('admin/content/node_export');
    }
    elseif (!$nodes) {

      // No $nodes passed, but $code_string came from session.
      return drupal_get_form('node_export_form', $nids, $code_string, $format);
    }
  }
  else {

    // Get file.
    node_export_get_file($nids, $code_string, $format);
  }
}