description() public method

public description ( $description )
$blogCommentChannel->url('https://blog.jacobemerick.com');
// todo depends on env
$blogCommentChannel->appendTo($blogCommentFeed);
$query = "\n    SELECT `comment_meta`.`id`, `comment_meta`.`date`, `comment`.`body`, `commenter`.`name`,\n           `post`.`title`, `post`.`category`, `post`.`path`\n    FROM `jpemeric_comment`.`comment_meta`\n    INNER JOIN `jpemeric_comment`.`comment` ON `comment`.`id` = `comment_meta`.`comment`\n    INNER JOIN `jpemeric_comment`.`commenter` ON `commenter`.`id` = `comment_meta`.`commenter` AND\n                                                 `commenter`.`trusted` = :trusted_commenter\n    INNER JOIN `jpemeric_comment`.`comment_page` ON `comment_page`.`id` = `comment_meta`.`comment_page` AND\n                                                    `comment_page`.`site` = :comment_site\n    INNER JOIN `jpemeric_blog`.`post` ON `post`.`path` = `comment_page`.`path` AND\n                                         `post`.`display` = :display_post\n    WHERE `comment_meta`.`display` = :active_comment\n    ORDER BY `comment_meta`.`date` DESC";
$bindings = ['trusted_commenter' => 1, 'comment_site' => 2, 'display_post' => 1, 'active_comment' => 1];
$activeBlogComments = $db->getRead()->fetchAll($query, $bindings);
foreach ($activeBlogComments as $blogComment) {
    $blogCommentItem = new Item();
    $blogCommentItem->title("Comment on '{$blogComment['title']}' from {$blogComment['name']}");
    $url = "https://blog.jacobemerick.com/{$blogComment['category']}/{$blogComment['path']}/";
    $url .= "#comment-{$blogComment['id']}";
    $blogCommentItem->url($url);
    $blogCommentItem->guid($url, true);
    $description = $blogComment['body'];
    $description = strip_tags($description);
    $description = strtok($description, "\n");
    if (strlen($description) > 250) {
        $description = wordwrap($description, 250);
        $description = strtok($description, "\n");
        if (substr($description, -1) != '.') {
            $description .= '…';
        }
    }
    $description = html_entity_decode($description);
    $description = trim($description);
    $blogCommentItem->description($description);
    $pubDate = new DateTime($blogComment['date']);
    $blogCommentItem->pubDate($pubDate->getTimestamp());
    $blogCommentItem->appendTo($blogCommentChannel);
}
$buildFeed($blogCommentFeed, 'blog', 'rss-comments');
Beispiel #2
0
 public function testPreferCdata()
 {
     $item = new Item();
     $item->title('<h1>title</h1>');
     $item->description('<p>description</p>');
     // By default, prefer no CDATA on title and description
     $actualXml = $item->asXML()->asXML();
     $this->assertContains('<title>&lt;h1&gt;title&lt;/h1&gt;</title>', $actualXml);
     $this->assertContains('<description>&lt;p&gt;description&lt;/p&gt;</description>', $actualXml);
     // Once prefer-cdata is enabled, title and description is wrapped by CDATA
     $item->preferCdata(true);
     $actualXml = $item->asXML()->asXML();
     $this->assertContains('<title><![CDATA[<h1>title</h1>]]></title>', $actualXml);
     $this->assertContains('<description><![CDATA[<p>description</p>]]></description>', $actualXml);
     // Of course, prefer-cdata can be disabled again
     $item->preferCdata(false);
     $actualXml = $item->asXML()->asXML();
     $this->assertContains('<title>&lt;h1&gt;title&lt;/h1&gt;</title>', $actualXml);
     $this->assertContains('<description>&lt;p&gt;description&lt;/p&gt;</description>', $actualXml);
     // And like other APIs `preferCdata` is also fluent interface
     $obj = $item->preferCdata(true);
     $this->assertSame($obj, $item);
 }
Beispiel #3
0
    $channel = new Channel();
    $channel->title('Wurst update status');
    $channel->description("Uni-Hamburg server");
    $channel->url('http://zbh.uni-hamburg.de');
    $channel->appendTo($feed);
    $transformerCategory = new RecordToCategoryTransformer();
    $transformerTitle = new RecordToTitleTransformer($transformerCategory);
    $transformerDescription = new RecordToDescriptionTransformer($app['twig']);
    foreach ($app['wurst.history']->collection() as $id => $element) {
        $item = new Item();
        $item->author("wurst update");
        $item->url("http://{$SERVER_ROOT_SCRIPT}/details/{$id}");
        $item->pubDate($element->getDate());
        $item->title($transformerTitle->transform($element));
        $item->category($transformerCategory->transform($element));
        $item->description($transformerDescription->transform($element));
        $item->appendTo($channel);
    }
    return new Response($feed, 200);
});
/**
 * Method to show details for given record in rss stream
 *
 * @todo ids for all records are not unique,
 * @todo so it may be a problem but this situation is not so probable
 * @todo we can just ignore that, but it should be changed for good
 *      
 */
$app->get('/details/{unique}', function (Request $request, $unique) use($app) {
    assert($collection = $app['wurst.history']->collection(), "History can not be empty");
    assert($element = isset($collection[$unique]) ? $collection[$unique] : null, "Unknown record index");