本文整理匯總了PHP中Preference::setPreferenceValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP Preference::setPreferenceValue方法的具體用法?PHP Preference::setPreferenceValue怎麽用?PHP Preference::setPreferenceValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Preference
的用法示例。
在下文中一共展示了Preference::setPreferenceValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: preference
function preference($args)
{
// Preference methods automatically refer only to preferences
// belonging to the current user.
$method = $_SERVER['REQUEST_METHOD'];
switch ($method) {
case 'GET':
$name = getUserGetVar('name');
if ($name) {
$preferenceDao = new PreferenceDAO();
$preference =& $preferenceDao->getPreference($name);
if (null == $preference) {
header('HTTP/1.1 404 Not Found');
echo '<h1>404 Not Found</h1><p>No such preference</p>';
} else {
header('Content-type: text/plain');
echo $preference->getPreferenceName() . ':' . $preference->getPreferenceValue();
}
} else {
$preferenceDao = new PreferenceDAO();
$preferences =& $preferenceDao->getPreferences();
header('Content-type: text/plain');
$first = true;
foreach ($preferences as $pref) {
if (!$first) {
echo "\n";
} else {
$first = false;
}
echo $pref->getPreferenceName() . ':' . $pref->getPreferenceValue();
}
}
break;
case 'POST':
$name = getUserGetVar('name');
$value = getUserPostVar('value');
if (null == $name || null == $value) {
header('HTTP/1.1 400 Bad Request');
echo "<h1>400 Bad Request</h1><p>Must specify name and vaule parameters</p>";
} else {
if ('annotations.show' == $name || 'annotations.show-user' == $name || 'annotations.note-edit-mode' == $name) {
$preference = new Preference();
$preference->setPreferenceName($name);
$preference->setPreferenceValue($value);
$preferenceDao = new PreferenceDAO();
if (null == $preferenceDao->getPreference($name)) {
$preferenceDao->insertPreference($preference);
} else {
$preferenceDao->updatePreference($preference);
}
header('HTTP/1.1 204 Preference Set');
} else {
header('HTTP/1.1 404 Invalid Preference');
echo "<h1>404 Invalid Preference</h1><p>The preference name you specificed is not valid.</p>";
}
}
break;
}
}