Ejemplo n.º 1
0
 public function testMyBlogFeed()
 {
     $sFilePath = "tests" . DIRECTORY_SEPARATOR . "resources" . DIRECTORY_SEPARATOR . "myblogfeed.xml";
     $sFileContents = File::get($sFilePath);
     $oFile = Helper::oXMLStringToFeedObject($sFileContents);
     return $this->assertTrue(true);
 }
Ejemplo n.º 2
0
 public function fabrics()
 {
     $prod = Product::find(Input::get('id'));
     $brand = \App\Library\Helper::getBrand($prod);
     // dd($brand);
     $finish = Finish::where('brand', $brand)->with('fabrics')->get();
     $action = 'admin.products.updatefabrics';
     return view(Config('constants.adminProductView') . '.fabrics', compact('finish', 'prod', 'action'));
 }
Ejemplo n.º 3
0
 public static function pullFeed($id)
 {
     $oFeed = Feed::find($id);
     if (isset($oFeed)) {
         try {
             echo "pulling: ", $oFeed->url, "<br/>";
             // get the guid of the last pulled item so we know where to stop
             $oFeedItem = $oFeed->feedItems->first();
             // stop at null, unless we have some feed items already, then stop at most recent
             $sStopAt = null;
             if (isset($oFeedItem)) {
                 // there are already items from this feed
                 $sStopAt = $oFeedItem->guid;
             }
             $context = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));
             $xmlFeed = @file_get_contents($oFeed->url, false, $context);
             $iItemsFetched = 0;
             if (!empty($xmlFeed)) {
                 $oScrapedFeed = Helper::getFeedStructureFromXML($oFeed, $xmlFeed, $sStopAt);
                 $iItemsFetched += count($oScrapedFeed->aoItems);
                 if (isset($oScrapedFeed->thumb)) {
                     $oFeed->thumb = $oScrapedFeed->thumb;
                 }
             } else {
                 // todo: failed to fetch feed
             }
             $oFeed->lastPulledCount = $iItemsFetched;
             $oFeed->hit_count = $oFeed->hit_count + 1;
             $oFeed->item_count = $oFeed->item_count + $iItemsFetched;
             $mytime = Carbon::now();
             $oFeed->lastPulled = $mytime->toDateTimeString();
             $oFeed->save();
         } catch (Exception $e) {
             echo "fetching feed (", $oFeed->id, ") ", $oFeed->url, " failed", "<br/>";
         }
     }
 }