Ejemplo n.º 1
0
 private function _getAddress($element)
 {
     $addressEl = ActivityUtils::child($element, PoCoAddress::ADDRESS, PoCo::NS);
     if (!empty($addressEl)) {
         $formatted = ActivityUtils::childContent($addressEl, PoCoAddress::FORMATTED, self::NS);
         if (!empty($formatted)) {
             $address = new PoCoAddress();
             $address->formatted = $formatted;
             return $address;
         }
     }
     return null;
 }
Ejemplo n.º 2
0
 function _fromRssItem($item, $channel)
 {
     $verbEl = $this->_child($item, self::VERB);
     if (!empty($verbEl)) {
         $this->verb = trim($verbEl->textContent);
     } else {
         $this->verb = ActivityVerb::POST;
         // XXX: do other implied stuff here
     }
     $pubDateEl = $this->_child($item, self::PUBDATE, self::RSS);
     if (!empty($pubDateEl)) {
         $this->time = strtotime($pubDateEl->textContent);
     }
     if ($authorEl = $this->_child($item, self::AUTHOR, self::RSS)) {
         $this->actor = ActivityObject::fromRssAuthor($authorEl);
     } else {
         if ($dcCreatorEl = $this->_child($item, self::CREATOR, self::DC)) {
             $this->actor = ActivityObject::fromDcCreator($dcCreatorEl);
         } else {
             if ($posterousEl = $this->_child($item, ActivityObject::AUTHOR, ActivityObject::POSTEROUS)) {
                 // Special case for Posterous.com
                 $this->actor = ActivityObject::fromPosterousAuthor($posterousEl);
             } else {
                 if (!empty($channel)) {
                     $this->actor = ActivityObject::fromRssChannel($channel);
                 } else {
                     // No actor!
                 }
             }
         }
     }
     $this->title = ActivityUtils::childContent($item, ActivityObject::TITLE, self::RSS);
     $contentEl = ActivityUtils::child($item, self::ENCODED, self::CONTENTNS);
     if (!empty($contentEl)) {
         // <content:encoded> XML node's text content is HTML; no further processing needed.
         $this->content = $contentEl->textContent;
     } else {
         $descriptionEl = ActivityUtils::child($item, self::DESCRIPTION, self::RSS);
         if (!empty($descriptionEl)) {
             // Per spec, <description> must be plaintext.
             // In practice, often there's HTML... but these days good
             // feeds are using <content:encoded> which is explicitly
             // real HTML.
             // We'll treat this following spec, and do HTML escaping
             // to convert from plaintext to HTML.
             $this->content = htmlspecialchars($descriptionEl->textContent);
         }
     }
     $this->link = ActivityUtils::childContent($item, ActivityUtils::LINK, self::RSS);
     // @fixme enclosures
     // @fixme thumbnails... maybe
     $guidEl = ActivityUtils::child($item, self::GUID, self::RSS);
     if (!empty($guidEl)) {
         $this->id = $guidEl->textContent;
         if ($guidEl->hasAttribute('isPermaLink') && $guidEl->getAttribute('isPermaLink') != 'false') {
             // overwrites <link>
             $this->link = $this->id;
         }
     }
     $this->objects[] = new ActivityObject($item);
     $this->context = new ActivityContext($item);
 }
Ejemplo n.º 3
0
 private function _getSource($element)
 {
     $sourceEl = ActivityUtils::child($element, 'source');
     if (empty($sourceEl)) {
         return null;
     } else {
         $href = ActivityUtils::getLink($sourceEl, 'self');
         if (!empty($href)) {
             return $href;
         } else {
             return ActivityUtils::childContent($sourceEl, 'id');
         }
     }
 }
 public function testGeotaggedActivity()
 {
     $notice = Notice::saveNew($this->author1->id, common_good_rand(4), 'test', array('uri' => null, 'lat' => 45.5, 'lon' => -73.59999999999999));
     $entry = $notice->asAtomEntry();
     $element = $this->_entryToElement($entry, true);
     $this->assertEquals('45.5 -73.6', ActivityUtils::childContent($element, 'point', "http://www.georss.org/georss"));
 }