Example #1
0
 public function indexAction()
 {
     $this->view->social_types = Podcast::getSocialTypes();
     // Paginate episodes.
     $query = $this->em->createQuery('SELECT pe FROM Entity\\PodcastEpisode pe WHERE pe.podcast_id = :podcast ORDER BY pe.timestamp DESC')->setParameter('podcast', $this->podcast->id);
     $this->view->pager = new \DF\Paginator\Doctrine($query, $this->getParam('page', 1), 25);
     // Generate traffic metrics.
     $influx = $this->di->get('influx');
     $raw_analytics = $influx->setDatabase('pvlive_analytics')->query('SELECT * FROM /^1(d|h).podcast.' . $this->podcast->id . '.*/ WHERE time > now() - 180d', 'm');
     $analytic_totals = array();
     foreach ($raw_analytics as $row_schema => $row_entries) {
         $schema_parts = explode('.', $row_schema);
         $duration = $schema_parts[0];
         foreach ($row_entries as $row_entry) {
             $time = $row_entry['time'];
             if (!isset($analytic_totals[$duration][$time])) {
                 $analytic_totals[$duration][$time] = 0;
             }
             $analytic_totals[$duration][$time] += $row_entry['count'];
         }
     }
     @ksort($analytic_totals['1d']);
     @ksort($analytic_totals['1h']);
     $chart_data = array('1d' => '[]', '1h' => '[]');
     foreach ($analytic_totals as $total_duration => $total_entries) {
         $new_chart_data = array();
         foreach ($total_entries as $entry_timestamp => $entry_value) {
             $new_chart_data[] = array($entry_timestamp, $entry_value);
         }
         $chart_data[$total_duration] = json_encode($new_chart_data);
     }
     $this->view->chart_data = $chart_data;
 }
Example #2
0
 public function viewAction()
 {
     $id = (int) $this->getParam('id');
     $podcast = Podcast::find($id);
     if (!$podcast instanceof Podcast) {
         throw new \DF\Exception\DisplayOnly('Podcast not found!');
     }
     $this->view->podcast = $podcast;
     $this->view->social_types = Podcast::getSocialTypes();
     // Stringify list of stations that play this podcast.
     $airs_on = '';
     if (count($podcast->stations) > 0) {
         $airs_on_array = array();
         foreach ($podcast->stations as $station) {
             $airs_on_array[] = '<a href="' . $station->web_url . '" target="_blank">' . $station->name . '</a>';
         }
         $airs_on = 'Airs on ' . \DF\Utilities::joinCompound($airs_on_array);
     }
     $this->view->podcast_airs_on = $airs_on;
     // Paginate episodes.
     $query = $this->em->createQuery('SELECT pe FROM Entity\\PodcastEpisode pe WHERE pe.podcast_id = :podcast AND pe.is_active = 1 ORDER BY pe.timestamp DESC')->setParameter('podcast', $id);
     $this->view->pager = new \DF\Paginator\Doctrine($query, $this->getParam('page', 1), 25);
 }
Example #3
0
 public function contactAction()
 {
     $all_categories = Station::getStationsInCategories();
     $audio_stations = \DF\Utilities::columns($all_categories['audio']['stations'], 2);
     $video_stations = $all_categories['video']['stations'];
     $this->view->station_columns = array(array('<i class="icon ' . $all_categories['audio']['icon'] . '"></i> ' . $all_categories['audio']['name'], $audio_stations[0]), array('&nbsp;', $audio_stations[1]), array('<i class="icon ' . $all_categories['video']['icon'] . '"></i> ' . $all_categories['video']['name'], $video_stations));
     $active_podcasts = array_filter(Podcast::fetchArray('name'), function ($row) {
         return $row['is_approved'];
     });
     $this->view->podcasts = \DF\Utilities::columns($active_podcasts, 3);
     $this->view->podcast_social_types = Podcast::getSocialTypes();
 }
Example #4
0
 public static function getSocialTypes()
 {
     return Podcast::getSocialTypes();
 }