本文整理汇总了PHP中Preferences::getSaveBlacklist方法的典型用法代码示例。如果您正苦于以下问题:PHP Preferences::getSaveBlacklist方法的具体用法?PHP Preferences::getSaveBlacklist怎么用?PHP Preferences::getSaveBlacklist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preferences
的用法示例。
在下文中一共展示了Preferences::getSaveBlacklist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptionKinds
/**
* Return an associative array mapping preferences keys to the kind of a preference they're
* used for. Different kinds are handled differently when setting or reading preferences.
*
* See User::listOptionKinds for the list of valid option types that can be provided.
*
* @see User::listOptionKinds
* @param IContextSource $context
* @param array $options Assoc. array with options keys to check as keys.
* Defaults to $this->mOptions.
* @return array The key => kind mapping data
*/
public function getOptionKinds(IContextSource $context, $options = null)
{
$this->loadOptions();
if ($options === null) {
$options = $this->mOptions;
}
$prefs = Preferences::getPreferences($this, $context);
$mapping = array();
// Pull out the "special" options, so they don't get converted as
// multiselect or checkmatrix.
$specialOptions = array_fill_keys(Preferences::getSaveBlacklist(), true);
foreach ($specialOptions as $name => $value) {
unset($prefs[$name]);
}
// Multiselect and checkmatrix options are stored in the database with
// one key per option, each having a boolean value. Extract those keys.
$multiselectOptions = array();
foreach ($prefs as $name => $info) {
if (isset($info['type']) && $info['type'] == 'multiselect' || isset($info['class']) && $info['class'] == 'HTMLMultiSelectField') {
$opts = HTMLFormField::flattenOptions($info['options']);
$prefix = isset($info['prefix']) ? $info['prefix'] : $name;
foreach ($opts as $value) {
$multiselectOptions["{$prefix}{$value}"] = true;
}
unset($prefs[$name]);
}
}
$checkmatrixOptions = array();
foreach ($prefs as $name => $info) {
if (isset($info['type']) && $info['type'] == 'checkmatrix' || isset($info['class']) && $info['class'] == 'HTMLCheckMatrix') {
$columns = HTMLFormField::flattenOptions($info['columns']);
$rows = HTMLFormField::flattenOptions($info['rows']);
$prefix = isset($info['prefix']) ? $info['prefix'] : $name;
foreach ($columns as $column) {
foreach ($rows as $row) {
$checkmatrixOptions["{$prefix}{$column}-{$row}"] = true;
}
}
unset($prefs[$name]);
}
}
// $value is ignored
foreach ($options as $key => $value) {
if (isset($prefs[$key])) {
$mapping[$key] = 'registered';
} elseif (isset($multiselectOptions[$key])) {
$mapping[$key] = 'registered-multiselect';
} elseif (isset($checkmatrixOptions[$key])) {
$mapping[$key] = 'registered-checkmatrix';
} elseif (isset($specialOptions[$key])) {
$mapping[$key] = 'special';
} elseif (substr($key, 0, 7) === 'userjs-') {
$mapping[$key] = 'userjs';
} else {
$mapping[$key] = 'unused';
}
}
return $mapping;
}