当前位置: 首页>>代码示例>>PHP>>正文


PHP filter_manager::reset_caches方法代码示例

本文整理汇总了PHP中filter_manager::reset_caches方法的典型用法代码示例。如果您正苦于以下问题:PHP filter_manager::reset_caches方法的具体用法?PHP filter_manager::reset_caches怎么用?PHP filter_manager::reset_caches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在filter_manager的用法示例。


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

示例1: reset_all_data

 /**
  * Reset contents of all database tables to initial values, reset caches, etc.
  *
  * Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
  *
  * @static
  * @param bool $detectchanges
  *      true  - changes in global state and database are reported as errors
  *      false - no errors reported
  *      null  - only critical problems are reported as errors
  * @return void
  */
 public static function reset_all_data($detectchanges = false)
 {
     global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
     // Stop any message redirection.
     phpunit_util::stop_message_redirection();
     // Stop any message redirection.
     phpunit_util::stop_phpmailer_redirection();
     // Stop any message redirection.
     phpunit_util::stop_event_redirection();
     // We used to call gc_collect_cycles here to ensure desctructors were called between tests.
     // This accounted for 25% of the total time running phpunit - so we removed it.
     // Show any unhandled debugging messages, the runbare() could already reset it.
     self::display_debugging_messages();
     self::reset_debugging();
     // reset global $DB in case somebody mocked it
     $DB = self::get_global_backup('DB');
     if ($DB->is_transaction_started()) {
         // we can not reset inside transaction
         $DB->force_transaction_rollback();
     }
     $resetdb = self::reset_database();
     $warnings = array();
     if ($detectchanges === true) {
         if ($resetdb) {
             $warnings[] = 'Warning: unexpected database modification, resetting DB state';
         }
         $oldcfg = self::get_global_backup('CFG');
         $oldsite = self::get_global_backup('SITE');
         foreach ($CFG as $k => $v) {
             if (!property_exists($oldcfg, $k)) {
                 $warnings[] = 'Warning: unexpected new $CFG->' . $k . ' value';
             } else {
                 if ($oldcfg->{$k} !== $CFG->{$k}) {
                     $warnings[] = 'Warning: unexpected change of $CFG->' . $k . ' value';
                 }
             }
             unset($oldcfg->{$k});
         }
         if ($oldcfg) {
             foreach ($oldcfg as $k => $v) {
                 $warnings[] = 'Warning: unexpected removal of $CFG->' . $k;
             }
         }
         if ($USER->id != 0) {
             $warnings[] = 'Warning: unexpected change of $USER';
         }
         if ($COURSE->id != $oldsite->id) {
             $warnings[] = 'Warning: unexpected change of $COURSE';
         }
     }
     if (ini_get('max_execution_time') != 0) {
         // This is special warning for all resets because we do not want any
         // libraries to mess with timeouts unintentionally.
         // Our PHPUnit integration is not supposed to change it either.
         if ($detectchanges !== false) {
             $warnings[] = 'Warning: max_execution_time was changed to ' . ini_get('max_execution_time');
         }
         set_time_limit(0);
     }
     // restore original globals
     $_SERVER = self::get_global_backup('_SERVER');
     $CFG = self::get_global_backup('CFG');
     $SITE = self::get_global_backup('SITE');
     $_GET = array();
     $_POST = array();
     $_FILES = array();
     $_REQUEST = array();
     $COURSE = $SITE;
     // reinitialise following globals
     $OUTPUT = new bootstrap_renderer();
     $PAGE = new moodle_page();
     $FULLME = null;
     $ME = null;
     $SCRIPT = null;
     // Empty sessison and set fresh new not-logged-in user.
     \core\session\manager::init_empty_session();
     // reset all static caches
     \core\event\manager::phpunit_reset();
     accesslib_clear_all_caches(true);
     get_string_manager()->reset_caches(true);
     reset_text_filters_cache(true);
     events_get_handlers('reset');
     core_text::reset_caches();
     get_message_processors(false, true);
     filter_manager::reset_caches();
     // Reset internal users.
     core_user::reset_internal_users();
     //TODO MDL-25290: add more resets here and probably refactor them to new core function
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:util.php

示例2: 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

示例3: 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

示例4: 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.
     /** @var mod_glossary_generator $generator */
     $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&amp;D'));
     filter_manager::reset_caches();
     \mod_glossary\local\concept_cache::reset_caches();
     // Format text with all three entries in HTML.
     $html = '<p>A&amp;B C&amp;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('~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&amp;B', $matches[2][0]);
     $this->assertEquals($glossary->name . ': C&amp;D', $matches[2][1]);
     $this->assertEquals($glossary->name . ': normal', $matches[2][2]);
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:39,代码来源:filter_test.php

示例5: reset_all_data

 /**
  * Reset contents of all database tables to initial values, reset caches, etc.
  */
 public static function reset_all_data()
 {
     // Reset database.
     self::reset_database();
     // Purge dataroot directory.
     self::reset_dataroot();
     // Reset all static caches.
     accesslib_clear_all_caches(true);
     // Reset the nasty strings list used during the last test.
     nasty_strings::reset_used_strings();
     filter_manager::reset_caches();
     // Reset course and module caches.
     if (class_exists('format_base')) {
         // If file containing class is not loaded, there is no cache there anyway.
         format_base::reset_course_cache(0);
     }
     get_fast_modinfo(0, 0, true);
     // Inform data generator.
     self::get_data_generator()->reset();
     // Initialise $CFG with default values. This is needed for behat cli process, so we don't have modified
     // $CFG values from the old run. @see set_config.
     initialise_cfg();
 }
开发者ID:janeklb,项目名称:moodle,代码行数:26,代码来源:util.php

示例6: 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

示例7: reset_all_data

 /**
  * Reset contents of all database tables to initial values, reset caches, etc.
  */
 public static function reset_all_data()
 {
     // Reset database.
     self::reset_database();
     // Purge dataroot directory.
     self::reset_dataroot();
     // Reset all static caches.
     accesslib_clear_all_caches(true);
     // Reset the nasty strings list used during the last test.
     nasty_strings::reset_used_strings();
     filter_manager::reset_caches();
     // Reset course and module caches.
     if (class_exists('format_base')) {
         // If file containing class is not loaded, there is no cache there anyway.
         format_base::reset_course_cache(0);
     }
     get_fast_modinfo(0, 0, true);
     // Inform data generator.
     self::get_data_generator()->reset();
 }
开发者ID:reconnectmedia,项目名称:moodle,代码行数:23,代码来源:util.php

示例8: reset_all_data

 /**
  * Reset contents of all database tables to initial values, reset caches, etc.
  *
  * Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
  *
  * @static
  * @param bool $logchanges log changes in global state and database in error log
  * @return void
  */
 public static function reset_all_data($logchanges = false)
 {
     global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
     // Stop any message redirection.
     phpunit_util::stop_message_redirection();
     // Release memory and indirectly call destroy() methods to release resource handles, etc.
     gc_collect_cycles();
     // Show any unhandled debugging messages, the runbare() could already reset it.
     self::display_debugging_messages();
     self::reset_debugging();
     // reset global $DB in case somebody mocked it
     $DB = self::get_global_backup('DB');
     if ($DB->is_transaction_started()) {
         // we can not reset inside transaction
         $DB->force_transaction_rollback();
     }
     $resetdb = self::reset_database();
     $warnings = array();
     if ($logchanges) {
         if ($resetdb) {
             $warnings[] = 'Warning: unexpected database modification, resetting DB state';
         }
         $oldcfg = self::get_global_backup('CFG');
         $oldsite = self::get_global_backup('SITE');
         foreach ($CFG as $k => $v) {
             if (!property_exists($oldcfg, $k)) {
                 $warnings[] = 'Warning: unexpected new $CFG->' . $k . ' value';
             } else {
                 if ($oldcfg->{$k} !== $CFG->{$k}) {
                     $warnings[] = 'Warning: unexpected change of $CFG->' . $k . ' value';
                 }
             }
             unset($oldcfg->{$k});
         }
         if ($oldcfg) {
             foreach ($oldcfg as $k => $v) {
                 $warnings[] = 'Warning: unexpected removal of $CFG->' . $k;
             }
         }
         if ($USER->id != 0) {
             $warnings[] = 'Warning: unexpected change of $USER';
         }
         if ($COURSE->id != $oldsite->id) {
             $warnings[] = 'Warning: unexpected change of $COURSE';
         }
     }
     // restore original globals
     $_SERVER = self::get_global_backup('_SERVER');
     $CFG = self::get_global_backup('CFG');
     $SITE = self::get_global_backup('SITE');
     $COURSE = $SITE;
     // reinitialise following globals
     $OUTPUT = new bootstrap_renderer();
     $PAGE = new moodle_page();
     $FULLME = null;
     $ME = null;
     $SCRIPT = null;
     $SESSION = new stdClass();
     $_SESSION['SESSION'] =& $SESSION;
     // set fresh new not-logged-in user
     $user = new stdClass();
     $user->id = 0;
     $user->mnethostid = $CFG->mnet_localhost_id;
     session_set_user($user);
     // reset all static caches
     accesslib_clear_all_caches(true);
     get_string_manager()->reset_caches(true);
     reset_text_filters_cache(true);
     events_get_handlers('reset');
     textlib::reset_caches();
     if (class_exists('repository')) {
         repository::reset_caches();
     }
     filter_manager::reset_caches();
     //TODO MDL-25290: add more resets here and probably refactor them to new core function
     // Reset course and module caches.
     if (class_exists('format_base')) {
         // If file containing class is not loaded, there is no cache there anyway.
         format_base::reset_course_cache(0);
     }
     get_fast_modinfo(0, 0, true);
     // Reset other singletons.
     if (class_exists('plugin_manager')) {
         plugin_manager::reset_caches(true);
     }
     if (class_exists('available_update_checker')) {
         available_update_checker::reset_caches(true);
     }
     if (class_exists('available_update_deployer')) {
         available_update_deployer::reset_caches(true);
     }
//.........这里部分代码省略.........
开发者ID:Burick,项目名称:moodle,代码行数:101,代码来源:util.php

示例9: test_filter_manager_instance

 public function test_filter_manager_instance()
 {
     set_config('perfdebug', 7);
     filter_manager::reset_caches();
     $filterman = filter_manager::instance();
     $this->assertInstanceOf('filter_manager', $filterman);
     $this->assertNotInstanceOf('performance_measuring_filter_manager', $filterman);
     set_config('perfdebug', 15);
     filter_manager::reset_caches();
     $filterman = filter_manager::instance();
     $this->assertInstanceOf('filter_manager', $filterman);
     $this->assertInstanceOf('performance_measuring_filter_manager', $filterman);
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:13,代码来源:filterlib_test.php

示例10: 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_manager::reset_caches();
     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:Chocolate-lightning,项目名称:moodle,代码行数:23,代码来源:filelib_test.php

示例11: taskchain_navigation_accesscontrol_form


//.........这里部分代码省略.........
            $name = block_taskchain_navigation::filter_text($name);
            $name = trim(strip_tags($name));
            $name = block_taskchain_navigation::trim_text($name, $cm_namelength, $cm_headlength, $cm_taillength);
            echo $name;
            echo '</td></tr>' . "\n";
        }
    }
    if ($sortgradeitems || $creategradecats || $removegradecats || $reset_filter_caches || $rebuild_course_cache || $regrade_course_grades || isset($success)) {
        if ($started_list == false) {
            $started_list = true;
            echo '<table border="0" cellpadding="4" cellspacing="4" class="selectedactivitylist"><tbody>' . "\n";
        }
        if ($sortgradeitems) {
            echo '<tr><td class="notifymessage" colspan="2">';
            $msg = get_string('sortedgradeitems', $plugin);
            echo $OUTPUT->notification($msg, 'notifysuccess');
            echo '</td></tr>' . "\n";
        }
        if ($creategradecats) {
            echo '<tr><td class="notifymessage" colspan="2">';
            $msg = get_string('createdgradecategories', $plugin);
            echo $OUTPUT->notification($msg, 'notifysuccess');
            echo '</td></tr>' . "\n";
        }
        if ($removegradecats) {
            echo '<tr><td class="notifymessage" colspan="2">';
            $msg = get_string('removedgradecategories', $plugin);
            echo $OUTPUT->notification($msg, 'notifysuccess');
            echo '</td></tr>' . "\n";
        }
        if ($reset_filter_caches) {
            echo '<tr><td class="notifymessage" colspan="2">';
            echo get_string('resettingfiltercache', $plugin) . ' ... ';
            filter_manager::reset_caches();
            //unset($FILTERLIB_PRIVATE->active[$context->id]);
            echo get_string('ok') . '</td></tr>' . "\n";
        }
        if ($rebuild_course_cache) {
            echo '<tr><td class="notifymessage" colspan="2">';
            echo get_string('rebuildingcoursecache', $plugin) . ' ... ';
            rebuild_course_cache($course->id);
            echo get_string('ok') . '</td></tr>' . "\n";
        }
        if ($regrade_course_grades) {
            echo '<tr><td class="notifymessage" colspan="2">';
            echo get_string('recalculatingcoursegrades', $plugin) . ' ... ';
            grade_regrade_final_grades($course->id);
            echo get_string('ok') . '</td></tr>' . "\n";
        }
        if ($success === true) {
            echo '<tr><td class="notifymessage" colspan="2">';
            $msg = get_string('success');
            echo $OUTPUT->notification($msg, 'notifysuccess');
            echo '</td></tr>' . "\n";
        }
        if ($success === false) {
            echo '<tr><td class="notifymessage" colspan="2">';
            $msg = get_string('activityupdatefailure', $plugin);
            echo $OUTPUT->notification($msg, 'notifyproblem');
            echo '</td></tr>' . "\n";
        }
    }
    if ($started_list) {
        $started_list = false;
        echo '</tbody></table>' . "\n";
    }
开发者ID:gbateson,项目名称:moodle-block_taskchain_navigation,代码行数:67,代码来源:accesscontrol.php


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