summaryrefslogtreecommitdiffstats
path: root/includes/ical_export.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2022-06-18 11:38:26 +0200
committerHarald Eilertsen <haraldei@anduin.net>2022-06-18 11:38:26 +0200
commit0e42a12a33b9bb193fa7851628edf018bd922362 (patch)
treef01c0f82d0d8399f9c502d769c8e182e3b6df153 /includes/ical_export.php
parentc0ff4d1d2ca7e4226d718bf11a636f431c470fe6 (diff)
downloadgigologadmin-0e42a12a33b9bb193fa7851628edf018bd922362.tar.gz
gigologadmin-0e42a12a33b9bb193fa7851628edf018bd922362.tar.bz2
gigologadmin-0e42a12a33b9bb193fa7851628edf018bd922362.zip
Add phpcs config and do automatic fixups.
Diffstat (limited to 'includes/ical_export.php')
-rw-r--r--includes/ical_export.php65
1 files changed, 30 insertions, 35 deletions
diff --git a/includes/ical_export.php b/includes/ical_export.php
index 9a3b0c0..627c83b 100644
--- a/includes/ical_export.php
+++ b/includes/ical_export.php
@@ -7,46 +7,43 @@
use Kigkonsult\Icalcreator\Vcalendar;
-if ( ! class_exists( "GiglogAdmin_IcalExport" ) )
-{
- class Giglogadmin_IcalExport
- {
- static function textclean(string $txt) : string
- {
- $cleantext = preg_replace("/[^A-Za-z0-9 ]/", "",$txt);
- $cleantext = str_replace(' ','_',$cleantext);
- return($cleantext);
+if ( ! class_exists( 'GiglogAdmin_IcalExport' ) ) {
+ class Giglogadmin_IcalExport {
+
+ static function textclean( string $txt ) : string {
+ $cleantext = preg_replace( '/[^A-Za-z0-9 ]/', '', $txt );
+ $cleantext = str_replace( ' ', '_', $cleantext );
+ return( $cleantext );
}
- public static function export_ical()
- {
- $evid = $_GET['evid'];
+ public static function export_ical() {
+ $evid = $_GET['evid'];
- $concert = GiglogAdmin_Concert::get($evid);
- $cfullname = $concert->cname().' live at '. $concert->venue()->name() .', '.$concert->venue()->city();
- $cshortname=substr($cfullname,0,20);
- $fdate = strtotime($concert->cdate());
- $newformat = date('Ymd',$fdate);
- $filename='Concert '.$concert->venue()->name().' '.$newformat.' '.substr($concert->cname(),0,30);
- $filename=Giglogadmin_IcalExport::textclean($filename);
+ $concert = GiglogAdmin_Concert::get( $evid );
+ $cfullname = $concert->cname() . ' live at ' . $concert->venue()->name() . ', ' . $concert->venue()->city();
+ $cshortname = substr( $cfullname, 0, 20 );
+ $fdate = strtotime( $concert->cdate() );
+ $newformat = date( 'Ymd', $fdate );
+ $filename = 'Concert ' . $concert->venue()->name() . ' ' . $newformat . ' ' . substr( $concert->cname(), 0, 30 );
+ $filename = self::textclean( $filename );
// create a new calendar
- $vcalendar = Vcalendar::factory( [ Vcalendar::UNIQUE_ID => "kigkonsult.se", ] )
+ $vcalendar = Vcalendar::factory( array( Vcalendar::UNIQUE_ID => 'kigkonsult.se' ) )
// with calendaring info
->setMethod( Vcalendar::PUBLISH )
->setXprop(
Vcalendar::X_WR_CALNAME,
- "Calendar Sample"
+ 'Calendar Sample'
)
->setXprop(
Vcalendar::X_WR_CALDESC,
- "Concert ".$cfullname . ""
+ 'Concert ' . $cfullname . ''
)
->setXprop(
Vcalendar::X_WR_RELCALID,
- "3E26604A-50F4-4449-8B3E-E4F4932D05B5"
+ '3E26604A-50F4-4449-8B3E-E4F4932D05B5'
)
->setXprop(
Vcalendar::X_WR_TIMEZONE,
- "Europe/Oslo"
+ 'Europe/Oslo'
);
// create a new event
@@ -55,21 +52,19 @@ if ( ! class_exists( "GiglogAdmin_IcalExport" ) )
->setClass( Vcalendar::P_BLIC )
->setSequence( 1 )
// describe the event
- ->setSummary("".$cfullname."" )
- ->setDescription("".$cfullname."" )
- ->setComment ("".$cfullname."" )
+ ->setSummary( '' . $cfullname . '' )
+ ->setDescription( '' . $cfullname . '' )
+ ->setComment( '' . $cfullname . '' )
// place the event
- ->setLocation( "".$concert->venue()->name() .', '.$concert->venue()->city() ."" )
+ ->setLocation( '' . $concert->venue()->name() . ', ' . $concert->venue()->city() . '' )
// set the time
->setDtstart(
new DateTime(
- $newformat.'T190000',
+ $newformat . 'T190000',
new DateTimezone( 'Europe/Oslo' )
)
)
- ->setDuration ("PT4H")
-
- ;
+ ->setDuration( 'PT4H' );
$vcalendarString =
// apply appropriate Vtimezone with Standard/DayLight components
$vcalendar->vtimezonePopulate()
@@ -77,15 +72,15 @@ if ( ! class_exists( "GiglogAdmin_IcalExport" ) )
->createCalendar();
header( 'Content-Type: text/calendar' );
- header( 'content-disposition: attachment;filename='.$filename.'.ics');
+ header( 'content-disposition: attachment;filename=' . $filename . '.ics' );
echo $vcalendarString;
die();
}
}
/** @psalm-suppress HookNotFound */
- add_action( 'wp_ajax_nopriv_giglog_export_ical', [ 'GiglogAdmin_IcalExport', 'export_ical' ] );
+ add_action( 'wp_ajax_nopriv_giglog_export_ical', array( 'GiglogAdmin_IcalExport', 'export_ical' ) );
/** @psalm-suppress HookNotFound */
- add_action( 'wp_ajax_giglog_export_ical', [ 'GiglogAdmin_IcalExport', 'export_ical' ] );
+ add_action( 'wp_ajax_giglog_export_ical', array( 'GiglogAdmin_IcalExport', 'export_ical' ) );
}