• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP filter_set_local_config函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中filter_set_local_config函数的典型用法代码示例。如果您正苦于以下问题:PHP filter_set_local_config函数的具体用法?PHP filter_set_local_config怎么用?PHP filter_set_local_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了filter_set_local_config函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: save_changes

 /**
  * Override this method to save the settings to the database. The default
  * implementation will probalby be sufficient for most simple cases.
  * @param object $data the form data that was submitted.
  */
 public function save_changes($data)
 {
     $data = (array) $data;
     unset($data['filter']);
     unset($data['contextid']);
     foreach ($data as $name => $value) {
         if ($value !== '') {
             filter_set_local_config($this->filter, $this->context->id, $name, $value);
         } else {
             filter_unset_local_config($this->filter, $this->context->id, $name);
         }
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:18,代码来源:local_settings_form.php


示例2: process_config

 public function process_config($data)
 {
     $data = (object) $data;
     if (strpos($data->filter, 'filter/') === 0) {
         $data->filter = substr($data->filter, 7);
     } else {
         if (strpos($data->filter, '/') !== false) {
             // Unsupported old filter.
             return;
         }
     }
     if (!filter_is_enabled($data->filter)) {
         // Not installed or not enabled, nothing to do
         return;
     }
     filter_set_local_config($data->filter, $this->task->get_contextid(), $data->name, $data->value);
 }
开发者ID:Jinelle,项目名称:moodle,代码行数:17,代码来源:restore_stepslib.php


示例3: process_config

    public function process_config($data) {

        $data = (object)$data;

        if (!filter_is_enabled($data->filter)) { // Not installed or not enabled, nothing to do
            return;
        }
        filter_set_local_config($data->filter, $this->task->get_contextid(), $data->name, $data->value);
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:9,代码来源:restore_stepslib.php


示例4: test_filter_delete_all_for_context

 public function test_filter_delete_all_for_context()
 {
     // Setup fixture.
     filter_set_global_state('filter/name', TEXTFILTER_ON);
     filter_set_local_state('filter/name', 123, TEXTFILTER_OFF);
     filter_set_local_config('filter/name', 123, 'settingname', 'A value');
     filter_set_local_config('filter/other', 123, 'settingname', 'Other value');
     filter_set_local_config('filter/other', 122, 'settingname', 'Other value');
     // Exercise SUT.
     filter_delete_all_for_context(123);
     // Validate.
     $this->assertEqual(1, $this->testdb->count_records('filter_active'));
     $this->assertTrue($this->testdb->record_exists('filter_active', array('contextid' => $this->syscontext->id)));
     $this->assertEqual(1, $this->testdb->count_records('filter_config'));
     $this->assertTrue($this->testdb->record_exists('filter_config', array('filter' => 'filter/other')));
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:16,代码来源:testfilterconfig.php


示例5: populate_test_database

function populate_test_database($syscontext, $numcategories, $numcourses, $nummodules, $numoverrides, $numconfigs)
{
    global $DB, $OUTPUT;
    set_time_limit(600);
    $syscontext->id = $DB->insert_record('context', $syscontext);
    // Category contexts.
    $categoryparents = array($syscontext);
    $categories = array();
    for ($i = 0; $i < $numcategories; $i++) {
        $context = insert_context(CONTEXT_COURSECAT, $i, $categoryparents[array_rand($categoryparents)]);
        $categoryparents[] = $context;
        $categories[$context->id] = $context;
    }
    echo $OUTPUT->notification('Created ' . $numcategories . ' course category contexts.', 'notifysuccess');
    flush();
    // Course contexts.
    $courses = array();
    for ($i = 0; $i < $numcourses; $i++) {
        $context = insert_context(CONTEXT_COURSE, $i, $categories[array_rand($categories)]);
        $courses[$context->id] = $context;
    }
    echo $OUTPUT->notification('Created ' . $numcourses . ' course contexts.', 'notifysuccess');
    flush();
    // Activities contexts.
    $mods = array();
    $prog = new progress_bar('modbar', 500, true);
    $transaction = $DB->start_delegated_transaction();
    for ($i = 0; $i < $nummodules; $i++) {
        $context = insert_context(CONTEXT_MODULE, $i, $courses[array_rand($courses)]);
        $mods[$context->id] = $context;
        if ($i % 50) {
            $prog->update($i, $nummodules, '');
        }
    }
    $transaction->allow_commit();
    echo $OUTPUT->notification('Created ' . $nummodules . ' module contexts.', 'notifysuccess');
    flush();
    $contexts = $categories + $courses + $mods;
    // Global settings.
    $installedfilters = filter_get_all_installed();
    $counts = array(TEXTFILTER_DISABLED => 0, TEXTFILTER_OFF => 0, TEXTFILTER_ON => 0);
    foreach ($installedfilters as $filter => $notused) {
        $state = array_rand($counts);
        filter_set_global_state($filter, $state);
        $counts[$state]++;
    }
    echo $OUTPUT->notification('Set global setting: ' . $counts[TEXTFILTER_DISABLED] . ' disabled, ' . $counts[TEXTFILTER_OFF] . ' off and ' . $counts[TEXTFILTER_ON] . ' on.', 'notifysuccess');
    flush();
    // Local overrides.
    $localstates = array(TEXTFILTER_OFF => 0, TEXTFILTER_ON => 0);
    $prog = new progress_bar('locbar', 500, true);
    $transaction = $DB->start_delegated_transaction();
    for ($i = 0; $i < $numoverrides; $i++) {
        filter_set_local_state(array_rand($installedfilters), array_rand($contexts), array_rand($localstates));
        if ($i % 50) {
            $prog->update($i, $numoverrides, '');
        }
    }
    $transaction->allow_commit();
    echo $OUTPUT->notification('Set ' . $numoverrides . ' local overrides.', 'notifysuccess');
    flush();
    // Local config.
    $variablenames = array('frog' => 0, 'toad' => 0, 'elver' => 0, 'eft' => 0, 'tadpole' => 0);
    $prog = new progress_bar('confbar', 500, true);
    $transaction = $DB->start_delegated_transaction();
    for ($i = 0; $i < $numconfigs; $i++) {
        filter_set_local_config(array_rand($installedfilters), array_rand($contexts), array_rand($variablenames), random_string(rand(20, 40)));
        if ($i % 50) {
            $prog->update($i, $numconfigs, '');
        }
    }
    $transaction->allow_commit();
    echo $OUTPUT->notification('Set ' . $numconfigs . ' local configs.', 'notifysuccess');
    flush();
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:75,代码来源:filtersettingsperformancetester.php


示例6: test_filter_get_globally_enabled_filters_with_config

 public function test_filter_get_globally_enabled_filters_with_config()
 {
     $this->setup_available_in_context_tests();
     // Set few filters.
     filter_set_global_state('one', TEXTFILTER_ON);
     filter_set_global_state('three', TEXTFILTER_OFF, -1);
     filter_set_global_state('two', TEXTFILTER_DISABLED);
     // Set global config.
     filter_set_local_config('one', $this->syscontext->id, 'test1a', 'In root');
     filter_set_local_config('one', $this->syscontext->id, 'test1b', 'In root');
     filter_set_local_config('two', $this->syscontext->id, 'test2a', 'In root');
     filter_set_local_config('two', $this->syscontext->id, 'test2b', 'In root');
     // Set child config.
     filter_set_local_config('one', $this->childcontext->id, 'test1a', 'In child');
     filter_set_local_config('one', $this->childcontext->id, 'test1b', 'In child');
     filter_set_local_config('two', $this->childcontext->id, 'test2a', 'In child');
     filter_set_local_config('two', $this->childcontext->id, 'test2b', 'In child');
     filter_set_local_config('three', $this->childcontext->id, 'test3a', 'In child');
     filter_set_local_config('three', $this->childcontext->id, 'test3b', 'In child');
     // Check.
     $actual = filter_get_globally_enabled_filters_with_config();
     $this->assertCount(2, $actual);
     $this->assertEquals(['three', 'one'], array_keys($actual));
     // Checks sortorder.
     $this->assertArrayHasKey('one', $actual);
     $this->assertArrayNotHasKey('two', $actual);
     $this->assertArrayHasKey('three', $actual);
     $this->assertEquals(['test1a' => 'In root', 'test1b' => 'In root'], $actual['one']);
     $this->assertEquals([], $actual['three']);
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:30,代码来源:filterlib_test.php


示例7: restore_write_local_filter_settings

/**
 * Write any per-context filter settings from the backup XML to the DB.
 * @param object $restore the restore we are part of.
 * @param object $data sata loaded from the XML.
 * @param object $newmodcontext the restored context object.
 */
function restore_write_local_filter_settings($restore, $data, $newcontext)
{
    if (filter_context_may_have_filter_settings($newcontext)) {
        return;
    }
    $installedfilters = filter_get_all_installed();
    if (!isset($data->filteractives)) {
        $data->filteractives = array();
    }
    foreach ($data->filteractives as $filter => $state) {
        if (isset($installedfilters[$filter])) {
            filter_set_local_state($filter, $newcontext->id, $state);
        }
    }
    if (!isset($data->filterconfigs)) {
        $data->filterconfigs = array();
    }
    foreach ($data->filterconfigs as $fc) {
        if (isset($installedfilters[$fc->filter])) {
            filter_set_local_config($fc->filter, $newcontext->id, $fc->name, $fc->value);
        }
    }
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:29,代码来源:restorelib.php



注:本文中的filter_set_local_config函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP filter_set_local_state函数代码示例发布时间:2022-05-15
下一篇:
PHP filter_set_global_state函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap