コード例 #1
0
    public function PageLoad()
    {
        ob_clean();
        $this->presenter->PageLoad();
        $config = Configuration::Instance();
        $feed = new FeedWriter(ATOM);
        $title = $config->GetKey(ConfigKeys::APP_TITLE);
        $feed->setTitle("{$title} Reservations");
        $url = $config->GetScriptUrl();
        $feed->setLink($url);
        $feed->setChannelElement('updated', date(DATE_ATOM, time()));
        $feed->setChannelElement('author', array('name' => $title));
        foreach ($this->reservations as $reservation) {
            /** @var FeedItem $item */
            $item = $feed->createNewItem();
            $item->setTitle($reservation->Summary);
            $item->setLink($reservation->ReservationUrl);
            $item->setDate($reservation->DateCreated->Timestamp());
            $item->setDescription(sprintf('<div><span>Start</span> %s</div>
										  <div><span>End</span> %s</div>
										  <div><span>Organizer</span> %s</div>
										  <div><span>Description</span> %s</div>', $reservation->DateStart->ToString(), $reservation->DateEnd->ToString(), $reservation->Organizer, $reservation->Description));
            $feed->addItem($item);
        }
        $feed->genarateFeed();
    }
コード例 #2
0
 public function PageLoad()
 {
     $this->presenter->PageLoad();
     header("Content-Type: text/Calendar");
     header("Content-Disposition: inline; filename=calendar.ics");
     $display = new CalendarExportDisplay();
     echo $display->Render($this->reservations);
 }
コード例 #3
0
 public function PageLoad()
 {
     $this->presenter->PageLoad();
     header("Content-Type: text/Calendar");
     header("Content-Disposition: inline; filename=calendar.ics");
     $config = Configuration::Instance();
     $this->Set('phpScheduleItVersion', $config->GetKey(ConfigKeys::VERSION));
     $this->Set('DateStamp', Date::Now());
     /*
     				   ScriptUrl is used to generate iCal UID's. As a workaround to this bug
     				   https://bugzilla.mozilla.org/show_bug.cgi?id=465853
     				   we need to avoid using any slashes "/"
     */
     $url = $config->GetScriptUrl();
     $this->Set('ScriptUrl', parse_url($url, PHP_URL_HOST));
     $this->Display('Export/ical.tpl');
 }
コード例 #4
0
 public function testGetsUserReservationsForTheNextYearByResourceId()
 {
     $publicId = '1';
     $reservationResult = array(new TestReservationItemView(1, Date::Now(), Date::Now()));
     $userId = 999;
     $user = new FakeUser($userId);
     $weekAgo = Date::Now()->AddDays(-7);
     $nextYear = Date::Now()->AddDays(365);
     $this->page->expects($this->once())->method('GetUserId')->will($this->returnValue($publicId));
     $this->service->expects($this->once())->method('GetUser')->with($this->equalTo($publicId))->will($this->returnValue($user));
     $this->repo->expects($this->once())->method('GetReservationList')->with($this->equalTo($weekAgo), $this->equalTo($nextYear), $this->equalTo($userId), $this->isNull(), $this->isNull(), $this->isNull())->will($this->returnValue($reservationResult));
     $this->page->expects($this->once())->method('SetReservations')->with($this->arrayHasKey(0));
     $this->presenter->PageLoad();
 }