Esempio n. 1
0
 function testToXmlNullElements()
 {
     $doc = new GnipDOMDocument();
     $root = $doc->createElement('activity');
     $doc->appendChild($root);
     $expected_xml = "<activity/>";
     $place = new Services_Gnip_Place();
     $place->toXML($doc, $root);
     $this->assertEquals($expected_xml, $doc->asXML());
 }
Esempio n. 2
0
 function xtestToXmlUnbound()
 {
     $mediaURLS = array(array("mediaURL" => "http://gnipcentral.com", "type" => "image"), array("mediaURL" => "http://flickr.com/tour", "type" => "video"));
     $doc = new GnipDOMDocument();
     $root = $doc->createElement('activity');
     $doc->appendChild($root);
     $expected_xml = '<activity><payload><title>title</title><body>body</body>' . '<mediaURL type="image">http://gnipcentral.com</mediaURL>' . '<mediaURL type="video">http://flickr.com/tour</mediaURL>' . '<raw>H4sIAAAAAAAAAytKLAcAVduzGgMAAAA=</raw></payload></activity>';
     $payload = new Services_Gnip_Payload("raw", "title", "body", $mediaURLS);
     $payload->toXML($doc, $root);
     $this->assertEquals($expected_xml, $doc->asXML());
 }
Esempio n. 3
0
 /**
  * Converts the rules to properly formatted XML.
  * 
  * @return XML formatted rule data
  */
 public function toXML()
 {
     $doc = new GnipDOMDocument();
     $ruleRoot = $doc->createElement('rule', $this->value);
     $doc->appendChild($ruleRoot);
     $attrName = $doc->createAttribute('type');
     $ruleRoot->appendChild($attrName);
     $attrVal = $doc->createTextNode($this->type);
     $attrName->appendChild($attrVal);
     return trim($doc->asXML());
 }
Esempio n. 4
0
 /**
  * Converts the activity to properly formatted XML.     
  * 
  * @return XML formatted activity data
  */
 public function toXML()
 {
     $doc = new GnipDOMDocument();
     $root = $doc->createElement('activity');
     $doc->appendChild($root);
     $root->appendChild($doc->createElement('at', $this->at->format(DATE_ATOM)));
     $root->appendChild($doc->createElement('action', $this->action));
     if ($this->activityID != null) {
         $root->appendChild($doc->createElement('activityID', $this->activityID));
     }
     if ($this->URL != null) {
         $root->appendChild($doc->createElement('URL', $this->URL));
     }
     if ($this->source != null) {
         $doc->appendChildren($doc, $root, "source", $this->source);
     }
     if ($this->keyword != null) {
         $doc->appendChildren($doc, $root, "keyword", $this->keyword);
     }
     if ($this->place != null) {
         foreach ($this->place as $key => $val) {
             $val->toXML($doc, $root);
         }
     }
     if ($this->actor != null) {
         $doc->appendChildren($doc, $root, "actor", $this->actor);
     }
     if ($this->destinationURL != null) {
         $doc->appendChildren($doc, $root, "destinationURL", $this->destinationURL);
     }
     if ($this->tag != null) {
         $doc->appendChildren($doc, $root, "tag", $this->tag);
     }
     if ($this->to != null) {
         $doc->appendChildren($doc, $root, "to", $this->to);
     }
     if ($this->regardingURL != null) {
         $doc->appendChildren($doc, $root, "regardingURL", $this->regardingURL);
     }
     if ($this->payload != null) {
         if (@property_exists($this->payload, "raw")) {
             $this->payload->toXML($doc, $root);
         }
     }
     return $doc->asXML();
 }