123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- function taxonomy_term_page($term) {
-
-
-
- drupal_set_title($term->name);
-
- $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/' . $current->tid);
- }
- $breadcrumb[] = l(t('Home'), NULL);
- $breadcrumb = array_reverse($breadcrumb);
- drupal_set_breadcrumb($breadcrumb);
- drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);
-
- $uri = entity_uri('taxonomy_term', $term);
- drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
-
- drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
-
-
-
-
-
- $build['term_heading'] = array(
- '#prefix' => '<div class="term-listing-heading">',
- '#suffix' => '</div>',
- 'term' => taxonomy_term_view($term, 'full'),
- );
- if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) {
- $nodes = node_load_multiple($nids);
- $build += node_view_multiple($nodes);
- $build['pager'] = array(
- '#theme' => 'pager',
- '#weight' => 5,
- );
- }
- else {
- $build['no_content'] = array(
- '#prefix' => '<p>',
- '#markup' => t('There is currently no content classified with this term.'),
- '#suffix' => '</p>',
- );
- }
- return $build;
- }
- function taxonomy_term_feed($term) {
- $channel['link'] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE));
- $channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $term->name;
-
-
- $channel['description'] = check_markup($term->description, $term->format, '', TRUE);
- $nids = taxonomy_select_nodes($term->tid, FALSE, variable_get('feed_default_items', 10));
- node_feed($nids, $channel);
- }
- function taxonomy_autocomplete($field_name = '', $tags_typed = '') {
-
-
- $args = func_get_args();
-
- array_shift($args);
- $tags_typed = implode('/', $args);
-
- if (!($field = field_info_field($field_name)) || $field['type'] !== 'taxonomy_term_reference') {
-
-
- print t('Taxonomy field @field_name not found.', array('@field_name' => $field_name));
- exit;
- }
-
- $tags_typed = drupal_explode_tags($tags_typed);
- $tag_last = drupal_strtolower(array_pop($tags_typed));
- $term_matches = array();
- if ($tag_last != '') {
-
- $vids = array();
- $vocabularies = taxonomy_vocabulary_get_names();
- foreach ($field['settings']['allowed_values'] as $tree) {
- $vids[] = $vocabularies[$tree['vocabulary']]->vid;
- }
- $query = db_select('taxonomy_term_data', 't');
- $query->addTag('translatable');
- $query->addTag('term_access');
-
- if (!empty($tags_typed)) {
- $query->condition('t.name', $tags_typed, 'NOT IN');
- }
-
- $tags_return = $query
- ->fields('t', array('tid', 'name'))
- ->condition('t.vid', $vids)
- ->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
- ->range(0, 10)
- ->execute()
- ->fetchAllKeyed();
- $prefix = count($tags_typed) ? drupal_implode_tags($tags_typed) . ', ' : '';
- foreach ($tags_return as $tid => $name) {
- $n = $name;
-
- if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) {
- $n = '"' . str_replace('"', '""', $name) . '"';
- }
- $term_matches[$prefix . $n] = check_plain($name);
- }
- }
- drupal_json_output($term_matches);
- }
|