/[drupal]/contributions/modules/taxonomy_context/taxonomy_context.theme.inc
ViewVC logotype

Diff of /contributions/modules/taxonomy_context/taxonomy_context.theme.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Tue Oct 13 18:20:38 2009 UTC revision 1.1.2.1, Tue Oct 13 18:20:38 2009 UTC
# Line 0  Line 1 
1    <?php
2    // $Id $
3    
4    /**
5     * @file
6     * Theme functions for Taxonomy Context.
7     */
8    
9    /**
10     * Display related terms.
11     */
12    function theme_taxonomy_context_related($term) {
13      $output = '';
14      if ($term->related) {
15        $output .= '<div class="taxonomy-context-related"><span>'
16          . t('Related') . '</span>: '
17          . check_plain(implode(', ', array_keys($term->related)))
18          . '</div>';
19      }
20      return $output;
21    }
22    
23    /**
24     * Display synonyms for terms.
25     */
26    function theme_taxonomy_context_synonyms($term) {
27      $output = '';
28      if ($term->synonyms) {
29        $output .= '<div class="taxonomy-context-synonyms"><span>'
30          . t('Synonyms') . '</span>: '
31          . check_plain(implode(', ', $term->synonyms))
32          . '</div>';
33      }
34      return $output;
35    }
36    
37    /**
38     * Display subterms.
39     */
40    function theme_taxonomy_context_subterms($terms) {
41      $output = '';
42      if (count($terms)) {
43        foreach ($terms as $term) {
44          taxonomy_context_load('term', $term);
45          $term->subterm = TRUE;
46          $term->teaser = isset($term->description) ? node_teaser($term->description, isset($term->format) ? $term->format : NULL) : '';
47          $term = taxonomy_context_prepare($term, TRUE);
48          $term->links = module_invoke_all('link', 'term', $term);
49          $output .= theme('taxonomy_context_term', $term);
50        }
51      }
52      return $output;
53    }
54    
55    /**
56     * Theme a term output.
57     */
58    function theme_taxonomy_context_term($term) {
59      $indent_char = variable_get('taxonomy_context_subterm_indent', '&mdash;');
60      $show_related = variable_get('taxonomy_context_show_related', 0);
61      $show_synonyms = variable_get('taxonomy_context_show_synonyms', 0);
62      $type = $term->subterm ? 'subterm' : 'term';
63      $output = "<div class=\"$type-container\">\n  <div class=\"$type\">\n";
64      $indent = str_repeat($indent_char, $term->depth) .' ';
65      $img = taxonomy_image_display($term->tid, NULL, NULL, array('wrapper' => TRUE));
66      $name = tt("taxonomy:term:$term->tid:name", $term->name, NULL, TRUE);
67      $level = 2 + $term->subterm;
68      $output .= '<h' . $level . ' class="title">'
69        . $img
70        . $indent
71        . l($name, taxonomy_term_path($term))
72        . "</h$level>";
73      $term->description = tt("taxonomy:term:$term->tid:description", $term->description, NULL, FALSE);
74      $output .= '<div class="' . ($term->teaser ? 'teaser' : 'description') .'">' . $term->description . '</div>';
75    
76      if ($show_related) {
77        $output .= theme('taxonomy_context_related', $term);
78      }
79    
80      if ($show_synonyms) {
81        $output .= theme('taxonomy_context_synonyms', $term);
82      }
83    
84      if ($term->links) {
85        $output .= '<div class="links">'. theme('links', $term->links) . "</div>\n";
86      }
87    
88      if ($node_list = _taxonomy_context_get_titles($term->tid)) {
89        $output .= theme('item_list', $node_list);
90      }
91      $output .= "  </div>\n";
92      $output .= "</div>\n";
93      return $output;
94    }
95    
96    /**
97     * Theme a vocabulary output.
98     */
99    function theme_taxonomy_context_vocabulary($vocabulary) {
100      $output .= "<div class=\"vocabulary-container\">\n";
101      $output .= "  <div class=\"vocabulary\">\n";
102      $output .= '   <div class="description">' . $vocabulary->description . "</div>\n";
103      if ($vocabulary->links) {
104        $output .= '   <div class="links">'. theme('links', $vocabulary->links) . "</div>\n";
105      }
106      if ($vocabulary->terms && is_array($vocabulary->terms)) {
107        foreach ($vocabulary->terms as $term) {
108          $term->subterm = TRUE;
109          $output .= theme('taxonomy_context_term', $term);
110        }
111      }
112      $output .= "  </div>\n";
113      $output .= "</div>\n";
114    
115      return $output;
116    }
117    
118    /**
119     * Theme a list of vocabulary and term links.
120     */
121    function theme_taxonomy_context_vocabulary_list($vocabulary) {
122      $indent_char = variable_get('taxonomy_context_subterm_indent', '&mdash;');
123      $output = '<div class="vocabulary-list-'. $vocabulary->vid .'">';
124      $output .= '<h3 class="title">' . l($vocabulary->name, "taxonomy/vocabulary/$vocabulary->vid") . "</h3>\n";
125      $items = array();
126      foreach ($vocabulary->terms as $term) {
127        // Indent child terms.
128        $indent = str_repeat($indent_char, $term->depth) .' ';
129        $node_list = array();
130        $indent = str_repeat($indent_char, $term->depth) .' ';
131        $img = taxonomy_image_display($term->tid, NULL, NULL, array('wrapper' => TRUE));
132        $name = tt("taxonomy:term:$term->tid:name", $term->name, NULL, TRUE);
133        $items[] = array(
134          'data' => $img . $indent . l($name, taxonomy_term_path($term)),
135          'children' => _taxonomy_context_get_titles($term->tid),
136          'class' => 'vocabulary-list depth-'. $term->depth,
137          );
138      }
139      $output .= theme('item_list', $items);
140      return $output .'</div>';
141    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2