/[drupal]/contributions/modules/webcomic/webcomic_theme.inc
ViewVC logotype

Contents of /contributions/modules/webcomic/webcomic_theme.inc

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


Revision 1.4 - (show annotations) (download) (as text)
Tue Jan 29 06:21:11 2008 UTC (21 months, 4 weeks ago) by vyoma
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +0 -0 lines
File MIME type: text/x-php
#215354 by Vyoma: Switching on the views integration
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Theme functions for webcomic.module. This is the stuff you'll probably want to override in your own themes.
7 */
8
9 /**
10 * Theme a teaser
11 *
12 * @ingroup themeable
13 */
14 function theme_webcomic_teaser($node) {
15 return l(image_display($node, 'thumbnail'), 'node/'. $node->nid, array(), NULL, NULL, FALSE, TRUE) . $node->teaser;
16 }
17
18 /**
19 * Theme a body
20 *
21 * @ingroup themeable
22 */
23 function theme_webcomic_body($node, $size) {
24 return image_display($node, $size) . $node->body;
25 }
26
27 /**
28 * Prepares the links to children (TOC) and forward/backward
29 * navigation for a node presented as a webcomic page.
30 *
31 * @ingroup themeable
32 */
33 function theme_webcomic_navigation($node) {
34 $output = '<div class="webcomic-navigation">';
35 $output .= theme('webcomic_first_link', $node);
36 $output .= theme('webcomic_prev_link', $node);
37 $output .= theme('webcomic_index_link', $node);
38 $output .= theme('webcomic_next_link', $node);
39 $output .= theme('webcomic_last_link', $node);
40 $output .= '</div>';
41
42 return $output;
43 }
44
45 /**
46 * Theme first link
47 *
48 * @ingroup themeable
49 */
50 function theme_webcomic_first_link($node) {
51 if ($first = webcomic_first($node)) {
52 $path = drupal_get_path('module', 'webcomic') .'/img/go-first.png';
53 drupal_add_link(array('rel' => 'first', 'href' => url('node/'. $first->nid)));
54 return l('<img src="'. $path .'" title="'. t('first') .'" />', 'node/'. $first->nid, array('class' => 'page-first', 'title' => $first->title), NULL, NULL, FALSE, TRUE);
55 }
56 else {
57 $path = drupal_get_path('module', 'webcomic') .'/img/go-first-dim.png';
58 return '<img src="'. $path .'" />';
59 }
60 }
61
62 /**
63 * Theme prev link
64 *
65 * @ingroup themeable
66 */
67 function theme_webcomic_prev_link($node) {
68 if ($prev = webcomic_prev($node)) {
69 $path = drupal_get_path('module', 'webcomic') .'/img/go-previous.png';
70 drupal_add_link(array('rel' => 'prev', 'href' => url('node/'. $prev->nid)));
71 return l('<img src="'. $path .'" title="'. t('previous') .'" />', 'node/'. $prev->nid, array('class' => 'page-prev', 'title' => $prev->title), NULL, NULL, FALSE, TRUE);
72 }
73 else {
74 $path = drupal_get_path('module', 'webcomic') .'/img/go-previous-dim.png';
75 return '<img src="'. $path .'" />';
76 }
77 }
78
79 /**
80 * Theme index link
81 *
82 * @ingroup themeable
83 */
84 function theme_webcomic_index_link($node) {
85 $path = drupal_get_path('module', 'webcomic') .'/img/go-up.png';
86 drupal_add_link(array('rel' => 'index', 'href' => webcomic_index()));
87
88 return l('<img src="'. $path .'" title="'. t('index') .'" />', webcomic_index(), array('class' => 'page-up', 'title' => t('Go to index page')), NULL, NULL, FALSE, TRUE);
89 }
90
91 /**
92 * Theme next link
93 *
94 * @ingroup themeable
95 */
96 function theme_webcomic_next_link($node) {
97 if ($next = webcomic_next($node)) {
98 $path = drupal_get_path('module', 'webcomic') .'/img/go-next.png';
99 drupal_add_link(array('rel' => 'next', 'href' => url('node/' . $next->nid)));
100 return l('<img src="'. $path .'" title="'. t('next') .'" />', 'node/'. $next->nid, array('class' => 'page-next', 'title' => $next->title), NULL, NULL, FALSE, TRUE);
101 }
102 else {
103 $path = drupal_get_path('module', 'webcomic') .'/img/go-next-dim.png';
104 return '<img src="'. $path .'" />';
105 }
106 }
107
108 /**
109 * Theme last link
110 *
111 * @ingroup themeable
112 */
113 function theme_webcomic_last_link($node) {
114 if ($latest = webcomic_last($node)) {
115 $path = drupal_get_path('module', 'webcomic') .'/img/go-last.png';
116 drupal_add_link(array('rel' => 'last', 'href' => url('node/' . $latest->nid)));
117 return l('<img src="'. $path .'" title="'. t('latest') .'" />', 'node/'. $latest->nid, array('class' => 'page-latest', 'title' => $latest->title), NULL, NULL, FALSE, TRUE);
118 } else {
119 $path = drupal_get_path('module', 'webcomic') .'/img/go-last-dim.png';
120 return '<img src="'. $path .'" />';
121 }
122 }
123
124 function _webcomic_is_new_value($value) {
125 static $last;
126 if ($value != $last) {
127 $last = $value;
128 return $value;
129 }
130 else {
131 $path = drupal_get_path('module', 'webcomic') .'/img/go-first-dim.png';
132 return '<img src="'. $path .'" title="'. t('first') .'" />';
133 }
134 }
135
136 /**
137 * Theme strip archive
138 *
139 * @ingroup themeable
140 */
141 function theme_views_view_strip_archive($view, $type, $nodes) {
142 if ($type == 'page') {
143 $output = '';
144
145 // we should only really be switching on these four.
146 switch (variable_get('webcomic_archive_mode', 'strips_month')) {
147 case 'strips':
148 foreach ($nodes as $nid) {
149 $node = node_load($nid->nid);
150 $list[] = theme('webcomic_strip_listing', $node);
151 }
152 $output .= theme('node_list', $list);
153 break;
154
155 case 'strips_month':
156 foreach ($nodes as $nid) {
157 $node = node_load($nid->nid);
158 $month = _webcomic_is_new_value(format_date($node->publish_timestamp, 'custom', 'F Y'));
159 if ($month) {
160 if (is_array($list)) {
161 $output .= theme('node_list', $list);
162 $list = array();
163 }
164 $output .= '<h3 class="date_header">'. $month .'</h3>';
165 }
166 $list[] = theme('webcomic_strip_listing', $node);
167 }
168 $output .= theme('node_list', $list);
169 break;
170
171 case 'strips_year':
172 foreach ($nodes as $nid) {
173 $node = node_load($nid->nid);
174 $year = _webcomic_is_new_value(format_date($node->publish_timestamp, 'custom', 'Y'));
175 if ($year) {
176 if (is_array($list)) {
177 $output .= theme('node_list', $list);
178 $list = array();
179 }
180 $output .= '<h3 class="date_header">'. $year .'</h3>';
181 }
182 $list[] = theme('webcomic_strip_listing', $node);
183 }
184 $output .= theme('node_list', $list);
185 break;
186
187 case 'strips_episode':
188 foreach ($nodes as $nid) {
189 $node = node_load($nid->nid);
190 $episode_nid = _webcomic_is_new_value($node->parent_nid);
191 if ($episode_nid) {
192 if (is_array($list)) {
193 $output .= theme('node_list', $list);
194 $list = array();
195 }
196 $episode = node_load($episode_nid);
197 $output .= theme('webcomic_episode_grouping', $episode);
198 }
199 $list[] = theme('webcomic_strip_listing', $node);
200 }
201 $output .= theme('node_list', $list);
202 break;
203 }
204
205 return "<div class='archive'>$output</div>\n";
206 }
207 else {
208 return theme('views_view', $view, $type, $nodes);
209 }
210 }
211
212 /*
213 * Formatting functions for the line-listing and summary header
214 * views of the assorted node types.
215 */
216
217 /**
218 * Theme strip listing
219 *
220 * @ingroup themeable
221 */
222 function theme_webcomic_strip_listing($node) {
223 return l($node->title, 'node/'. $node->nid);
224 }
225
226 /**
227 * Theme episode listing
228 *
229 * @ingroup themeable
230 */
231 function theme_webcomic_episode_listing($node) {
232 return l($node->title, 'node/'. $node->nid);
233 }
234
235 /**
236 * Theme episode grouping
237 *
238 * @ingroup themeable
239 */
240 function theme_webcomic_episode_grouping($node) {
241 $output .= '<h3 class="episode_header">'. $node->title .'</h3>';
242 $output .= '<p class="episode_teaser">'. $node->teaser .'</p>';
243
244 return $output;
245 }
246
247 /**
248 * Theme storyline listing
249 *
250 * @ingroup themeable
251 */
252 function theme_webcomic_storyline_listing($node) {
253 return l($node->title, 'node/'. $node->nid);
254 }
255
256 /**
257 * Theme storyline grouping
258 *
259 * @ingroup themeable
260 */
261 function theme_webcomic_storyline_grouping($node) {
262 $output .= '<h3 class="storyline_header">'. $node->title .'</h3>';
263 $output .= '<p class="storyline_teaser">'. $node->teaser .'</p>';
264
265 return $output;
266 }

  ViewVC Help
Powered by ViewVC 1.1.2