本文整理汇总了PHP中filter_set_global_state函数的典型用法代码示例。如果您正苦于以下问题:PHP filter_set_global_state函数的具体用法?PHP filter_set_global_state怎么用?PHP filter_set_global_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_set_global_state函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_ampersands
/**
* Test ampersands.
*/
public function test_ampersands()
{
global $CFG;
$this->resetAfterTest(true);
// Enable glossary filter at top level.
filter_set_global_state('glossary', TEXTFILTER_ON);
$CFG->glossary_linkentries = 1;
// Create a test course.
$course = $this->getDataGenerator()->create_course();
$context = context_course::instance($course->id);
// Create a glossary.
$glossary = $this->getDataGenerator()->create_module('glossary', array('course' => $course->id, 'mainglossary' => 1));
// Create two entries with ampersands and one normal entry.
$generator = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
$normal = $generator->create_content($glossary, array('concept' => 'normal'));
$amp1 = $generator->create_content($glossary, array('concept' => 'A&B'));
$amp2 = $generator->create_content($glossary, array('concept' => 'C&D'));
// Format text with all three entries in HTML.
$html = '<p>A&B C&D normal</p>';
$filtered = format_text($html, FORMAT_HTML, array('context' => $context));
// Find all the glossary links in the result.
$matches = array();
preg_match_all('~courseid=' . $course->id . '&eid=([0-9]+).*?title="(.*?)"~', $filtered, $matches);
// There should be 3 glossary links.
$this->assertEquals(3, count($matches[1]));
$this->assertEquals($amp1->id, $matches[1][0]);
$this->assertEquals($amp2->id, $matches[1][1]);
$this->assertEquals($normal->id, $matches[1][2]);
// Check text and escaping of title attribute.
$this->assertEquals($glossary->name . ': A&B', $matches[2][0]);
$this->assertEquals($glossary->name . ': C&D', $matches[2][1]);
$this->assertEquals($glossary->name . ': normal', $matches[2][2]);
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:36,代码来源:filter_test.php
示例2: test_maths_rendering
public function test_maths_rendering()
{
if (!stack_maths_output_maths::filter_is_installed()) {
$this->markTestSkipped('The OU maths filter is not installed.');
}
if (!defined('FILTER_MATHS_TEST_SERVICE_URL_BASE')) {
$this->markTestSkipped('To run the OU maths filter output tests, ' . 'you must define FILTER_MATHS_TEST_SERVICE_URL_BASE in config.php.');
}
$this->resetAfterTest();
set_config('mathsdisplay', 'maths', 'qtype_stack');
set_config('texservice', FILTER_MATHS_TEST_SERVICE_URL_BASE . 'tex', 'filter_maths');
set_config('imageservice', FILTER_MATHS_TEST_SERVICE_URL_BASE . 'imagetex', 'filter_maths');
set_config('englishservice', FILTER_MATHS_TEST_SERVICE_URL_BASE . 'english', 'filter_maths');
stack_utils::clear_config_cache();
filter_set_global_state('mathjaxloader', TEXTFILTER_DISABLED);
// Test language string.
$this->assertRegExp('~^Your answer needs to be a single fraction of the form <a .*alt="a over b".*</a>\\. $~', stack_string('ATSingleFrac_part'));
// Test docs - make sure maths inside <code> is not rendered.
$this->assertRegExp('~^<p><code>\\\\\\(x\\^2\\\\\\)</code> gives <a .*alt="x squared".*</a>\\.</p>\\n$~', stack_docs_render_markdown('<code>\\(x^2\\)</code> gives \\(x^2\\).', ''));
// Test docs - make sure maths inside <textarea> is not rendered.
$this->assertRegExp('~^<p>\\n' . 'Differentiate \\\\\\\\\\[x\\^2 \\+ y\\^2\\\\\\\\\\] with respect to \\\\\\\\\\(x\\\\\\\\\\).</p>\\n$~', stack_docs_render_markdown('<textarea readonly="readonly" rows="3" cols="50">' . "\n" . 'Differentiate \\[x^2 + y^2\\] with respect to \\(x\\).</textarea>', ''));
// Test CAS text with inline maths.
$this->assertEquals('What is <tex mode="inline">x^2</tex>?', stack_maths::process_display_castext('What is \\(x^2\\)?'));
// Test CAS text with display maths.
$this->assertEquals('What is <span class="displayequation"><tex mode="display">x^2</tex></span>?', stack_maths::process_display_castext('What is \\[x^2\\]?'));
// Test with replacedollars.
set_config('replacedollars', '1', 'qtype_stack');
stack_utils::clear_config_cache();
$this->assertEquals('What is <tex mode="inline">x^2</tex> or ' . '<span class="displayequation"><tex mode="display">x^2</tex></span>?', stack_maths::process_display_castext('What is $x^2$ or $$x^2$$?'));
stack_utils::clear_config_cache();
}
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:31,代码来源:mathsoutputmaths_test.php
示例3: test_one_filter_of_two_disabled
public function test_one_filter_of_two_disabled()
{
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
filter_set_global_state('urltolink', TEXTFILTER_ON);
$this->assertRegExp('~^<p><img class="emoticon" alt="smile" ([^>]+)> http://google.com/</p>$~', $this->filter_text('<p>:-) http://google.com/</p>', array('glossary', 'urltolink')));
}
开发者ID:evltuma,项目名称:moodle,代码行数:7,代码来源:filter_manager_test.php
示例4: test_filter
/**
* Tests that the filter applies the required changes.
*
* @return void
*/
public function test_filter()
{
$this->resetAfterTest(true);
$this->setAdminUser();
filter_manager::reset_caches();
filter_set_global_state('data', TEXTFILTER_ON);
$course1 = $this->getDataGenerator()->create_course();
$coursecontext1 = context_course::instance($course1->id);
$course2 = $this->getDataGenerator()->create_course();
$coursecontext2 = context_course::instance($course2->id);
$sitecontext = context_course::instance(SITEID);
$site = get_site();
$this->add_simple_database_instance($site, array('SiteEntry'));
$this->add_simple_database_instance($course1, array('CourseEntry'));
$html = '<p>I like CourseEntry and SiteEntry</p>';
// Testing at course level (both site and course).
$filtered = format_text($html, FORMAT_HTML, array('context' => $coursecontext1));
$this->assertRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
$this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
// Testing at site level (only site).
$filtered = format_text($html, FORMAT_HTML, array('context' => $sitecontext));
$this->assertNotRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
$this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
// Changing to another course to test the caches invalidation (only site).
$filtered = format_text($html, FORMAT_HTML, array('context' => $coursecontext2));
$this->assertNotRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
$this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
}
开发者ID:evltuma,项目名称:moodle,代码行数:33,代码来源:filter_test.php
示例5: xmldb_filter_mediaplugin_install
/**
* Media filter post install hook
*
* @package filter
* @subpackage mediaplugin
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_filter_mediaplugin_install()
{
global $CFG;
//enable by default in new installs and upgrades (because we did not have version.php before)
// but only if insecure swf embedding is off - we definitely do not want to open security hopes on existing sites
if (empty($CFG->filter_mediaplugin_enable_swf)) {
filter_set_global_state('filter/mediaplugin', TEXTFILTER_ON);
}
}
开发者ID:vuchannguyen,项目名称:web,代码行数:17,代码来源:install.php
示例6: test_stack_docs_render_markdown
public function test_stack_docs_render_markdown()
{
$this->resetAfterTest();
filter_set_global_state('mathjaxloader', TEXTFILTER_DISABLED);
$this->assertEquals("<p>Test</p>\n", stack_docs_render_markdown('Test', '.../doc/content'));
$this->assertEquals('<p><a href=".../doc/content/readme.txt">Readme</a></p>' . "\n", stack_docs_render_markdown('[Readme](%CONTENT/readme.txt)', '.../doc/content'));
$this->assertEquals("<p>Literal %CONTENT</p>\n", stack_docs_render_markdown('Literal \\%CONTENT', '.../doc/content'));
$this->assertEquals("<p><code>\\(x^2\\)</code> gives \\(x^2\\).</p>\n", stack_docs_render_markdown('`\\(x^2\\)` gives \\(x^2\\).', '.../doc/content'));
}
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:9,代码来源:docslib_test.php
示例7: test_maths_output_mathsjax
public function test_maths_output_mathsjax()
{
filter_set_global_state('mathjaxloader', TEXTFILTER_DISABLED);
// MathJax output is the default.
$this->assertEquals('Your answer needs to be a single fraction of the form \\( {a}\\over{b} \\). ', stack_string('ATSingleFrac_part'));
$this->assertEquals("<p><code>\\(x^2\\)</code> gives \\(x^2\\).</p>\n", stack_docs_render_markdown('`\\(x^2\\)` gives \\(x^2\\).', ''));
$this->assertEquals('What is \\(x^2\\)?', stack_maths::process_display_castext('What is \\(x^2\\)?'));
$this->resetAfterTest();
set_config('replacedollars', '1', 'qtype_stack');
stack_utils::clear_config_cache();
$this->assertEquals('What is \\(x^2\\) or \\[x^2\\]?', stack_maths::process_display_castext('What is $x^2$ or $$x^2$$?'));
stack_utils::clear_config_cache();
}
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:13,代码来源:mathsoutputmathjax_test.php
示例8: test_filter_external_file
public function test_filter_external_file()
{
global $CFG;
$this->resetAfterTest(true);
$this->setAdminUser();
filter_manager::reset_caches();
filter_set_global_state('viewerjs', TEXTFILTER_ON);
$course1 = $this->getDataGenerator()->create_course();
$coursecontext1 = context_course::instance($course1->id);
$url = 'http://www.example.org/frog.ppt';
$html = '<a href= "' . $url . '">Link</a>';
$this->assertContains($url, format_text($html, FORMAT_HTML, array('context' => $coursecontext1)), 'did not transform external url');
$url = 'http://www.example.org/frog.pdf';
$html = '<a href= "' . $url . '">Link</a>';
$this->assertContains($url, format_text($html, FORMAT_HTML, array('context' => $coursecontext1)), 'did not transform external url even though it had a supported extension');
}
开发者ID:ispedals,项目名称:moodle-filter_viewerjs,代码行数:16,代码来源:filter_test.php
示例9: 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
示例10: test_tex_rendering
public function test_tex_rendering()
{
$this->resetAfterTest();
set_config('mathsdisplay', 'tex', 'qtype_stack');
stack_utils::clear_config_cache();
filter_set_global_state('mathjaxloader', TEXTFILTER_DISABLED);
// Test language string.
// The <span class="MathJax_Preview"> bit is something that got added in
// Moodle 2.8, so match it optionally.
$this->assertRegExp('~^Your answer needs to be a single fraction of the form ' . '(<span class="MathJax_Preview">)?<a .*alt=" \\{a\\}\\\\over\\{b\\} ".*</(a|script)> \\. ~', stack_string('ATSingleFrac_part'));
// Test docs - make sure maths inside <code> is not rendered.
$this->assertRegExp('~^<p><code>\\\\\\(x\\^2\\\\\\)</code> gives (<span class="MathJax_Preview">)?<a .*alt="x\\^2".*</(a|script)> \\.</p>\\n$~', stack_docs_render_markdown('<code>\\(x^2\\)</code> gives \\(x^2\\).', ''));
// Test docs - make sure maths inside <textarea> is not rendered.
$this->assertRegExp('~^<p>\\n' . 'Differentiate \\\\\\\\\\[x\\^2 \\+ y\\^2\\\\\\\\\\] with respect to \\\\\\\\\\(x\\\\\\\\\\).</p>\\n$~', stack_docs_render_markdown('<textarea readonly="readonly" rows="3" cols="50">' . "\n" . 'Differentiate \\[x^2 + y^2\\] with respect to \\(x\\).</textarea>', ''));
// Test CAS text with inline maths.
$this->assertEquals('What is \\[x^2\\]?', stack_maths::process_display_castext('What is \\(x^2\\)?'));
// Test CAS text with display maths.
$this->assertEquals('What is <span class="displayequation">\\[\\displaystyle x^2\\]</span>?', stack_maths::process_display_castext('What is \\[x^2\\]?'));
// Test with replacedollars.
set_config('replacedollars', '1', 'qtype_stack');
stack_utils::clear_config_cache();
$this->assertEquals('What is \\[x^2\\] or <span class="displayequation">\\[\\displaystyle x^2\\]</span>?', stack_maths::process_display_castext('What is $x^2$ or $$x^2$$?'));
stack_utils::clear_config_cache();
}
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:24,代码来源:mathsoutputtex_test.php
示例11: get_plugins
public static function get_plugins($type, $typerootdir, $typeclass) {
global $CFG, $DB;
$filters = array();
// get the list of filters from both /filter and /mod location
$installed = filter_get_all_installed();
foreach ($installed as $filterlegacyname => $displayname) {
$plugin = new $typeclass();
$plugin->type = $type;
$plugin->typerootdir = $typerootdir;
$plugin->name = self::normalize_legacy_name($filterlegacyname);
$plugin->rootdir = $CFG->dirroot . '/' . $filterlegacyname;
$plugin->displayname = $displayname;
$plugin->load_disk_version();
$plugin->load_db_version();
$plugin->load_required_main_version();
$plugin->init_is_standard();
$filters[$plugin->name] = $plugin;
}
$globalstates = self::get_global_states();
if ($DB->get_manager()->table_exists('filter_active')) {
// if we're upgrading from 1.9, the table does not exist yet
// if it does, make sure that all installed filters are registered
$needsreload = false;
foreach (array_keys($installed) as $filterlegacyname) {
if (!isset($globalstates[self::normalize_legacy_name($filterlegacyname)])) {
filter_set_global_state($filterlegacyname, TEXTFILTER_DISABLED);
$needsreload = true;
}
}
if ($needsreload) {
$globalstates = self::get_global_states(true);
}
}
// make sure that all registered filters are installed, just in case
foreach ($globalstates as $name => $info) {
if (!isset($filters[$name])) {
// oops, there is a record in filter_active but the filter is not installed
$plugin = new $typeclass();
$plugin->type = $type;
$plugin->typerootdir = $typerootdir;
$plugin->name = $name;
$plugin->rootdir = $CFG->dirroot . '/' . $info->legacyname;
$plugin->displayname = $info->legacyname;
$plugin->load_db_version();
if (is_null($plugin->versiondb)) {
// this is a hack to stimulate 'Missing from disk' error
// because $plugin->versiondisk will be null !== false
$plugin->versiondb = false;
}
$filters[$plugin->name] = $plugin;
}
}
return $filters;
}
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:66,代码来源:pluginlib.php
示例12: 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
示例13: 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
示例14: 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
示例15: get_string
$title = get_string('deletingfilter', 'admin', $filtername);
admin_externalpage_print_header();
echo $OUTPUT->heading($title);
// Delete all data for this plugin.
filter_delete_all_for_filter($filterpath);
$a = new stdClass();
$a->filter = $filtername;
$a->directory = $filterpath;
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
echo $OUTPUT->continue_button($returnurl);
echo $OUTPUT->footer();
exit;
}
// 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();
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:filters.php
示例16: test_format_text_format_moodle_no_filters
public function test_format_text_format_moodle_no_filters()
{
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
$this->assertEquals('<div class="text_to_html"><p>:-)</p></div>', format_text('<p>:-)</p>', FORMAT_MOODLE, array('filter' => false)));
}
开发者ID:evltuma,项目名称:moodle,代码行数:6,代码来源:weblib_format_text_test.php
示例17: xmldb_main_upgrade
//.........这里部分代码省略.........
}
if ($result && $oldversion < 2009040301) {
/// Define table filter_config to be created
$table = new xmldb_table('filter_config');
/// Adding fields to table filter_config
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('filter', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null);
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('value', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
/// Adding keys to table filter_config
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));
/// Adding indexes to table filter_config
$table->add_index('contextid-filter-name', XMLDB_INDEX_UNIQUE, array('contextid', 'filter', 'name'));
/// Conditionally launch create table for filter_config
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
/// Main savepoint reached
upgrade_main_savepoint($result, 2009040301);
}
if ($result && $oldversion < 2009040302) {
/// Transfer current settings from $CFG->textfilters
$disabledfilters = filter_get_all_installed();
if (empty($CFG->textfilters)) {
$activefilters = array();
} else {
$activefilters = explode(',', $CFG->textfilters);
}
$syscontext = get_context_instance(CONTEXT_SYSTEM);
$sortorder = 1;
foreach ($activefilters as $filter) {
filter_set_global_state($filter, TEXTFILTER_ON, $sortorder);
$sortorder += 1;
unset($disabledfilters[$filter]);
}
foreach ($disabledfilters as $filter => $notused) {
filter_set_global_state($filter, TEXTFILTER_DISABLED, $sortorder);
$sortorder += 1;
}
/// Main savepoint reached
upgrade_main_savepoint($result, 2009040302);
}
if ($result && $oldversion < 2009040600) {
/// Ensure that $CFG->stringfilters is set.
if (empty($CFG->stringfilters)) {
if (!empty($CFG->filterall)) {
set_config('stringfilters', $CFG->textfilters);
} else {
set_config('stringfilters', '');
}
}
set_config('filterall', !empty($CFG->stringfilters));
unset_config('textfilters');
/// Main savepoint reached
upgrade_main_savepoint($result, 2009040600);
}
if ($result && $oldversion < 2009041700) {
/// To ensure the UI remains consistent with no behaviour change, any
/// 'until' date in an activity condition should have 1 second subtracted
/// (to go from 0:00 on the following day to 23:59 on the previous one).
$DB->execute('UPDATE {course_modules} SET availableuntil = availableuntil - 1 WHERE availableuntil <> 0');
require_once $CFG->dirroot . '/course/lib.php';
rebuild_course_cache(0, true);
/// Main savepoint reached
开发者ID:ajv,项目名称:Offline-Caching,代码行数:67,代码来源:upgrade.php
示例18: xmldb_filter_mathjaxloader_install
function xmldb_filter_mathjaxloader_install()
{
global $CFG;
require_once "{$CFG->libdir}/filterlib.php";
filter_set_global_state('mathjaxloader', TEXTFILTER_ON, -1);
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:6,代码来源:install.php
示例19: xmldb_filter_databasetagcloud_install
/**
* @package filter_databasetagcloud
* @copyright 2015 onwards Andrew Hancox ([email protected])
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_filter_databasetagcloud_install()
{
global $CFG;
require_once "{$CFG->libdir}/filterlib.php";
filter_set_global_state('databasetagcloud', TEXTFILTER_ON, 1);
}
开发者ID:andrewhancox,项目名称:filter_databasetagcloud,代码行数:11,代码来源:install.php
示例20: xmldb_filter_activitynames_install
/**
* Filter post install hook
*
* @package filter_activitynames
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_filter_activitynames_install()
{
global $CFG;
require_once "{$CFG->libdir}/filterlib.php";
filter_set_global_state('activitynames', TEXTFILTER_ON);
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:13,代码来源:install.php
注:本文中的filter_set_global_state函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论