コード例 #1
0
ファイル: ComponentTest.php プロジェクト: reinvented/levees
 public function testDescriptionWithNewLines()
 {
     $input = "new string \n new line \n new line \n new string";
     $vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
     $vEvent = new \Eluceo\iCal\Component\Event();
     $vEvent->setDtStart(new \DateTime('2014-12-24'));
     $vEvent->setDtEnd(new \DateTime('2014-12-24'));
     $vEvent->setDescription($input);
     $vCalendar->addComponent($vEvent);
     $output = $vCalendar->render();
     $this->assertContains($input, $output);
 }
コード例 #2
0
ファイル: ComponentTest.php プロジェクト: eluceo/ical
 public function testFoldWithMultibyte()
 {
     $input = "x" . str_repeat("あいうえお", 5);
     $vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
     $vEvent = new \Eluceo\iCal\Component\Event();
     $vEvent->setDtStart(new \DateTime('2012-12-24'));
     $vEvent->setDtEnd(new \DateTime('2012-12-24'));
     $vEvent->setDescription($input);
     $vCalendar->addEvent($vEvent);
     $output = $vCalendar->render();
     $output = preg_replace('/\\r\\n /u', '', $output);
     $this->assertContains($input, $output);
 }
コード例 #3
0
 /**
  * Renders an ical file for a specific group
  */
 public function group(Group $group)
 {
     // 1. Create new calendar
     $vCalendar = new \Eluceo\iCal\Component\Calendar(config('app.url'));
     $vCalendar->setName(config('mobilizator.name') . ' : ' . $group->name);
     $vCalendar->setDescription(summary($group->body, 500));
     // returns actions started the last 60 days
     $actions = $group->actions()->where('start', '>=', Carbon::now()->subDays(60))->get();
     foreach ($actions as $action) {
         // 2. Create an event
         $vEvent = new \Eluceo\iCal\Component\Event();
         $vEvent->setDtStart($action->start);
         $vEvent->setDtEnd($action->stop);
         $vEvent->setSummary($action->name);
         $vEvent->setDescription(summary($action->body), 1000);
         $vEvent->setLocation($action->location);
         $vEvent->setUrl(action('ActionController@show', [$action->group->id, $action->id]));
         $vEvent->setUseUtc(false);
         //TODO fixme
         $vCalendar->addComponent($vEvent);
     }
     return response($vCalendar->render())->header('Content-Type', 'text/calendar; charset=utf-8')->header('Content-Disposition', 'attachment; filename="cal.ics"');
 }
コード例 #4
0
<?php

// use composer autoloader
require_once __DIR__ . '/../vendor/autoload.php';
// set default timezone (PHP 5.4)
date_default_timezone_set('Europe/Berlin');
// 1. Create new calendar
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
// 2. Create an event
$vEvent = new \Eluceo\iCal\Component\Event();
$vEvent->setDtStart(new \DateTime('2012-12-24'));
$vEvent->setDtEnd(new \DateTime('2012-12-24'));
$vEvent->setNoTime(true);
$vEvent->setSummary('Christmas');
$vEvent->setDescription('Happy Christmas!');
$vEvent->setDescriptionHTML('<b>Happy Christmas!</b>');
// add some location information for apple devices
$vEvent->setLocation("Infinite Loop\nCupertino CA 95014", 'Infinite Loop', '37.332095,-122.030743');
// 3. Add event to calendar
$vCalendar->addComponent($vEvent);
// 4. Set headers
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="cal.ics"');
// 5. Output
echo $vCalendar->render();
コード例 #5
0
 public function generateIcal()
 {
     // set default timezone (PHP 5.4)
     date_default_timezone_set('Europe/Berlin');
     $ical_name = 'HSG Wesel - Gesamtspielplan';
     $ical_calid = 'hsg_wesel_1516_total';
     $ics_file_name = 'hsg_wesel_1516_total.ics';
     $team_info = $this->getTeamInfo();
     if (is_array($team_info)) {
         $ical_name = 'HSG Wesel - Saison 2015/16 - ' . $team_info['team'];
         $ical_calid = 'hsg_wesel_1516_' . $team_info['liga_id'];
         $ics_file_name = 'hsg_wesel_1516_' . $this->getTeam() . '.ics';
     } else {
         switch ($this->art) {
             case '188':
                 $ical_name = 'HSG Wesel - Saison 2015/16 - Spielplan Heim';
                 $ical_calid = 'hsg_wesel_1516_1330105011_heim';
                 $ics_file_name = 'hsg_wesel_1516_spielplan_heim' . '.ics';
                 break;
             case '199':
                 $ical_name = 'HSG Wesel - Saison 2015/16 - Spielplan Auswärts';
                 $ical_calid = 'hsg_wesel_1516_1330105011_auswaerts';
                 $ics_file_name = 'hsg_wesel_1516_auswaerts' . '.ics';
                 break;
         }
     }
     // 1. Create new calendar
     $vCalendar = new \Eluceo\iCal\Component\Calendar('HSG Wesel SIS-Handball ICS-Generator');
     $vCalendar->setName($ical_name);
     $vCalendar->setDescription('HSG Wesel / photominister.de');
     $vCalendar->setCalId($ical_calid);
     $vCalendar->setMethod('PUBLISH');
     // 2. Create an event
     // $this->framework->dump($this->art);
     if (count($this->xml->Spiel) > 0) {
         foreach ($this->xml->Spiel as $spiel) {
             $element = $this->getHash($spiel);
             $show_heim = substr($spiel->Heim, 0, 9) == 'HSG Wesel';
             $show_gast = substr($spiel->Gast, 0, 9) == 'HSG Wesel';
             switch ($this->art) {
                 case '188':
                     $cond = $show_heim;
                     break;
                 case '199':
                     $cond = $show_gast;
                     break;
                 default:
                     $cond = $show_heim || $show_gast;
                     break;
             }
             if ($cond) {
                 $description = $spiel->LigaName . '..... www.hsg-wesel.de ..... www.handballinwesel.de ..... www.facebook.com/hsgwesel';
                 $description = str_replace("\r\n", "\\n", $description);
                 $vEvent = new \Eluceo\iCal\Component\Event();
                 $vEvent->setDtStart(new \DateTime($spiel->SpielVon));
                 $vEvent->setDtEnd(new \DateTime($spiel->SpielBis));
                 $vEvent->setSummary($spiel->Heim . ' - ' . $spiel->Gast);
                 $vEvent->setDescription($description);
                 $vEvent->setLocation($spiel->HallenName . ', ' . $spiel->HallenStrasse . ', ' . $spiel->HallenOrt);
                 $vEvent->setUseTimezone(TRUE);
                 // 3. Add event to calendar
                 $vCalendar->addComponent($vEvent);
                 unset($vEvent);
             }
         }
     }
     // 4. Set headers
     header('Content-Type: text/calendar; charset=utf-8');
     header('Content-Disposition: attachment; filename="' . $ics_file_name . '"');
     // 5. Output
     echo $vCalendar->render();
     exit;
 }
コード例 #6
0
 /**
  *
  */
 public function exportIcalAction()
 {
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/Component.php';
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/PropertyBag.php';
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/Property.php';
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/Component/Calendar.php';
     require_once Mage::getBaseDir() . '/lib/iCal/Eluceo/iCal/Component/Event.php';
     //date_default_timezone_set('Europe/Berlin');
     $vCalendar = new \Eluceo\iCal\Component\Calendar(Mage::app()->getStore()->getName());
     $coll = Mage::getModel('payperrentals/reservationorders')->getCollection()->groupByOrderId();
     if (urldecode($this->getRequest()->getParam('store'))) {
         $coll->getSelect()->joinLeft(array('so' => Mage::getSingleton('core/resource')->getTableName('sales_flat_order')), 'main_table.order_id = ' . 'so.entity_id', array('so.store_id as store_id'));
         $coll->getSelect()->where('so.store_id=?', $this->getRequest()->getParam('store'));
     }
     foreach ($coll as $item) {
         $_order = Mage::getModel('sales/order')->load($item->getOrderId());
         $_address = $_order->getShippingAddress();
         $vEvent = new \Eluceo\iCal\Component\Event();
         $vEvent->setDtStart(new \DateTime($item->getStartDate()));
         $vEvent->setDtEnd(new \DateTime($item->getEndDate()));
         $vEvent->setDescription($_order->getCustomerFirstname() . ' ' . $_order->getCustomerLastname());
         $_addressString = '';
         if ($_address instanceof Mage_Sales_Model_Order_Address) {
             $_addressString .= implode(' ', $_address->getStreet()) . ', ' . $_address->getPostcode() . ', ' . $_address->getCity();
         }
         $vEvent->setLocation($_order->getCustomerFirstname() . ' ' . $_order->getCustomerLastname() . ($_addressString != '' ? ', ' . $_addressString : ''));
         //$vEvent->setNoTime(true);
         $vEvent->setSummary($item->getOrderId());
         //$vEvent->setUseTimezone(true);
         $vCalendar->addEvent($vEvent);
     }
     header('Content-Type: text/calendar; charset=utf-8');
     header('Content-Disposition: attachment; filename="cal.ics"');
     echo $vCalendar->render();
 }
コード例 #7
-1
 /**
  * _getCalendarEvent
  * @param Cake\Entity $entity passed
  * @param array $options with extra settings
  * @return \Eluceo\iCal\Component\Event $vEvent
  */
 protected function _getCalendarEvent($entity, $options = [])
 {
     $vEvent = new \Eluceo\iCal\Component\Event();
     $vOrganizer = new \Eluceo\iCal\Property\Event\Organizer($options['organizer'], ['MAILTO' => $options['organizer']]);
     $vEvent->setOrganizer($vOrganizer);
     $vEvent->setSummary($options['subject']);
     if ($entity->description) {
         $vEvent->setDescription($entity->description);
     }
     $dates = $this->_getEventTime($entity, $options);
     $vEvent->setDtStart($dates['start']);
     $vEvent->setDtEnd($dates['end']);
     if ($entity->location) {
         $vEvent->setLocation($entity->location, "Location:");
     }
     return $vEvent;
 }