/** * Output's a URL content type gadget, it adds libs=<list:of:js:libraries>.js and user preferences * to the href url, and redirects the browser to it * * @param Gadget $gadget */ private function outputUrlGadget($gadget, $context, $view) { // Preserve existing query string parameters. $redirURI = $view->getHref(); $queryStr = strpos($redirURI, '?') !== false ? substr($redirURI, strpos($redirURI, '?')) : ''; $query = $queryStr; // TODO: userprefs on the fragment rather than query string $query .= $this->getPrefsQueryString($gadget->getUserPrefValues()); $libs = array(); $forcedLibs = Config::get('focedJsLibs'); if ($forcedLibs == null) { $reqs = $gadget->getRequires(); foreach ($reqs as $key => $val) { $libs[] = $key; } } else { $libs = explode(':', $forcedLibs); } $query .= $this->appendLibsToQuery($libs, $gadget); // code bugs out with me because of the invalid url syntax since we dont have a URI class to fix it for us // this works around that if (substr($query, 0, 1) == '&') { $query = '?' . substr($query, 1); } $redirURI .= $query; header('Location: ' . $redirURI); die; }
/** * Tests Gadget->setPrefs() */ public function testSetPrefs() { $this->Gadget->setPrefs('prefs'); $this->assertEquals('prefs', $this->Gadget->getUserPrefValues()); }