Ejemplo n.º 1
0
 public function testNormalLinkShouldHaveNoExtensionElements()
 {
     $this->link->rel = "http://nowhere.invalid/";
     $this->link->title = "Somewhere";
     $this->link->href = "http://somewhere.invalid/";
     $this->link->type = "text/plain";
     $this->link->webContent = new Zend_Gdata_Calendar_Extension_WebContent("a", "1", "2");
     $this->assertEquals($this->link->rel, "http://nowhere.invalid/");
     $this->assertEquals($this->link->title, "Somewhere");
     $this->assertEquals($this->link->href, "http://somewhere.invalid/");
     $this->assertEquals($this->link->type, "text/plain");
     $this->assertEquals($this->link->webcontent->url, "a");
     $this->assertEquals($this->link->webcontent->height, "1");
     $this->assertEquals($this->link->webcontent->width, "2");
     $this->assertEquals(count($this->link->extensionElements), 0);
     $newLink = new Zend_Gdata_Calendar_Extension_Link();
     $newLink->transferFromXML($this->link->saveXML());
     $this->assertEquals(count($newLink->extensionElements), 0);
     $newLink->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(count($newLink->extensionElements), 1);
     $this->assertEquals($this->link->rel, "http://nowhere.invalid/");
     $this->assertEquals($this->link->title, "Somewhere");
     $this->assertEquals($this->link->href, "http://somewhere.invalid/");
     $this->assertEquals($this->link->type, "text/plain");
     $this->assertEquals($this->link->webcontent->url, "a");
     $this->assertEquals($this->link->webcontent->height, "1");
     $this->assertEquals($this->link->webcontent->width, "2");
     /* try constructing using magic factory */
     $cal = new Zend_Gdata_Calendar();
     $newLink2 = $cal->newLink();
     $newLink2->transferFromXML($newLink->saveXML());
     $this->assertEquals(count($newLink2->extensionElements), 1);
     $this->assertEquals($this->link->rel, "http://nowhere.invalid/");
     $this->assertEquals($this->link->title, "Somewhere");
     $this->assertEquals($this->link->href, "http://somewhere.invalid/");
     $this->assertEquals($this->link->type, "text/plain");
     $this->assertEquals($this->link->webcontent->url, "a");
     $this->assertEquals($this->link->webcontent->height, "1");
     $this->assertEquals($this->link->webcontent->width, "2");
 }
Ejemplo n.º 2
0
/**
 * Creates a new web content event on the authenticated user's default 
 * calendar with the specified event details. For simplicity, the event 
 * is created as an all day event and does not include a description.
 *
 * @param Zend_Http_Client $client The authenticated client object
 * @param string $title The event title
 * @param string $startDate The start date of the event in YYYY-MM-DD format
 * @param string $endDate The end time of the event in HH:MM 24hr format
 * @param string $icon URL pointing to a 16x16 px icon representing the event.
 * @param string $url The URL containing the web content for the event.
 * @param string $height The desired height of the web content pane.
 * @param string $width The desired width of the web content pane.
 * @param string $type The MIME type of the web content.
 * @return string The ID URL for the event.
 */
function createWebContentEvent($client, $title = 'World Cup 2006', $startDate = '2006-06-09', $endDate = '2006-06-09', $icon = 'http://www.google.com/calendar/images/google-holiday.gif', $url = 'http://www.google.com/logos/worldcup06.gif', $height = '120', $width = '276', $type = 'image/gif')
{
    $gc = new Zend_Gdata_Calendar($client);
    $newEntry = $gc->newEventEntry();
    $newEntry->title = $gc->newTitle(trim($title));
    $when = $gc->newWhen();
    $when->startTime = $startDate;
    $when->endTime = $endDate;
    $newEntry->when = array($when);
    $wc = $gc->newWebContent();
    $wc->url = $url;
    $wc->height = $height;
    $wc->width = $width;
    $wcLink = $gc->newLink();
    $wcLink->rel = "http://schemas.google.com/gCal/2005/webContent";
    $wcLink->title = $title;
    $wcLink->type = $type;
    $wcLink->href = $icon;
    $wcLink->webContent = $wc;
    $newEntry->link = array($wcLink);
    $createdEntry = $gc->insertEvent($newEntry);
    return $createdEntry->id->text;
}