Exemplo n.º 1
0
 public function indexAction()
 {
     $this->forceInsecure();
     // Pull podcasts.
     $podcasts = Podcast::fetchLatest();
     $this->view->podcasts = $podcasts;
     // Pull large photos and news for rotator.
     $network_news = NetworkNews::fetchFeatured();
     $this->view->network_news = $network_news;
     // Pull stations and calendar events.
     $this->_initStations();
     $this->_initEvents();
     // Pull conventions.
     $conventions = Convention::getAllConventions();
     $this->view->conventions_upcoming = $conventions['upcoming'];
     $this->view->conventions_archived = $conventions['archived'];
     /*
     // Pull rotators.
     $rotators = Rotator::fetch();
     $this->view->rotators = $rotators;
     */
     // Special event flagging and special formatting.
     $special_event = \PVL\Utilities::showSpecialEventsMode();
     $this->view->special_event = $special_event;
     if ($special_event) {
         $autoplay_station = Settings::getSetting('special_event_station_id', 0);
         if ($autoplay_station != 0) {
             $this->view->station_id = $autoplay_station;
             $this->view->autoplay = true;
         }
         $this->view->special_event_embed = trim(Settings::getSetting('special_event_embed_code'));
         $this->view->special_chat_embed = trim(Settings::getSetting('special_event_chat_code'));
     }
     $this->view->autoplay = (bool) $this->getParam('autoplay', true);
 }
Exemplo n.º 2
0
 public static function run()
 {
     $di = \Phalcon\Di::getDefault();
     $em = $di->get('em');
     // Assemble news items from other sources.
     $news_items_raw = array(self::_runTumblrNews($di), self::_runConventionPromotions($di), self::_runPodcastEpisodes($di), self::_runScheduleItems($di));
     $news_items = array();
     foreach ($news_items_raw as $item_group) {
         $news_items = array_merge($news_items, (array) $item_group);
     }
     // Replace/insert into database.
     $news_stats = array('inserted' => 0, 'updated' => 0, 'deleted' => 0);
     if (!empty($news_items)) {
         $old_news_raw = NetworkNews::fetchAll();
         $old_news = array();
         foreach ($old_news_raw as $old_row) {
             $old_news[$old_row->id] = $old_row;
         }
         // Update or insert items.
         foreach ($news_items as $item) {
             if (isset($old_news[$item['id']])) {
                 $news_stats['updated']++;
                 $record = $old_news[$item['id']];
             } else {
                 $news_stats['inserted']++;
                 $record = new NetworkNews();
             }
             $record->fromArray($item);
             $em->persist($record);
             unset($old_news[$item['id']]);
         }
         // Delete unreferenced items.
         foreach ($old_news as $item_id => $item_to_remove) {
             $news_stats['deleted']++;
             $em->remove($item_to_remove);
         }
         $em->flush();
         // Flush cache of homepage news.
         \DF\Cache::remove('homepage_featured_news');
     }
     \PVL\Debug::print_r($news_stats);
 }