本文整理汇总了PHP中filter_get_global_states函数的典型用法代码示例。如果您正苦于以下问题:PHP filter_get_global_states函数的具体用法?PHP filter_get_global_states怎么用?PHP filter_get_global_states使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_get_global_states函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
global $CFG, $DB;
require_once $CFG->libdir . '/adminlib.php';
// various admin-only functions
require_once $CFG->libdir . '/classes/plugin_manager.php';
$filtername = $this->arguments[0];
$newstate = $this->arguments[1];
if ($newstate != 1 && $newstate != -1 && $newstate != -9999) {
cli_error("Invalid filter value, use: 1 for on, -1 per course, -9999 for off");
}
// Clean up bogus filter states first.
$plugininfos = core_plugin_manager::instance()->get_plugins_of_type('filter');
$filters = array();
$states = filter_get_global_states();
foreach ($states as $state) {
if (!isset($plugininfos[$state->filter]) and !get_config('filter_' . $state->filter, 'version')) {
// Purge messy leftovers after incorrectly uninstalled plugins and unfinished installs.
$DB->delete_records('filter_active', array('filter' => $state->filter));
$DB->delete_records('filter_config', array('filter' => $state->filter));
error_log('Deleted bogus "filter_' . $state->filter . '" states and config data.');
} else {
$filters[$state->filter] = $state;
}
}
if (!isset($filters[$filtername])) {
cli_error("Invalid filter name: '{$filtername}''. Possible values: " . implode(",", array_keys($filters)) . '.');
}
filter_set_global_state($filtername, $newstate);
if ($newstate == TEXTFILTER_DISABLED) {
filter_set_applies_to_strings($filtername, false);
}
reset_text_filters_cache();
core_plugin_manager::reset_caches();
echo "Updated {$filtername} to state = {$newstate}\n";
}
开发者ID:dariogs,项目名称:moosh,代码行数:36,代码来源:FilterSet.php
示例2: filter_get_globally_enabled
/**
* Return a list of all the filters that may be in use somewhere.
*
* @staticvar array $enabledfilters
* @return array where the keys and values are both the filter name, like 'tex'.
*/
function filter_get_globally_enabled()
{
static $enabledfilters = null;
if (is_null($enabledfilters)) {
$filters = filter_get_global_states();
$enabledfilters = array();
foreach ($filters as $filter => $filerinfo) {
if ($filerinfo->active != TEXTFILTER_DISABLED) {
$enabledfilters[$filter] = $filter;
}
}
}
return $enabledfilters;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:20,代码来源:filterlib.php
示例3: get_global_states
/**
* Provides access to the results of {@link filter_get_global_states()}
* but indexed by the normalized filter name
*
* The legacy filter name is available as ->legacyname property.
*
* @param bool $disablecache do not attempt to obtain data from the cache
* @return array
*/
protected static function get_global_states($disablecache = false)
{
global $DB;
$cache = cache::make('core', 'plugininfo_filter');
$globalstates = $cache->get('globalstates');
if ($globalstates === false or $disablecache) {
if (!$DB->get_manager()->table_exists('filter_active')) {
// Not installed yet.
$cache->set('globalstates', array());
return array();
}
$globalstates = array();
foreach (filter_get_global_states() as $name => $info) {
if (strpos($name, '/') !== false) {
// Skip existing before upgrade to new names.
continue;
}
$filterinfo = new stdClass();
$filterinfo->active = $info->active;
$filterinfo->sortorder = $info->sortorder;
$globalstates[$name] = $filterinfo;
}
$cache->set('globalstates', $globalstates);
}
return $globalstates;
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:35,代码来源:pluginlib.php
示例4: get_global_states
/**
* Provides access to the results of {@link filter_get_global_states()}
* but indexed by the normalized filter name
*
* The legacy filter name is available as ->legacyname property.
*
* @param bool $disablecache
* @return array
*/
protected static function get_global_states($disablecache=false) {
global $DB;
static $globalstatescache = null;
if ($disablecache or is_null($globalstatescache)) {
if (!$DB->get_manager()->table_exists('filter_active')) {
// we're upgrading from 1.9 and the table used by {@link filter_get_global_states()}
// does not exist yet
$globalstatescache = array();
} else {
foreach (filter_get_global_states() as $legacyname => $info) {
$name = self::normalize_legacy_name($legacyname);
$filterinfo = new stdClass();
$filterinfo->legacyname = $legacyname;
$filterinfo->active = $info->active;
$filterinfo->sortorder = $info->sortorder;
$globalstatescache[$name] = $filterinfo;
}
}
}
return $globalstatescache;
}
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:34,代码来源:pluginlib.php
示例5: foreach
// Add any missing filters to the DB table.
foreach ($newfilters as $filter => $notused) {
filter_set_global_state($filter, TEXTFILTER_DISABLED);
}
// Reset caches and return
if ($action) {
reset_text_filters_cache();
redirect($returnurl);
}
/// End of process actions =====================================================
/// Print the page heading.
admin_externalpage_print_header();
echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
$activechoices = array(TEXTFILTER_DISABLED => get_string('disabled', 'filters'), TEXTFILTER_OFF => get_string('offbutavailable', 'filters'), TEXTFILTER_ON => get_string('on', 'filters'));
$applytochoices = array(0 => get_string('content', 'filters'), 1 => get_string('contentandheadings', 'filters'));
$filters = filter_get_global_states();
// In case any new filters have been installed, but not put in the table yet.
$filternames = filter_get_all_installed();
$newfilters = $filternames;
foreach ($filters as $filter => $notused) {
unset($newfilters[$filter]);
}
$stringfilters = filter_get_string_filters();
$table = new html_table();
$table->head = array(get_string('filter'), get_string('isactive', 'filters'), get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('delete'));
$table->align = array('left', 'left', 'center', 'left', 'left');
$table->width = '100%';
$table->data = array();
$lastactive = null;
foreach ($filters as $filter => $filterinfo) {
if ($filterinfo->active != TEXTFILTER_DISABLED) {
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:filters.php
示例6: test_filter_get_global_states
public function test_filter_get_global_states()
{
// Setup fixture.
filter_set_global_state('filter/1', TEXTFILTER_ON);
filter_set_global_state('filter/2', TEXTFILTER_OFF);
filter_set_global_state('filter/3', TEXTFILTER_DISABLED);
// Exercise SUT.
$filters = filter_get_global_states();
// Validate.
$this->assertEqual(array('filter/1' => (object) array('filter' => 'filter/1', 'active' => TEXTFILTER_ON, 'sortorder' => 1), 'filter/2' => (object) array('filter' => 'filter/2', 'active' => TEXTFILTER_OFF, 'sortorder' => 2), 'filter/3' => (object) array('filter' => 'filter/3', 'active' => TEXTFILTER_DISABLED, 'sortorder' => 3)), $filters);
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:11,代码来源:testfilterconfig.php
示例7: get_global_states
/**
* Provides access to the results of {@link filter_get_global_states()}
* but indexed by the normalized filter name
*
* The legacy filter name is available as ->legacyname property.
*
* @param bool $disablecache
* @return array
*/
protected static function get_global_states($disablecache = false)
{
global $DB;
static $globalstatescache = null;
if ($disablecache or is_null($globalstatescache)) {
$globalstatescache = array();
if (!$DB->get_manager()->table_exists('filter_active')) {
// Not installed yet.
return $globalstatescache;
}
foreach (filter_get_global_states() as $name => $info) {
if (strpos($name, '/') !== false) {
// Skip existing before upgrade to new names.
continue;
}
$filterinfo = new stdClass();
$filterinfo->active = $info->active;
$filterinfo->sortorder = $info->sortorder;
$globalstatescache[$name] = $filterinfo;
}
}
return $globalstatescache;
}
开发者ID:Burick,项目名称:moodle,代码行数:32,代码来源:pluginlib.php
注:本文中的filter_get_global_states函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论