/** * Create an Audio object from XML * * @param SimpleXMLElement $xml simpleXML element containing a single audio XML * * @static * * @return phpOpenNOS\Model\Audio */ public static function fromXML(\SimpleXMLElement $xml) { $audio = new Audio(); $audio->setId((int) $xml->id); $audio->setTitle((string) $xml->title); $audio->setDescription((string) $xml->description); $audio->setPublished((string) $xml->published); $audio->setLastUpdate((string) $xml->last_update); $audio->setThumbnailXS((string) $xml->thumbnail_xs); $audio->setThumbnailS((string) $xml->thumbnail_s); $audio->setThumbnailM((string) $xml->thumbnail_m); $audio->setLink((string) $xml->link); $audio->setEmbedCode((string) $xml->embedcode); $keywords = array(); foreach ($xml->keywords->keyword as $keyword) { $keywords[] = (string) $keyword; } $audio->setKeywords($keywords); return $audio; }
public function testEmbedCode() { $audio = new Audio(); $audio->setEmbedCode('<object width="550" height="309"><param name="movie" value="http://s.nos.nl/swf/embed/nos_partner_video.swf?tcmid=tcm-5-870639&platform=open&partner=speeltuin"></param><param name="wmode" value="transparent"></param><param name="allowScriptAccess" value="always"></param><param name="allowfullscreen" value="true"></param><embed src="http://s.nos.nl/swf/embed/nos_partner_video.swf?tcmid=tcm-5-870639&platform=open&partner=speeltuin" type="application/x-shockwave-flash" wmode="transparent" width="550" height="309" allowfullscreen="true" allowScriptAccess="always"></embed></object>'); $this->assertEquals($audio->getEmbedCode(), '<object width="550" height="309"><param name="movie" value="http://s.nos.nl/swf/embed/nos_partner_video.swf?tcmid=tcm-5-870639&platform=open&partner=speeltuin"></param><param name="wmode" value="transparent"></param><param name="allowScriptAccess" value="always"></param><param name="allowfullscreen" value="true"></param><embed src="http://s.nos.nl/swf/embed/nos_partner_video.swf?tcmid=tcm-5-870639&platform=open&partner=speeltuin" type="application/x-shockwave-flash" wmode="transparent" width="550" height="309" allowfullscreen="true" allowScriptAccess="always"></embed></object>'); }