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

PHP filter_set_applies_to_strings函数代码示例

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

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



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

 /**
  * Tests the get_mimetype_description function.
  */
 public function test_get_mimetype_description()
 {
     $this->resetAfterTest();
     // Test example type (.doc).
     $this->assertEquals(get_string('application/msword', 'mimetypes'), get_mimetype_description(array('filename' => 'test.doc')));
     // Test an unknown file type.
     $this->assertEquals(get_string('document/unknown', 'mimetypes'), get_mimetype_description(array('filename' => 'test.frog')));
     // Test a custom filetype with no lang string specified.
     core_filetypes::add_type('frog', 'application/x-frog', 'document');
     $this->assertEquals('application/x-frog', get_mimetype_description(array('filename' => 'test.frog')));
     // Test custom description.
     core_filetypes::update_type('frog', 'frog', 'application/x-frog', 'document', array(), '', 'Froggy file');
     $this->assertEquals('Froggy file', get_mimetype_description(array('filename' => 'test.frog')));
     // Test custom description using multilang filter.
     filter_set_global_state('multilang', TEXTFILTER_ON);
     filter_set_applies_to_strings('multilang', true);
     core_filetypes::update_type('frog', 'frog', 'application/x-frog', 'document', array(), '', '<span lang="en" class="multilang">Green amphibian</span>' . '<span lang="fr" class="multilang">Amphibian vert</span>');
     $this->assertEquals('Green amphibian', get_mimetype_description(array('filename' => 'test.frog')));
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:22,代码来源:filelib_test.php


示例3: test_external_format_string

 public function test_external_format_string()
 {
     $this->resetAfterTest();
     $settings = external_settings::get_instance();
     $currentraw = $settings->get_raw();
     $currentfilter = $settings->get_filter();
     // Enable multilang filter to on content and heading.
     filter_set_global_state('multilang', TEXTFILTER_ON);
     filter_set_applies_to_strings('multilang', 1);
     $filtermanager = filter_manager::instance();
     $filtermanager->reset_caches();
     $settings->set_raw(true);
     $settings->set_filter(true);
     $context = context_system::instance();
     $test = '<span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> ' . '<script>hi</script> <h3>there</h3>!';
     $correct = $test;
     $this->assertSame($correct, external_format_string($test, $context->id));
     $settings->set_raw(false);
     $settings->set_filter(false);
     $test = '<span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> ' . '<script>hi</script> <h3>there</h3>?';
     $correct = 'ENFR hi there?';
     $this->assertSame($correct, external_format_string($test, $context->id));
     $settings->set_filter(true);
     $test = '<span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> ' . '<script>hi</script> <h3>there</h3>@';
     $correct = 'EN hi there@';
     $this->assertSame($correct, external_format_string($test, $context->id));
     // Filters can be opted out.
     $test = '<span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> ' . '<script>hi</script> <h3>there</h3>%';
     $correct = 'ENFR hi there%';
     $this->assertSame($correct, external_format_string($test, $context->id, false, ['filter' => false]));
     $settings->set_raw($currentraw);
     $settings->set_filter($currentfilter);
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:33,代码来源:externallib_test.php


示例4: test_resort_courses

 /**
  * Test a categories ability to resort courses.
  */
 public function test_resort_courses()
 {
     $this->resetAfterTest(true);
     $generator = $this->getDataGenerator();
     $category = $generator->create_category();
     $course1 = $generator->create_course(array('category' => $category->id, 'idnumber' => '006-01', 'shortname' => 'Biome Study', 'fullname' => '<span lang="ar" class="multilang">' . 'دراسة منطقة إحيائية' . '</span><span lang="en" class="multilang">Biome Study</span>', 'timecreated' => '1000000001'));
     $course2 = $generator->create_course(array('category' => $category->id, 'idnumber' => '007-02', 'shortname' => 'Chemistry Revision', 'fullname' => 'Chemistry Revision', 'timecreated' => '1000000002'));
     $course3 = $generator->create_course(array('category' => $category->id, 'idnumber' => '007-03', 'shortname' => 'Swiss Rolls and Sunflowers', 'fullname' => 'Aarkvarks guide to Swiss Rolls and Sunflowers', 'timecreated' => '1000000003'));
     $course4 = $generator->create_course(array('category' => $category->id, 'idnumber' => '006-04', 'shortname' => 'Scratch', 'fullname' => '<a href="test.php">Basic Scratch</a>', 'timecreated' => '1000000004'));
     $c1 = (int) $course1->id;
     $c2 = (int) $course2->id;
     $c3 = (int) $course3->id;
     $c4 = (int) $course4->id;
     $coursecat = coursecat::get($category->id);
     $this->assertTrue($coursecat->resort_courses('idnumber'));
     $this->assertSame(array($c1, $c4, $c2, $c3), array_keys($coursecat->get_courses()));
     $this->assertTrue($coursecat->resort_courses('shortname'));
     $this->assertSame(array($c1, $c2, $c4, $c3), array_keys($coursecat->get_courses()));
     $this->assertTrue($coursecat->resort_courses('timecreated'));
     $this->assertSame(array($c1, $c2, $c3, $c4), array_keys($coursecat->get_courses()));
     try {
         // Enable the multilang filter and set it to apply to headings and content.
         filter_manager::reset_caches();
         filter_set_global_state('multilang', TEXTFILTER_ON);
         filter_set_applies_to_strings('multilang', true);
         $expected = array($c3, $c4, $c1, $c2);
     } catch (coding_exception $ex) {
         $expected = array($c3, $c4, $c2, $c1);
     }
     $this->assertTrue($coursecat->resort_courses('fullname'));
     $this->assertSame($expected, array_keys($coursecat->get_courses()));
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:35,代码来源:coursecatlib_test.php


示例5: redirect

        redirect($returnurl);
    }
}
switch ($action) {
    case 'setstate':
        if ($newstate = optional_param('newstate', '', PARAM_INTEGER)) {
            filter_set_global_state($filterpath, $newstate);
            if ($newstate == TEXTFILTER_DISABLED) {
                filter_set_applies_to_strings($filterpath, false);
            }
            unset($newfilters[$filterpath]);
        }
        break;
    case 'setapplyto':
        $applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
        filter_set_applies_to_strings($filterpath, $applytostrings);
        break;
    case 'down':
        if (isset($filters[$filterpath])) {
            $oldpos = $filters[$filterpath]->sortorder;
            if ($oldpos <= count($filters)) {
                filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos + 1);
            }
        }
        break;
    case 'up':
        if (isset($filters[$filterpath])) {
            $oldpos = $filters[$filterpath]->sortorder;
            if ($oldpos >= 1) {
                filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos - 1);
            }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:filters.php


示例6: test_unset_multi

 public function test_unset_multi()
 {
     global $CFG;
     // Setup fixture.
     $CFG->filterall = 1;
     $CFG->stringfilters = 'filter/name,filter/other';
     // Exercise SUT.
     filter_set_applies_to_strings('filter/name', false);
     // Validate.
     $this->assertEqual('filter/other', $CFG->stringfilters);
     $this->assertTrue($CFG->filterall);
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:12,代码来源:testfilterconfig.php


示例7: filter_delete_all_for_filter

/**
 * Delete all the data in the database relating to a filter, prior to deleting it.
 *
 * @param string $filter The filter name, for example 'tex'.
 */
function filter_delete_all_for_filter($filter)
{
    global $DB;
    filter_set_applies_to_strings($filter, false);
    unset_all_config_for_plugin('filter_' . $filter);
    $DB->delete_records('filter_active', array('filter' => $filter));
    $DB->delete_records('filter_config', array('filter' => $filter));
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:13,代码来源:filterlib.php


示例8: test_unset_multi

 public function test_unset_multi()
 {
     global $CFG;
     $this->assertFileExists("{$CFG->dirroot}/filter/emailprotect");
     // Any standard filter.
     $this->assertFileExists("{$CFG->dirroot}/filter/tidy");
     // Any standard filter.
     $this->assertFileExists("{$CFG->dirroot}/filter/multilang");
     // Any standard filter.
     // Setup fixture.
     set_config('filterall', 1);
     set_config('stringfilters', 'emailprotect,tidy,multilang');
     // Exercise SUT.
     filter_set_applies_to_strings('tidy', false);
     // Validate.
     $this->assertEquals('emailprotect,multilang', $CFG->stringfilters);
     $this->assertEquals(1, $CFG->filterall);
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:18,代码来源:filterlib_test.php


示例9: test_user_multi_custom_field_on_user_create

 /**
  * Validate that custom user fields are synched over to Moodle when PM user is created
  * during an import
  */
 public function test_user_multi_custom_field_on_user_create()
 {
     global $CFG, $DB, $USER;
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elis::lib('data/customfield.class.php');
     require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php');
     require_once elispm::file('accesslib.php');
     require_once elispm::lib('data/user.class.php');
     require_once $CFG->dirroot . '/user/profile/lib.php';
     require_once $CFG->dirroot . '/user/profile/definelib.php';
     require_once $CFG->dirroot . '/user/profile/field/menu/define.class.php';
     $CFG->filterall = true;
     $USER = get_admin();
     $context = context_user::instance($USER->id);
     /*
       $filternames = filter_get_all_installed();
       ob_start();
       var_dump($filternames);
       $tmp = ob_get_contents();
       ob_end_clean();
       error_log("test_user_multi_custom_field_on_user_create: all-filters => {$tmp}");
     */
     // Note: >= m25 filter paths no longer prefixed with 'filter/'
     filter_set_global_state('multilang', TEXTFILTER_ON);
     filter_set_applies_to_strings('multilang', true);
     $multilangoption1 = '<span class="multilang" lang="en">Male</span><span class="multilang" lang="pt_br">Masculino</span>' . '<span class="multilang" lang="es">Masculino</span>';
     $multilangoption2 = '<span class="multilang" lang="en">Female</span><span class="multilang" lang="pt_br">Feminino</span>' . '<span class="multilang" lang="es">Femenino</span>';
     // The associated Moodle user profile field.
     $profiledefinemenu = new profile_define_menu();
     $data = new stdClass();
     $data->datatype = 'menu';
     $data->categoryid = 99999;
     $data->shortname = 'testfieldgender';
     $data->name = 'testfieldgender';
     $data->param1 = "{$multilangoption1}\n{$multilangoption2}";
     $data->defaultdata = $multilangoption2;
     $profiledefinemenu->define_save($data);
     // Reset cached custom fields.
     $user = new user();
     $user->reset_custom_field_list();
     // Field category.
     $fieldcategory = new field_category(array('name' => 'testcategoryname'));
     $fieldcategory->save();
     // Custom field.
     $field = new field(array('categoryid' => $fieldcategory->id, 'shortname' => 'testfieldgender', 'name' => 'testfieldgender', 'datatype' => 'text', 'multivalued' => 1));
     $field->save();
     // Field owners
     field_owner::ensure_field_owner_exists($field, 'moodle_profile');
     $manualowneroptions = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'menu', 'options' => "{$multilangoption1}\n{$multilangoption2}");
     field_owner::ensure_field_owner_exists($field, 'manual', $manualowneroptions);
     // Field context level assocation.
     $fieldcontextlevel = new field_contextlevel(array('fieldid' => $field->id, 'contextlevel' => CONTEXT_ELIS_USER));
     $fieldcontextlevel->save();
     // Run the user create action.
     $record = new stdClass();
     $record->action = 'create';
     $record->idnumber = 'testuseridnumber';
     $record->username = 'testuserusername';
     $record->firstname = 'testuserfirstname';
     $record->lastname = 'testuserlastname';
     $record->email = '[email protected]';
     $record->address = 'testuseraddress';
     $record->city = 'testusercity';
     $record->country = 'CA';
     $record->language = 'en';
     $record->testfieldgender = 'Male/Female';
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->process_record('user', $record, 'bogus');
     // Validation.
     $userid = $DB->get_field(user::TABLE, 'id', array('username' => 'testuserusername'));
     $user = new user($userid);
     $user->load();
     $user = $user->to_object();
     /*
       $datars = field_data::get_for_context_and_field(\local_elisprogram\context\user::instance($user->id), 'testfieldgender');
       foreach ($datars as $data) {
           ob_start();
           var_dump($data);
           $tmp = ob_get_contents();
           ob_end_clean();
           error_log("test_user_multi_custom_field_on_user_create: data => {$tmp}");
       }
     */
     /*
       ob_start();
       var_dump($user);
       $tmp = ob_get_contents();
       ob_end_clean();
       error_log("test_user_multi_custom_field_on_user_create: user => {$tmp}");
     */
     $this->assertEquals(array($multilangoption1, $multilangoption2), $user->field_testfieldgender);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:97,代码来源:elis_user_sync_test.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP filter_set_global_state函数代码示例发布时间:2022-05-15
下一篇:
PHP filter_save_tags函数代码示例发布时间: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