예제 #1
0
 public function do_print(\Podlove\Chapters\Chapters $chapters)
 {
     $xml = new \SimpleXMLElement('<psc:chapters version="1.2" xmlns:psc="http://podlove.org/simple-chapters" />');
     $xml = array_reduce($chapters->toArray(), function ($xml, $chapter) {
         $child = $xml->addChild('psc:chapter');
         $child->addAttribute('start', $chapter->get_time());
         $child->addAttribute('title', $chapter->get_title());
         if ($chapter->get_link()) {
             $child->addAttribute('href', $chapter->get_link());
         }
         if ($chapter->get_image()) {
             $child->addAttribute('image', $chapter->get_image());
         }
         return $xml;
     }, $xml);
     $xml_string = $xml->asXML();
     $xml_string = $this->format_xml($xml_string);
     $xml_string = $this->remove_xml_header($xml_string);
     return $xml_string;
 }
예제 #2
0
 public function do_print(\Podlove\Chapters\Chapters $chapters)
 {
     return implode("\n", array_map(function ($chapter) {
         return $chapter->get_time() . ' ' . $chapter->get_title() . ($chapter->get_link() ? ' <' . $chapter->get_link() . '>' : '');
     }, $chapters->toArray()));
 }
예제 #3
0
 public function do_print(\Podlove\Chapters\Chapters $chapters)
 {
     return json_encode(array_map(function ($chapter) {
         return (object) array('start' => $chapter->get_time(), 'title' => $chapter->get_title(), 'href' => $chapter->get_link(), 'image' => $chapter->get_image());
     }, $chapters->toArray()));
 }