Skip to content

Commit 7c4adeb

Browse files
committed
Converted feed to atom, cleaned up output, temporarily hardcoded some values
1 parent d9c6566 commit 7c4adeb

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

htdocs/src/Blend/PartialContentBundle/Controller/BlogController.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,17 @@ public function feed($subTreeLocationId = 2)
294294
$feed->title = 'Partial Content';
295295
$feed->description = '';
296296
$feed->published = time();
297+
$pc = new \ezcFeedPersonElement();
298+
$pc->name = "Partial Content";
299+
$pc->uri = "http://partialcontent.com";
300+
$feed->author = $pc;
297301
$feed->updated = $modificationDate;
302+
$feed->id = "http://partialcontent.com/feed/pc";
298303
$link = $feed->add( 'link' );
299304
$link->href = 'http://partialcontent.com';
300305

306+
$converter = $this->container->get("ezpublish.fieldType.ezxmltext.converter.html5");
307+
301308
foreach ( $posts as $post )
302309
{
303310
$location = $locationService->loadLocation(
@@ -312,10 +319,16 @@ public function feed($subTreeLocationId = 2)
312319
$guid->isPermaLink = "false";
313320
$item->link = "http://partialcontent.com" . $urlAliasService->reverseLookup($location)->path;
314321
$item->pubDate = $post->contentInfo->modificationDate; //$post->getField( 'date' )->value->value;
322+
$item->updated = $post->contentInfo->modificationDate;
315323
$item->published = $post->contentInfo->modificationDate; // $post->getField( 'date' )->value->value;
316324
//echo "<pre>"; print_r($post->getFieldValue('body')); echo "</pre>";
317325

318-
$item->description = $post->getFieldValue( 'body' )->xml->textContent;
326+
$html = $converter->convert($post->getFieldValue( 'body' )->xml);
327+
$item->description = $html;
328+
$joe = new \ezcFeedPersonElement();
329+
$joe->name = "Joe Kepley";
330+
$joe->uri = "http://partialcontent.com";
331+
$item->author = $joe;
319332
$dublinCore = $item->addModule( 'DublinCore' );
320333
$creator = $dublinCore->add( 'creator' );
321334
//$parentLocation =
@@ -325,9 +338,10 @@ public function feed($subTreeLocationId = 2)
325338
)->contentInfo->name,
326339
ENT_NOQUOTES, 'UTF-8'
327340
);
341+
328342
}
329343

330-
$xml = $feed->generate( 'rss2' );
344+
$xml = $feed->generate( 'atom' );
331345
$response->headers->set( 'content-type', $feed->getContentType() );
332346
$response->setContent( $xml );
333347
return $response;

0 commit comments

Comments
 (0)