getFilename(); if (($file->isDot() || $name[0] == '.') && $ignoreDot) { continue; } if ($file->isDir() && $recurse) { $filelist = array_merge($filelist, self::_help_scan_directory($path . $name, $recurse, $ignoreDot, $pathAdd . BSFunctions::fetch_source_path(str_replace($path, '', $file->getPathname())))); continue; } $filelist[] = $pathAdd . $name; } return $filelist; } /** * Changes line breaks into one format * * @param string Text * @param string New line break (default is UNIX \n format) * * @return string Text with one type of line break */ public static function convert_line_breaks($text, $convert_to = "\n") { $text = trim($text); $text = str_replace(array("\r\n", "\r", "\n"), "\n", $text); $text = str_replace("\n", $convert_to, $text); return $text; } /** * Removes all empty() [by PHP's standards] elements in an array. This * can be used in place of using PREG_SPLIT_NO_EMPTY. * * @param array An array to strip empties from * * @return array Full-valued array */ public static function array_strip_empty($array) { foreach ($array as $key => $value) { if (is_array($array["$key"])) { $array["$key"] = self::array_strip_empty($array["$key"]); } else if (empty($value) || is_null($value)) { unset($array["$key"]); } } return $array; } /** * A backtrace formatter. * * This is very slightly modified from PEAR/PHP_Compat (PHP license) * * @author Laurent Laville * @author Aidan Lister * * @param array The backtrace from debug_backtrace() to format * * @return string Formatted output */ public static function format_backtrace($backtrace) { // Unset call to debug_print_backtrace array_shift($backtrace); if (empty($backtrace)) { return ''; } // Iterate backtrace $calls = array(); foreach ($backtrace as $i => $call) { if (!isset($call['file'])) { $call['file'] = '(null)'; } if (!isset($call['line'])) { $call['line'] = '0'; } $location = $call['file'] . ':' . $call['line']; $function = (isset($call['class'])) ? $call['class'] . (isset($call['type']) ? $call['type'] : '.') . $call['function'] : $call['function']; $params = ''; if (isset($call['args'])) { $args = array(); foreach ($call['args'] as $arg) { if (is_array($arg)) { $args[] = 'Array'; } elseif (is_object($arg)) { $args[] = get_class($arg); } else { $args[] = $arg; } } $params = implode(', ', $args); } $calls[] = sprintf('#%d %s(%s) called at [%s]', $i, $function, $params, $location); } return implode("\n", $calls); } /** * A variation of PHP's substr() method that takes in the start * and end position of a string, rather than a start and length. This * mimics Java's String.substring() method. * * @param string The string * @param integer Start position * @param integer End position * * @return string Part of a string */ public static function substring($string, $start, $end) { return substr($string, $start, $end - $start); } /** * Converts a boolean value into the string 'Yes' or 'No' * * @param boolean * @return string */ public static function bool_to_string($bool) { return ($bool ? _('Yes') : _('No')); } } ?>