public function deleteAction() { $record = Record::find($this->getParam('id')); if ($record) { $record->delete(); } $this->alert('Record deleted.', 'green'); $this->redirectFromHere(array('action' => 'index', 'id' => NULL, 'csrf' => NULL)); }
public function feedAction() { $this->doNotRender(); if ($this->hasParam('id')) { $id = (int) $this->getParam('id'); $record = Podcast::find($id); if (!$record instanceof Podcast) { throw new \DF\Exception\DisplayOnly('Show record not found!'); } $feed_title = $record->name; $feed_desc = $record->description ? $record->description : 'A Ponyville Live! Show.'; $cache_name = 'podcasts_' . $id . '_feed'; $q = $this->em->createQuery('SELECT pe, p FROM Entity\\PodcastEpisode pe JOIN pe.podcast p WHERE p.is_approved = 1 AND p.id = :id ORDER BY pe.timestamp DESC')->setParameter('id', $id); } else { $feed_title = 'Ponyville Live! Shows'; $feed_desc = 'The partner shows of the Ponyville Live! network, including commentary, interviews, episode reviews, convention coverage, and more.'; $cache_name = 'podcasts_all_feed'; $q = $this->em->createQuery('SELECT pe, p FROM Entity\\PodcastEpisode pe JOIN pe.podcast p WHERE p.is_approved = 1 AND pe.timestamp >= :threshold ORDER BY pe.timestamp DESC')->setParameter('threshold', strtotime('-3 months')); } $rss = \DF\Cache::get($cache_name); if (!$rss) { $records = $q->getArrayResult(); // Initial RSS feed setup. $feed = new \Zend\Feed\Writer\Feed(); $feed->setTitle($feed_title); $feed->setLink('http://ponyvillelive.com/'); $feed->setDescription($feed_desc); $feed->addAuthor(array('name' => 'Ponyville Live!', 'email' => '*****@*****.**', 'uri' => 'http://ponyvillelive.com')); $feed->setDateModified(time()); foreach ((array) $records as $episode) { try { $podcast = $episode['podcast']; $title = $episode['title']; // Check for podcast name preceding episode name. if (substr($title, 0, strlen($podcast['name'])) == $podcast['name']) { $title = substr($title, strlen($podcast['name'])); } $title = trim($title, " :-\t\n\r\v"); $title = $podcast['name'] . ' - ' . $title; // Create record. $entry = $feed->createEntry(); $entry->setTitle($title); $entry->setLink($episode['web_url']); $entry->addAuthor(array('name' => $podcast['name'], 'uri' => $podcast['web_url'])); $entry->setDateModified($episode['timestamp']); $entry->setDateCreated($episode['timestamp']); if ($podcast['description']) { $entry->setDescription($podcast['description']); } if ($episode['body']) { $entry->setContent($episode['body']); } $feed->addEntry($entry); } catch (\Exception $e) { } } // Export feed. $rss = $feed->export('rss'); \DF\Cache::set($rss, $cache_name, array(), 60 * 15); } header("Content-Type: application/rss+xml"); echo $rss; }