/[drupal]/contributions/modules/moviedb/mdb_theme.inc
ViewVC logotype

Contents of /contributions/modules/moviedb/mdb_theme.inc

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


Revision 1.3 - (show annotations) (download) (as text)
Mon Feb 23 20:51:19 2009 UTC (9 months ago) by ultimatedruid
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.2: +51 -42 lines
File MIME type: text/x-php
no message
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Control the theme output
7 */
8 function theme_mdb_movie(&$node) {
9
10 $output = "<div class=\"moviedb\">\n";
11 $output .= "<table width=\"100%\">";
12 $output .= "<tr><td colspan=\"2\">&nbsp;</td></tr>";
13 $output .= "<tr><td width=\"15%\" class=\"mr_cover\" align=\"left\" valign=\"top\">";
14 if ($node->cover) {
15 $output .= " <div class=\"cover\"><img src=\"$node->cover\"></div>\n";
16 }
17 $output .= "</td>";
18 $output .= "<td width=\"85%\" class=\"mr_detail\">";
19 if ($node->actors[0]) {
20 $actors = theme_mdb_movie_people($node->actors);
21 $output .= " <div class=\"label2\">". t("Starring") .": </div><div class=\"content2\">". $actors ."</div>";
22 }
23
24 if ($node->directors[0]) {
25 $directors = theme_mdb_movie_people($node->directors);
26 $output .= " <div class=\"label2\">". t('Directed by') .": </div><div class=\"content2\">". $directors ."</div>\n";
27 }
28 if ($node->writers[0]) {
29 $writers = theme_mdb_movie_people($node->writers);
30 $output .= " <div class=\"label2\">". t('Written by') .": </div><div class=\"content2\">". $writers ."</div>\n";
31 }
32
33 if ($node->producers[0]) {
34 $producers = theme_mdb_movie_people($node->producers);
35 $output .= " <div class=\"label2\">". t('Produced by') .": </div><div class=\"content2\">". $producers ."</div>\n";
36 }
37
38 if ($node->genre) {
39 foreach ($node->genre as $term) {
40 if ($tlist != '') {
41 $tlist .= ', ';
42 }
43 $tlist .= l($term->name, 'taxonomy/term/'. $term->tid);
44 }
45 if ($tlist) {
46 $output .= "<div class=\"label2\">". t('Genre') .": </div><div class=\"content2\">". $tlist ."</div>\n";
47 }
48 }
49
50
51 if ($node->releaseyear) {
52 $output .= " <div class=\"label2\">". t('Year') .": </div><div class=\"content2\">". $node->releaseyear ."</div>\n";
53 }
54 if ($node->country) {
55 $output .= " <div class=\"label2\">". t('Country') .": </div><div class=\"content2\">". $node->country ."</div>\n";
56 }
57 if ($node->language) {
58 $output .= " <div class=\"label2\">". t('Language') .": </div><div class=\"content2\">". $node->language ."</div>\n";
59 }
60 if ($node->runtime) {
61 $output .= " <div class=\"label2\">". t('Runtime') .": </div><div class=\"content2\">". $node->runtime ."</div>\n";
62 }
63 if ($node->imdb) {
64 $output .= " <div class=\"label2\">". t('Imdb') .": </div><div class=\"content2\">"."<a href=\"http://www.imdb.com/title/". $node->imdb ."/\" target=\"_blank\">". $node->imdb ."</a></div>\n";
65 }
66
67
68 $output .= "</td>";
69 $output .= "</tr>";
70 $output .= "<tr><td colspan=\"2\">&nbsp;</td></tr>";
71 $output .= "</table>";
72
73
74 $output .= " \n"; // end of header
75 if ($node->body) {
76 $output .= " <div class=\"synopsis\">\n";
77 $output .= " <span class=\"label4\">". t('Synopsis') ."</span><br />\n";
78 $output .= " <span class=\"content2\">". $node->body ."</span>\n";
79 $output .= " </div><br />\n";
80 }
81 if ($node->movielinks[0]) {
82 $output .= " <div class=\"movielinks\">\n";
83 $output .= " <span class=\"label4\">". t('Related links') .":</span><br />\n";
84 $numlinks = count($node->movielinks);
85 for ($i = 0; $i < $numlinks; $i++) {
86 $movielink = $node->movielinks[$i];
87 $linkdescription = $node->linkdescriptions[$i] ? $node->linkdescriptions[$i] : $node->movielinks[$i];
88 if (ereg('^http://|^https://|ftp://', "$movielink")) {
89 // off site link
90 $movielink = "<a href=\"$movielink\">". check_markup($linkdescription, $node->format) .'</a>';
91 }
92 elseif ($movielink) {
93 // on site link
94 $movielink = l("$linkdescription", "$movielink");
95 }
96 $output .= " <span class=\"content2\">". check_markup($movielink, $node->format) ."</span>\n";
97 }
98 $output .= " </div>\n";
99 }
100 $output .= "</div>"; // end of moviedb
101
102 return $output;
103 }
104
105 /**
106 * Theme function to format people links
107 *
108 */
109 function theme_mdb_movie_people($people) {
110
111 foreach ($people as $person) {
112 if ($return)
113 $return .= ', '. l($person->title, 'node/'. $person->nid);
114 else
115 $return = l($person->title, 'node/'. $person->nid);
116 }
117
118 return $return;
119 }
120
121
122 /**
123 * Formats the person node to show a bigraphy and a filmography
124 *
125 * @param node $node
126 * The node
127 * @return
128 * String of The formatted body
129 */
130 function theme_mdb_person($node) {
131
132 $roles = array();
133
134 if (count($node->actor)) {
135 $items = array();
136 foreach ($node->actor as $movie) {
137 $items[] = l($movie->title .' ('. $movie->releaseyear .')', 'node/'. $movie->nid);
138
139 }
140 $roles[] = theme_item_list($items, t('Actor'), 'ol');
141
142 }
143
144 if (count($node->director)) {
145 $items = array();
146 foreach ($node->director as $movie) {
147 $items[] = l($movie->title .' ('. $movie->releaseyear .')', 'node/'. $movie->nid);
148
149 }
150 $roles[] = theme_item_list($items, t('Director'), 'ol');
151
152 }
153
154 if (count($node->writer)) {
155 $items = array();
156 foreach ($node->writer as $movie) {
157 $items[] = l($movie->title .' ('. $movie->releaseyear .')', 'node/'. $movie->nid);
158
159 }
160 $roles[] = theme_item_list($items, t('Writer'), 'ol');
161
162 }
163
164 if (count($node->producer)) {
165 $items = array();
166 foreach ($node->producer as $movie) {
167 $items[] = l($movie->title .' ('. $movie->releaseyear .')', 'node/'. $movie->nid);
168
169 }
170 $roles[] = theme_item_list($items, t('Producer'), 'ol');
171
172 }
173
174 usort($roles, 'moviedb_person_usort');
175
176 if (!empty($node->body)) {
177
178 $body = '<h2>'. t('Biography') .'</h2>';
179 $body .= check_markup($node->body, $node->format);
180 }
181 else {
182 $body = '';
183 }
184
185 $body .= '<h2>'. t('Filmography') .'</h2>';
186
187 foreach ($roles as $role) {
188 $body .= $role;
189
190 }
191
192 return $body;
193 }

  ViewVC Help
Powered by ViewVC 1.1.2