Skip to content

Commit

Permalink
merge australia changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Uncle Cheese committed Mar 7, 2011
2 parents 2865ada + 0a62761 commit 6a680b5
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 150 deletions.
12 changes: 1 addition & 11 deletions _config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
require_once(Director::baseFolder().'/event_calendar/code/sfDateTimeToolkit.class.php');
require_once(Director::baseFolder().'/event_calendar/code/CalendarUI.class.php');

if(!class_exists("DataObjectManager"))
user_error(_t('EventCalendar.DATAOBJECTMANAGER','Event Calendar requires the DataObjectManager module.'),E_USER_ERROR);

LeftAndMain::require_javascript('event_calendar/javascript/calendar_interface.js');
LeftAndMain::require_css('event_calendar/css/calendar_cms.css');

Expand All @@ -27,7 +24,6 @@

/**
* Available date format keys
** Start Date **
%{sWeekDayShort} e.g. Mon
%{sWeekDayFull} e.g. Monday
Expand All @@ -40,7 +36,6 @@
%{sMonFull} e.g. October
%{sYearShort} e.g. 09
%{sYearFull} e.g. 2009
** End Date **
%{eWeekDayShort}
%{eWeekDayFull}
Expand All @@ -53,14 +48,12 @@
%{eMonFull}
%{eYearShort}
%{eYearFull}
*/
*/
global $customDateTemplates;
$customDateTemplates = array(
/*
You can modify the date display by assigning new date templates to any of the following
date scenarios. Use the above date format keys.
'OneDay' => '%{sMonShort}. %{sDayNumShort}, %{sYearFull}'
'SameMonthSameYear' => '%{sMonShort}. %{sDayNumShort} - %{eDayNumShort}, %{eYearFull}'
'DiffMonthSameYear' => '%{sMonShort}. %{sDayNumShort} - %{eMonShort}. %{eDayNumShort}, %{eYearFull}'
Expand All @@ -72,6 +65,3 @@
*/
);


?>
53 changes: 29 additions & 24 deletions code/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public function getCMSFields()
$announcements = _t('Calendar.Announcements','Announcements');
$f->addFieldToTab("Root.Content.$announcements", $table);

$table = new DataObjectManager(
$tableClass = class_exists('DataObjectManager') ? 'DataObjectManager' : 'ComplexTableField';
$table = new $tableClass(
$this,
'Feeds',
'ICSFeed',
Expand Down Expand Up @@ -235,23 +236,35 @@ protected function getStandardEvents($filter = null)
$this->getEventJoin()
);
}


protected function getRecurringEvents($filter = null)
{
/**
* Gets all recurring events attached to this calendar and any nested
* calendars.
*
* @param string $filter
* @return DataObjectSet
*/
protected function getRecurringEvents($filter = null) {
$parents = array();

$where = "Recursion = 1 AND ParentID = {$this->ID}";
$where .= $filter !== null ? " AND " . $filter : "";
foreach ($this->getAllCalendars() as $calendar) {
$parents[] = $calendar->ID;
}

$where = sprintf(
'"Recursion" = 1 AND "ParentID" IN (%s)', implode(', ', $parents)
);

if ($filter) $where .= "AND $filter";

return DataObject::get(
$this->getEventClass(),
$where,
"`CalendarDateTime`.StartDate ASC",
$this->getDateJoin()
);

'"CalendarDateTime"."StartDate" ASC',
$this->getDateJoin());
}



protected function addRecurringEvents($recurring_events,$all_events)
{
$date_counter = $this->start_date;
Expand Down Expand Up @@ -681,7 +694,7 @@ public function ics()
}
if(is_numeric($id) && isset($this->urlParams['OtherID'])) {
if(!$feed) {
$event = DataObject::get_by_id($announcement ? $this->getModel()->getEventDateTimeClass() : $this->getModel()->getEventClass(), $id);
$event = DataObject::get_by_id($announcement ? $this->data()->getEventDateTimeClass() : $this->data()->getEventClass(), $id);
$FILENAME = $announcement ? preg_replace("/[^a-zA-Z0-9s]/", "", $event->Title) : $event->URLSegment;
}
else
Expand Down Expand Up @@ -734,7 +747,7 @@ public function RSSLink()

public function rss()
{
$events = $this->getModel()->UpcomingEvents(null,$this->DefaultEventDisplay);
$events = $this->data()->UpcomingEvents(null,$this->DefaultEventDisplay);
foreach($events as $event) {
$event->Title = strip_tags($event->_Dates()) . " : " . $event->EventTitle();
$event->Description = $event->EventContent();
Expand Down Expand Up @@ -778,7 +791,7 @@ public function import()
}
if(isset($event[$dt_start]) && isset($event[$dt_end])) {
list($start_date, $end_date, $start_time, $end_time) = CalendarUtil::date_info_from_ics($event[$dt_start], $event[$dt_end]);
$c = $this->getModel()->getEventDateTimeClass();
$c = $this->data()->getEventDateTimeClass();
$new_date = new $c();
$new_date->StartDate = $start_date;
$new_date->StartTime = $start_time;
Expand Down Expand Up @@ -846,22 +859,14 @@ public function DateHeader()
break;
}
}

public function getModel()
{
$model_class = str_replace("_Controller", "", get_class($this));
return DataObject::get_by_id($model_class,$this->ID);
}


public function Events($filter = null, $announcement_filter = null)
{
if(list($db_clauses,$event_filters,$datetime_filters) = Calendar::getFiltersForDB()) {
$filter = (sizeof($db_clauses > 1)) ? implode(" AND ", $db_clauses) : $db_clauses;
if(!empty($datetime_filters))
$announcement_filter = sizeof($datetime_filters) > 1 ? implode(" AND ", $datetime_filters) : $datetime_filters;
}
return $this->getModel()->Events($filter, $this->start_date, $this->end_date, ($this->view == "default"), null, $announcement_filter);
return $this->data()->Events($filter, $this->start_date, $this->end_date, ($this->view == "default"), null, $announcement_filter);
}

public function CalendarWidget()
Expand Down Expand Up @@ -891,7 +896,7 @@ public function CalendarFilterForm()
$form = new Form(
$this,
'CalendarFilterForm',
$this->getModel()->getFilterFields(),
$this->data()->getFilterFields(),
new FieldSet(
new FormAction('doCalendarFilter',_t('Calendar.FILTER','Filter'))
)
Expand Down
Loading

0 comments on commit 6a680b5

Please sign in to comment.