function &getTestCaseList($directory)
	{
		if(!file_exists($directory))
			return '';

		$directory = dir :: 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";
	} 
  function test_recursive_find()
  {
  	$this->_create_file_system();
  	 
  	$res = dir :: recursive_find(TEST_DIR_ABSOLUTE_PATH . '/tmp/', 'test\d_1');
	sort($res);

  	$this->assertEqual(
  		$res, 
  		array(
  			dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/test1_1'),
  			dir :: clean_path(TEST_DIR_ABSOLUTE_PATH . '/tmp/wow/hey/test3_1'),
  			dir :: 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'))
		{

			$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(dir :: 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 find_subitems($dir, $types = 'dfl', $exclude_regex = '', $add_path = true, $include_hidden = false)
 {
     $dir = dir::clean_path($dir);
     $dir = dir::chop($dir);
     $items = array();
     $separator = dir::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 path($names, $include_end_separator = false, $type = DIR_SEPARATOR_UNIX)
 {
     $separator = dir::separator($type);
     $path = implode($separator, $names);
     $path = dir::clean_path($path, $type);
     $has_end_separator = strlen($path) > 0 && $path[strlen($path) - 1] == $separator;
     if ($include_end_separator && !$has_end_separator) {
         $path .= $separator;
     } elseif (!$include_end_separator && $has_end_separator) {
         $path = substr($path, 0, strlen($path) - 1);
     }
     return $path;
 }