/**
  * @param SimpleXMLElement $mrss
  * @param SimpleXMLElement $metadata
  * @param kMrssParameters $mrssParams
  * @return SimpleXMLElement
  */
 public function contributeMetadataObject(SimpleXMLElement $mrss, SimpleXMLElement $metadata, kMrssParameters $mrssParams = null, $currentXPath)
 {
     $currentXPath .= "/*[local-name()='" . $metadata->getName() . "']";
     $metadataObject = $mrss->addChild($metadata->getName());
     foreach ($metadata->attributes() as $attributeField => $attributeValue) {
         $metadataObject->addAttribute($attributeField, $attributeValue);
     }
     foreach ($metadata as $metadataField => $metadataValue) {
         if ($metadataValue instanceof SimpleXMLElement && count($metadataValue)) {
             $this->contributeMetadataObject($metadataObject, $metadataValue, $mrssParams, $currentXPath);
         } else {
             $metadataObject->addChild($metadataField, kString::stringToSafeXml($metadataValue));
             $itemXPath = $currentXPath . "/*[local-name()='{$metadataField}']";
             if ($mrssParams && is_array($mrssParams->getItemXpathsToExtend()) && in_array($itemXPath, $mrssParams->getItemXpathsToExtend())) {
                 $relatedEntry = entryPeer::retrieveByPK((string) $metadataValue);
                 if ($relatedEntry) {
                     $relatedItemField = $metadataObject->addChild($metadataField . '_item');
                     $recursionMrssParams = null;
                     if ($mrssParams) {
                         $recursionMrssParams = clone $mrssParams;
                         $recursionMrssParams->setItemXpathsToExtend(array());
                         // stop the recursion
                     }
                     $relatedEntryMrss = kMrssManager::getEntryMrssXml($relatedEntry, $relatedItemField, $recursionMrssParams);
                 }
             }
         }
     }
 }
예제 #2
0
 /**
  * @param SimpleXMLElement $mrss
  * @param SimpleXMLElement $metadata
  * @param kMrssParameters $mrssParams
  * @return SimpleXMLElement
  */
 public function contributeMetadataObject(SimpleXMLElement $mrss, SimpleXMLElement $metadata, kMrssParameters $mrssParams = null, $currentXPath)
 {
     $currentXPath .= "/*[local-name()='" . $metadata->getName() . "']";
     $metadataObject = $mrss->addChild($metadata->getName());
     foreach ($metadata->attributes() as $attributeField => $attributeValue) {
         $metadataObject->addAttribute($attributeField, $attributeValue);
     }
     foreach ($metadata as $metadataField => $metadataValue) {
         if ($metadataValue instanceof SimpleXMLElement && count($metadataValue)) {
             $this->contributeMetadataObject($metadataObject, $metadataValue, $mrssParams, $currentXPath);
         } else {
             $metadataObject->addChild($metadataField, kString::stringToSafeXml($metadataValue));
         }
     }
 }