/[drupal]/contributions/themes/andreas02/template.php
ViewVC logotype

Contents of /contributions/themes/andreas02/template.php

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


Revision 1.1 - (show annotations) (download) (as text)
Fri Feb 29 19:44:48 2008 UTC (20 months, 4 weeks ago) by nickbits
Branch: MAIN
CVS Tags: DRUPAL-5--1-3-dev, DRUPAL-5--1-8, DRUPAL-5--1-4, DRUPAL-5--1-7, DRUPAL-5--1-6, DRUPAL-5--1-0, DRUPAL-5--1-2, HEAD
Branch point for: DRUPAL-5, DRUPAL-6--1
File MIME type: text/x-php
Initial release...
1 <?php
2 /** Define the regions **/
3 function andreas02_regions() {
4 return array(
5 'sidebar' => t('sidebar'),
6 'main_block' => t('main_block'),
7 'content' => t('content'),
8 'header' => t('header'),
9 'footer' => t('footer'),
10 );
11 }
12 //Hack to ensure primary menu (the active item) stays highlighted when a secondary item is selested
13 //see http://drupal.org/node/140491
14 function phptemplate_andreas02_primarylinks($links, $attributes = array('class' => 'links')) {
15 $output = '';
16
17 if (count($links) > 0) {
18 $output = '<ul'. drupal_attributes($attributes) .'>';
19
20 $num_links = count($links);
21 $i = 1;
22
23 foreach ($links as $key => $link) {
24 $class = '';
25
26 // Automatically add a class to each link and also to each LI
27 if (isset($link['attributes']) && isset($link['attributes']['class'])) {
28 $link['attributes']['class'] .= ' ' . $key;
29 $class = $key;
30 }
31 else {
32 $link['attributes']['class'] = $key;
33 $class = $key;
34 }
35
36 $explode_array = explode('-',$link['attributes']['class']);
37 if(count($explode_array)== 5)
38 {
39 array_push($explode_array,'active');
40 $link['attributes']['class'] = implode('-',$explode_array);
41 $pos = strrpos($link['attributes']['class'], "-");
42 $link['attributes']['class'] = substr_replace($link['attributes']['class'], ' ', $pos, -6);
43 }
44 // Add first and last classes to the list of links to help out themers.
45 $extra_class = '';
46 if ($i == 1) {
47 $extra_class .= 'first ';
48 }
49 if ($i == $num_links) {
50 $extra_class .= 'last ';
51 }
52 $output .= '<li class="'. $extra_class . $class .'">';
53
54 // Is the title HTML?
55 $html = isset($link['html']) && $link['html'];
56
57 // Initialize fragment and query variables.
58 $link['query'] = isset($link['query']) ? $link['query'] : NULL;
59 $link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
60
61 if (isset($link['href'])) {
62 //$output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
63 $output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, true);
64 }
65 else if ($link['title']) {
66 //Some links are actually not links, but we wrap these in <span> for adding title and class attributes
67 if (!$html) {
68 $link['title'] = check_plain($link['title']);
69 }
70 $output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
71 }
72
73 $i++;
74 $output .= "</li>\n";
75 }
76
77 $output .= '</ul>';
78 }
79
80 return $output;
81 }
82 // split out taxonomy terms by vocabulary
83 //see http://drupal.org/node/133223
84 function andreas02_print_terms($nid) {
85 $vocabularies = taxonomy_get_vocabularies();
86 $output = '';
87 foreach($vocabularies as $vocabulary) {
88 if ($vocabularies) {
89 $terms = taxonomy_node_get_terms_by_vocabulary($nid, $vocabulary->vid);
90 if ($terms) {
91 $links = array();
92 //$output .= '' . $vocabulary->name . ': ';
93 foreach ($terms as $term) {
94 $links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
95 }
96 $output .= implode(', ', $links);
97 }
98 }
99 }
100
101 return $output;
102 }
103 ?>

  ViewVC Help
Powered by ViewVC 1.1.2