/[drupal]/contributions/modules/countdown/countdown.tpl.php
ViewVC logotype

Contents of /contributions/modules/countdown/countdown.tpl.php

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


Revision 1.3 - (show annotations) (download) (as text)
Fri May 8 21:55:27 2009 UTC (6 months, 2 weeks ago) by deekayen
Branch: MAIN
CVS Tags: DRUPAL-7--1-0-ALPHA1, HEAD
Changes since 1.2: +11 -6 lines
File MIME type: text/x-php
#402436 - format_plural() output by hop
1 <?php
2 // $Id: countdown.tpl.php,v 1.1.2.2 2008/07/25 16:12:52 deekayen Exp $
3
4 /**
5 * @file countdown.tpl.php
6 *
7 * Theme implementation to display a list of related content.
8 *
9 * Available variables:
10 * - $items: the list.
11 */
12 $time = time();
13 $difference = variable_get('countdown_timestamp', $time) - $time;
14 if ($difference < 0) {
15 $passed = 1;
16 $difference = abs($difference);
17 }
18 else {
19 $passed = 0;
20 }
21
22 $accuracy = variable_get('countdown_accuracy', 'd');
23 $days_left = floor($difference/60/60/24);
24 $hrs_left = floor(($difference - $days_left*60*60*24)/60/60);
25 $min_left = floor(($difference - $days_left*60*60*24 - $hrs_left*60*60)/60);
26 $secs_left = floor(($difference - $days_left*60*60*24 - $hrs_left*60*60 - $min_left*60));
27
28 print format_plural($days_left, '1 day', '@count days');
29 if ($accuracy == 'h' || $accuracy == 'm' || $accuracy == 's') {
30 print format_plural($hrs_left, ', 1 hour', ', @count hours');
31 }
32 if ($accuracy == 'm' || $accuracy == 's') {
33 print format_plural($min_left, ', 1 minute', ', @count minutes');
34 }
35 if ($accuracy == 's') {
36 print format_plural($secs_left, ', 1 second', ', @count seconds');
37 }
38
39 $event_name = variable_get('countdown_event_name', '');
40 $url = variable_get('countdown_url', '');
41 $event_name = empty($url) || $url == 'http://' ? $event_name : l($event_name, $url, array('absolute' => TRUE));
42
43 print t(($passed) ? ' since !s.' : ' until !s.', array('!s' => $event_name));
44
45 if ($accuracy != 'd') {
46 $path = drupal_get_path('module', 'countdown');
47 drupal_add_js($path .'/countdown.js');
48
49 print <<<___EOS___
50 <script type="text/javascript"><!--
51 init_countdown('$accuracy');
52 // --></script>
53 ___EOS___;
54 }

  ViewVC Help
Powered by ViewVC 1.1.2