function test_flush() { $this->_write_simple_cache('f_test1', $content1 = 'test-content1'); $this->_write_simple_cache('f_test2', $content2 ='test-content2'); $this->_write_simple_cache('not_page_file', $content3 ='test-content3'); $cache_manager =& new full_page_cache_manager(); $cache_manager->flush(); $files = fs :: find(PAGE_CACHE_DIR); $this->assertEqual(sizeof($files), 1); $file = reset($files); $this->assertEqual(fs :: normalize_path($file), fs :: normalize_path(PAGE_CACHE_DIR . fs :: separator() . 'not_page_file')); $this->_clean_simple_cache('not_page_file'); }
function _generate_debug_editor_link_html(&$code, $file_path) { if(!defined('WS_SCRIPT_WRITTEN')) { if(defined('TEMPLATE_EDITOR_PATH')) $editor_path = TEMPLATE_EDITOR_PATH; else $editor_path = 'notepad.exe %s'; $code->write_html(" <SCRIPT LANGUAGE='JScript'> function run_template_editor(path) { WS = new ActiveXObject('WScript.shell'); if(!WS) return; editor = '{$editor_path}'; re = /%s/i; editor = editor.replace(re, path); WS.exec(editor); } </SCRIPT>"); define('WS_SCRIPT_WRITTEN', true); } $file_path = addslashes(fs :: normalize_path($file_path)); $code->write_html("<a href='#'><img onclick='run_template_editor(this.title)' class='debug-info-img' src='/shared/images/i.gif' alt='i' title='{$file_path}' border='0'></a>"); }
function walk_dir($dir, $function_def, $params=array(), $include_first=false) { $return_params = array(); $separator = fs :: separator(); $dir = fs :: normalize_path($dir); $dir = fs :: chop($dir); $params['separator'] = $separator; fs :: _do_walk_dir($dir, $separator, $function_def, $return_params, $params, $include_first); return $return_params; }
function test_recursive_find() { $this->_create_file_system(); $res = fs :: recursive_find(TEST_DIR_ABSOLUTE_PATH . '/tmp/', 'fd', '~test\d_1~'); sort($res); $this->assertEqual( $res, array( fs :: normalize_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/test1_1'), fs :: normalize_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey/test3_1'), fs :: normalize_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/test2_1'), ) ); $this->_remove_file_system(); }
function &_getRecursiveFileList($directory, $file_test_function) { if(!is_dir($directory)) return array(); $dh = opendir($directory); $file_list = array(); while ($file = readdir($dh)) { $file_path = $directory . '/' . $file; if (0 === strpos($file, '.')) continue; if (is_dir($file_path)) { $file_list = array_merge($file_list, $this->_getRecursiveFileList( $file_path, $file_test_function)); } if ($file_test_function[0]->$file_test_function[1]($file)) { $file_list[] = fs :: normalize_path($file_path); } } closedir($dh); sort($file_list); return $file_list; }