Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.480 diff -u -p -r1.480 taxonomy.module --- modules/taxonomy/taxonomy.module 22 Jun 2009 09:10:06 -0000 1.480 +++ modules/taxonomy/taxonomy.module 26 Jun 2009 20:52:32 -0000 @@ -167,15 +167,17 @@ function taxonomy_menu() { 'type' => MENU_LOCAL_TASK, ); - $items['taxonomy/term/%taxonomy_terms'] = array( + $items['taxonomy/term/%taxonomy_term'] = array( 'title' => 'Taxonomy term', + 'title callback' => 'taxonomy_term_title', + 'title arguments' => array(2), 'page callback' => 'taxonomy_term_page', 'page arguments' => array(2), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); - $items['taxonomy/term/%taxonomy_terms/view'] = array( + $items['taxonomy/term/%taxonomy_term/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, ); @@ -188,7 +190,15 @@ function taxonomy_menu() { 'type' => MENU_LOCAL_TASK, 'weight' => 10, ); - + $items['taxonomy/term/%taxonomy_term/feed'] = array( + 'title' => 'Taxonomy term', + 'title callback' => 'taxonomy_term_title', + 'title arguments' => array(2), + 'page callback' => 'taxonomy_term_feed', + 'page arguments' => array(2), + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); $items['taxonomy/autocomplete'] = array( 'title' => 'Autocomplete taxonomy', 'page callback' => 'taxonomy_autocomplete', @@ -1329,17 +1339,6 @@ function taxonomy_vocabulary_load($vid) } /** - * Return array of tids and join operator. - * - * This is a wrapper function for taxonomy_terms_parse_string which is called - * by the menu system when loading a path with taxonomy terms. - */ -function taxonomy_terms_load($str_tids) { - $terms = taxonomy_terms_parse_string($str_tids); - return $terms; -} - -/** * Load multiple taxonomy terms based on certain conditions. * * This function should be used whenever you need to load more than one term @@ -1399,6 +1398,7 @@ function taxonomy_term_load_multiple($ti // $tids still to load, or if $conditions was passed without $tids. if ($tids || ($conditions && !$passed_tids)) { $query = db_select('taxonomy_term_data', 't'); + $query->addTag('term_access'); $query->join('taxonomy_vocabulary', 'v', 't.vid = v.vid'); $taxonomy_term_data = drupal_schema_fields_sql('taxonomy_term_data'); $query->fields('t', $taxonomy_term_data); @@ -1716,32 +1716,6 @@ function taxonomy_node_update_index($nod } /** - * Parses a comma or plus separated string of term IDs. - * - * @param $str_tids - * A string of term IDs, separated by plus or comma. - * comma (,) means AND - * plus (+) means OR - * - * @return an associative array with an operator key (either 'and' - * or 'or') and a tid key containing an array of the term ids. - */ -function taxonomy_terms_parse_string($str_tids) { - $terms = array('operator' => '', 'tids' => array()); - if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_tids)) { - $terms['operator'] = 'or'; - // The '+' character in a query string may be parsed as ' '. - $terms['tids'] = preg_split('/[+ ]/', $str_tids); - } - elseif (preg_match('/^([0-9]+,)*[0-9]+$/', $str_tids)) { - $terms['operator'] = 'and'; - $terms['tids'] = explode(',', $str_tids); - } - $terms['str_tids'] = $str_tids; - return $terms; -} - -/** * Implement hook_help(). */ function taxonomy_help($path, $arg) { @@ -1825,3 +1799,15 @@ function taxonomy_hook_info() { ), ); } + +/** + * Title callback for term pages. + * + * @param $term + * A term object. + * @return + * The term name to be used as the page title. + */ +function taxonomy_term_title($term) { + return check_plain($term->name); +} Index: modules/taxonomy/taxonomy.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v retrieving revision 1.29 diff -u -p -r1.29 taxonomy.pages.inc --- modules/taxonomy/taxonomy.pages.inc 12 Jun 2009 13:59:56 -0000 1.29 +++ modules/taxonomy/taxonomy.pages.inc 26 Jun 2009 20:52:33 -0000 @@ -8,104 +8,72 @@ /** * Menu callback; displays all nodes associated with a term. + * + * @param $term + * The taxonomy term. + * @return + * The page content. */ -function taxonomy_term_page($terms, $depth = 0, $op = 'page') { - if ($terms['operator'] != 'and' && $terms['operator'] != 'or') { - drupal_not_found(); +function taxonomy_term_page($term) { + // Build breadcrumb based on first hierarchy of first term: + $current = (object) array( + 'tid' => $term->tid, + ); + $breadcrumb = array(); + while ($parents = taxonomy_get_parents($current->tid)) { + $current = array_shift($parents); + $breadcrumb[] = l($current->name, taxonomy_term_path($current)); + } + $breadcrumb[] = l(t('Home'), NULL); + $breadcrumb = array_reverse($breadcrumb); + drupal_set_breadcrumb($breadcrumb); + drupal_add_feed(url('taxonomy/term/' . $term->tid . '/feed'), 'RSS - ' . $term->name); + drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css'); + + $build = array(); + $build += field_attach_view('taxonomy_term', $term); + if (!empty($term->description)) { + $build['term_description'] = array( + '#markup' => filter_xss_admin($term->description), + '#weight' => -1, + '#prefix' => '
', - '#markup' => t('There are currently no posts in this category.'), - '#suffix' => '
', - ); - } - - return $build; - - case 'feed': - $channel['link'] = url('taxonomy/term/' . $str_tids . '/' . $depth, array('absolute' => TRUE)); - $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_term_load($tids[0]); - // HTML will be removed from feed description, so no need to filter here. - $channel['description'] = $term->description; - } - $nids = taxonomy_select_nodes($tids, $terms['operator'], $depth, FALSE); + if ($nids = taxonomy_select_nodes(array($term->tid), NULL, TRUE)) { + $nodes = node_load_multiple($nids); + $build += node_build_multiple($nodes); + $build['pager'] = array( + '#markup' => theme('pager', NULL), + '#weight' => 5, + ); + } + else { + $build['no_content'] = array( + '#prefix' => '', + '#markup' => t('There are currently no posts in this category.'), + '#suffix' => '
', + ); + } + return $build; +} - node_feed($nids, $channel); - break; +/** + * Generate the content feed for a taxonomy term. + * + * @param $term + * The taxonomy term. + */ +function taxonomy_term_feed($term) { + $channel['link'] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE)); + $channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $term->name; + // Only display the description if we have a single term, to avoid clutter and confusion. + // HTML will be removed from feed description, so no need to filter here. + $channel['description'] = $term->description; + $nids = taxonomy_select_nodes(array($term->tid, NULL, NULL, FALSE)); - default: - drupal_not_found(); - } - } - else { - drupal_not_found(); - } - } + node_feed($nids, $channel); } /**