Index: taxonomy_delegate.module =================================================================== --- taxonomy_delegate.module (revision 517) +++ taxonomy_delegate.module (working copy) @@ -26,6 +26,17 @@ } /** + * Implementation of hook_theme(). + */ +function taxonomy_delegate_theme() { + return array( + 'taxonomy_delegate_overview_terms' => array( + 'arguments' => array('vocabulary' => NULL), + ) + ); +} + +/** * Implementation of hook_menu(). */ function taxonomy_delegate_menu() { @@ -41,12 +52,31 @@ 'type' => MENU_LOCAL_TASK, ); - // User admin callback. $items['category_admin'] = array( 'title' => '@name', 'title arguments' => array('@name' => variable_get('taxonomy_delegate_menu', t('Administer My Categories'))), 'page callback' => 'taxonomy_delegate_mycategories', 'access callback' => '_taxonomy_delegate_access', + 'type' => MENU_CALLBACK, + ); + $items['category_admin/list/%'] = array( + 'title' => 'Vocabulary overview', + 'page callback' => 'taxonomy_delegate_mycategories_list', + 'page arguments' => array(2), + 'access callback' => '_taxonomy_delegate_access', + 'type' => MENU_CALLBACK, + ); + $items['category_admin/add/%'] = array( + 'title' => 'Add term', + 'page callback' => 'taxonomy_delegate_mycategories_add', + 'page arguments' => array(2), + 'access callback' => '_taxonomy_delegate_access', + ); + $items['category_admin/edit/%'] = array( + 'title' => 'Edit term', + 'page callback' => 'taxonomy_delegate_mycategories_edit', + 'page arguments' => array(2), + 'access callback' => '_taxonomy_delegate_access', ); // Admin settings. @@ -309,47 +339,8 @@ /** * */ -function taxonomy_delegate_mycategories($op=NULL, $vid=NULL) { - global $user; - $output = NULL; - - // Make sure we should be here to help prevent cheaters typing in the path to avoid legitimate security. - if ($op == 'list') { // Do list stuff. - $vocabs = _taxonomy_delegate_my_vocabularies(); - if (isset($vocabs[$vid])) { - return taxonomy_delegate_overview_terms($vid); - } - else { - drupal_access_denied(); - return; - } - } - - if ($op == 'add') { // Do add stuff. - $vocabs = _taxonomy_delegate_my_vocabularies(); - if (isset($vocabs[$vid])) { - return taxonomy_add_term_page(taxonomy_vocabulary_load($vid)); - } - else { - drupal_access_denied(); - return; - } - } - - if ($op == 'edit') { - // Edit a term (the $vid paramter is actually the tid). - $tid = $vid; - $term = taxonomy_get_term($tid); - $vid = $term->vid; - $vocabs = _taxonomy_delegate_my_vocabularies(); - if (isset($vocabs[$vid])) { - return taxonomy_admin_term_edit($tid); - } - else { - drupal_access_denied(); - return; - } - } +function taxonomy_delegate_mycategories() { + $output = '
'; $vocabs = _taxonomy_delegate_my_vocabularies(); @@ -373,18 +364,63 @@ } /** + * + */ +function taxonomy_delegate_mycategories_list($vid) { + $vocabs = _taxonomy_delegate_my_vocabularies(); + if (isset($vocabs[$vid])) { + $vocabulary = taxonomy_vocabulary_load($vid); + if (!$vocabulary) { + return drupal_not_found(); + } + + drupal_set_title(t('Terms for @vocab', array('@vocab' => $vocabulary->name))); + + return theme('taxonomy_delegate_overview_terms', $vocabulary); + } + else { + drupal_access_denied(); + return; + } +} + +/** + * + */ +function taxonomy_delegate_mycategories_add($vid) { + $vocabs = _taxonomy_delegate_my_vocabularies(); + if (isset($vocabs[$vid])) { + return taxonomy_add_term_page(taxonomy_vocabulary_load($vid)); + } + else { + drupal_access_denied(); + return; + } +} + +/** + * + */ +function taxonomy_delegate_mycategories_edit($tid) { + $term = taxonomy_get_term($tid); + $vid = $term->vid; + $vocabs = _taxonomy_delegate_my_vocabularies(); + if (isset($vocabs[$vid])) { + return taxonomy_admin_term_edit($tid); + } + else { + drupal_access_denied(); + return; + } +} + +/** * Display a tree of all the terms in a vocabulary, with options to edit each one. */ -function taxonomy_delegate_overview_terms($vid) { +function theme_taxonomy_delegate_overview_terms($vid) { $destination = drupal_get_destination(); $use_image = module_exists('taxonomy_image'); - $vocabulary = taxonomy_vocabulary_load($vid); - if (!$vocabulary) { - return drupal_not_found(); - } - - drupal_set_title(t('Terms for @vocab', array('@vocab' => $vocabulary->name))); $output = NULL; if ($vocabulary->tags) {