Ejemplo n.º 1
0
 static function getIframeURL($gadget, $context)
 {
     $v = $gadget->getChecksum();
     $view = HttpUtil::getView($gadget, $context);
     $up = '';
     $prefs = $context->getUserPrefs();
     foreach ($gadget->getUserPrefs() as $pref) {
         $name = $pref->getName();
         $value = $prefs->getPref($name);
         if ($value == null) {
             $value = $pref->getDefaultValue();
         }
         $up .= '&up_' . urlencode($name) . '=' . urlencode($value);
     }
     // note: put the URL last, else some browsers seem to get confused (reported by hi5)
     return Config::get('default_iframe_prefix') . 'container=' . $context->getContainer() . ($context->getIgnoreCache() ? '&nocache=1' : '&v=' . $v) . ($context->getModuleId() != 0 ? '&mid=' . $context->getModuleId() : '') . '&lang=' . $context->getLocale()->getLanguage() . '&country=' . $context->getLocale()->getCountry() . '&view=' . $view->getName() . $up . '&url=' . urlencode($context->getUrl());
 }
 /**
  * Tests HttpUtil::getView()
  */
 public function testGetView()
 {
     $this->GadgetServer = new GadgetServer();
     // prevent polution from other test cases + make sure we're not testing
     // a cached result
     $_GET = array('nocache' => 1, 'view' => 'profile');
     $_POST = array();
     $this->GadgetContext = new GadgetContext('GADGET');
     $this->GadgetContext->setUrl('http://test.chabotc.com/testGadget.xml');
     $this->gadget = $this->GadgetServer->processGadget($this->GadgetContext);
     $view = HttpUtil::getView($this->gadget, $this->GadgetContext);
     $this->assertEquals('profile', $view->getName());
     $this->assertEquals('HTML', $view->getType());
     $this->assertEquals('', $view->getHref());
     $this->assertEquals("content", $view->getContent());
     $this->assertEquals("400", $view->preferedHeight);
     $this->assertEquals("300", $view->preferedWidth);
     $this->assertFalse($view->getQuirks());
 }
Ejemplo n.º 3
0
 /**
  * Takes the gadget to output, and depending on its content type calls either outputHtml-
  * or outputUrlGadget
  *
  * @param Gadget $gadget gadget to render
  * @param string $view the view to render (only valid with a html content type)
  */
 private function outputGadget($gadget, $context)
 {
     $view = HttpUtil::getView($gadget, $context);
     switch ($view->getType()) {
         case 'HTML':
             $this->outputHtmlGadget($gadget, $context, $view);
             break;
         case 'URL':
             $this->outputUrlGadget($gadget, $context, $view);
             break;
     }
 }