本文整理匯總了PHP中Gadget::getUserPrefValues方法的典型用法代碼示例。如果您正苦於以下問題:PHP Gadget::getUserPrefValues方法的具體用法?PHP Gadget::getUserPrefValues怎麽用?PHP Gadget::getUserPrefValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Gadget
的用法示例。
在下文中一共展示了Gadget::getUserPrefValues方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: outputUrlGadget
/**
* 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;
}
示例2: testSetPrefs
/**
* Tests Gadget->setPrefs()
*/
public function testSetPrefs()
{
$this->Gadget->setPrefs('prefs');
$this->assertEquals('prefs', $this->Gadget->getUserPrefValues());
}