Author: Nick Sagona, III (dev@nolainteractive.com)
Beispiel #1
0
 public function testPhp()
 {
     $headers = array('title' => 'Test Feed Title', 'subtitle' => 'Test Feed Description', 'link' => 'http://www.testfeed.com/', 'language' => 'en', 'updated' => '2010-01-12 13:01:32', 'generator' => 'http://www.website.com/', 'author' => 'Some Editor');
     $entry = array('title' => 'Entry Title 1', 'link' => 'http://www.testfeed.com/entry1', 'comments' => 'http://www.testfeed.com/entry1#comments', 'author' => 'Entry Author 1', 'updated' => '2010-01-13 14:12:24', 'summary' => 'Entry Desc 1');
     $feed = new Writer($headers, array($entry), Writer::PHP);
     $this->assertContains('Test Feed Title', $feed->render(true));
 }
Beispiel #2
0
 /**
  * Get the feed
  *
  * @param  array               $feedHeaders
  * @param  string              $feedType
  * @param  int                 $feedLimit
  * @param  \Pop\Module\Manager $modules
  * @return Writer
  */
 public function getFeed($feedHeaders, $feedType, $feedLimit, \Pop\Module\Manager $modules)
 {
     $items = [];
     $feed = Table\Feed::findAll();
     foreach ($feed->rows() as $f) {
         if ($f->type == 'content') {
             if ($modules->isRegistered('phire-fields')) {
                 $item = \Phire\Fields\Model\FieldValue::getModelObject('Phire\\Content\\Model\\Content', ['id' => $f->id]);
             } else {
                 $item = new \Phire\Content\Model\Content();
                 $item->getById($f->id);
             }
             if ($item->status == 1 && count($item->roles) == 0) {
                 $items[] = $this->formatItem($item, 'content', $feedType);
             }
         } else {
             if ($f->type == 'media') {
                 if ($modules->isRegistered('phire-fields')) {
                     $item = \Phire\Fields\Model\FieldValue::getModelObject('Phire\\Media\\Model\\Media', ['id' => $f->id]);
                 } else {
                     $item = new \Phire\Media\Model\Media();
                     $item->getById($f->id);
                 }
                 $item->publish = $item->uploaded;
                 $items[] = $this->formatItem($item, 'media', $feedType);
             }
         }
     }
     usort($items, function ($a, $b) {
         $t1 = strtotime($a['publish']);
         $t2 = strtotime($b['publish']);
         return $t2 - $t1;
     });
     if ((int) $feedLimit > 0) {
         if (count($items) > (int) $feedLimit) {
             $items = array_slice($items, 0, (int) $feedLimit);
         }
     }
     $writer = new Writer($feedHeaders, $items);
     if ($feedType == 'atom') {
         $writer->setAtom();
     }
     return $writer;
 }
Beispiel #3
0
<?php

require_once '../../bootstrap.php';
use Pop\Feed;
try {
    $feedHeaders = array('title' => 'Test Feed Title', 'subtitle' => 'Test Feed Description', 'link' => 'http://www.testfeed.com/', 'language' => 'en', 'updated' => '2010-01-12 13:01:32', 'generator' => 'http://www.website.com/', 'author' => 'Some Editor');
    $entry1 = array('title' => 'Entry Title 1', 'link' => 'http://www.testfeed.com/entry1', 'comments' => 'http://www.testfeed.com/entry1#comments', 'author' => 'Entry Author 1', 'updated' => '2010-01-13 14:12:24', 'summary' => 'Entry Desc 1');
    $entry2 = array('title' => 'Entry Title 2', 'link' => 'http://www.testfeed.com/entry2', 'comments' => 'http://www.testfeed.com/entry2#comments', 'author' => 'Entry Author 2', 'updated' => '2010-01-12 14:12:24', 'summary' => 'Entry Desc 2');
    $entry3 = array('title' => 'Entry Title 3', 'link' => 'http://www.testfeed.com/entry3', 'comments' => 'http://www.testfeed.com/entry3#comments', 'author' => 'Entry Author 3', 'updated' => '2010-01-11 14:12:24', 'summary' => 'Entry Desc 3');
    $feedEntries = array($entry1, $entry2, $entry3);
    $feed = new Feed\Writer($feedHeaders, $feedEntries, Feed\Writer::ATOM);
    $feed->render();
} catch (\Exception $e) {
    echo $e->getMessage();
}