Skip to content

Commit

Permalink
add offset start and end hours #1918
Browse files Browse the repository at this point in the history
  • Loading branch information
Heklaterriol committed Mar 1, 2025
1 parent 19b7d6b commit 774edc0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
52 changes: 32 additions & 20 deletions plugins/plg_content_jemlistevents/jemlistevents.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ class PlgContentJemlistevents extends CMSPlugin
/** all options with their default values
*/
protected static $optionDefaults = array(
'type' => 'unfinished',
'show_featured' => 'off',
'title' => 'on',
'cut_title' => 40,
'show_date' => 'on',
'date_format' => '',
'show_time' => 'on',
'time_format' => '',
'show_enddatetime' => 'off', // for backward compatibility
'catids' => '',
'show_category' => 'off',
'venueids' => '',
'show_venue' => 'off',
'max_events' => '5',
'no_events_msg' => '',
'type' => 'unfinished',
'show_featured' => 'off',
'title' => 'on',
'cut_title' => 40,
'show_date' => 'on',
'date_format' => '',
'show_time' => 'on',
'time_format' => '',
'offset_starthours' => 0,
'show_enddatetime' => 'off', // for backward compatibility
'offset_endhours' => 0,
'catids' => '',
'show_category' => 'off',
'venueids' => '',
'show_venue' => 'off',
'max_events' => '5',
'no_events_msg' => '',
);

/** options we have to convert from numbers to 'on'/'off'
Expand All @@ -57,7 +59,7 @@ class PlgContentJemlistevents extends CMSPlugin
/** all text tokens with their corresponding option
*/
protected static $optionTokens = array( // {jemlistevents
'type' => 'type', // [type=today|unfinished|upcoming|archived|newest|open|all|ongoing];
'type' => 'type', // [type=today|unfinished|ongoing|upcoming|archived|newest|open|all];
'featured' => 'show_featured', // [featured=on|off];
'title' => 'title', // [title=on|link|off];
'cuttitle' => 'cut_title', // [cuttitle=n];
Expand Down Expand Up @@ -245,8 +247,9 @@ protected function _load($parameters)
}

$type = $parameters['type'];
$offset_hourss = 0;

$startoffset = $parameters['offset_starthours'];
$endoffset = $parameters['offset_endhours'];

switch ($type) {
case 'today': // All events starting today.
//$offset_minutes = ($offset_hourss * 60);
Expand All @@ -272,13 +275,22 @@ protected function _load($parameters)
break;
case 'upcoming': // All upcoming events, excl. today.
$timestamp = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$offset_minutes = ($offset_hourss * 60);
// $offset_minutes = ($offset_hourss * 60);
$model->setState('filter.published', 1);
$model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
$to_date = date('Y-m-d', $timestamp);
$where = ' DATEDIFF (a.dates, "'. $to_date .'") > 0';
$model->setState('filter.calendar_to', $where);
break;
case 'ongoing': // All now ongoing events.
//$offset_minutes = ($offset_hourss * 60);
$timestamp = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$model->setState('filter.published', 1);
$model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
$to_date = date('Y-m-d', $timestamp);
$where = ' (DATEDIFF (a.dates, "'. $to_date .'") = 0 AND a.enddates IS null) OR (DATEDIFF (a.dates, "'. $to_date .'") <= 0 AND DATEDIFF (a.enddates, "'. $to_date .'") >= 0)';
$model->setState('filter.calendar_to', $where);
break;
case 'archived': // Archived events only.
$model->setState('filter.published', 2);
$model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC'));
Expand Down Expand Up @@ -352,7 +364,7 @@ protected function _display($rows, $parameters, $listevents_id)
foreach ($rows as $event)
{
$linkdetails = Route::_(JemHelperRoute::getEventRoute($event->slug));
$linkdate = Route::_(JemHelperRoute::getRoute(str_replace('-', '', $event->dates), 'day'));
$linkdate = Route::_(JemHelperRoute::getRoute($event->dates !== null ? str_replace('-', '', $event->dates) : '','day'));
$linkvenue = Route::_(JemHelperRoute::getVenueRoute($event->venueslug));

$html_list .= '<tr class="listevent event'.($n_event + 1).'">';
Expand Down
12 changes: 12 additions & 0 deletions plugins/plg_content_jemlistevents/jemlistevents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
description="PLG_CONTENT_JEMLISTEVENTS_TIME_FORMAT_DESC"
showon="show_time:1"
/>
<field name="offset_starthours" type="text"
size="4"
default=""
label="PLG_CONTENT_JEMLISTEVENTS_OFFSET_STARTHOURS"
description="PLG_CONTENT_JEMLISTEVENTS_OFFSET_STARTHOURS_DESC"
/>
<field name="show_enddatetime" type="radio"
class="btn-group btn-group-yesno"
default="1"
Expand All @@ -106,6 +112,12 @@
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="offset_endhours" type="text"
size="4"
default=""
label="PLG_CONTENT_JEMLISTEVENTS_OFFSET_ENDHOURS"
description="PLG_CONTENT_JEMLISTEVENTS_OFFSET_ENDHOURS_DESC"
/>
<field name="catids" type="text"
size="10"
default=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ PLG_CONTENT_JEMLISTEVENTS_ARCHIVED_EVENTS="Archived events"
PLG_CONTENT_JEMLISTEVENTS_NEWEST_EVENTS="Newest events"
PLG_CONTENT_JEMLISTEVENTS_OPEN_EVENTS="Open date events"
PLG_CONTENT_JEMLISTEVENTS_ALL_EVENTS="All events (except trashed)"
PLG_CONTENT_JEMLISTEVENTS_OFFSET_STARTHOURS="Sart time offset (in hours)"
PLG_CONTENT_JEMLISTEVENTS_OFFSET_STARTHOURS_DESC="Moves display starttime into future (positive values) or into past (negative values)"
PLG_CONTENT_JEMLISTEVENTS_OFFSET_ENDHOURS="End time offset (in hours)"
PLG_CONTENT_JEMLISTEVENTS_OFFSET_ENDHOURS_DESC="Moves display end time into future (positive values) or into past (negative values)"
PLG_CONTENT_JEMLISTEVENTS_FEATURED_LABEL="Featured only"
PLG_CONTENT_JEMLISTEVENTS_FEATURED_DESCRIPTION="Only show featured events accordiung to the settings above"
PLG_CONTENT_JEMLISTEVENTS_TYPE_LABEL="Type of events"
Expand Down

0 comments on commit 774edc0

Please sign in to comment.