Ejemplo n.º 1
0
 public function onRun()
 {
     $all_data = RssModel::all();
     foreach ($all_data as $rss_data) {
         // for loading sources
         $rss = simplexml_load_file($rss_data->url);
         $last_updated_date = (int) $rss_data->last_build_date;
         foreach ($rss->channel->item as $item) {
             if ($last_updated_date >= (int) strtotime($item->pubDate)) {
                 break;
             } else {
                 // update rainlab blog RssModel here
                 $blog_post = new Post();
                 $blog_post->title = $item->title;
                 $temp_slug = str_replace(array("http://www.gamespot.com/articles/", "http://www.gamespot.com/reviews/", "http://ap.ign.com/"), "", $item->link);
                 $blog_post->slug = str_replace("/", "-", $temp_slug);
                 $blog_post->content = str_replace("<iframe src=\" ", "<iframe src= \"www.gamespot.com", $item->description);
                 $blog_post->excerpt = substr(strip_tags($item->description), 0, 500);
                 $blog_post->published = '0';
                 // set it to 0 if moderator wants to publish it manually
                 $blog_post->published_at = strtotime($item->pubDate);
                 $blog_post->save();
             }
         }
         if ($last_updated_date != (int) strtotime($rss->channel->item[0]->pubDate)) {
             $rss_data->last_build_date = strtotime($rss->channel->item[0]->pubDate);
             $rss_data->save();
         }
     }
     // these following codes  are required for updating rss_sources table
     //$rss_post = new RssModel();
     //$rss_post->name = "Gamespot News ";
     //$rss_post->name = "Gamespot Reviews ";
     //$rss_post->name = "Ign Rss ";
     //$rss_post->url = "http://www.gamespot.com/feeds/news/";
     //$rss_post->url = "http://www.gamespot.com/feeds/reviews/";
     //$rss_post->url = "http://ap.ign.com/feed.xml";
     //$rss_post->last_build_date = "";
     //$rss_post->save();
 }
Ejemplo n.º 2
0
 public function run()
 {
     RssModel::create(['name' => 'Gamespot News', 'url' => 'http://www.gamespot.com/feeds/news/', 'last_build_date' => strtotime(date('Y-m-d H:i:s')), 'created_date' => date('Y-m-d H:i:s')]);
     RssModel::create(['name' => 'Gamespot Reviews', 'url' => 'http://www.gamespot.com/feeds/reviews/', 'last_build_date' => strtotime(date('Y-m-d H:i:s')), 'created_date' => date('Y-m-d H:i:s')]);
     RssModel::create(['name' => 'Ign Rss ', 'url' => 'http://ap.ign.com/feed.xml', 'last_build_date' => strtotime(date('Y-m-d H:i:s')), 'created_date' => date('Y-m-d H:i:s')]);
 }