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); }
<?php // require files require_once '../src/Eluceo/iCal/Component.php'; require_once '../src/Eluceo/iCal/PropertyBag.php'; require_once '../src/Eluceo/iCal/Property.php'; require_once '../src/Eluceo/iCal/Component/Calendar.php'; require_once '../src/Eluceo/iCal/Component/Event.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'); // Adding Timezone (optional) $vEvent->setUseTimezone(true); // 3. Add event to calendar $vCalendar->addEvent($vEvent); // 4. Set headers header('Content-Type: text/calendar; charset=utf-8'); header('Content-Disposition: attachment; filename="cal.ics"'); // 5. Output echo $vCalendar->render();
/** * */ 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(); }