You are here

function bueditor_export_buttons in BUEditor 6

Same name and namespace in other branches
  1. 5 bueditor.module \bueditor_export_buttons()
  2. 6.2 admin/bueditor.admin.inc \bueditor_export_buttons()
  3. 7 admin/bueditor.admin.inc \bueditor_export_buttons()

Export buttons as CSV.

1 call to bueditor_export_buttons()
bueditor_selaction_submit in ./bueditor.admin.inc
Export or delete selected buttons.

File

./bueditor.admin.inc, line 411

Code

function bueditor_export_buttons($bids = array()) {
  if ($n = count($bids)) {
    $result = db_query("SELECT * FROM {bueditor_buttons} WHERE bid IN (" . str_repeat("%d, ", $n - 1) . "%d) ORDER BY weight, title", $bids);
    while ($button = db_fetch_array($result)) {
      unset($button['bid'], $button['eid']);
      if (!isset($output)) {
        $output = '"' . implode('", "', array_keys($button)) . '"' . "\n";
      }
      $output .= '"' . implode('", "', array_map('addslashes', array_values($button))) . '"' . "\n";
    }
  }
  if (isset($output)) {
    header('Content-type: text/csv; charset=utf-8');
    header('Content-Disposition: attachment; filename=bueditor_buttons.csv');
    print $output;
    exit;
  }
  drupal_set_message(t('There is no button to export.'), 'error');
}