| 1 |
<?php |
<?php |
| 2 |
// $Id: countdown.module,v 1.4.2.1 2008/05/12 13:56:28 deekayen Exp $ |
// $Id: countdown.module,v 1.4.2.3 2008/05/12 15:36:33 deekayen Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Count to or from a specified date and display the output in a block |
* Count to or from a specified date and display the output in a block |
| 43 |
'#size' => 30, |
'#size' => 30, |
| 44 |
'#maxlength' => 200, |
'#maxlength' => 200, |
| 45 |
'#description' => t("Event name you're counting to or from."), |
'#description' => t("Event name you're counting to or from."), |
| 46 |
'#required' => true |
'#required' => TRUE |
| 47 |
|
); |
| 48 |
|
$form['countdown_url'] = array( |
| 49 |
|
'#type' => 'textfield', |
| 50 |
|
'#title' => t('Event URL'), |
| 51 |
|
'#default_value' => variable_get('countdown_url', ''), |
| 52 |
|
'#size' => 30, |
| 53 |
|
'#maxlength' => 200, |
| 54 |
|
'#description' => t("Turn the event description into a link to more information about the event"), |
| 55 |
|
'#required' => FALSE |
| 56 |
); |
); |
| 57 |
|
|
| 58 |
$form['countdown_accuracy'] = array( |
$form['countdown_accuracy'] = array( |
| 129 |
|
|
| 130 |
case 'save': |
case 'save': |
| 131 |
variable_set('countdown_event_name', $edit['countdown_event_name']); |
variable_set('countdown_event_name', $edit['countdown_event_name']); |
| 132 |
|
variable_set('countdown_url', $edit['countdown_url']); |
| 133 |
variable_set('countdown_accuracy', $edit['countdown_accuracy']); |
variable_set('countdown_accuracy', $edit['countdown_accuracy']); |
| 134 |
variable_set('countdown_timestamp', mktime((int)$edit['hour'], (int)$edit['min'], (int)$edit['sec'], (int)$edit['month'], (int)$edit['day'], (int)$edit['year'])); |
variable_set('countdown_timestamp', mktime((int)$edit['hour'], (int)$edit['min'], (int)$edit['sec'], (int)$edit['month'], (int)$edit['day'], (int)$edit['year'])); |
| 135 |
|
|
| 171 |
if ($accuracy == 's') { |
if ($accuracy == 's') { |
| 172 |
$block .= t(', %i seconds', array('%i' => $secs_left)); |
$block .= t(', %i seconds', array('%i' => $secs_left)); |
| 173 |
} |
} |
| 174 |
$block .= t(($passed) ? ' since %s.' : ' until %s.', array('%s' => variable_get('countdown_event_name', ''))); |
|
| 175 |
|
$event_name = variable_get('countdown_event_name', ''); |
| 176 |
|
$url = variable_get('countdown_url', ''); |
| 177 |
|
$event_name = empty($url) || $url == 'http://' ? $event_name : l($event_name, $url, NULL, NULL, NULL, TRUE); |
| 178 |
|
|
| 179 |
|
$block .= t(($passed) ? ' since !s.' : ' until !s.', array('!s' => $event_name)); |
| 180 |
|
|
| 181 |
|
|
| 182 |
if ($accuracy != 'd') { |
if ($accuracy != 'd') { |
| 183 |
$path = drupal_get_path('module', 'countdown'); |
$path = drupal_get_path('module', 'countdown'); |
| 184 |
drupal_add_js($path .'/countdown.js'); |
drupal_add_js($path .'/countdown.js'); |