You are here

function taxonomy_server_menu in Taxonomy import/export via XML 7

Implementation of hook_menu: Define menu links.

File

taxonomy_server/taxonomy_server.module, line 44
Extends taxonomy_xml to publish downloadable or queriable taxonomy vocabularies and terms. Extends the Drupal URLs to make vocabulary information available under /taxonomy/vocabulary and /taxonomy/vocabulary/{vid}.

Code

function taxonomy_server_menu() {
  if (!module_exists('taxonomy_xml')) {
    return;
  }
  $items = array();
  $items['admin/structure/taxonomy/server'] = array(
    'title' => t('Taxonomy server'),
    'description' => t('Taxonomy server settings'),
    'type' => MENU_NORMAL_ITEM,
    'access arguments' => array(
      'administer taxonomy',
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'taxonomy_server_settings',
    ),
  );
  $items['taxonomy/vocabulary'] = array(
    'title' => t('Vocabularies'),
    'access arguments' => array(
      'access vocabularies',
    ),
    'page callback' => 'taxonomy_server_vocabulary_page',
    'type' => MENU_SUGGESTED_ITEM,
  );
  $items['taxonomy/vocabulary/%taxonomy_vocabulary'] = array(
    'title' => t('Vocabulary'),
    'type' => MENU_NORMAL_ITEM,
    'access arguments' => array(
      'access content',
    ),
    'page callback' => 'taxonomy_server_vocabulary_page',
    'page arguments' => array(
      2,
    ),
  );
  $items['taxonomy/vocabulary/%taxonomy_vocabulary/view'] = array(
    'title' => 'View',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 1,
  );

  // Depending on the settings, the data dump is either available
  // invisibly or as a visible tab
  $items['taxonomy/vocabulary/%taxonomy_vocabulary/rdf'] = array(
    'title' => 'RDF',
    'type' => variable_get('taxonomy_xml_show_data_tabs', FALSE) ? MENU_LOCAL_TASK : MENU_CALLBACK,
    'access arguments' => array(
      'access content',
    ),
    'page callback' => 'taxonomy_server_export_vocabulary',
    'page arguments' => array(
      2,
      'rdf',
    ),
    'weight' => 9,
  );

  // Hijack and override the normal taxonomy_term_page
  // to insert content-negotiation!
  // Returns the usual page in usual circumstances, but allows for clients to
  // get other formats too.
  // Copied from taxonomy.module
  $items['taxonomy/term/%taxonomy_term'] = array(
    'title' => 'Taxonomy term',
    'title callback' => 'taxonomy_term_title',
    'title arguments' => array(
      2,
    ),
    'page callback' => 'taxonomy_server_term_page',
    'page arguments' => array(
      2,
    ),
    'access arguments' => array(
      'access content',
    ),
    'type' => MENU_CALLBACK,
  );

  // Export individual taxonomy term information
  // This approach is closer to how rdf.module expects to do it
  $items['taxonomy/term/%taxonomy_term/rdf'] = array(
    'title' => 'RDF',
    'type' => variable_get('taxonomy_xml_show_data_tabs', FALSE) ? MENU_LOCAL_TASK : MENU_CALLBACK,
    'access arguments' => array(
      'access content',
    ),
    'page callback' => 'taxonomy_server_export_term',
    'page arguments' => array(
      2,
      'rdf',
    ),
    'weight' => 9,
  );
  return $items;
}