? 302440-2.patch ? hook_taxonomy_term_load.patch ? taxonomy_list_plus_test.patch ? taxonomy_refactor.patch ? taxonomy_term_load.patch ? term.patch ? term_edit.patch ? unappaproved.patch ? modules/taxonomy/taxonomyrelation ? modules/taxonomy/taxonomysynonyms ? sites/default/files ? sites/default/settings.php Index: modules/forum/forum.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.admin.inc,v retrieving revision 1.12 diff -u -p -r1.12 forum.admin.inc --- modules/forum/forum.admin.inc 16 Jul 2008 21:59:26 -0000 1.12 +++ modules/forum/forum.admin.inc 10 Sep 2008 21:52:52 -0000 @@ -160,7 +160,7 @@ function forum_form_container(&$form_sta * @param $tid ID of the term to be deleted */ function forum_confirm_delete(&$form_state, $tid) { - $term = taxonomy_get_term($tid); + $term = taxonomy_term_load($tid); $form['tid'] = array('#type' => 'value', '#value' => $tid); $form['name'] = array('#type' => 'value', '#value' => $term->name); Index: modules/taxonomy/taxonomy.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v retrieving revision 1.27 diff -u -p -r1.27 taxonomy.admin.inc --- modules/taxonomy/taxonomy.admin.inc 16 Jul 2008 21:59:28 -0000 1.27 +++ modules/taxonomy/taxonomy.admin.inc 10 Sep 2008 21:52:52 -0000 @@ -233,9 +233,9 @@ function taxonomy_admin_vocabulary_edit( /** * Page to edit a vocabulary term. */ -function taxonomy_admin_term_edit($tid) { - if ($term = (array)taxonomy_get_term($tid)) { - return drupal_get_form('taxonomy_form_term', taxonomy_vocabulary_load($term['vid']), $term); +function taxonomy_admin_term_edit($term) { + if (isset($term)) { + return drupal_get_form('taxonomy_form_term', taxonomy_vocabulary_load($term->vid), (array)$term); } return drupal_not_found(); } @@ -835,7 +835,7 @@ function taxonomy_term_confirm_parents(& * @see taxonomy_term_confirm_delete_submit() */ function taxonomy_term_confirm_delete(&$form_state, $tid) { - $term = taxonomy_get_term($tid); + $term = taxonomy_term_load($tid); $form['type'] = array('#type' => 'value', '#value' => 'term'); $form['name'] = array('#type' => 'value', '#value' => $term->name); Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.425 diff -u -p -r1.425 taxonomy.module --- modules/taxonomy/taxonomy.module 24 Jul 2008 16:25:19 -0000 1.425 +++ modules/taxonomy/taxonomy.module 10 Sep 2008 21:52:52 -0000 @@ -142,9 +142,10 @@ function taxonomy_menu() { 'type' => MENU_CALLBACK, ); - $items['admin/content/taxonomy/edit/term'] = array( + $items['admin/content/taxonomy/edit/term/%taxonomy_term'] = array( 'title' => 'Edit term', 'page callback' => 'taxonomy_admin_term_edit', + 'page arguments' => array(5), 'access arguments' => array('administer taxonomy'), 'type' => MENU_CALLBACK, ); @@ -156,6 +157,18 @@ function taxonomy_menu() { 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); + $items['taxonomy/term/%/view'] = array( + 'title' => 'View', + 'type' => MENU_DEFAULT_LOCAL_TASK, + ); + $items['taxonomy/term/%taxonomy_term/edit'] = array( + 'title' => 'Edit term', + 'page callback' => 'taxonomy_admin_term_edit', + 'page arguments' => array(2), + 'access arguments' => array('administer taxonomy'), + 'type' => MENU_LOCAL_TASK, + 'weight' => 10, + ); $items['taxonomy/autocomplete'] = array( 'title' => 'Autocomplete taxonomy', @@ -386,7 +399,7 @@ function taxonomy_del_term($tid) { } } - $term = (array) taxonomy_get_term($tid); + $term = (array) taxonomy_term_load($tid); db_query('DELETE FROM {term_data} WHERE tid = %d', $tid); db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $tid); @@ -745,6 +758,22 @@ function taxonomy_get_related($tid, $key } /** + * Find all parent tids of a given term ID. + */ +function taxonomy_get_parent_tids($tid) { + if ($tid) { + $result = db_query(db_rewrite_sql("SELECT t.tid FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid WHERE h.tid = :tid ORDER BY weight, name", 't', 'tid'), array(':tid' => $tid)); + $parents = array(); + foreach ($result AS $tid) { + drupal_set_message('
' . var_dump($tid->tid) . ''); + + $parents[] = $tid->tid; + } + } + return $parents; +} + +/** * Find all parents of a given term ID. */ function taxonomy_get_parents($tid, $key = 'tid') { @@ -1005,11 +1034,48 @@ function taxonomy_vocabulary_load($vid) * @return Object * A term object. Results are statically cached. */ +function taxonomy_term_load($tid) { + static $terms = array(); + static $vocabularies = array(); + + // Ensure numeric tid to avoid loading the first term on 1+2 URLs. + // The db layer casts '1 2' to '1', so doesn't help here. + if (!is_numeric($tid)) { + return FALSE; + } + + if (!isset($terms[$tid])) { + $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = :tid', array(':tid' => $tid))); + + $term = $terms[$tid]; + $vocabulary = taxonomy_vocabulary_load($term->vid); + if ($vocabulary->hierarchy) { + $term->parents = taxonomy_get_parent_tids($term->tid); + } + module_invoke_all('taxonomy_term_load', $term); + drupal_set_message('
' . var_dump($term) . ''); + $terms[$tid] = $term; + } + return $terms[$tid]; +} + +/** + * Return a term object with name and description. + * @param $tid + * A term's ID + * @return Object + * A term object. Results are statically cached. + */ function taxonomy_get_term($tid) { static $terms = array(); + // Ensure numeric tid to avoid loading the first term on 1+2 URLs. + // The db layer casts '1 2' to '1', so doesn't help here. + if (!is_numeric($tid)) { + return FALSE; + } if (!isset($terms[$tid])) { - $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid)); + $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = :tid', array(':tid' => $tid))); } return $terms[$tid]; Index: modules/taxonomy/taxonomy.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v retrieving revision 1.12 diff -u -p -r1.12 taxonomy.pages.inc --- modules/taxonomy/taxonomy.pages.inc 21 Aug 2008 19:36:38 -0000 1.12 +++ modules/taxonomy/taxonomy.pages.inc 10 Sep 2008 21:52:52 -0000 @@ -51,7 +51,7 @@ function taxonomy_term_page($str_tids = $channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $title; // Only display the description if we have a single term, to avoid clutter and confusion. if (count($tids) == 1) { - $term = taxonomy_get_term($tids[0]); + $term = taxonomy_term_load($tids[0]); // HTML will be removed from feed description, so no need to filter here. $channel['description'] = $term->description; } @@ -92,7 +92,7 @@ function theme_taxonomy_term_page($tids, // Only display the description if we have a single term, to avoid clutter and confusion. if (count($tids) == 1) { - $term = taxonomy_get_term($tids[0]); + $term = taxonomy_term_load($tids[0]); $description = $term->description; // Check that a description is set.