Ejemplo n.º 1
0
 public function doGet()
 {
     try {
         if (empty($_GET['url'])) {
             throw new GadgetException("Missing required parameter: url");
         }
         $this->context = new GadgetContext('GADGET');
         $gadgetSigner = Config::get('security_token_signer');
         $gadgetSigner = new $gadgetSigner();
         try {
             $token = $this->context->extractAndValidateToken($gadgetSigner);
         } catch (Exception $e) {
             // no token given, this is a fatal error if 'render_token_required' is set to true
             if (Config::get('render_token_required')) {
                 $this->showError($e);
             } else {
                 $token = '';
             }
         }
         $gadgetSpecFactory = new GadgetFactory($this->context, $token);
         $gadget = $gadgetSpecFactory->createGadget();
         $this->setCachingHeaders();
         $this->renderGadget($gadget);
     } catch (Exception $e) {
         $this->showError($e);
     }
 }
 /**
  * fetch a OpenSocial application metadata
  *
  * @param string $url
  * @param string $culture
  */
 public static function fetchGadgetMetadata($url, $culture)
 {
     $cul = explode('_', $culture);
     $_GET['nocache'] = 1;
     $context = new MetadataGadgetContext(self::arrayToObject(array('country' => isset($cul[1]) ? $cul[1] : 'ALL', 'language' => $cul[0], 'view' => 'default', 'container' => 'openpne')), $url);
     $gadgetServer = new GadgetFactory($context, null);
     $gadgets = $gadgetServer->createGadget();
     return $gadgets;
 }
Ejemplo n.º 3
0
 public function process($requests)
 {
     $response = array();
     foreach ($requests->gadgets as $gadget) {
         try {
             $gadgetUrl = $gadget->url;
             $gadgetModuleId = $gadget->moduleId;
             $context = new MetadataGadgetContext($requests->context, $gadgetUrl);
             $token = $this->getSecurityToken();
             $gadgetServer = new GadgetFactory($context, $token);
             $gadget = $gadgetServer->createGadget($gadgetUrl);
             $response[] = $this->makeResponse($gadget, $gadgetModuleId, $gadgetUrl, $context);
         } catch (Exception $e) {
             $response[] = array('errors' => array($e->getMessage()), 'moduleId' => $gadgetModuleId, 'url' => $gadgetUrl);
         }
     }
     return $response;
 }
Ejemplo n.º 4
0
 /**
  * Uses the GadgetFactory to instrance the specified gadget
  *
  * @param string $gadgetUrl
  */
 private function createGadget($gadgetUrl)
 {
     // Only include these files if appropiate, else it would slow down the entire proxy way to much
     require_once 'src/gadgets/GadgetSpecParser.php';
     require_once 'src/gadgets/GadgetBlacklist.php';
     require_once 'src/gadgets/sample/BasicGadgetBlacklist.php';
     require_once 'src/gadgets/GadgetContext.php';
     require_once 'src/gadgets/GadgetFactory.php';
     require_once 'src/gadgets/GadgetSpec.php';
     require_once 'src/gadgets/Gadget.php';
     require_once 'src/gadgets/GadgetException.php';
     require_once 'src/gadgets/rewrite/GadgetRewriter.php';
     require_once 'src/gadgets/rewrite/DomRewriter.php';
     require_once 'src/gadgets/rewrite/ContentRewriter.php';
     // make sure our context returns the gadget url and not the proxied document url
     $this->context->setUrl($gadgetUrl);
     // and create & return the gadget
     $gadgetSpecFactory = new GadgetFactory($this->context, null);
     $gadget = $gadgetSpecFactory->createGadget();
     return $gadget;
 }
 public function __construct(GadgetContext $context, $token)
 {
     parent::__construct($context, $token);
 }