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::clean_path($file_path); } } closedir($dh); return $file_list; }
function find_subitems($dir, $types = 'dfl', $exclude_regex = '', $add_path = true, $include_hidden = false) { $dir = fs :: clean_path($dir); $dir = fs :: chop($dir); $items = array(); $separator = fs :: separator(); if ($handle = opendir($dir)) { while(($element = readdir($handle)) !== false) { if ($element == '.' || $element == '..') continue; if (!$include_hidden && $element[0] == '.') continue; if ($exclude_regex && preg_match($exclude_regex, $element)) continue; if (is_dir($dir . $separator . $element) && strpos($types, 'd') === false) continue; if (is_link($dir . $separator . $element) && strpos($types, 'l') === false) continue; if (is_file( $dir . $separator . $element ) && strpos($types, 'f') === false) continue; if ($add_path) { if (is_string($add_path)) $items[] = $add_path . $separator . $element; else $items[] = $dir . $separator . $element; } else $items[] = $element; } closedir($handle); } return $items; }
function test_recursive_find() { $this->_create_file_system(); $res = fs :: recursive_find(TEST_DIR_ABSOLUTE_PATH . '/tmp/', 'test\d_1'); sort($res); $this->assertEqual( $res, array( fs :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/test1_1'), fs :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey/test3_1'), fs :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/test2_1'), ) ); $this->_remove_file_system(); }
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 :: clean_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 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_subitems(PAGE_CACHE_DIR); $this->assertEqual(sizeof($files), 1); $file = reset($files); $this->assertEqual(fs::clean_path($file), fs::clean_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')) { $code->write_html(' <SCRIPT LANGUAGE="JScript"> function run_template_editor(path) { WS = new ActiveXObject("WScript.shell"); WS.exec("uedit32.exe " + path); } </SCRIPT>'); define('WS_SCRIPT_WRITTEN', true); } $file_path = addslashes(fs :: clean_path($file_path)); $code->write_html("<a href='#'><img onclick='run_template_editor(\"{$file_path}\");' src='/shared/images/i.gif' alt='{$file_path}'></a>"); }
function _generate_debug_editor_link_html(& $code, $file_path) { // if(!defined('WS_SCRIPT_WRITTEN')) // { // // $code->write_html(' <SCRIPT LANGUAGE="JScript"> // function run_template_editor(path) // { // WS = new ActiveXObject("WScript.shell"); // WS.exec("uedit32.exe " + path); // } // </SCRIPT>'); // // define('WS_SCRIPT_WRITTEN', true); // } $file_path = addslashes(fs :: clean_path($file_path)); $code->write_html("<a href='#'><img class='debug-info-img' src='/shared/images/i.gif' alt='{$file_path}' title='{$file_path}' border='0'></a>"); }
/** * Make a file name (with path) * * @param string $id cache id * @param string $group name of the group * @access private */ function _set_file_name($id, $group) { if ($this->_file_name_protection) { $this->_file = fs::clean_path($this->_cache_dir . '/cache_' . md5($group) . '_' . md5($id)); } else { $this->_file = fs::clean_path($this->_cache_dir . '/cache_' . $group . '_' . $id); } }
function &getTestCaseList($directory) { if (!file_exists($directory)) { return ''; } $directory = fs::clean_path($directory); $manager =& new HTMLTestManager(); $testcases =& $manager->_getTestFileList($directory); if (1 > count($testcases)) { return "<p>No test cases set up!</p>"; } $buffer = "<p>Available test cases:</p>\n<ul>"; foreach ($testcases as $testcase_file => $testcase) { $buffer .= "<li><a href='" . $manager->getBaseURL() . "?case=" . urlencode($testcase_file) . "'>" . $testcase . "</a></li>\n"; } return $buffer . "</ul>\n"; }