My GE exports kept failing because I have HTML in the descriptions of things that was not being padded well with CDATA tags.
There's certainly a better way to do this, I just include CDATA tags inside all descriptions, but it works...
Here's my diff:
$ svn diff GoogleEarth.inc
Index: GoogleEarth.inc
===================================================================
--- GoogleEarth.inc (revision 267)
+++ GoogleEarth.inc (working copy)
@@ -193,9 +193,9 @@
: '';
$returnstring = '<Folder id="g2id_'. $item->getId() . '"><name>'
. GalleryUtilities::markup($item->getTitle())
- . "</name>\n<description>"
+ . "</name>\n<description><![CDATA["
. GoogleEarthView::_createThumbnailLink($item)
- . GalleryUtilities::markup($descstring) . '</description><Snippet>'
+ . GalleryUtilities::markup($descstring) . ']]></description><Snippet>'
. GalleryUtilities::markup($item->getSummary()) . "</Snippet>\n"
. GoogleEarthView::_createLookAtBlock($coordstring, $LookAtstring)
. $returnstring . "</Folder>\n";
@@ -254,10 +254,10 @@
$LookAtstring = (!empty($fielddata['GELookAt'])) ? $fielddata['GELookAt'] : '';
$returnstring .= '<Placemark id="g2id_' . $item->getId() . '"><name>'
. GalleryUtilities::markup($item->getTitle())
- . "</name>\n<description>"
+ . "</name>\n<description><![CDATA["
. GoogleEarthView::_createThumbnailLink($item)
. GalleryUtilities::markup($descstring)
- . '</description><Snippet>'
+ . ']]></description><Snippet>'
. GalleryUtilities::markup($item->getSummary()) . '</Snippet>'
. "<styleUrl>#PhotoIconPair</styleUrl>\n" . $point
. GoogleEarthView::_createLookAtBlock($coordstring, $LookAtstring)
@@ -356,10 +356,10 @@
array('view' => 'core.ShowItem', 'itemId' => $theid),
array('forceFullUrl' => true, 'htmlEntities' => false));
if ($hsitemLink != '' and $dthumbLink != '') {
- $returnstring = '<![CDATA[<a href="' . $hsitemLink
- . "\">\n<img src=\"" . $dthumbLink . '"></a><br>]]>';
+ $returnstring = '<a href="' . $hsitemLink
+ . "\">\n<img src=\"" . $dthumbLink . '"></a><br>';
}
return $returnstring;
}
}
-?>
\ No newline at end of file
+?>
Posts: 508
Thanks, nice catch. I'm expanding it to include all items that pass through GalleryUtilities::markup.
Posts: 508
Okay, I committed the fix. Let me know if it works for you.
Posts: 35
Yep, that's better.
It would be nice if it only wrapped CDATA's around data, leaving empty fields actually empty in the XML instead of <![CDATA[]]> but no big deal...
Posts: 508
Okay, I reworked it a bit more taking the empty fields into account. Looking at the KML documentation for the Snippet element, HTML content is not allowed (even though it renders correctly in Google Earth), so I stripped out markup tags from that field. I compromised by adding the marked-up item Summary to the description element, above the thumbnail.