/**
  * Retrieves a gadget specification from the Internet, processes its views and
  * adds it to the cache.
  */
 private function fetchFromWeb($url, $ignoreCache)
 {
     $remoteContentRequest = new RemoteContentRequest($url);
     $remoteContentRequest->getRequest($url, $ignoreCache);
     $spec = $this->fetcher->fetchRequest($remoteContentRequest);
     $specParser = new GadgetSpecParser();
     $context = new ProxyGadgetContext($url);
     $gadgetSpec = $specParser->parse($spec->getResponseContent(), $context);
     return $gadgetSpec;
 }
 /**
  * Retrieves a gadget specification from the Internet, processes its views and
  * adds it to the cache.
  */
 private function fetchFromWeb($url, $ignoreCache)
 {
     $remoteContentRequest = new RemoteContentRequest($url);
     $remoteContentRequest->getOptions()->ignoreCache = $ignoreCache;
     $remoteContent = new BasicRemoteContent();
     $spec = $remoteContent->fetch($remoteContentRequest);
     $gadgetSpecParser = new GadgetSpecParser();
     $gadgetSpec = $gadgetSpecParser->parse($spec->getResponseContent());
     return $gadgetSpec;
 }
Esempio n. 3
0
 private function specLoad($context)
 {
     if ($context->getBlacklist() != null && $context->getBlacklist()->isBlacklisted($context->getUrl())) {
         throw new GadgetException("Gadget is blacklisted");
     }
     $request = new RemoteContentRequest($context->getUrl());
     $xml = $context->getHttpFetcher()->fetch($request, $context);
     if ($xml->getHttpCode() != '200') {
         throw new GadgetException("Failed to retrieve gadget content");
     }
     $specParser = new GadgetSpecParser();
     $gadget = $specParser->parse($xml->getResponseContent(), $context);
     return $gadget;
 }
 /**
  * Returns the processed gadget spec
  *
  * @return GadgetSpec
  */
 public function createGadget()
 {
     $gadgetUrl = $this->context->getUrl();
     if ($this->context->getBlacklist() != null && $this->context->getBlacklist()->isBlacklisted($gadgetUrl)) {
         throw new GadgetException("The Gadget ({$gadgetUrl}) is blacklisted and can not be rendered");
     }
     // Fetch the gadget's content and create a GadgetSpec
     $gadgetContent = $this->fetchGadget($gadgetUrl);
     $gadgetSpecParser = new GadgetSpecParser();
     $gadgetSpec = $gadgetSpecParser->parse($gadgetContent);
     $gadget = new Shindig_Gadget($gadgetSpec, $this->context);
     // Process the gadget: fetching remote resources, processing & applying the correct translations, user prefs and feature resolving
     $this->fetchResources($gadget);
     $this->mergeLocales($gadget);
     $this->parseUserPrefs($gadget);
     $this->addSubstitutions($gadget);
     $this->applySubstitutions($gadget);
     $this->parseFeatures($gadget);
     return $gadget;
 }
 /**
  * Tests GadgetSpecParser->parse()
  */
 public function testParse()
 {
     $gadgetParsed = $this->GadgetSpecParser->parse($this->Gadget, $this->Context);
     $views = $gadgetParsed->getViews();
     $this->assertEquals('<h1>Hello, world!</h1>', trim($views[DEFAULT_VIEW]->getContent()));
 }
Esempio n. 6
0
 /**
  * Tests GadgetSpecParser->parse()
  */
 public function testParse()
 {
     $gadgetParsed = $this->GadgetSpecParser->parse($this->Gadget, $this->Context);
     $view = $gadgetParsed->views['home'];
     $this->assertEquals('<h1>Hello, world!</h1>', trim($view['content']));
 }