| 1 |
<?php |
<?php |
| 2 |
// $Id: rsvp_dateconnector.module,v 1.2.2.9 2009/06/17 19:10:25 ulf1 Exp $ |
// $Id: rsvp_dateconnector.module,v 1.2.2.10 2009/10/14 06:11:20 ulf1 Exp $ |
| 3 |
|
|
| 4 |
|
|
| 5 |
class RsvpDateConnectorImpl extends RsvpConnectorImpl { |
class RsvpDateConnectorImpl extends RsvpConnectorImpl { |
| 29 |
|
|
| 30 |
|
|
| 31 |
//returns startdate as is to use it as hash |
//returns startdate as is to use it as hash |
| 32 |
function get_startdate($node, $field, $pos) { |
function get_startdateAsHash($node, $field, $pos) { |
| 33 |
|
|
| 34 |
$date_value = $node->{$field['field_name']}[$pos]['value']; |
$date_value = $node->{$field['field_name']}[$pos]['value']; |
| 35 |
return $date_value; |
return $date_value; |
| 36 |
/* |
} |
| 37 |
|
|
| 38 |
|
//returns startdate as is to use it as hash |
| 39 |
|
function get_startdateAsUTC($node, $field, $pos) { |
| 40 |
|
|
| 41 |
|
$date_value = $this->get_startdateAsHash($node, $field, $pos); |
| 42 |
|
|
| 43 |
$db_tz = $this->_get_dbtimezone($node, $field, $pos); |
$db_tz = $this->_get_dbtimezone($node, $field, $pos); |
| 44 |
|
|
| 45 |
// Create a date object |
// Create a date object |
| 50 |
$date_utc = date_format($date, 'U'); |
$date_utc = date_format($date, 'U'); |
| 51 |
|
|
| 52 |
return $date_utc; |
return $date_utc; |
|
*/ |
|
|
} |
|
| 53 |
|
|
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
|
| 57 |
//returns startdate as string in local timezone |
//returns startdate as string in local timezone |
| 58 |
function get_startdateAsString($node, $field, $pos) { |
function get_startdateAsString($node, $field, $pos) { |
| 60 |
} |
} |
| 61 |
|
|
| 62 |
//returns enddate in utc form |
//returns enddate in utc form |
| 63 |
function get_enddate($node, $field, $pos) { |
function get_enddateAsUTC($node, $field, $pos) { |
| 64 |
|
|
| 65 |
//if no "toDate" is set, return the "StartDate" of the event instead. |
if ($this->has_enddate($node, $field, $pos) == true) |
| 66 |
if (!isset($node->{$field['field_name']}[$pos]['value2'])) |
{ |
|
$date_value = $this->get_startdate($node, $field, $pos); |
|
|
else |
|
| 67 |
$date_value = $node->{$field['field_name']}[$pos]['value2']; |
$date_value = $node->{$field['field_name']}[$pos]['value2']; |
| 68 |
|
|
| 69 |
$db_tz = $this->_get_dbtimezone($node, $field, $pos); |
$db_tz = $this->_get_dbtimezone($node, $field, $pos); |
| 70 |
|
|
| 71 |
// Create a date object |
// Create a date object |
| 72 |
$date = date_make_date($date_value, $db_tz, $field['type']); |
$date = date_make_date($date_value, $db_tz, $field['type']); |
| 73 |
// Make sure the date object is going to print UTC values. |
// Make sure the date object is going to print UTC values. |
| 74 |
date_timezone_set($date, timezone_open('UTC')); |
date_timezone_set($date, timezone_open('UTC')); |
| 75 |
|
|
| 76 |
$date_utc = date_format($date, 'U'); |
$date_utc = date_format($date, 'U'); |
| 77 |
|
|
| 78 |
return $date_utc; |
return $date_utc; |
| 79 |
|
} |
| 80 |
|
else { |
| 81 |
|
return null; |
| 82 |
|
} |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
//returns if event has a valid enddate |
| 86 |
|
function has_enddate($node, $field, $pos) { |
| 87 |
|
return isset($node->{$field['field_name']}[$pos]['value2']); |
| 88 |
} |
} |
| 89 |
|
|
| 90 |
//returns the position for a particular hash, or -1 if invalid hash |
//returns the position for a particular hash, or -1 if invalid hash |
| 93 |
$count = $this->get_datecount($node, $field); |
$count = $this->get_datecount($node, $field); |
| 94 |
|
|
| 95 |
for ($i = 0; $i < $count; $i++) { |
for ($i = 0; $i < $count; $i++) { |
| 96 |
$unixdate = $this->get_startdate($node, $field, $i); |
$unixdate = $this->get_startdateAsHash($node, $field, $i); |
| 97 |
if ($unixdate == $hash) { |
if ($unixdate == $hash) { |
| 98 |
return $i; |
return $i; |
| 99 |
} |
} |
| 157 |
} |
} |
| 158 |
$date_out = date_format_date($date, 'custom', $format); |
$date_out = date_format_date($date, 'custom', $format); |
| 159 |
|
|
| 160 |
if ($include_to_date) { |
if ($include_to_date && $this->has_enddate($node, $field, $pos)) { |
| 161 |
if (isset($node->{$field['field_name']})) { |
if (isset($node->{$field['field_name']})) { |
| 162 |
$date_value = $node->{$field['field_name']}[$pos]['value2']; |
$date_value = $node->{$field['field_name']}[$pos]['value2']; |
| 163 |
} |
} |