function quotes_export in Quotes 7
Same name and namespace in other branches
- 5 quotes.module \quotes_export()
- 6 quotes.admin.inc \quotes_export()
Export function page.
Return value
array A form with a tab-delimited list of quotes.
1 string reference to 'quotes_export'
- quotes_menu in ./
quotes.module - Implements hook_menu().
File
- ./
quotes.admin.inc, line 216 - The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.
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_select('node', 'n');
$nr_alias = $sql
->join('node_revision', 'nr', 'nr.vid = n.vid');
$sql
->fields('nr', array(
'title',
));
$frb_alais = $sql
->join('field_revision_body', 'frb', 'frb.revision_id = nr.vid');
$sql
->fields('frb', array(
'body_value',
));
$q_alais = $sql
->join('quotes', 'q', 'q.vid=n.vid');
$sql
->fields('q', array(
'aid',
'citation',
));
$sql
->condition('n.status', 1)
->condition('n.type', 'quotes')
->orderby('q.aid');
$result = $sql
->execute();
$author = '';
$current_aid = 0;
foreach ($result as $row) {
if ($current_aid < $row->aid) {
$current_aid = $row->aid;
$author = db_query("SELECT qa.name FROM {quotes_authors} qa where qa.aid = :current_aid", array(
':current_aid' => $current_aid,
))
->fetchField();
}
$row->author = $author;
++$count;
$output .= _quotes_escape_newlines($row->body_value) . "\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;
}