You are here

function quotes_export in Quotes 5

Same name and namespace in other branches
  1. 6 quotes.admin.inc \quotes_export()
  2. 7 quotes.admin.inc \quotes_export()

Export function page.

Return value

A form with a tab-delimited list of quotes.

1 string reference to 'quotes_export'
quotes_menu in ./quotes.module
Implementation of hook_menu().

File

./quotes.module, line 1686

Code

function quotes_export() {
  $form['intro'] = array(
    '#type' => 'item',
    '#title' => t('Copy and paste this list to the receiving site.'),
  );
  $output = NULL;
  $count = 0;
  $sql = db_rewrite_sql("SELECT nr.body, nr.title, qa.name AS author, q.citation FROM {node} n INNER JOIN {node_revisions} nr USING (vid) INNER JOIN {quotes} q USING (vid) INNER JOIN {quotes_authors} qa USING (aid) WHERE n.status=1 AND n.type='quotes' ORDER BY qa.name");
  $result = db_query($sql);
  while ($row = db_fetch_object($result)) {
    ++$count;
    $output .= _quotes_escape_newlines($row->body) . "\t" . _quotes_escape_newlines($row->author) . "\t" . _quotes_escape_newlines($row->citation) . "\n";
  }
  drupal_set_message(t('Found !count quotes.', array(
    '!count' => $count,
  )));
  if ($count == 0) {
    $count = 1;
    $output = t('No quotes were found.');
  }
  $form['list'] = array(
    '#type' => 'textarea',
    '#value' => $output,
    '#rows' => min(30, $count),
  );
  return $form;
}