Skip to content

Commit

Permalink
Full Calendar allDay end date is now exclusive, need to add a day
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed May 11, 2017
1 parent c6193db commit 0f1565c
Showing 1 changed file with 128 additions and 127 deletions.
255 changes: 128 additions & 127 deletions plugins/fabrik_visualization/fullcalendar/models/fullcalendar.php
Expand Up @@ -525,7 +525,14 @@ public function getEvents($listid = '')
$row->startdate = $date->format('Y-m-d H:i:s', true);
}

$date = JFactory::getDate($row->enddate);
$date = JFactory::getDate($row->enddate);

// Full Calendar allDay end date is now exclusive, need to add a day
if ($row->allday)
{
$date->modify('+1 day');
}

$row->enddate = $date->format('Y-m-d H:i:s', true);

if (!$endLocal)
Expand Down Expand Up @@ -555,156 +562,150 @@ public function getEvents($listid = '')
}
}

$params = $this->getParams();
$addEvent = json_encode($jsevents);
$params = $this->getParams();
$addEvent = json_encode($jsevents);

return $addEvent;
}
return $addEvent;
}

/**
* Get the js code to create the legend
*
* @return string
*/
/**
* Get the js code to create the legend
*
* @return string
*/

public
function getLegend()
{
$db = FabrikWorker::getDbo();
$params = $this->getParams();
$this->setupEvents();
$tables = (array) $params->get('fullcalendar_table');
$colour = (array) $params->get('colour');
$legend = (array) $params->get('legendtext');

// @TODO: json encode the returned value and move to the view
$calendar = $this->getRow();
$aLegend = array();
$jsevents = array();

foreach ($this->events as $listid => $record)
public function getLegend()
{
$listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
$listModel->setId($listid);
$table = $listModel->getTable();
$db = FabrikWorker::getDbo();
$params = $this->getParams();
$this->setupEvents();
$tables = (array) $params->get('fullcalendar_table');
$colour = (array) $params->get('colour');
$legend = (array) $params->get('legendtext');

foreach ($record as $data)
{
$rubbish = $table->db_table_name . '___';
$colour = FabrikString::ltrimword($data['colour'], $rubbish);
$legend = FabrikString::ltrimword($data['legendtext'], $rubbish);
$label = (empty($legend)) ? $table->label : $legend;
$aLegend[] = array('label' => $label, 'colour' => $colour);
}
}
// @TODO: json encode the returned value and move to the view
$calendar = $this->getRow();
$aLegend = array();
$jsevents = array();

return $aLegend;
}
foreach ($this->events as $listid => $record)
{
$listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
$listModel->setId($listid);
$table = $listModel->getTable();

/**
* Get calendar js name
*
* @deprecated Use getJSRenderContext() instead
*
* @return NULL
*/
foreach ($record as $data)
{
$rubbish = $table->db_table_name . '___';
$colour = FabrikString::ltrimword($data['colour'], $rubbish);
$legend = FabrikString::ltrimword($data['legendtext'], $rubbish);
$label = (empty($legend)) ? $table->label : $legend;
$aLegend[] = array('label' => $label, 'colour' => $colour);
}
}

public
function getCalName()
{
if (is_null($this->calName))
{
$calendar = $this->getRow();
$this->calName = 'oCalendar' . $calendar->id;
return $aLegend;
}

return $this->calName;
}
/**
* Get calendar js name
*
* @deprecated Use getJSRenderContext() instead
*
* @return NULL
*/

/**
* Update an event - Not working/used!
*
* @return void
*/
public function getCalName()
{
if (is_null($this->calName))
{
$calendar = $this->getRow();
$this->calName = 'oCalendar' . $calendar->id;
}

public
function updateevent()
{
$oPluginManager = FabrikWorker::getPluginManager();
}
return $this->calName;
}

/**
* Delete an event
*
* @return void
*/
/**
* Update an event - Not working/used!
*
* @return void
*/

public
function deleteEvent()
{
$app = JFactory::getApplication();
$input = $app->input;
$id = $input->getInt('id');
$listid = $input->getInt('listid');
if (!empty($id) && !empty($listid))
public function updateevent()
{
$ids = array($id);
$listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
$listModel->setId($listid);
$ok = $listModel->deleteRows($ids);
$oPluginManager = FabrikWorker::getPluginManager();
}
}

/**
* Create the min/max dates between which events can be added.
*
* @return stdClass min/max properties containing sql formatted dates
*/
public
function getDateLimits()
{
$params = $this->getParams();
$limits = new stdClass;
$min = $params->get('limit_min', '');
$max = $params->get('limit_max', '');
/**@@@trob: seems Firefox needs this date format in calendar.js (limits not working with toSQL */
$limits->min = ($min === '') ? '' : JFactory::getDate($min)->toISO8601();
$limits->max = ($max === '') ? '' : JFactory::getDate($max)->toISO8601();

return $limits;
}

/**
* Build the notice which explains between which dates you can add events.
*
* @return string
*/
public
function getDateLimitsMsg()
{
$params = $this->getParams();
$min = $params->get('limit_min', '');
$max = $params->get('limit_max', '');
$msg = '';
$f = FText::_('DATE_FORMAT_LC2');
/**
* Delete an event
*
* @return void
*/

if ($min !== '' && $max === '')
public function deleteEvent()
{
$msg = '<br />' . JText::sprintf('PLG_VISUALIZATION_FULLCALENDAR_LIMIT_AFTER', JFactory::getDate($min)->format($f));
$app = JFactory::getApplication();
$input = $app->input;
$id = $input->getInt('id');
$listid = $input->getInt('listid');
if (!empty($id) && !empty($listid))
{
$ids = array($id);
$listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
$listModel->setId($listid);
$ok = $listModel->deleteRows($ids);
}
}

if ($min === '' && $max !== '')
/**
* Create the min/max dates between which events can be added.
*
* @return stdClass min/max properties containing sql formatted dates
*/
public function getDateLimits()
{
$msg = '<br />' . JText::sprintf('PLG_VISUALIZATION_FULLCALENDAR_LIMIT_BEFORE', JFactory::getDate($max)->format($f));
$params = $this->getParams();
$limits = new stdClass;
$min = $params->get('limit_min', '');
$max = $params->get('limit_max', '');
/**@@@trob: seems Firefox needs this date format in calendar.js (limits not working with toSQL */
$limits->min = ($min === '') ? '' : JFactory::getDate($min)->toISO8601();
$limits->max = ($max === '') ? '' : JFactory::getDate($max)->toISO8601();

return $limits;
}

if ($min !== '' && $max !== '')
/**
* Build the notice which explains between which dates you can add events.
*
* @return string
*/
public function getDateLimitsMsg()
{
$min = JFactory::getDate($min)->format($f);
$max = JFactory::getDate($max)->format($f);
$msg = '<br />' . JText::sprintf('PLG_VISUALIZATION_FULLCALENDAR_LIMIT_RANGE', $min, $max);
}
$params = $this->getParams();
$min = $params->get('limit_min', '');
$max = $params->get('limit_max', '');
$msg = '';
$f = FText::_('DATE_FORMAT_LC2');

return $msg;
}
if ($min !== '' && $max === '')
{
$msg = '<br />' . JText::sprintf('PLG_VISUALIZATION_FULLCALENDAR_LIMIT_AFTER', JFactory::getDate($min)->format($f));
}

if ($min === '' && $max !== '')
{
$msg = '<br />' . JText::sprintf('PLG_VISUALIZATION_FULLCALENDAR_LIMIT_BEFORE', JFactory::getDate($max)->format($f));
}

if ($min !== '' && $max !== '')
{
$min = JFactory::getDate($min)->format($f);
$max = JFactory::getDate($max)->format($f);
$msg = '<br />' . JText::sprintf('PLG_VISUALIZATION_FULLCALENDAR_LIMIT_RANGE', $min, $max);
}

return $msg;
}
}

0 comments on commit 0f1565c

Please sign in to comment.