コード例 #1
0
ファイル: OpfResourceDumper.php プロジェクト: jonhargett/epub
 private function appendMetadataElement(\DOMDocument $document, Metadata $metadata)
 {
     $node = $document->createElement('metadata');
     foreach ($metadata->all() as $items) {
         foreach ($items as $item) {
             // $child = $document->createElementNS(NamespaceRegistry::NAMESPACE_DC, $item->name, $item->value);
             $child = $document->createElement(sprintf('%s:%s', NamespaceRegistry::PREFIX_DC, $item->name), $item->value);
             if ($item->name === 'identifier') {
                 $child->setAttribute('id', 'dcidid');
             }
             foreach ($item->attributes as $attrName => $attrValue) {
                 // if (false !== $pos = strpos($attrName, ':')) {
                 // 	$nsPrefix = substr($attrName, 0, $pos);
                 // 	$attrName = substr($attrName, $pos + 1);
                 // 	$namespace = constant('ePub\NamespaceRegistry::NAMESPACE_' . strtoupper($nsPrefix));
                 // 	$child->setAttributeNS($namespace, $attrName, $attrValue);
                 // } else {
                 $child->setAttribute($attrName, $attrValue);
                 // }
             }
             $node->appendChild($child);
         }
     }
     return $node;
 }
コード例 #2
0
ファイル: OpfResource.php プロジェクト: jonhargett/epub
 private function processMetadataElement(SimpleXMLElement $xml, Metadata $metadata)
 {
     foreach ($xml->children(NamespaceRegistry::NAMESPACE_DC) as $child) {
         $item = new MetadataItem();
         $item->name = $child->getName();
         $item->value = trim((string) $child);
         $item->attributes = $this->getXmlAttributes($child);
         $metadata->add($item);
     }
 }
コード例 #3
0
ファイル: OpfResource.php プロジェクト: ridibooks/epub
 private function processMetadataElement(SimpleXMLElement $xml, Metadata $metadata)
 {
     if ($xml->count() === 0) {
         return;
     }
     foreach ($xml->children(NamespaceRegistry::NAMESPACE_DC) as $child) {
         $item = new MetadataItem();
         $item->name = $child->getName();
         $item->value = trim((string) $child);
         $item->attributes = $this->getXmlAttributes($child);
         $metadata->add($item);
     }
     // Xml with no DC namespace.
     foreach ($xml->children()->meta as $child) {
         $item = new MetadataItem();
         $item->name = (string) $child['name'];
         $item->value = (string) $child['content'];
         $item->attributes = array();
         $metadata->add($item);
     }
 }