You are here

function taxonomy_xml_export in Taxonomy import/export via XML 7

Same name and namespace in other branches
  1. 5.2 taxonomy_xml.module \taxonomy_xml_export()
  2. 5 taxonomy_xml.module \taxonomy_xml_export()
  3. 6.2 taxonomy_xml.module \taxonomy_xml_export()
  4. 6 taxonomy_xml.module \taxonomy_xml_export()

Displays an unordered list of all available vocabularies for export.

Return value

array An unordered HTML list

1 string reference to 'taxonomy_xml_export'
taxonomy_xml_menu in ./taxonomy_xml.module
Implements hook_menu().

File

./taxonomy_xml.export.inc, line 13
Helper functions for vocab exports.

Code

function taxonomy_xml_export() {

  // Return the list of vocabularies.
  $output = '';
  $vocabularies = taxonomy_get_vocabularies();
  $format_infos = taxonomy_xml_format_info();
  if (empty($vocabularies)) {
    $output .= t('There are no vocabularies present');
  }
  else {
    $export_table = array();
    foreach ($vocabularies as $vocabulary) {
      $row = array();
      $vocabcount = db_query("SELECT count(*) FROM {taxonomy_term_data} WHERE vid = :vid", array(
        ':vid' => $vocabulary->vid,
      ))
        ->fetchField();
      $row['name'] = $vocabulary->name . ' (' . $vocabcount . ' ' . t('terms') . ')';
      foreach ($format_infos as $format_id => $format_info) {
        if (!empty($format_info['create'])) {
          $link = "taxonomy/vocabulary/" . $vocabulary->vid . "/" . $format_id;
          $link = TAXONOMY_XML_VOCAB_PATH . '/' . $vocabulary->machine_name . '/' . $format_id;
          $description = @$format_info['description'];
          $extra = array(
            'attributes' => array(
              'title' => $description,
            ),
          );
          $row[$format_id] = l($format_info['name'], $link, $extra);
        }
      }
      $export_table[$vocabulary->vid] = $row;
    }
    $output = theme('table', array(
      'rows' => $export_table,
    ));
  }
  return $output;
}