Example #1
0
 public function accept(MediaType $contentType)
 {
     return in_array($contentType->getName(), MediaType\Xml::getMediaTypes()) || substr($contentType->getSubType(), -4) == '+xml' || substr($contentType->getSubType(), -4) == '/xml';
 }
Example #2
0
File: Atom.php Project: seytar/psx
 public static function textConstruct(DOMElement $el)
 {
     $text = new \stdClass();
     $type = strtolower($el->getAttribute('type'));
     if (empty($type) || $type == 'text' || $type == 'html' || substr($type, 0, 5) == 'text/') {
         $content = $el->nodeValue;
     } elseif ($type == 'xhtml' || in_array($type, MediaType\Xml::getMediaTypes()) || substr($type, -4) == '+xml' || substr($type, -4) == '/xml') {
         // get first child element
         $child = null;
         foreach ($el->childNodes as $node) {
             if ($node->nodeType == XML_ELEMENT_NODE) {
                 $child = $node;
                 break;
             }
         }
         if ($child !== null) {
             $content = $el->ownerDocument->saveXML($child);
         } else {
             $content = null;
         }
     } else {
         $content = base64_decode($el->nodeValue);
     }
     if (!empty($type)) {
         $text->type = $type;
     }
     $text->content = $content;
     return $text;
 }