public function executeEdit($request, $new = false) { $this->form = new PodcastForm($new ? null : PodcastPeer::retrieveByPk($request->getParameter('id'))); $this->podcast = $this->form->getObject(); $this->episodes = $this->podcast->getEpisodes(); $this->feeds = $this->podcast->getFeeds(); $this->podcast_feed_form = new FeedForm(); $this->podcast_feed_form->setDefaults(array('podcast_id' => $this->podcast->getId()), array()); if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters(), array()); // FIXME bind to real files array if ($this->form->isValid()) { $podcast = $this->form->save(); if ($new) { $feed = new Feed(); // add a sensible default feed $feed->setTitle('default'); $feed->setSlug('default'); $podcast->addFeed($feed); $feed->save(); $podcast->setDefaultFeed($feed); $podcast->save(); } $this->redirect('podcast/edit?id=' . $podcast->getId()); } } }
public function testToAPI() { $feed = new Feed(); $feed->setId(3); $feed->setUrl('http://google'); $feed->setTitle('title'); $feed->setFaviconLink('favicon'); $feed->setAdded(123); $feed->setFolderId(1); $feed->setUnreadCount(321); $feed->setLink('https://google'); $this->assertEquals(array('id' => 3, 'url' => 'http://google', 'title' => 'title', 'faviconLink' => 'favicon', 'added' => 123, 'folderId' => 1, 'unreadCount' => 321, 'link' => 'https://google'), $feed->toAPI()); }
private function createFeed() { $feed = new Feed(); $feed->setId(3); $feed->setLastModified(44); $feed->setEtag(45); $feed->setUrl('http://google.com/some/weird/path'); $feed->setTitle('title'); $feed->setFaviconLink('favicon'); $feed->setAdded(123); $feed->setFolderId(1); $feed->setUnreadCount(321); $feed->setLink('https://www.google.com/some/weird/path'); $feed->setLocation('http://google.at'); $feed->setOrdering(2); return $feed; }
$z->open('xml/' . $source); $feeds = array(); $doc = new DOMDocument(); require_once 'models/feed.php'; function x_attribute($object, $attribute) { if (isset($object[$attribute])) { return (string) $object[$attribute]; } } while ($z->read() && $z->name !== 'source') { } while ($z->name === 'source') { $node = new SimpleXMLElement($z->readOuterXML()); $feed = new Feed(); $feed->setTitle($node->title); $feed->setURL($node->feed_url); $feed->setPicture($node->picture); $feeds[] = $feed; if (!file_exists('xml/feeds/' . $feed->title . '.xml')) { file_put_contents('xml/feeds/' . $feed->title . ".xml", file_get_contents($feed->feed_url)); } else { $ttl = 1800; $age = time() - filemtime('xml/feeds/' . $feed->title . '.xml'); if ($age >= $ttl) { unlink('xml/feeds/' . $feed->title . '.xml'); file_put_contents('xml/feeds/' . $feed->title . ".xml", file_get_contents($feed->feed_url)); } } $z->next('source'); }