Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #135 - mehrtägige bzw wiederkehrende Veranstaltungen #144

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions advanced-custom-fields/veranstaltungen.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<?php

/**
Expand Down Expand Up @@ -127,7 +128,7 @@ function cptui_register_my_cpts_veranstaltungen() {
'label' => __('Datum','quartiersplattform'),
'name' => 'event_date',
'type' => 'date_picker',
'instructions' => __('Wann wird deine Veranstaltung stattfinden?','quartiersplattform'),
'instructions' => __('Wann wird deine Veranstaltung stattfinden/beginnen?','quartiersplattform'),
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
Expand Down Expand Up @@ -172,6 +173,50 @@ function cptui_register_my_cpts_veranstaltungen() {
'display_format' => 'H:i',
'return_format' => 'H:i:s',
),
array(
'key' => 'field_5fc8d1ae96113',
'label' => __('Enddatum (bei mehrtägigen Veranstaltungen)','quartiersplattform'),
'name' => 'event_end_date',
'type' => 'date_picker',
'instructions' => __('Wann findet die mehrtägige Veranstaltung zuletzt statt?','quartiersplattform'),
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'display_format' => 'F j, Y',
'return_format' => 'Y-m-d',
'first_day' => 1,
),
array(
'key' => 'field_63137dc0b7174',
'label' => 'Wiederholung',
'name' => 'event_frequency',
'type' => 'select',
'instructions' => __('In welchem Rhytmus findet die Veranstaltung statt?','quartiersplattform'),
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'täglich' => 'täglich',
'wöchentlich' => 'wöchentlich',
'monatlich' => 'monatlich',
'jährlich' => 'jährlich',
),
'default_value' => 'daily',
'allow_null' => 0,
'multiple' => 0,
'ui' => 0,
'return_format' => 'value',
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_5fc8d1c4d15c8',
'label' => __('Website','quartiersplattform'),
Expand Down Expand Up @@ -296,5 +341,5 @@ function cptui_register_my_cpts_veranstaltungen() {
'active' => true,
'description' => '',
));
endif;

endif;
31 changes: 28 additions & 3 deletions components/calendar/calendar_download.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@
$date = get_field('event_date', $post);
$time = get_field('event_time', $post);
$time_end = get_field('event_end_time', $post);
$date_end = get_field('event_end_date', $post);
$frequenz = get_field('event_frequency',$post);

$title = get_the_title();
$start = date('Ymd', strtotime("$date $time")) . "T" . date('His', strtotime("$date $time"));
$ende = date('Ymd', strtotime("$date $time")) . "T" . date('His', strtotime("$date $time_end"));

if (empty($ende) || strtotime($start) > strtotime($ende) ) {
if (empty($time_end) || strtotime($start) > strtotime($ende) ) {
// one hour after start
$ende = date('Ymd', strtotime($start) + (60*60)) . "T" . date('His', strtotime($start) + (60*60));
}

if (!empty($date_end)) {
// Enddatum given
$letzter = date('Ymd', strtotime("$date_end")) . "T" . date('His', strtotime("$ende"));
}
else {
$letzter = $ende;
}

// directory
$links = get_template_directory_uri();
$destination_folder = $_SERVER['DOCUMENT_ROOT'];
Expand All @@ -40,6 +50,21 @@

$kb_start = $start;
$kb_end = $ende;

if($frequenz == 'täglich' ) {
$kb_freq = 'daily';
}
else if($frequenz == 'wöchentlich' ) {
$kb_freq = 'weekly';
}
else if($frequenz == 'monatlich' ) {
$kb_freq = 'monthly';
}
else {
$kb_freq = 'yearly';
}

$kb_until = $letzter;
$kb_current_time = date("Ymd")."T".date("His");
$kb_title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
$kb_location = preg_replace('/([\,;])/','\\\$1',$location);
Expand Down Expand Up @@ -71,7 +96,7 @@
'DTEND:'.$kb_end.$eol.
'LOCATION:'.$kb_location.$eol.
'DTSTAMP:'.$kb_current_time.$eol.
// 'RRULE:FREQ='.$kb_freq.';UNTIL='.ende_der_widerholung.
'RRULE:FREQ='.$kb_freq.';UNTIL='.$kb_until.$eol.
'SUMMARY:'.$kb_title.$eol.
'URL;VALUE=URI:'.$kb_url.$eol.
'DESCRIPTION:'.$kb_description.$eol.
Expand All @@ -84,4 +109,4 @@

?>

<a class="button" href="<?php echo get_bloginfo('template_url') .'/assets/generated/calendar-files/'.$kb_file_name.'.ics' ?>" target="_self"><?php _e('.iCal Herunterladen','quartiersplattform'); ?></a>
<a class="button" href="<?php echo get_bloginfo('template_url') .'/assets/generated/calendar-files/'.$kb_file_name.'.ics' ?>" target="_self"><?php _e('.iCal Herunterladen','quartiersplattform'); ?></a>
6 changes: 4 additions & 2 deletions pages/form-veranstaltungen.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
'field_5fc8d0b28edb0', //Text
'field_5fc8d15b8765b', //Date
'field_5fc8d16e8765c', //Start AP1
'field_5fc8d18b8765d', //End AP1
'field_5fc8d18b8765d', //End AP1
'field_5fc8d1ae96113', //EndDate
'field_63137dc0b7174', //Frequenz
'field_5fc8d1e0d15c9', //Livestream
'field_5fc8d1f4d15ca', //Ticket
'field_5fc8d1c4d15c8', //Website
Expand All @@ -86,4 +88,4 @@

</main><!-- #site-content -->

<?php get_footer(); ?>
<?php get_footer(); ?>
8 changes: 5 additions & 3 deletions pages/single-veranstaltungen.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
// get project by Term
?>
<h2 class="heading-size-3 highlight">
<span class="date"><?php _e('Veranstaltung', 'quartiersplattform'); ?> <br> <?php echo qp_date(get_field('event_date'), true, get_field('event_time')); if (get_field('event_end_time')) echo " ".__('bis','quartiersplattform')." ".qp_date(get_field('event_date'), true, get_field('event_end_time'), true); ?></span>
<span class="date"><?php _e('Veranstaltung', 'quartiersplattform'); ?> <br> <?php echo qp_date(get_field('event_date'), true, get_field('event_time')); if (get_field('event_end_time')) echo " ".__('bis','quartiersplattform')." ".qp_date(get_field('event_date'), true, get_field('event_end_time'), true); ?> <br> <?php if (get_field('event_end_date')) echo "".get_field('event_frequency')." ".__('bis zum','quartiersplattform')." ".qp_date(get_field('event_end_date')); ?></span>
</h2>
<h1 class="heading-size-1 large-margin-bottom"><?php the_title(); ?></h1>

Expand Down Expand Up @@ -197,7 +197,9 @@
'field_5fc8d0b28edb0', //Text
'field_5fc8d15b8765b', //Date
'field_5fc8d16e8765c', //Start
'field_5fc8d18b8765d', //End
'field_5fc8d18b8765d', //End
'field_5fc8d1ae96113', //EndDate
'field_63137dc0b7174', //Frequenz
'field_5fc8d1e0d15c9', //Livestream
'field_5fc8d1f4d15ca', //Ticket
'field_5fc8d1c4d15c8', //Website
Expand Down Expand Up @@ -271,4 +273,4 @@
</main><!-- #site-content -->


<?php get_footer(); ?>
<?php get_footer(); ?>