From: Michael M Slusarz Date: Wed, 3 Feb 2010 19:50:50 +0000 (-0700) Subject: Convert File_CSV to H4 format X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=41b3e2f56953bf6ae826e3b45321ec7fd1f63415;p=horde.git Convert File_CSV to H4 format --- diff --git a/framework/Data/Data/csv.php b/framework/Data/Data/csv.php index 4896028fd..a1724f747 100644 --- a/framework/Data/Data/csv.php +++ b/framework/Data/Data/csv.php @@ -34,7 +34,7 @@ class Horde_Data_csv extends Horde_Data { */ function discoverFormat($filename) { - return File_CSV::discoverFormat($filename); + return Horde_File_Csv::discoverFormat($filename); } /** @@ -52,12 +52,13 @@ class Horde_Data_csv extends Horde_Data { * @return array A two-dimensional array of all imported data rows. If * $header was true the rows are associative arrays with the * field/column names as the keys. + *@throws Horde_File_Csv_Exception */ function importFile($filename, $header = false, $sep = '', $quote = '', $fields = null, $import_mapping = array(), $charset = null, $crlf = null) { - /* File_CSV is a bit picky at what parameters it expects. */ + /* Horde_File_Csv is a bit picky at what parameters it expects. */ $conf = array(); if ($fields) { $conf['fields'] = $fields; @@ -79,20 +80,14 @@ class Horde_Data_csv extends Horde_Data { /* Strip and keep the first line if it contains the field * names. */ if ($header) { - $head = File_CSV::read($filename, $conf); - if (is_a($head, 'PEAR_Error')) { - return $head; - } + $head = Horde_File_Csv::read($filename, $conf); if (!empty($charset)) { $head = Horde_String::convertCharset($head, $charset, Horde_Nls::getCharset()); } } $data = array(); - while ($line = File_CSV::read($filename, $conf)) { - if (is_a($line, 'PEAR_Error')) { - return $line; - } + while ($line = Horde_File_Csv::read($filename, $conf)) { if (!empty($charset)) { $line = Horde_String::convertCharset($line, $charset, Horde_Nls::getCharset()); } @@ -112,12 +107,12 @@ class Horde_Data_csv extends Horde_Data { } } - $fp = File_CSV::getPointer($filename, $conf); - if ($fp && !is_a($fp, 'PEAR_Error')) { + $fp = Horde_File_Csv::getPointer($filename, $conf); + if ($fp) { rewind($fp); } - $this->_warnings = File_CSV::warning(); + $this->_warnings = Horde_File_Csv::warning(); return $data; } diff --git a/framework/File_CSV/CSV.php b/framework/File_CSV/CSV.php deleted file mode 100644 index d844f9fc2..000000000 --- a/framework/File_CSV/CSV.php +++ /dev/null @@ -1,565 +0,0 @@ - - * Copyright 2005-2010 The Horde Project (http://www.horde.org/) - * - * This source file is subject to version 2.0 of the PHP license, that is - * bundled with this package in the file LICENSE, and is available at through - * the world-wide-web at http://www.php.net/license/2_02.txt. If you did not - * receive a copy of the PHP license and are unable to obtain it through the - * world-wide-web, please send a note to license@php.net so we can mail you a - * copy immediately. - * - * @author Tomas Von Veschler Cox - * @author Jan Schneider - * @package File_CSV - */ -class File_CSV { - - /** - * Discovers the format of a CSV file (the number of fields, the separator, - * the quote string, and the line break). - * - * We can't use the auto_detect_line_endings PHP setting, because it's not - * supported by fgets() contrary to what the manual says. - * - * @static - * - * @param string The CSV file name - * @param array Extra separators that should be checked for. - * - * @return array The format hash. - */ - function discoverFormat($file, $extraSeps = array()) - { - if (!$fp = @fopen($file, 'r')) { - return PEAR::raiseError('Could not open file: ' . $file); - } - - $seps = array("\t", ';', ':', ',', '~'); - $seps = array_merge($seps, $extraSeps); - $matches = array(); - $crlf = null; - $conf = array(); - - /* Take the first 10 lines and store the number of ocurrences for each - * separator in each line. */ - for ($i = 0; ($i < 10) && ($line = fgets($fp));) { - /* Do we have Mac line endings? */ - $lines = preg_split('/\r(?!\n)/', $line, 10); - $j = 0; - $c = count($lines); - if ($c > 1) { - $crlf = "\r"; - } - while ($i < 10 && $j < $c) { - $line = $lines[$j]; - if (!isset($crlf)) { - foreach (array("\r\n", "\n") as $c) { - if (substr($line, -strlen($c)) == $c) { - $crlf = $c; - break; - } - } - } - $i++; - $j++; - foreach ($seps as $sep) { - $matches[$sep][$i] = substr_count($line, $sep); - } - } - } - if (isset($crlf)) { - $conf['crlf'] = $crlf; - } - - /* Group the results by amount of equal occurrences. */ - $fields = array(); - $amount = array(); - foreach ($matches as $sep => $lines) { - $times = array(); - $times[0] = 0; - foreach ($lines as $num) { - if ($num > 0) { - $times[$num] = (isset($times[$num])) ? $times[$num] + 1 : 1; - } - } - arsort($times); - $fields[$sep] = key($times); - $amount[$sep] = $times[key($times)]; - } - arsort($amount); - $sep = key($amount); - - $conf['fields'] = $fields[$sep] + 1; - $conf['sep'] = $sep; - - /* Test if there are fields with quotes around in the first 10 - * lines. */ - $quotes = '"\''; - $quote = ''; - rewind($fp); - for ($i = 0; ($i < 10) && ($line = fgets($fp)); $i++) { - if (preg_match("|$sep([$quotes]).*([$quotes])$sep|U", $line, $match)) { - if ($match[1] == $match[2]) { - $quote = $match[1]; - break; - } - } - if (preg_match("|^([$quotes]).*([$quotes])$sep|", $line, $match) || - preg_match("|([$quotes]).*([$quotes])$sep\s$|Us", $line, $match)) { - if ($match[1] == $match[2]) { - $quote = $match[1]; - break; - } - } - } - $conf['quote'] = $quote; - - fclose($fp); - - // XXX What about trying to discover the "header"? - return $conf; - } - - /** - * Reads a row from a CSV file and returns it as an array. - * - * This method normalizes linebreaks to single newline characters (0x0a). - * - * @param string $file The name of the CSV file. - * @param array $conf The configuration for the CSV file. - * - * @return array|boolean The CSV data or false if no more data available. - */ - function read($file, &$conf) - { - $fp = File_CSV::getPointer($file, $conf, HORDE_FILE_CSV_MODE_READ); - if (is_a($fp, 'PEAR_Error')) { - return $fp; - } - - $line = fgets($fp); - $line_length = strlen($line); - - /* Use readQuoted() if we have Mac line endings. */ - if (preg_match('/\r(?!\n)/', $line)) { - fseek($fp, -$line_length, SEEK_CUR); - return File_CSV::readQuoted($file, $conf); - } - - /* Normalize line endings. */ - $line = str_replace("\r\n", "\n", $line); - if (!strlen(trim($line))) { - return false; - } - - File_CSV::_line(File_CSV::_line() + 1); - - if ($conf['fields'] == 1) { - return array($line); - } - - $fields = explode($conf['sep'], $line); - if ($conf['quote']) { - $last = ltrim($fields[count($fields) - 1]); - /* Fallback to read the line with readQuoted() if we assume that - * the simple explode won't work right. */ - $last_len = strlen($last); - if (($last_len && - $last[$last_len - 1] == "\n" && - $last[0] == $conf['quote'] && - $last[strlen(rtrim($last)) - 1] != $conf['quote']) || - (count($fields) != $conf['fields']) - // XXX perhaps there is a separator inside a quoted field - // preg_match("|{$conf['quote']}.*{$conf['sep']}.*{$conf['quote']}|U", $line) - ) { - fseek($fp, -$line_length, SEEK_CUR); - return File_CSV::readQuoted($file, $conf); - } else { - foreach ($fields as $k => $v) { - $fields[$k] = File_CSV::unquote(trim($v), $conf['quote']); - } - } - } else { - foreach ($fields as $k => $v) { - $fields[$k] = trim($v); - } - } - - if (count($fields) < $conf['fields']) { - File_CSV::warning(sprintf(_("Wrong number of fields in line %d. Expected %d, found %d."), File_CSV::_line(), $conf['fields'], count($fields))); - $fields = array_merge($fields, array_fill(0, $conf['fields'] - count($fields), '')); - } elseif (count($fields) > $conf['fields']) { - File_CSV::warning(sprintf(_("More fields found in line %d than the expected %d."), File_CSV::_line(), $conf['fields'])); - array_splice($fields, $conf['fields']); - } - - return $fields; - } - - /** - * Reads a row from a CSV file and returns it as an array. - * - * This method is able to read fields with multiline data and normalizes - * linebreaks to single newline characters (0x0a). - * - * @param string $file The name of the CSV file. - * @param array $conf The configuration for the CSV file. - * - * @return array|boolean The CSV data or false if no more data available. - */ - function readQuoted($file, &$conf) - { - $fp = File_CSV::getPointer($file, $conf, HORDE_FILE_CSV_MODE_READ); - if (is_a($fp, 'PEAR_Error')) { - return $fp; - } - - /* A buffer with all characters of the current field read so far. */ - $buff = ''; - /* The current character. */ - $c = null; - /* The read fields. */ - $ret = false; - /* The number of the current field. */ - $i = 0; - /* Are we inside a quoted field? */ - $in_quote = false; - /* Did we just process an escaped quote? */ - $quote_escaped = false; - /* Is the last processed quote the first of a field? */ - $first_quote = false; - - while (($ch = fgetc($fp)) !== false) { - /* Normalize line breaks. */ - if ($ch == $conf['crlf']) { - $ch = "\n"; - } elseif (strlen($conf['crlf']) == 2 && $ch == $conf['crlf'][0]) { - $next = fgetc($fp); - if (!$next) { - break; - } - if ($next == $conf['crlf'][1]) { - $ch = "\n"; - } - } - - /* Previous character. */ - $prev = $c; - /* Current character. */ - $c = $ch; - - /* Simple character. */ - if ($c != $conf['quote'] && - $c != $conf['sep'] && - $c != "\n") { - $buff .= $c; - if (!$i) { - $i = 1; - } - $quote_escaped = false; - $first_quote = false; - continue; - } - - if ($c == $conf['quote'] && !$in_quote) { - /* Quoted field begins. */ - $in_quote = true; - $buff = ''; - if (!$i) { - $i = 1; - } - } elseif ($in_quote) { - /* We do NOT check for the closing quote immediately, but when - * we got the character AFTER the closing quote. */ - if ($c == $conf['quote'] && $prev == $conf['quote'] && - !$quote_escaped) { - /* Escaped (double) quotes. */ - $quote_escaped = true; - $first_quote = true; - $prev = null; - /* Simply skip the second quote. */ - continue; - } elseif ($c == $conf['sep'] && $prev == $conf['quote']) { - /* Quoted field ends with a delimiter. */ - $in_quote = false; - $quote_escaped = false; - $first_quote = true; - } elseif ($c == "\n") { - /* We have a linebreak inside the quotes. */ - if (strlen($buff) == 1 && - $buff[0] == $conf['quote'] && - $quote_escaped && $first_quote) { - /* A line break after a closing quote of an empty - * field, field and row end here. */ - $in_quote = false; - } elseif (strlen($buff) >= 1 && - $buff[strlen($buff) - 1] == $conf['quote'] && - !$quote_escaped && !$first_quote) { - /* A line break after a closing quote, field and row - * end here. This is NOT the closing quote if we - * either process an escaped (double) quote, or if the - * quote before the line break was the opening - * quote. */ - $in_quote = false; - } else { - /* Only increment the line number. Line breaks inside - * quoted fields are part of the field content. */ - File_CSV::_line(File_CSV::_line() + 1); - } - $quote_escaped = false; - $first_quote = true; - } - } - - if (!$in_quote && - ($c == $conf['sep'] || $c == "\n")) { - /* End of line or end of field. */ - if ($c == $conf['sep'] && - (count($ret) + 1) == $conf['fields']) { - /* More fields than expected. Forward the line pointer to - * the EOL and drop the remainder. */ - while ($c !== false && $c != "\n") { - $c = fgetc($fp); - } - File_CSV::warning(sprintf(_("More fields found in line %d than the expected %d."), File_CSV::_line(), $conf['fields'])); - } - - if ($c == "\n" && - $i != $conf['fields']) { - /* Less fields than expected. */ - if ($i == 0) { - /* Skip empty lines. */ - return $ret; - } - File_CSV::warning(sprintf(_("Wrong number of fields in line %d. Expected %d, found %d."), File_CSV::_line(), $conf['fields'], $i)); - - $ret[] = File_CSV::unquote($buff, $conf['quote']); - $ret = array_merge($ret, array_fill(0, $conf['fields'] - $i, '')); - return $ret; - } - - /* Remove surrounding quotes from quoted fields. */ - if ($buff == '"') { - $ret[] = ''; - } else { - $ret[] = File_CSV::unquote($buff, $conf['quote']); - } - if (count($ret) == $conf['fields']) { - return $ret; - } - - $buff = ''; - $i++; - continue; - } - $buff .= $c; - } - - return $ret; - } - - /** - * Writes a hash into a CSV file. - * - * @param string $file The name of the CSV file. - * @param array $fields The CSV data. - * @param array $conf The configuration for the CSV file. - * - * @return boolean True on success, PEAR_Error on failure. - */ - function write($file, $fields, &$conf) - { - if (is_a($fp = File_CSV::getPointer($file, $conf, HORDE_FILE_CSV_MODE_WRITE), 'PEAR_Error')) { - return $fp; - } - - if (count($fields) != $conf['fields']) { - return PEAR::raiseError(sprintf(_("Wrong number of fields. Expected %d, found %d."), $conf['fields'], count($fields))); - } - - $write = ''; - for ($i = 0; $i < count($fields); $i++) { - if (!is_numeric($fields[$i]) && $conf['quote']) { - $write .= $conf['quote'] . $fields[$i] . $conf['quote']; - } else { - $write .= $fields[$i]; - } - if ($i < (count($fields) - 1)) { - $write .= $conf['sep']; - } else { - $write .= $conf['crlf']; - } - } - - if (!fwrite($fp, $write)) { - return PEAR::raiseError(sprintf(_("Cannot write to file \"%s\""), $file)); - } - - return true; - } - - /** - * Removes surrounding quotes from a string and normalizes linebreaks. - * - * @param string $field The string to unquote. - * @param string $quote The quote character. - * @param string $crlf The linebreak character. - * - * @return string The unquoted data. - */ - function unquote($field, $quote, $crlf = null) - { - /* Skip empty fields (form: ;;) */ - if (!strlen($field)) { - return $field; - } - if ($quote && $field[0] == $quote && - $field[strlen($field) - 1] == $quote) { - /* Normalize only for BC. */ - if ($crlf) { - $field = str_replace($crlf, "\n", $field); - } - return substr($field, 1, -1); - } - return $field; - } - - /** - * Sets or gets the current line being parsed. - * - * @param integer $line If specified, the current line. - * - * @return integer The current line. - */ - function _line($line = null) - { - static $current_line = 0; - - if (!is_null($line)) { - $current_line = $line; - } - - return $current_line; - } - - /** - * Adds a warning to or retrieves and resets the warning stack. - * - * @param string A warning string. If not specified, the existing - * warnings will be returned instead and the warning stack - * gets emptied. - * - * @return array If no parameter has been specified, the list of existing - * warnings. - */ - function warning($warning = null) - { - static $warnings = array(); - - if (is_null($warning)) { - $return = $warnings; - $warnings = array(); - return $return; - } - - $warnings[] = $warning; - } - - /** - * Returns or creates the file descriptor associated with a file. - * - * @static - * - * @param string $file The name of the file - * @param array $conf The configuration - * @param string $mode The open mode. HORDE_FILE_CSV_MODE_READ or - * HORDE_FILE_CSV_MODE_WRITE. - * - * @return resource The file resource or PEAR_Error on error. - */ - function getPointer($file, &$conf, $mode = HORDE_FILE_CSV_MODE_READ) - { - static $resources = array(); - static $config = array(); - - if (isset($resources[$file])) { - $conf = $config[$file]; - return $resources[$file]; - } - if (is_a($error = File_CSV::_checkConfig($conf), 'PEAR_Error')) { - return $error; - } - $config[$file] = $conf; - - $fp = @fopen($file, $mode); - if (!is_resource($fp)) { - return PEAR::raiseError(sprintf(_("Cannot open file \"%s\"."), $file)); - } - $resources[$file] = $fp; - File_CSV::_line(0); - - if ($mode == HORDE_FILE_CSV_MODE_READ && !empty($conf['header'])) { - if (is_a($header = File_CSV::read($file, $conf), 'PEAR_Error')) { - return $header; - } - } - - return $fp; - } - - /** - * Checks the configuration given by the user. - * - * @param array $conf The configuration assoc array - * @param string $error The error will be written here if any - */ - function _checkConfig(&$conf) - { - // check conf - if (!is_array($conf)) { - return PEAR::raiseError('Invalid configuration.'); - } - - if (!isset($conf['fields']) || !is_numeric($conf['fields'])) { - return PEAR::raiseError(_("The number of fields must be numeric.")); - } - - if (isset($conf['sep'])) { - if (strlen($conf['sep']) != 1) { - return PEAR::raiseError(_("The separator must be one single character.")); - } - } elseif ($conf['fields'] > 1) { - return PEAR::raiseError(_("No separator specified.")); - } - - if (!empty($conf['quote'])) { - if (strlen($conf['quote']) != 1) { - return PEAR::raiseError(_("The quote character must be one single character.")); - } - } else { - $conf['quote'] = ''; - } - - if (!isset($conf['crlf'])) { - $conf['crlf'] = "\n"; - } - } - -} diff --git a/framework/File_CSV/package.xml b/framework/File_CSV/package.xml deleted file mode 100644 index d898fb308..000000000 --- a/framework/File_CSV/package.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - File_CSV - pear.horde.org - Reads and writes CSV files - The File_CSV package allows reading and creating of CSV data and files. It -is a fork of the File_CSV class of PEAR's File package. - - - Jan Schneider - jan - jan@horde.org - yes - - 2006-05-08 - - - 0.1.1 - 0.1.1 - - - beta - beta - - PHP - -* Converted to package.xml 2.0 for pear.horde.org -* Close Horde bug #6372 (ritaselsky@gmail.com) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4.3.0 - - - 1.4.0b1 - - - PEAR - pear.php.net - - - pcre - - - - - - - - 0.1.0 - 0.1.0 - - - beta - beta - - 2004-01-01 - PHP - First release. - - - - diff --git a/framework/File_CSV/tests/001.csv b/framework/File_CSV/tests/001.csv deleted file mode 100755 index d217fb0fc..000000000 --- a/framework/File_CSV/tests/001.csv +++ /dev/null @@ -1,4 +0,0 @@ -"Field 1-1", "Field 1-2", "Field 1-3", "Field 1-4" -"Field 2-1", "Field 2-2", "Field 2-3" -"Field 3-1", "Field 3-2" -"Field 4-1" diff --git a/framework/File_CSV/tests/001.phpt b/framework/File_CSV/tests/001.phpt deleted file mode 100755 index 33ff355e7..000000000 --- a/framework/File_CSV/tests/001.phpt +++ /dev/null @@ -1,84 +0,0 @@ ---TEST-- -File_CSV Test Case 001: Fields count less than expected ---FILE-- - ---EXPECT-- -array(4) { - ["crlf"]=> - string(1) " -" - ["fields"]=> - int(4) - ["sep"]=> - string(1) "," - ["quote"]=> - string(1) """ -} -array(4) { - [0]=> - array(4) { - [0]=> - string(9) "Field 1-1" - [1]=> - string(9) "Field 1-2" - [2]=> - string(9) "Field 1-3" - [3]=> - string(9) "Field 1-4" - } - [1]=> - array(4) { - [0]=> - string(9) "Field 2-1" - [1]=> - string(9) "Field 2-2" - [2]=> - string(9) "Field 2-3" - [3]=> - string(0) "" - } - [2]=> - array(4) { - [0]=> - string(9) "Field 3-1" - [1]=> - string(9) "Field 3-2" - [2]=> - string(0) "" - [3]=> - string(0) "" - } - [3]=> - array(4) { - [0]=> - string(9) "Field 4-1" - [1]=> - string(0) "" - [2]=> - string(0) "" - [3]=> - string(0) "" - } -} diff --git a/framework/File_CSV/tests/002.csv b/framework/File_CSV/tests/002.csv deleted file mode 100755 index bcd6ce0ca..000000000 --- a/framework/File_CSV/tests/002.csv +++ /dev/null @@ -1,4 +0,0 @@ -"Field 1-1", "Field 1-2", "Field 1-3", "Field 1-4" -"Field 2-1", "Field 2-2", "Field 2-3", "Field 2-4", "Extra Field" -"Field 3-1", "Field 3-2" -"Field 4-1" diff --git a/framework/File_CSV/tests/002.phpt b/framework/File_CSV/tests/002.phpt deleted file mode 100755 index ccc536761..000000000 --- a/framework/File_CSV/tests/002.phpt +++ /dev/null @@ -1,84 +0,0 @@ ---TEST-- -File_CSV Test Case 002: Fields count more than expected ---FILE-- - ---EXPECT-- -array(4) { - ["crlf"]=> - string(1) " -" - ["fields"]=> - int(4) - ["sep"]=> - string(1) "," - ["quote"]=> - string(1) """ -} -array(4) { - [0]=> - array(4) { - [0]=> - string(9) "Field 1-1" - [1]=> - string(9) "Field 1-2" - [2]=> - string(9) "Field 1-3" - [3]=> - string(9) "Field 1-4" - } - [1]=> - array(4) { - [0]=> - string(9) "Field 2-1" - [1]=> - string(9) "Field 2-2" - [2]=> - string(9) "Field 2-3" - [3]=> - string(9) "Field 2-4" - } - [2]=> - array(4) { - [0]=> - string(9) "Field 3-1" - [1]=> - string(9) "Field 3-2" - [2]=> - string(0) "" - [3]=> - string(0) "" - } - [3]=> - array(4) { - [0]=> - string(9) "Field 4-1" - [1]=> - string(0) "" - [2]=> - string(0) "" - [3]=> - string(0) "" - } -} diff --git a/framework/File_CSV/tests/003.csv b/framework/File_CSV/tests/003.csv deleted file mode 100644 index 62cb0f7a6..000000000 --- a/framework/File_CSV/tests/003.csv +++ /dev/null @@ -1,4 +0,0 @@ -"Field 1-1","Field 1-2","Field 1-3","Field 1-4" -"Field 2-1","Field 2-2","Field 2-3","I'm multiline -Field" -"Field 3-1","Field 3-2","Field 3-3" diff --git a/framework/File_CSV/tests/003.phpt b/framework/File_CSV/tests/003.phpt deleted file mode 100644 index 26407594a..000000000 --- a/framework/File_CSV/tests/003.phpt +++ /dev/null @@ -1,67 +0,0 @@ ---TEST-- -File_CSV Test Case 003: Windows EOL ---FILE-- - ---EXPECT-- -Format: -Array -( - [crlf] => - - [fields] => 4 - [sep] => , - [quote] => " -) - -Data: -Array -( - [0] => Array - ( - [0] => Field 1-1 - [1] => Field 1-2 - [2] => Field 1-3 - [3] => Field 1-4 - ) - - [1] => Array - ( - [0] => Field 2-1 - [1] => Field 2-2 - [2] => Field 2-3 - [3] => I'm multiline -Field - ) - - [2] => Array - ( - [0] => Field 3-1 - [1] => Field 3-2 - [2] => Field 3-3 - [3] => - ) - -) diff --git a/framework/File_CSV/tests/004.csv b/framework/File_CSV/tests/004.csv deleted file mode 100644 index 62cb0f7a6..000000000 --- a/framework/File_CSV/tests/004.csv +++ /dev/null @@ -1,4 +0,0 @@ -"Field 1-1","Field 1-2","Field 1-3","Field 1-4" -"Field 2-1","Field 2-2","Field 2-3","I'm multiline -Field" -"Field 3-1","Field 3-2","Field 3-3" diff --git a/framework/File_CSV/tests/004.phpt b/framework/File_CSV/tests/004.phpt deleted file mode 100644 index e85be8180..000000000 --- a/framework/File_CSV/tests/004.phpt +++ /dev/null @@ -1,67 +0,0 @@ ---TEST-- -File_CSV Test Case 004: Unix EOL ---FILE-- - ---EXPECT-- -Format: -Array -( - [crlf] => - - [fields] => 4 - [sep] => , - [quote] => " -) - -Data: -Array -( - [0] => Array - ( - [0] => Field 1-1 - [1] => Field 1-2 - [2] => Field 1-3 - [3] => Field 1-4 - ) - - [1] => Array - ( - [0] => Field 2-1 - [1] => Field 2-2 - [2] => Field 2-3 - [3] => I'm multiline -Field - ) - - [2] => Array - ( - [0] => Field 3-1 - [1] => Field 3-2 - [2] => Field 3-3 - [3] => - ) - -) diff --git a/framework/File_CSV/tests/005.csv b/framework/File_CSV/tests/005.csv deleted file mode 100644 index 3b26aa998..000000000 --- a/framework/File_CSV/tests/005.csv +++ /dev/null @@ -1 +0,0 @@ -"Field 1-1","Field 1-2","Field 1-3","Field 1-4" "Field 2-1","Field 2-2","Field 2-3","I'm multiline Field" "Field 3-1","Field 3-2","Field 3-3" \ No newline at end of file diff --git a/framework/File_CSV/tests/005.phpt b/framework/File_CSV/tests/005.phpt deleted file mode 100644 index 78701c00c..000000000 --- a/framework/File_CSV/tests/005.phpt +++ /dev/null @@ -1,67 +0,0 @@ ---TEST-- -File_CSV Test Case 005: Mac EOL ---FILE-- - ---EXPECT-- -Format: -Array -( - [crlf] => - [fields] => 4 - [sep] => , - [quote] => " -) - -Data: -Array -( - [0] => Array - ( - [0] => Field 1-1 - [1] => Field 1-2 - [2] => Field 1-3 - [3] => Field 1-4 - ) - - [1] => Array - ( - [0] => Field 2-1 - [1] => Field 2-2 - [2] => Field 2-3 - [3] => I'm multiline -Field - ) - - [2] => Array - ( - [0] => Field 3-1 - [1] => Field 3-2 - [2] => Field 3-3 - [3] => - ) - -) diff --git a/framework/File_CSV/tests/bug_3839.csv b/framework/File_CSV/tests/bug_3839.csv deleted file mode 100644 index 7deda38f2..000000000 --- a/framework/File_CSV/tests/bug_3839.csv +++ /dev/null @@ -1,22 +0,0 @@ -Subject~Start Date~Start Time~End Date~End Time~All day event~Reminder on/off~Reminder Date~Reminder Time~Category~Description~Priority -"Inservice on new resource: ""CPNP Toolkit"""~2004-11-08~10:30 AM~2004-11-08~11:30 AM~FALSE~FALSE~~~Training~"CPN Program ... -Inservice on new resource: ""CPNP Toolkit"" - -Registration Deadline: October 27, 2004, noon - - - Session Evaluation - Eligibility for Prize! - - - Dial In Numbers for Sites Registered - - - Poster and Registration Form - -Facilitator: Manager - -preblurb preblurb preblurb preblurb preblurb preblurb preblurb preblurb preblurb ""CPNP Toolkit"". postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb . - -postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb - -Come check out the new resource!"~Normal diff --git a/framework/File_CSV/tests/bug_3839.phpt b/framework/File_CSV/tests/bug_3839.phpt deleted file mode 100644 index 4371409fe..000000000 --- a/framework/File_CSV/tests/bug_3839.phpt +++ /dev/null @@ -1,110 +0,0 @@ ---TEST-- -File_CSV: test for Bug #3839 ---FILE-- - ---EXPECT-- -array(2) { - [0]=> - array(12) { - [0]=> - string(7) "Subject" - [1]=> - string(10) "Start Date" - [2]=> - string(10) "Start Time" - [3]=> - string(8) "End Date" - [4]=> - string(8) "End Time" - [5]=> - string(13) "All day event" - [6]=> - string(15) "Reminder on/off" - [7]=> - string(13) "Reminder Date" - [8]=> - string(13) "Reminder Time" - [9]=> - string(8) "Category" - [10]=> - string(11) "Description" - [11]=> - string(8) "Priority" - } - [1]=> - array(12) { - [0]=> - string(41) "Inservice on new resource: "CPNP Toolkit"" - [1]=> - string(10) "2004-11-08" - [2]=> - string(8) "10:30 AM" - [3]=> - string(10) "2004-11-08" - [4]=> - string(8) "11:30 AM" - [5]=> - string(5) "FALSE" - [6]=> - string(5) "FALSE" - [7]=> - string(0) "" - [8]=> - string(0) "" - [9]=> - string(8) "Training" - [10]=> - string(1109) "CPN Program ... -Inservice on new resource: "CPNP Toolkit" - -Registration Deadline: October 27, 2004, noon - - - Session Evaluation - Eligibility for Prize! - - - Dial In Numbers for Sites Registered - - - Poster and Registration Form - -Facilitator: Manager - -preblurb preblurb preblurb preblurb preblurb preblurb preblurb preblurb preblurb "CPNP Toolkit". postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb . - -postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb - -Come check out the new resource!" - [11]=> - string(6) "Normal" - } -} diff --git a/framework/File_CSV/tests/bug_4025.csv b/framework/File_CSV/tests/bug_4025.csv deleted file mode 100644 index cd65cc0c4..000000000 --- a/framework/File_CSV/tests/bug_4025.csv +++ /dev/null @@ -1,3 +0,0 @@ -"Betreff","Beginnt am","Beginnt um","Endet am","Endet um","Ganztägiges Ereignis","Erinnerung Ein/Aus","Erinnerung am","Erinnerung um","Besprechungsplanung","Erforderliche Teilnehmer","Optionale Teilnehmer","Besprechungsressourcen","Abrechnungsinformationen","Beschreibung","Kategorien","Ort","Priorität","Privat","Reisekilometer","Vertraulichkeit","Zeitspanne zeigen als" -"Burger Download Session","2.5.2006","11:50:00","2.5.2006","13:00:00","Aus","Ein","2.5.2006","11:35:00","Haas, Jörg","Kuhl, Oliver",,,," -",,"Burger Upload Station (Burger King)","Normal","Aus",,"Normal","1" diff --git a/framework/File_CSV/tests/bug_4025.phpt b/framework/File_CSV/tests/bug_4025.phpt deleted file mode 100644 index edde443cb..000000000 --- a/framework/File_CSV/tests/bug_4025.phpt +++ /dev/null @@ -1,131 +0,0 @@ ---TEST-- -File_CSV: test for Bug #4025 ---FILE-- - ---EXPECT-- -array(2) { - [0]=> - array(22) { - [0]=> - string(7) "Betreff" - [1]=> - string(10) "Beginnt am" - [2]=> - string(10) "Beginnt um" - [3]=> - string(8) "Endet am" - [4]=> - string(8) "Endet um" - [5]=> - string(20) "Ganztägiges Ereignis" - [6]=> - string(18) "Erinnerung Ein/Aus" - [7]=> - string(13) "Erinnerung am" - [8]=> - string(13) "Erinnerung um" - [9]=> - string(19) "Besprechungsplanung" - [10]=> - string(24) "Erforderliche Teilnehmer" - [11]=> - string(20) "Optionale Teilnehmer" - [12]=> - string(22) "Besprechungsressourcen" - [13]=> - string(24) "Abrechnungsinformationen" - [14]=> - string(12) "Beschreibung" - [15]=> - string(10) "Kategorien" - [16]=> - string(3) "Ort" - [17]=> - string(9) "Priorität" - [18]=> - string(6) "Privat" - [19]=> - string(14) "Reisekilometer" - [20]=> - string(15) "Vertraulichkeit" - [21]=> - string(21) "Zeitspanne zeigen als" - } - [1]=> - array(22) { - [0]=> - string(23) "Burger Download Session" - [1]=> - string(8) "2.5.2006" - [2]=> - string(8) "11:50:00" - [3]=> - string(8) "2.5.2006" - [4]=> - string(8) "13:00:00" - [5]=> - string(3) "Aus" - [6]=> - string(3) "Ein" - [7]=> - string(8) "2.5.2006" - [8]=> - string(8) "11:35:00" - [9]=> - string(10) "Haas, Jörg" - [10]=> - string(12) "Kuhl, Oliver" - [11]=> - string(0) "" - [12]=> - string(0) "" - [13]=> - string(0) "" - [14]=> - string(1) " -" - [15]=> - string(0) "" - [16]=> - string(35) "Burger Upload Station (Burger King)" - [17]=> - string(6) "Normal" - [18]=> - string(3) "Aus" - [19]=> - string(0) "" - [20]=> - string(6) "Normal" - [21]=> - string(1) "1" - } -} diff --git a/framework/File_CSV/tests/bug_6311.csv b/framework/File_CSV/tests/bug_6311.csv deleted file mode 100644 index ef4f25f0e..000000000 --- a/framework/File_CSV/tests/bug_6311.csv +++ /dev/null @@ -1,5 +0,0 @@ -"Title","First Name","Middle Name","Last Name","Suffix","Company","Department","Job Title","Business Street","Business Street 2","Business Street 3","Business City","Business State","Business Postal Code","Business Country/Region","Home Street","Home Street 2","Home Street 3","Home City","Home State","Home Postal Code","Home Country/Region","Other Street","Other Street 2","Other Street 3","Other City","Other State","Other Postal Code","Other Country/Region","Assistant's Phone","Business Fax","Business Phone","Business Phone 2","Callback","Car Phone","Company Main Phone","Home Fax","Home Phone","Home Phone 2","ISDN","Mobile Phone","Other Fax","Other Phone","Pager","Primary Phone","Radio Phone","TTY/TDD Phone","Telex","Account","Anniversary","Assistant's Name","Billing Information","Birthday","Business Address PO Box","Categories","Children","Directory Server","E-mail Address","E-mail Type","E-mail Display Name","E-mail 2 Address","E-mail 2 Type","E-mail 2 Display Name","E-mail 3 Address","E-mail 3 Type","E-mail 3 Display Name","Gender","Government ID Number","Hobby","Home Address PO Box","Initials","Internet Free Busy","Keywords","Language","Location","Manager's Name","Mileage","Notes","Office Location","Organizational ID Number","Other Address PO Box","Priority","Private","Profession","Referred By","Sensitivity","Spouse","User 1","User 2","User 3","User 4","Web Page" -"","John","","Smith","","International Inc","","","",,,"","","","","",,,"","","","","",,,"","","","","","(123) 555-1111","(123) 555-2222","","","","","","","","","(123) 555-3333","","","","","","","","","0/0/00","",,"0/0/00",,"Programming",,,"john@example.com","SMTP","John Smith (john@example.com)",,,,,,,"Unspecified","",,,"J.S.","","","","","",,"PHP -Perl -Python -","","",,"Normal","False","",,"Normal","","","","","","" diff --git a/framework/File_CSV/tests/bug_6311.phpt b/framework/File_CSV/tests/bug_6311.phpt deleted file mode 100644 index b2f4428a8..000000000 --- a/framework/File_CSV/tests/bug_6311.phpt +++ /dev/null @@ -1,413 +0,0 @@ ---TEST-- -File_CSV: test for Bug #6311 ---FILE-- - ---EXPECT-- -array(2) { - [0]=> - array(92) { - [0]=> - string(5) "Title" - [1]=> - string(10) "First Name" - [2]=> - string(11) "Middle Name" - [3]=> - string(9) "Last Name" - [4]=> - string(6) "Suffix" - [5]=> - string(7) "Company" - [6]=> - string(10) "Department" - [7]=> - string(9) "Job Title" - [8]=> - string(15) "Business Street" - [9]=> - string(17) "Business Street 2" - [10]=> - string(17) "Business Street 3" - [11]=> - string(13) "Business City" - [12]=> - string(14) "Business State" - [13]=> - string(20) "Business Postal Code" - [14]=> - string(23) "Business Country/Region" - [15]=> - string(11) "Home Street" - [16]=> - string(13) "Home Street 2" - [17]=> - string(13) "Home Street 3" - [18]=> - string(9) "Home City" - [19]=> - string(10) "Home State" - [20]=> - string(16) "Home Postal Code" - [21]=> - string(19) "Home Country/Region" - [22]=> - string(12) "Other Street" - [23]=> - string(14) "Other Street 2" - [24]=> - string(14) "Other Street 3" - [25]=> - string(10) "Other City" - [26]=> - string(11) "Other State" - [27]=> - string(17) "Other Postal Code" - [28]=> - string(20) "Other Country/Region" - [29]=> - string(17) "Assistant's Phone" - [30]=> - string(12) "Business Fax" - [31]=> - string(14) "Business Phone" - [32]=> - string(16) "Business Phone 2" - [33]=> - string(8) "Callback" - [34]=> - string(9) "Car Phone" - [35]=> - string(18) "Company Main Phone" - [36]=> - string(8) "Home Fax" - [37]=> - string(10) "Home Phone" - [38]=> - string(12) "Home Phone 2" - [39]=> - string(4) "ISDN" - [40]=> - string(12) "Mobile Phone" - [41]=> - string(9) "Other Fax" - [42]=> - string(11) "Other Phone" - [43]=> - string(5) "Pager" - [44]=> - string(13) "Primary Phone" - [45]=> - string(11) "Radio Phone" - [46]=> - string(13) "TTY/TDD Phone" - [47]=> - string(5) "Telex" - [48]=> - string(7) "Account" - [49]=> - string(11) "Anniversary" - [50]=> - string(16) "Assistant's Name" - [51]=> - string(19) "Billing Information" - [52]=> - string(8) "Birthday" - [53]=> - string(23) "Business Address PO Box" - [54]=> - string(10) "Categories" - [55]=> - string(8) "Children" - [56]=> - string(16) "Directory Server" - [57]=> - string(14) "E-mail Address" - [58]=> - string(11) "E-mail Type" - [59]=> - string(19) "E-mail Display Name" - [60]=> - string(16) "E-mail 2 Address" - [61]=> - string(13) "E-mail 2 Type" - [62]=> - string(21) "E-mail 2 Display Name" - [63]=> - string(16) "E-mail 3 Address" - [64]=> - string(13) "E-mail 3 Type" - [65]=> - string(21) "E-mail 3 Display Name" - [66]=> - string(6) "Gender" - [67]=> - string(20) "Government ID Number" - [68]=> - string(5) "Hobby" - [69]=> - string(19) "Home Address PO Box" - [70]=> - string(8) "Initials" - [71]=> - string(18) "Internet Free Busy" - [72]=> - string(8) "Keywords" - [73]=> - string(8) "Language" - [74]=> - string(8) "Location" - [75]=> - string(14) "Manager's Name" - [76]=> - string(7) "Mileage" - [77]=> - string(5) "Notes" - [78]=> - string(15) "Office Location" - [79]=> - string(24) "Organizational ID Number" - [80]=> - string(20) "Other Address PO Box" - [81]=> - string(8) "Priority" - [82]=> - string(7) "Private" - [83]=> - string(10) "Profession" - [84]=> - string(11) "Referred By" - [85]=> - string(11) "Sensitivity" - [86]=> - string(6) "Spouse" - [87]=> - string(6) "User 1" - [88]=> - string(6) "User 2" - [89]=> - string(6) "User 3" - [90]=> - string(6) "User 4" - [91]=> - string(8) "Web Page" - } - [1]=> - array(92) { - [0]=> - string(0) "" - [1]=> - string(4) "John" - [2]=> - string(0) "" - [3]=> - string(5) "Smith" - [4]=> - string(0) "" - [5]=> - string(17) "International Inc" - [6]=> - string(0) "" - [7]=> - string(0) "" - [8]=> - string(0) "" - [9]=> - string(0) "" - [10]=> - string(0) "" - [11]=> - string(0) "" - [12]=> - string(0) "" - [13]=> - string(0) "" - [14]=> - string(0) "" - [15]=> - string(0) "" - [16]=> - string(0) "" - [17]=> - string(0) "" - [18]=> - string(0) "" - [19]=> - string(0) "" - [20]=> - string(0) "" - [21]=> - string(0) "" - [22]=> - string(0) "" - [23]=> - string(0) "" - [24]=> - string(0) "" - [25]=> - string(0) "" - [26]=> - string(0) "" - [27]=> - string(0) "" - [28]=> - string(0) "" - [29]=> - string(0) "" - [30]=> - string(14) "(123) 555-1111" - [31]=> - string(14) "(123) 555-2222" - [32]=> - string(0) "" - [33]=> - string(0) "" - [34]=> - string(0) "" - [35]=> - string(0) "" - [36]=> - string(0) "" - [37]=> - string(0) "" - [38]=> - string(0) "" - [39]=> - string(0) "" - [40]=> - string(14) "(123) 555-3333" - [41]=> - string(0) "" - [42]=> - string(0) "" - [43]=> - string(0) "" - [44]=> - string(0) "" - [45]=> - string(0) "" - [46]=> - string(0) "" - [47]=> - string(0) "" - [48]=> - string(0) "" - [49]=> - string(6) "0/0/00" - [50]=> - string(0) "" - [51]=> - string(0) "" - [52]=> - string(6) "0/0/00" - [53]=> - string(0) "" - [54]=> - string(11) "Programming" - [55]=> - string(0) "" - [56]=> - string(0) "" - [57]=> - string(16) "john@example.com" - [58]=> - string(4) "SMTP" - [59]=> - string(29) "John Smith (john@example.com)" - [60]=> - string(0) "" - [61]=> - string(0) "" - [62]=> - string(0) "" - [63]=> - string(0) "" - [64]=> - string(0) "" - [65]=> - string(0) "" - [66]=> - string(11) "Unspecified" - [67]=> - string(0) "" - [68]=> - string(0) "" - [69]=> - string(0) "" - [70]=> - string(4) "J.S." - [71]=> - string(0) "" - [72]=> - string(0) "" - [73]=> - string(0) "" - [74]=> - string(0) "" - [75]=> - string(0) "" - [76]=> - string(0) "" - [77]=> - string(16) "PHP -Perl -Python -" - [78]=> - string(0) "" - [79]=> - string(0) "" - [80]=> - string(0) "" - [81]=> - string(6) "Normal" - [82]=> - string(5) "False" - [83]=> - string(0) "" - [84]=> - string(0) "" - [85]=> - string(6) "Normal" - [86]=> - string(0) "" - [87]=> - string(0) "" - [88]=> - string(0) "" - [89]=> - string(0) "" - [90]=> - string(0) "" - [91]=> - string(0) "" - } -} diff --git a/framework/File_CSV/tests/bug_6370.csv b/framework/File_CSV/tests/bug_6370.csv deleted file mode 100644 index 9a9690209..000000000 --- a/framework/File_CSV/tests/bug_6370.csv +++ /dev/null @@ -1,3 +0,0 @@ -"Title","First Name","Middle Name","Last Name","Suffix","Company","Department","Job Title","Business Street","Business Street 2","Business Street 3","Business City","Business State","Business Postal Code","Business Country/Region","Home Street","Home Street 2","Home Street 3","Home City","Home State","Home Postal Code","Home Country/Region","Other Street","Other Street 2","Other Street 3","Other City","Other State","Other Postal Code","Other Country/Region","Assistant's Phone","Business Fax","Business Phone","Business Phone 2","Callback","Car Phone","Company Main Phone","Home Fax","Home Phone","Home Phone 2","ISDN","Mobile Phone","Other Fax","Other Phone","Pager","Primary Phone","Radio Phone","TTY/TDD Phone","Telex","Account","Anniversary","Assistant's Name","Billing Information","Birthday","Business Address PO Box","Categories","Children","Directory Server","E-mail Address","E-mail Type","E-mail Display Name","E-mail 2 Address","E-mail 2 Type","E-mail 2 Display Name","E-mail 3 Address","E-mail 3 Type","E-mail 3 Display Name","Gender","Government ID Number","Hobby","Home Address PO Box","Initials","Internet Free Busy","Keywords","Language","Location","Manager's Name","Mileage","Notes","Office Location","Organizational ID Number","Other Address PO Box","Priority","Private","Profession","Referred By","Sensitivity","Spouse","User 1","User 2","User 3","User 4","Web Page" -"","","","","","","","","Big Tower'"", 1"" Floor -123 Main Street",,,"","","","","",,,"","","","","",,,"","","","","","","","","","","","","","","","","","","","","","","","","0/0/00","",,"0/0/00",,,,,"","","",,,,,,,"Unspecified","",,,"","","","","","",,,"","",,"Normal","False","",,"Normal","","","","","","" diff --git a/framework/File_CSV/tests/bug_6370.phpt b/framework/File_CSV/tests/bug_6370.phpt deleted file mode 100644 index a322e2708..000000000 --- a/framework/File_CSV/tests/bug_6370.phpt +++ /dev/null @@ -1,411 +0,0 @@ ---TEST-- -File_CSV: test for Bug #6370 ---FILE-- - ---EXPECT-- -array(2) { - [0]=> - array(92) { - [0]=> - string(5) "Title" - [1]=> - string(10) "First Name" - [2]=> - string(11) "Middle Name" - [3]=> - string(9) "Last Name" - [4]=> - string(6) "Suffix" - [5]=> - string(7) "Company" - [6]=> - string(10) "Department" - [7]=> - string(9) "Job Title" - [8]=> - string(15) "Business Street" - [9]=> - string(17) "Business Street 2" - [10]=> - string(17) "Business Street 3" - [11]=> - string(13) "Business City" - [12]=> - string(14) "Business State" - [13]=> - string(20) "Business Postal Code" - [14]=> - string(23) "Business Country/Region" - [15]=> - string(11) "Home Street" - [16]=> - string(13) "Home Street 2" - [17]=> - string(13) "Home Street 3" - [18]=> - string(9) "Home City" - [19]=> - string(10) "Home State" - [20]=> - string(16) "Home Postal Code" - [21]=> - string(19) "Home Country/Region" - [22]=> - string(12) "Other Street" - [23]=> - string(14) "Other Street 2" - [24]=> - string(14) "Other Street 3" - [25]=> - string(10) "Other City" - [26]=> - string(11) "Other State" - [27]=> - string(17) "Other Postal Code" - [28]=> - string(20) "Other Country/Region" - [29]=> - string(17) "Assistant's Phone" - [30]=> - string(12) "Business Fax" - [31]=> - string(14) "Business Phone" - [32]=> - string(16) "Business Phone 2" - [33]=> - string(8) "Callback" - [34]=> - string(9) "Car Phone" - [35]=> - string(18) "Company Main Phone" - [36]=> - string(8) "Home Fax" - [37]=> - string(10) "Home Phone" - [38]=> - string(12) "Home Phone 2" - [39]=> - string(4) "ISDN" - [40]=> - string(12) "Mobile Phone" - [41]=> - string(9) "Other Fax" - [42]=> - string(11) "Other Phone" - [43]=> - string(5) "Pager" - [44]=> - string(13) "Primary Phone" - [45]=> - string(11) "Radio Phone" - [46]=> - string(13) "TTY/TDD Phone" - [47]=> - string(5) "Telex" - [48]=> - string(7) "Account" - [49]=> - string(11) "Anniversary" - [50]=> - string(16) "Assistant's Name" - [51]=> - string(19) "Billing Information" - [52]=> - string(8) "Birthday" - [53]=> - string(23) "Business Address PO Box" - [54]=> - string(10) "Categories" - [55]=> - string(8) "Children" - [56]=> - string(16) "Directory Server" - [57]=> - string(14) "E-mail Address" - [58]=> - string(11) "E-mail Type" - [59]=> - string(19) "E-mail Display Name" - [60]=> - string(16) "E-mail 2 Address" - [61]=> - string(13) "E-mail 2 Type" - [62]=> - string(21) "E-mail 2 Display Name" - [63]=> - string(16) "E-mail 3 Address" - [64]=> - string(13) "E-mail 3 Type" - [65]=> - string(21) "E-mail 3 Display Name" - [66]=> - string(6) "Gender" - [67]=> - string(20) "Government ID Number" - [68]=> - string(5) "Hobby" - [69]=> - string(19) "Home Address PO Box" - [70]=> - string(8) "Initials" - [71]=> - string(18) "Internet Free Busy" - [72]=> - string(8) "Keywords" - [73]=> - string(8) "Language" - [74]=> - string(8) "Location" - [75]=> - string(14) "Manager's Name" - [76]=> - string(7) "Mileage" - [77]=> - string(5) "Notes" - [78]=> - string(15) "Office Location" - [79]=> - string(24) "Organizational ID Number" - [80]=> - string(20) "Other Address PO Box" - [81]=> - string(8) "Priority" - [82]=> - string(7) "Private" - [83]=> - string(10) "Profession" - [84]=> - string(11) "Referred By" - [85]=> - string(11) "Sensitivity" - [86]=> - string(6) "Spouse" - [87]=> - string(6) "User 1" - [88]=> - string(6) "User 2" - [89]=> - string(6) "User 3" - [90]=> - string(6) "User 4" - [91]=> - string(8) "Web Page" - } - [1]=> - array(92) { - [0]=> - string(0) "" - [1]=> - string(0) "" - [2]=> - string(0) "" - [3]=> - string(0) "" - [4]=> - string(0) "" - [5]=> - string(0) "" - [6]=> - string(0) "" - [7]=> - string(0) "" - [8]=> - string(37) "Big Tower'", 1" Floor -123 Main Street" - [9]=> - string(0) "" - [10]=> - string(0) "" - [11]=> - string(0) "" - [12]=> - string(0) "" - [13]=> - string(0) "" - [14]=> - string(0) "" - [15]=> - string(0) "" - [16]=> - string(0) "" - [17]=> - string(0) "" - [18]=> - string(0) "" - [19]=> - string(0) "" - [20]=> - string(0) "" - [21]=> - string(0) "" - [22]=> - string(0) "" - [23]=> - string(0) "" - [24]=> - string(0) "" - [25]=> - string(0) "" - [26]=> - string(0) "" - [27]=> - string(0) "" - [28]=> - string(0) "" - [29]=> - string(0) "" - [30]=> - string(0) "" - [31]=> - string(0) "" - [32]=> - string(0) "" - [33]=> - string(0) "" - [34]=> - string(0) "" - [35]=> - string(0) "" - [36]=> - string(0) "" - [37]=> - string(0) "" - [38]=> - string(0) "" - [39]=> - string(0) "" - [40]=> - string(0) "" - [41]=> - string(0) "" - [42]=> - string(0) "" - [43]=> - string(0) "" - [44]=> - string(0) "" - [45]=> - string(0) "" - [46]=> - string(0) "" - [47]=> - string(0) "" - [48]=> - string(0) "" - [49]=> - string(6) "0/0/00" - [50]=> - string(0) "" - [51]=> - string(0) "" - [52]=> - string(6) "0/0/00" - [53]=> - string(0) "" - [54]=> - string(0) "" - [55]=> - string(0) "" - [56]=> - string(0) "" - [57]=> - string(0) "" - [58]=> - string(0) "" - [59]=> - string(0) "" - [60]=> - string(0) "" - [61]=> - string(0) "" - [62]=> - string(0) "" - [63]=> - string(0) "" - [64]=> - string(0) "" - [65]=> - string(0) "" - [66]=> - string(11) "Unspecified" - [67]=> - string(0) "" - [68]=> - string(0) "" - [69]=> - string(0) "" - [70]=> - string(0) "" - [71]=> - string(0) "" - [72]=> - string(0) "" - [73]=> - string(0) "" - [74]=> - string(0) "" - [75]=> - string(0) "" - [76]=> - string(0) "" - [77]=> - string(1) "" - [78]=> - string(0) "" - [79]=> - string(0) "" - [80]=> - string(0) "" - [81]=> - string(6) "Normal" - [82]=> - string(5) "False" - [83]=> - string(0) "" - [84]=> - string(0) "" - [85]=> - string(6) "Normal" - [86]=> - string(0) "" - [87]=> - string(0) "" - [88]=> - string(0) "" - [89]=> - string(0) "" - [90]=> - string(0) "" - [91]=> - string(0) "" - } -} diff --git a/framework/File_CSV/tests/bug_6372.csv b/framework/File_CSV/tests/bug_6372.csv deleted file mode 100644 index ec31094f5..000000000 --- a/framework/File_CSV/tests/bug_6372.csv +++ /dev/null @@ -1,4 +0,0 @@ -"Title","First Name","Middle Name","Last Name","Suffix","Company","Department","Job Title","Business Street","Business Street 2","Business Street 3","Business City","Business State","Business Postal Code","Business Country/Region","Home Street","Home Street 2","Home Street 3","Home City","Home State","Home Postal Code","Home Country/Region","Other Street","Other Street 2","Other Street 3","Other City","Other State","Other Postal Code","Other Country/Region","Assistant's Phone","Business Fax","Business Phone","Business Phone 2","Callback","Car Phone","Company Main Phone","Home Fax","Home Phone","Home Phone 2","ISDN","Mobile Phone","Other Fax","Other Phone","Pager","Primary Phone","Radio Phone","TTY/TDD Phone","Telex","Account","Anniversary","Assistant's Name","Billing Information","Birthday","Business Address PO Box","Categories","Children","Directory Server","E-mail Address","E-mail Type","E-mail Display Name","E-mail 2 Address","E-mail 2 Type","E-mail 2 Display Name","E-mail 3 Address","E-mail 3 Type","E-mail 3 Display Name","Gender","Government ID Number","Hobby","Home Address PO Box","Initials","Internet Free Busy","Keywords","Language","Location","Manager's Name","Mileage","Notes","Office Location","Organizational ID Number","Other Address PO Box","Priority","Private","Profession","Referred By","Sensitivity","Spouse","User 1","User 2","User 3","User 4","Web Page" -"","","","","","","","","123, 12th Floor, -Main Street",,,"","","","","",,,"","","","","",,,"","","","","","","","","","","","","","","","","","","","","","","","","0/0/00","",,"0/0/00",,"",,,"","","","","","",,,,"Unspecified","",,,"","","","","","",," -","","",,"Normal","False","",,"Normal","","","","","","" diff --git a/framework/File_CSV/tests/bug_6372.phpt b/framework/File_CSV/tests/bug_6372.phpt deleted file mode 100644 index 589164757..000000000 --- a/framework/File_CSV/tests/bug_6372.phpt +++ /dev/null @@ -1,412 +0,0 @@ ---TEST-- -File_CSV: test for Bug #6372 ---FILE-- - ---EXPECT-- -array(2) { - [0]=> - array(92) { - [0]=> - string(5) "Title" - [1]=> - string(10) "First Name" - [2]=> - string(11) "Middle Name" - [3]=> - string(9) "Last Name" - [4]=> - string(6) "Suffix" - [5]=> - string(7) "Company" - [6]=> - string(10) "Department" - [7]=> - string(9) "Job Title" - [8]=> - string(15) "Business Street" - [9]=> - string(17) "Business Street 2" - [10]=> - string(17) "Business Street 3" - [11]=> - string(13) "Business City" - [12]=> - string(14) "Business State" - [13]=> - string(20) "Business Postal Code" - [14]=> - string(23) "Business Country/Region" - [15]=> - string(11) "Home Street" - [16]=> - string(13) "Home Street 2" - [17]=> - string(13) "Home Street 3" - [18]=> - string(9) "Home City" - [19]=> - string(10) "Home State" - [20]=> - string(16) "Home Postal Code" - [21]=> - string(19) "Home Country/Region" - [22]=> - string(12) "Other Street" - [23]=> - string(14) "Other Street 2" - [24]=> - string(14) "Other Street 3" - [25]=> - string(10) "Other City" - [26]=> - string(11) "Other State" - [27]=> - string(17) "Other Postal Code" - [28]=> - string(20) "Other Country/Region" - [29]=> - string(17) "Assistant's Phone" - [30]=> - string(12) "Business Fax" - [31]=> - string(14) "Business Phone" - [32]=> - string(16) "Business Phone 2" - [33]=> - string(8) "Callback" - [34]=> - string(9) "Car Phone" - [35]=> - string(18) "Company Main Phone" - [36]=> - string(8) "Home Fax" - [37]=> - string(10) "Home Phone" - [38]=> - string(12) "Home Phone 2" - [39]=> - string(4) "ISDN" - [40]=> - string(12) "Mobile Phone" - [41]=> - string(9) "Other Fax" - [42]=> - string(11) "Other Phone" - [43]=> - string(5) "Pager" - [44]=> - string(13) "Primary Phone" - [45]=> - string(11) "Radio Phone" - [46]=> - string(13) "TTY/TDD Phone" - [47]=> - string(5) "Telex" - [48]=> - string(7) "Account" - [49]=> - string(11) "Anniversary" - [50]=> - string(16) "Assistant's Name" - [51]=> - string(19) "Billing Information" - [52]=> - string(8) "Birthday" - [53]=> - string(23) "Business Address PO Box" - [54]=> - string(10) "Categories" - [55]=> - string(8) "Children" - [56]=> - string(16) "Directory Server" - [57]=> - string(14) "E-mail Address" - [58]=> - string(11) "E-mail Type" - [59]=> - string(19) "E-mail Display Name" - [60]=> - string(16) "E-mail 2 Address" - [61]=> - string(13) "E-mail 2 Type" - [62]=> - string(21) "E-mail 2 Display Name" - [63]=> - string(16) "E-mail 3 Address" - [64]=> - string(13) "E-mail 3 Type" - [65]=> - string(21) "E-mail 3 Display Name" - [66]=> - string(6) "Gender" - [67]=> - string(20) "Government ID Number" - [68]=> - string(5) "Hobby" - [69]=> - string(19) "Home Address PO Box" - [70]=> - string(8) "Initials" - [71]=> - string(18) "Internet Free Busy" - [72]=> - string(8) "Keywords" - [73]=> - string(8) "Language" - [74]=> - string(8) "Location" - [75]=> - string(14) "Manager's Name" - [76]=> - string(7) "Mileage" - [77]=> - string(5) "Notes" - [78]=> - string(15) "Office Location" - [79]=> - string(24) "Organizational ID Number" - [80]=> - string(20) "Other Address PO Box" - [81]=> - string(8) "Priority" - [82]=> - string(7) "Private" - [83]=> - string(10) "Profession" - [84]=> - string(11) "Referred By" - [85]=> - string(11) "Sensitivity" - [86]=> - string(6) "Spouse" - [87]=> - string(6) "User 1" - [88]=> - string(6) "User 2" - [89]=> - string(6) "User 3" - [90]=> - string(6) "User 4" - [91]=> - string(8) "Web Page" - } - [1]=> - array(92) { - [0]=> - string(0) "" - [1]=> - string(0) "" - [2]=> - string(0) "" - [3]=> - string(0) "" - [4]=> - string(0) "" - [5]=> - string(0) "" - [6]=> - string(0) "" - [7]=> - string(0) "" - [8]=> - string(28) "123, 12th Floor, -Main Street" - [9]=> - string(0) "" - [10]=> - string(0) "" - [11]=> - string(0) "" - [12]=> - string(0) "" - [13]=> - string(0) "" - [14]=> - string(0) "" - [15]=> - string(0) "" - [16]=> - string(0) "" - [17]=> - string(0) "" - [18]=> - string(0) "" - [19]=> - string(0) "" - [20]=> - string(0) "" - [21]=> - string(0) "" - [22]=> - string(0) "" - [23]=> - string(0) "" - [24]=> - string(0) "" - [25]=> - string(0) "" - [26]=> - string(0) "" - [27]=> - string(0) "" - [28]=> - string(0) "" - [29]=> - string(0) "" - [30]=> - string(0) "" - [31]=> - string(0) "" - [32]=> - string(0) "" - [33]=> - string(0) "" - [34]=> - string(0) "" - [35]=> - string(0) "" - [36]=> - string(0) "" - [37]=> - string(0) "" - [38]=> - string(0) "" - [39]=> - string(0) "" - [40]=> - string(0) "" - [41]=> - string(0) "" - [42]=> - string(0) "" - [43]=> - string(0) "" - [44]=> - string(0) "" - [45]=> - string(0) "" - [46]=> - string(0) "" - [47]=> - string(0) "" - [48]=> - string(0) "" - [49]=> - string(6) "0/0/00" - [50]=> - string(0) "" - [51]=> - string(0) "" - [52]=> - string(6) "0/0/00" - [53]=> - string(0) "" - [54]=> - string(0) "" - [55]=> - string(0) "" - [56]=> - string(0) "" - [57]=> - string(0) "" - [58]=> - string(0) "" - [59]=> - string(0) "" - [60]=> - string(0) "" - [61]=> - string(0) "" - [62]=> - string(0) "" - [63]=> - string(0) "" - [64]=> - string(0) "" - [65]=> - string(0) "" - [66]=> - string(11) "Unspecified" - [67]=> - string(0) "" - [68]=> - string(0) "" - [69]=> - string(0) "" - [70]=> - string(0) "" - [71]=> - string(0) "" - [72]=> - string(0) "" - [73]=> - string(0) "" - [74]=> - string(0) "" - [75]=> - string(0) "" - [76]=> - string(0) "" - [77]=> - string(1) " -" - [78]=> - string(0) "" - [79]=> - string(0) "" - [80]=> - string(0) "" - [81]=> - string(6) "Normal" - [82]=> - string(5) "False" - [83]=> - string(0) "" - [84]=> - string(0) "" - [85]=> - string(6) "Normal" - [86]=> - string(0) "" - [87]=> - string(0) "" - [88]=> - string(0) "" - [89]=> - string(0) "" - [90]=> - string(0) "" - [91]=> - string(0) "" - } -} diff --git a/framework/File_CSV/tests/columns.phpt b/framework/File_CSV/tests/columns.phpt deleted file mode 100644 index c88b57450..000000000 --- a/framework/File_CSV/tests/columns.phpt +++ /dev/null @@ -1,98 +0,0 @@ ---TEST-- -File_CSV: column count tests ---FILE-- - ---EXPECT-- -array(4) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(5) "three" - } - [1]=> - array(3) { - [0]=> - string(4) "four" - [1]=> - string(4) "five" - [2]=> - string(0) "" - } - [2]=> - array(3) { - [0]=> - string(3) "six" - [1]=> - string(5) "seven" - [2]=> - string(5) "eight" - } - [3]=> - array(3) { - [0]=> - string(4) "nine" - [1]=> - string(3) "ten" - [2]=> - string(6) "eleven" - } -} -array(2) { - [0]=> - string(54) "Wrong number of fields in line 2. Expected 3, found 2." - [1]=> - string(48) "More fields found in line 4 than the expected 3." -} -array(4) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(5) "three" - } - [1]=> - array(3) { - [0]=> - string(4) "four" - [1]=> - string(4) "five" - [2]=> - string(0) "" - } - [2]=> - array(3) { - [0]=> - string(3) "six" - [1]=> - string(5) "seven" - [2]=> - string(5) "eight" - } - [3]=> - array(3) { - [0]=> - string(4) "nine" - [1]=> - string(3) "ten" - [2]=> - string(6) "eleven" - } -} -array(2) { - [0]=> - string(54) "Wrong number of fields in line 2. Expected 3, found 2." - [1]=> - string(48) "More fields found in line 4 than the expected 3." -} diff --git a/framework/File_CSV/tests/columns1.csv b/framework/File_CSV/tests/columns1.csv deleted file mode 100644 index be92c82ea..000000000 --- a/framework/File_CSV/tests/columns1.csv +++ /dev/null @@ -1,4 +0,0 @@ -one,two,three -four,five -six,seven,eight -nine,ten,eleven,twelve diff --git a/framework/File_CSV/tests/columns2.csv b/framework/File_CSV/tests/columns2.csv deleted file mode 100644 index da81f1e07..000000000 --- a/framework/File_CSV/tests/columns2.csv +++ /dev/null @@ -1,4 +0,0 @@ -"one","two","three" -"four","five" -"six","seven","eight" -"nine","ten","eleven","twelve" diff --git a/framework/File_CSV/tests/common.php b/framework/File_CSV/tests/common.php deleted file mode 100644 index 7677dd898..000000000 --- a/framework/File_CSV/tests/common.php +++ /dev/null @@ -1,31 +0,0 @@ - ---EXPECT-- -array(2) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(5) "three" - } - [1]=> - array(3) { - [0]=> - string(4) "four" - [1]=> - string(4) "five" - [2]=> - string(3) "six" - } -} -array(2) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(5) "three" - } - [1]=> - array(3) { - [0]=> - string(4) "four" - [1]=> - string(4) "five" - [2]=> - string(3) "six" - } -} -array(2) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(5) "three" - } - [1]=> - array(3) { - [0]=> - string(4) "four" - [1]=> - string(4) "five" - [2]=> - string(3) "six" - } -} -array(2) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(5) "three" - } - [1]=> - array(3) { - [0]=> - string(4) "four" - [1]=> - string(4) "five" - [2]=> - string(3) "six" - } -} -array(2) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(5) "three" - } - [1]=> - array(3) { - [0]=> - string(4) "four" - [1]=> - string(4) "five" - [2]=> - string(3) "six" - } -} diff --git a/framework/File_CSV/tests/multiline.phpt b/framework/File_CSV/tests/multiline.phpt deleted file mode 100644 index fc43c41f8..000000000 --- a/framework/File_CSV/tests/multiline.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -File_CSV: multiline tests ---FILE-- - ---EXPECT-- -array(4) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(10) "three -four" - } - [1]=> - array(3) { - [0]=> - string(4) "five" - [1]=> - string(9) "six -seven" - [2]=> - string(5) "eight" - } - [2]=> - array(3) { - [0]=> - string(4) "nine" - [1]=> - string(3) "ten" - [2]=> - string(14) "eleven -twelve" - } - [3]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(11) "three - four" - } -} diff --git a/framework/File_CSV/tests/multiline1.csv b/framework/File_CSV/tests/multiline1.csv deleted file mode 100644 index 5e836a7df..000000000 --- a/framework/File_CSV/tests/multiline1.csv +++ /dev/null @@ -1,8 +0,0 @@ -"one","two","three -four" -"five","six -seven","eight" -"nine","ten","eleven -twelve" -"one","two","three - four" diff --git a/framework/File_CSV/tests/notrailing_crlf.csv b/framework/File_CSV/tests/notrailing_crlf.csv deleted file mode 100644 index 5b60c9cc4..000000000 --- a/framework/File_CSV/tests/notrailing_crlf.csv +++ /dev/null @@ -1,2 +0,0 @@ -one,two,three -four,five,six diff --git a/framework/File_CSV/tests/notrailing_lf.csv b/framework/File_CSV/tests/notrailing_lf.csv deleted file mode 100644 index 5b60c9cc4..000000000 --- a/framework/File_CSV/tests/notrailing_lf.csv +++ /dev/null @@ -1,2 +0,0 @@ -one,two,three -four,five,six diff --git a/framework/File_CSV/tests/quote1.csv b/framework/File_CSV/tests/quote1.csv deleted file mode 100644 index e2fe57d10..000000000 --- a/framework/File_CSV/tests/quote1.csv +++ /dev/null @@ -1,2 +0,0 @@ -"one",two,"three" -four,"five six",seven diff --git a/framework/File_CSV/tests/quote2.csv b/framework/File_CSV/tests/quote2.csv deleted file mode 100644 index e2fe57d10..000000000 --- a/framework/File_CSV/tests/quote2.csv +++ /dev/null @@ -1,2 +0,0 @@ -"one",two,"three" -four,"five six",seven diff --git a/framework/File_CSV/tests/quote3.csv b/framework/File_CSV/tests/quote3.csv deleted file mode 100644 index c44409128..000000000 --- a/framework/File_CSV/tests/quote3.csv +++ /dev/null @@ -1,3 +0,0 @@ -"one two","three, four",five -six,"seven ",eight - diff --git a/framework/File_CSV/tests/quote4.csv b/framework/File_CSV/tests/quote4.csv deleted file mode 100644 index c44409128..000000000 --- a/framework/File_CSV/tests/quote4.csv +++ /dev/null @@ -1,3 +0,0 @@ -"one two","three, four",five -six,"seven ",eight - diff --git a/framework/File_CSV/tests/quote5.csv b/framework/File_CSV/tests/quote5.csv deleted file mode 100644 index 0629c42b4..000000000 --- a/framework/File_CSV/tests/quote5.csv +++ /dev/null @@ -1,2 +0,0 @@ -"one two","three, four","five" -"six","seven ","eight" diff --git a/framework/File_CSV/tests/quotes.phpt b/framework/File_CSV/tests/quotes.phpt deleted file mode 100644 index c027d9a8d..000000000 --- a/framework/File_CSV/tests/quotes.phpt +++ /dev/null @@ -1,110 +0,0 @@ ---TEST-- -File_CSV: quote tests ---FILE-- - ---EXPECT-- -array(2) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(5) "three" - } - [1]=> - array(3) { - [0]=> - string(4) "four" - [1]=> - string(8) "five six" - [2]=> - string(5) "seven" - } -} -array(2) { - [0]=> - array(3) { - [0]=> - string(3) "one" - [1]=> - string(3) "two" - [2]=> - string(5) "three" - } - [1]=> - array(3) { - [0]=> - string(4) "four" - [1]=> - string(8) "five six" - [2]=> - string(5) "seven" - } -} -array(2) { - [0]=> - array(3) { - [0]=> - string(7) "one two" - [1]=> - string(11) "three, four" - [2]=> - string(4) "five" - } - [1]=> - array(3) { - [0]=> - string(3) "six" - [1]=> - string(6) "seven " - [2]=> - string(5) "eight" - } -} -array(2) { - [0]=> - array(3) { - [0]=> - string(7) "one two" - [1]=> - string(11) "three, four" - [2]=> - string(4) "five" - } - [1]=> - array(3) { - [0]=> - string(3) "six" - [1]=> - string(6) "seven " - [2]=> - string(5) "eight" - } -} -array(2) { - [0]=> - array(3) { - [0]=> - string(7) "one two" - [1]=> - string(11) "three, four" - [2]=> - string(4) "five" - } - [1]=> - array(3) { - [0]=> - string(3) "six" - [1]=> - string(6) "seven " - [2]=> - string(5) "eight" - } -} diff --git a/framework/File_CSV/tests/simple_cr.csv b/framework/File_CSV/tests/simple_cr.csv deleted file mode 100644 index beb72ce15..000000000 --- a/framework/File_CSV/tests/simple_cr.csv +++ /dev/null @@ -1 +0,0 @@ -one,two,three four,five,six \ No newline at end of file diff --git a/framework/File_CSV/tests/simple_crlf.csv b/framework/File_CSV/tests/simple_crlf.csv deleted file mode 100644 index 5b60c9cc4..000000000 --- a/framework/File_CSV/tests/simple_crlf.csv +++ /dev/null @@ -1,2 +0,0 @@ -one,two,three -four,five,six diff --git a/framework/File_CSV/tests/simple_lf.csv b/framework/File_CSV/tests/simple_lf.csv deleted file mode 100644 index 5b60c9cc4..000000000 --- a/framework/File_CSV/tests/simple_lf.csv +++ /dev/null @@ -1,2 +0,0 @@ -one,two,three -four,five,six diff --git a/framework/File_Csv/lib/Horde/Csv.php b/framework/File_Csv/lib/Horde/Csv.php new file mode 100644 index 000000000..dce2760d1 --- /dev/null +++ b/framework/File_Csv/lib/Horde/Csv.php @@ -0,0 +1,531 @@ + + * Copyright 2005-2010 The Horde Project (http://www.horde.org/) + * + * This source file is subject to version 2.0 of the PHP license, that is + * bundled with this package in the file LICENSE, and is available at through + * the world-wide-web at http://www.php.net/license/2_02.txt. If you did not + * receive a copy of the PHP license and are unable to obtain it through the + * world-wide-web, please send a note to license@php.net so we can mail you a + * copy immediately. + * + * @author Tomas Von Veschler Cox + * @author Jan Schneider + * @category Horde + * @package Horde_File_Csv + */ +class Horde_File_Csv +{ + /** Mode to use for reading from files */ + const MODE_READ = 'rb'; + + /** Mode to use for truncating files, then writing */ + const MODE_WRITE = 'wb'; + + /** Mode to use for appending to files */ + const MODE_APPEND = 'ab'; + + /** + * Discovers the format of a CSV file (the number of fields, the + * separator, the quote string, and the line break). + * + * We can't use the auto_detect_line_endings PHP setting, because it's not + * supported by fgets() contrary to what the manual says. + * + * @param string $file The CSV file name + * @param array $extraSeps Extra separators that should be checked for. + * + * @return array The format hash. + * @throws Horde_File_Csv_Exception + */ + static public function discoverFormat($file, $extraSeps = array()) + { + if (!$fp = @fopen($file, 'r')) { + throw new Horde_File_Csv_Exception('Could not open file: ' . $file); + } + + $seps = array("\t", ';', ':', ',', '~'); + $seps = array_merge($seps, $extraSeps); + $conf = $matches = array(); + $crlf = null; + + /* Take the first 10 lines and store the number of ocurrences for each + * separator in each line. */ + for ($i = 0; ($i < 10) && ($line = fgets($fp));) { + /* Do we have Mac line endings? */ + $lines = preg_split('/\r(?!\n)/', $line, 10); + $j = 0; + $c = count($lines); + if ($c > 1) { + $crlf = "\r"; + } + while ($i < 10 && $j < $c) { + $line = $lines[$j]; + if (!isset($crlf)) { + foreach (array("\r\n", "\n") as $c) { + if (substr($line, -strlen($c)) == $c) { + $crlf = $c; + break; + } + } + } + ++$i; + ++$j; + foreach ($seps as $sep) { + $matches[$sep][$i] = substr_count($line, $sep); + } + } + } + + if (isset($crlf)) { + $conf['crlf'] = $crlf; + } + + /* Group the results by amount of equal occurrences. */ + $amount = $fields = array(); + foreach ($matches as $sep => $lines) { + $times = array(0 => 0); + foreach ($lines as $num) { + if ($num > 0) { + $times[$num] = (isset($times[$num])) ? $times[$num] + 1 : 1; + } + } + arsort($times); + $fields[$sep] = key($times); + $amount[$sep] = $times[key($times)]; + } + arsort($amount); + $sep = key($amount); + + $conf['fields'] = $fields[$sep] + 1; + $conf['sep'] = $sep; + + /* Test if there are fields with quotes around in the first 10 + * lines. */ + $quotes = '"\''; + $quote = ''; + rewind($fp); + for ($i = 0; ($i < 10) && ($line = fgets($fp)); ++$i) { + if (preg_match("|$sep([$quotes]).*([$quotes])$sep|U", $line, $match)) { + if ($match[1] == $match[2]) { + $quote = $match[1]; + break; + } + } + if (preg_match("|^([$quotes]).*([$quotes])$sep|", $line, $match) || + preg_match("|([$quotes]).*([$quotes])$sep\s$|Us", $line, $match)) { + if ($match[1] == $match[2]) { + $quote = $match[1]; + break; + } + } + } + $conf['quote'] = $quote; + + fclose($fp); + + // XXX What about trying to discover the "header"? + return $conf; + } + + /** + * Reads a row from a CSV file and returns it as an array. + * + * This method normalizes linebreaks to single newline characters (0x0a). + * + * @param string $file The name of the CSV file. + * @param array $conf The configuration for the CSV file. + * + * @return array|boolean The CSV data or false if no more data available. + * @throws Horde_File_Csv_Exception + */ + static public function read($file, &$conf) + { + $fp = self::getPointer($file, $conf, self::MODE_READ); + + $line = fgets($fp); + $line_length = strlen($line); + + /* Use readQuoted() if we have Mac line endings. */ + if (preg_match('/\r(?!\n)/', $line)) { + fseek($fp, -$line_length, SEEK_CUR); + return self::readQuoted($file, $conf); + } + + /* Normalize line endings. */ + $line = str_replace("\r\n", "\n", $line); + if (!strlen(trim($line))) { + return false; + } + + self::_line(self::_line() + 1); + + if ($conf['fields'] == 1) { + return array($line); + } + + $fields = explode($conf['sep'], $line); + if ($conf['quote']) { + $last = ltrim($fields[count($fields) - 1]); + /* Fallback to read the line with readQuoted() if we assume that + * the simple explode won't work right. */ + $last_len = strlen($last); + if (($last_len && + $last[$last_len - 1] == "\n" && + $last[0] == $conf['quote'] && + $last[strlen(rtrim($last)) - 1] != $conf['quote']) || + (count($fields) != $conf['fields']) + // XXX perhaps there is a separator inside a quoted field + // preg_match("|{$conf['quote']}.*{$conf['sep']}.*{$conf['quote']}|U", $line) + ) { + fseek($fp, -$line_length, SEEK_CUR); + return self::readQuoted($file, $conf); + } else { + foreach ($fields as $k => $v) { + $fields[$k] = self::unquote(trim($v), $conf['quote']); + } + } + } else { + foreach ($fields as $k => $v) { + $fields[$k] = trim($v); + } + } + + if (count($fields) < $conf['fields']) { + self::warning(sprintf(_("Wrong number of fields in line %d. Expected %d, found %d."), self::_line(), $conf['fields'], count($fields))); + $fields = array_merge($fields, array_fill(0, $conf['fields'] - count($fields), '')); + } elseif (count($fields) > $conf['fields']) { + self::warning(sprintf(_("More fields found in line %d than the expected %d."), self::_line(), $conf['fields'])); + array_splice($fields, $conf['fields']); + } + + return $fields; + } + + /** + * Reads a row from a CSV file and returns it as an array. + * + * This method is able to read fields with multiline data and normalizes + * linebreaks to single newline characters (0x0a). + * + * @param string $file The name of the CSV file. + * @param array $conf The configuration for the CSV file. + * + * @return array|boolean The CSV data or false if no more data available. + * @throws Horde_File_Csv_Exception + */ + static public function readQuoted($file, &$conf) + { + $fp = self::getPointer($file, $conf, self::MODE_READ); + + /* A buffer with all characters of the current field read so far. */ + $buff = ''; + /* The current character. */ + $c = null; + /* The read fields. */ + $ret = false; + /* The number of the current field. */ + $i = 0; + /* Are we inside a quoted field? */ + $in_quote = false; + /* Did we just process an escaped quote? */ + $quote_escaped = false; + /* Is the last processed quote the first of a field? */ + $first_quote = false; + + while (($ch = fgetc($fp)) !== false) { + /* Normalize line breaks. */ + if ($ch == $conf['crlf']) { + $ch = "\n"; + } elseif (strlen($conf['crlf']) == 2 && $ch == $conf['crlf'][0]) { + $next = fgetc($fp); + if (!$next) { + break; + } + if ($next == $conf['crlf'][1]) { + $ch = "\n"; + } + } + + /* Previous character. */ + $prev = $c; + /* Current character. */ + $c = $ch; + + /* Simple character. */ + if ($c != $conf['quote'] && + $c != $conf['sep'] && + $c != "\n") { + $buff .= $c; + if (!$i) { + $i = 1; + } + $first_quote = $quote_escaped = false; + continue; + } + + if ($c == $conf['quote'] && !$in_quote) { + /* Quoted field begins. */ + $in_quote = true; + $buff = ''; + if (!$i) { + $i = 1; + } + } elseif ($in_quote) { + /* We do NOT check for the closing quote immediately, but when + * we got the character AFTER the closing quote. */ + if ($c == $conf['quote'] && $prev == $conf['quote'] && + !$quote_escaped) { + /* Escaped (double) quotes. */ + $first_quote = $quote_escaped = true; + $prev = null; + /* Simply skip the second quote. */ + continue; + } elseif ($c == $conf['sep'] && $prev == $conf['quote']) { + /* Quoted field ends with a delimiter. */ + $in_quote = $quote_escaped = false; + $first_quote = true; + } elseif ($c == "\n") { + /* We have a linebreak inside the quotes. */ + if (strlen($buff) == 1 && + $buff[0] == $conf['quote'] && + $quote_escaped && $first_quote) { + /* A line break after a closing quote of an empty + * field, field and row end here. */ + $in_quote = false; + } elseif (strlen($buff) >= 1 && + $buff[strlen($buff) - 1] == $conf['quote'] && + !$quote_escaped && !$first_quote) { + /* A line break after a closing quote, field and row + * end here. This is NOT the closing quote if we + * either process an escaped (double) quote, or if the + * quote before the line break was the opening + * quote. */ + $in_quote = false; + } else { + /* Only increment the line number. Line breaks inside + * quoted fields are part of the field content. */ + self::_line(self::_line() + 1); + } + $quote_escaped = false; + $first_quote = true; + } + } + + if (!$in_quote && + ($c == $conf['sep'] || $c == "\n")) { + /* End of line or end of field. */ + if ($c == $conf['sep'] && + (count($ret) + 1) == $conf['fields']) { + /* More fields than expected. Forward the line pointer to + * the EOL and drop the remainder. */ + while ($c !== false && $c != "\n") { + $c = fgetc($fp); + } + self::warning(sprintf('More fields found in line %d than the expected %d.', self::_line(), $conf['fields'])); + } + + if ($c == "\n" && + $i != $conf['fields']) { + /* Less fields than expected. */ + if ($i == 0) { + /* Skip empty lines. */ + return $ret; + } + self::warning(sprintf('Wrong number of fields in line %d. Expected %d, found %d.', self::_line(), $conf['fields'], $i)); + + $ret[] = self::unquote($buff, $conf['quote']); + return array_merge($ret, array_fill(0, $conf['fields'] - $i, '')); + } + + /* Remove surrounding quotes from quoted fields. */ + $ret[] = ($buff == '"') + ? '' + : self::unquote($buff, $conf['quote']); + if (count($ret) == $conf['fields']) { + return $ret; + } + + $buff = ''; + ++$i; + continue; + } + $buff .= $c; + } + + return $ret; + } + + /** + * Writes a hash into a CSV file. + * + * @param string $file The name of the CSV file. + * @param array $fields The CSV data. + * @param array $conf The configuration for the CSV file. + * + * @throws Horde_File_Csv_Exception + */ + static public function write($file, $fields, &$conf) + { + $fp = self::getPointer($file, $conf, self::MODE_WRITE); + + if (count($fields) != $conf['fields']) { + throw new Horde_File_Csv_Exception(sprintf('Wrong number of fields. Expected %d, found %d.', $conf['fields'], count($fields))); + } + + $write = ''; + for ($i = 0; $i < count($fields); ++$i) { + $write .= (!is_numeric($fields[$i]) && $conf['quote']) + ? $conf['quote'] . $fields[$i] . $conf['quote'] + : $fields[$i]; + $write .= ($i < (count($fields) - 1)) + ? $conf['sep'] + : $conf['crlf']; + } + + if (!fwrite($fp, $write)) { + throw new Horde_File_Csv_Exception(sprintf('Cannot write to file "%s"', $file)); + } + + fclose($fp); + } + + /** + * Removes surrounding quotes from a string and normalizes linebreaks. + * + * @param string $field The string to unquote. + * @param string $quote The quote character. + * @param string $crlf The linebreak character. + * + * @return string The unquoted data. + */ + static public function unquote($field, $quote, $crlf = null) + { + /* Skip empty fields (form: ;;) */ + if (!strlen($field)) { + return $field; + } + + if ($quote && $field[0] == $quote && + $field[strlen($field) - 1] == $quote) { + /* Normalize only for BC. */ + if ($crlf) { + $field = str_replace($crlf, "\n", $field); + } + return substr($field, 1, -1); + } + + return $field; + } + + /** + * Sets or gets the current line being parsed. + * + * @param integer $line If specified, the current line. + * + * @return integer The current line. + */ + static protected function _line($line = null) + { + static $current_line = 0; + + if (!is_null($line)) { + $current_line = $line; + } + + return $current_line; + } + + /** + * Adds a warning to or retrieves and resets the warning stack. + * + * @param string A warning string. If not specified, the existing + * warnings will be returned instead and the warning stack + * gets emptied. + * + * @return array If no parameter has been specified, the list of existing + * warnings. + */ + static public function warning($warning = null) + { + static $warnings = array(); + + if (is_null($warning)) { + $return = $warnings; + $warnings = array(); + return $return; + } + + $warnings[] = $warning; + } + + /** + * Returns or creates the file descriptor associated with a file. + * + * @param string $file The name of the file + * @param array $conf The configuration + * @param string $mode The open mode. self::MODE_READ or + * self::MODE_WRITE. + * + * @return resource The file resource. + * + * @throws Horde_File_Csv_Exception + */ + static public function getPointer($file, &$conf, $mode = self::MODE_READ) + { + static $resources = array(); + static $config = array(); + + if (isset($resources[$file])) { + $conf = $config[$file]; + return $resources[$file]; + } + + if (!is_array($conf)) { + throw new Horde_File_Csv_Exception('Invalid configuration.'); + } + + if (!isset($conf['fields']) || !is_numeric($conf['fields'])) { + throw new Horde_File_Csv_Exception('The number of fields must be numeric.'); + } + + if (isset($conf['sep'])) { + if (strlen($conf['sep']) != 1) { + throw new Horde_File_Csv_Exception('The separator must be one single character.'); + } + } elseif ($conf['fields'] > 1) { + throw new Horde_File_Csv_Exception('No separator specified.'); + } + + if (!empty($conf['quote'])) { + if (strlen($conf['quote']) != 1) { + throw new Horde_File_Csv_Exception('The quote character must be one single character.'); + } + } else { + $conf['quote'] = ''; + } + + if (!isset($conf['crlf'])) { + $conf['crlf'] = "\n"; + } + + $config[$file] = $conf; + + $fp = @fopen($file, $mode); + if (!is_resource($fp)) { + throw new Horde_File_Csv_Exception(sprintf('Cannot open file "%s".', $file)); + } + $resources[$file] = $fp; + self::_line(0); + + if (($mode == self::MODE_READ) && !empty($conf['header'])) { + self::read($file, $conf); + } + + return $fp; + } + +} diff --git a/framework/File_Csv/lib/Horde/Csv/Exception.php b/framework/File_Csv/lib/Horde/Csv/Exception.php new file mode 100644 index 000000000..ed5bb5be1 --- /dev/null +++ b/framework/File_Csv/lib/Horde/Csv/Exception.php @@ -0,0 +1,20 @@ + + * @category Horde + * @package Horde_File_Csv + */ +class Horde_File_Csv_Exception extends Horde_Exception +{ +} diff --git a/framework/File_Csv/package.xml b/framework/File_Csv/package.xml new file mode 100644 index 000000000..5c0650695 --- /dev/null +++ b/framework/File_Csv/package.xml @@ -0,0 +1,122 @@ + + + File_Csv + pear.horde.org + Reads and writes CSV files + This package allows reading and creating of CSV data and files. It +is a fork of the File_CSV class of PEAR's File package. + + + Jan Schneider + jan + jan@horde.org + yes + + 2010-02-03 + + 0.2.0 + 0.2.0 + + + beta + beta + + PHP + * Initial Horde 4 Package + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.2.0 + + + 1.5.0 + + + PEAR + pear.php.net + + + pcre + + + + + + + + + + + + 2006-05-08 + + + 0.1.1 + 0.1.1 + + + beta + beta + + PHP + + * Converted to package.xml 2.0 for pear.horde.org + * Close Horde bug #6372 (ritaselsky@gmail.com) + + + + + 0.1.0 + 0.1.0 + + + beta + beta + + 2004-01-01 + PHP + First release. + + + + diff --git a/framework/File_Csv/test/Horde/Csv/001.csv b/framework/File_Csv/test/Horde/Csv/001.csv new file mode 100644 index 000000000..d217fb0fc --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/001.csv @@ -0,0 +1,4 @@ +"Field 1-1", "Field 1-2", "Field 1-3", "Field 1-4" +"Field 2-1", "Field 2-2", "Field 2-3" +"Field 3-1", "Field 3-2" +"Field 4-1" diff --git a/framework/File_Csv/test/Horde/Csv/001.phpt b/framework/File_Csv/test/Horde/Csv/001.phpt new file mode 100644 index 000000000..29fcba56a --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/001.phpt @@ -0,0 +1,84 @@ +--TEST-- +Horde_File_Csv Test Case 001: Fields count less than expected +--FILE-- + +--EXPECT-- +array(4) { + ["crlf"]=> + string(1) " +" + ["fields"]=> + int(4) + ["sep"]=> + string(1) "," + ["quote"]=> + string(1) """ +} +array(4) { + [0]=> + array(4) { + [0]=> + string(9) "Field 1-1" + [1]=> + string(9) "Field 1-2" + [2]=> + string(9) "Field 1-3" + [3]=> + string(9) "Field 1-4" + } + [1]=> + array(4) { + [0]=> + string(9) "Field 2-1" + [1]=> + string(9) "Field 2-2" + [2]=> + string(9) "Field 2-3" + [3]=> + string(0) "" + } + [2]=> + array(4) { + [0]=> + string(9) "Field 3-1" + [1]=> + string(9) "Field 3-2" + [2]=> + string(0) "" + [3]=> + string(0) "" + } + [3]=> + array(4) { + [0]=> + string(9) "Field 4-1" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/002.csv b/framework/File_Csv/test/Horde/Csv/002.csv new file mode 100644 index 000000000..bcd6ce0ca --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/002.csv @@ -0,0 +1,4 @@ +"Field 1-1", "Field 1-2", "Field 1-3", "Field 1-4" +"Field 2-1", "Field 2-2", "Field 2-3", "Field 2-4", "Extra Field" +"Field 3-1", "Field 3-2" +"Field 4-1" diff --git a/framework/File_Csv/test/Horde/Csv/002.phpt b/framework/File_Csv/test/Horde/Csv/002.phpt new file mode 100644 index 000000000..e0d293d98 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/002.phpt @@ -0,0 +1,84 @@ +--TEST-- +Horde_File_Csv Test Case 002: Fields count more than expected +--FILE-- + +--EXPECT-- +array(4) { + ["crlf"]=> + string(1) " +" + ["fields"]=> + int(4) + ["sep"]=> + string(1) "," + ["quote"]=> + string(1) """ +} +array(4) { + [0]=> + array(4) { + [0]=> + string(9) "Field 1-1" + [1]=> + string(9) "Field 1-2" + [2]=> + string(9) "Field 1-3" + [3]=> + string(9) "Field 1-4" + } + [1]=> + array(4) { + [0]=> + string(9) "Field 2-1" + [1]=> + string(9) "Field 2-2" + [2]=> + string(9) "Field 2-3" + [3]=> + string(9) "Field 2-4" + } + [2]=> + array(4) { + [0]=> + string(9) "Field 3-1" + [1]=> + string(9) "Field 3-2" + [2]=> + string(0) "" + [3]=> + string(0) "" + } + [3]=> + array(4) { + [0]=> + string(9) "Field 4-1" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/003.csv b/framework/File_Csv/test/Horde/Csv/003.csv new file mode 100644 index 000000000..62cb0f7a6 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/003.csv @@ -0,0 +1,4 @@ +"Field 1-1","Field 1-2","Field 1-3","Field 1-4" +"Field 2-1","Field 2-2","Field 2-3","I'm multiline +Field" +"Field 3-1","Field 3-2","Field 3-3" diff --git a/framework/File_Csv/test/Horde/Csv/003.phpt b/framework/File_Csv/test/Horde/Csv/003.phpt new file mode 100644 index 000000000..f179fc19c --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/003.phpt @@ -0,0 +1,67 @@ +--TEST-- +Horde_File_Csv Test Case 003: Windows EOL +--FILE-- + +--EXPECT-- +Format: +Array +( + [crlf] => + + [fields] => 4 + [sep] => , + [quote] => " +) + +Data: +Array +( + [0] => Array + ( + [0] => Field 1-1 + [1] => Field 1-2 + [2] => Field 1-3 + [3] => Field 1-4 + ) + + [1] => Array + ( + [0] => Field 2-1 + [1] => Field 2-2 + [2] => Field 2-3 + [3] => I'm multiline +Field + ) + + [2] => Array + ( + [0] => Field 3-1 + [1] => Field 3-2 + [2] => Field 3-3 + [3] => + ) + +) diff --git a/framework/File_Csv/test/Horde/Csv/004.csv b/framework/File_Csv/test/Horde/Csv/004.csv new file mode 100644 index 000000000..62cb0f7a6 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/004.csv @@ -0,0 +1,4 @@ +"Field 1-1","Field 1-2","Field 1-3","Field 1-4" +"Field 2-1","Field 2-2","Field 2-3","I'm multiline +Field" +"Field 3-1","Field 3-2","Field 3-3" diff --git a/framework/File_Csv/test/Horde/Csv/004.phpt b/framework/File_Csv/test/Horde/Csv/004.phpt new file mode 100644 index 000000000..5d34c98d7 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/004.phpt @@ -0,0 +1,67 @@ +--TEST-- +Horde_File_Csv Test Case 004: Unix EOL +--FILE-- + +--EXPECT-- +Format: +Array +( + [crlf] => + + [fields] => 4 + [sep] => , + [quote] => " +) + +Data: +Array +( + [0] => Array + ( + [0] => Field 1-1 + [1] => Field 1-2 + [2] => Field 1-3 + [3] => Field 1-4 + ) + + [1] => Array + ( + [0] => Field 2-1 + [1] => Field 2-2 + [2] => Field 2-3 + [3] => I'm multiline +Field + ) + + [2] => Array + ( + [0] => Field 3-1 + [1] => Field 3-2 + [2] => Field 3-3 + [3] => + ) + +) diff --git a/framework/File_Csv/test/Horde/Csv/005.csv b/framework/File_Csv/test/Horde/Csv/005.csv new file mode 100644 index 000000000..3b26aa998 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/005.csv @@ -0,0 +1 @@ +"Field 1-1","Field 1-2","Field 1-3","Field 1-4" "Field 2-1","Field 2-2","Field 2-3","I'm multiline Field" "Field 3-1","Field 3-2","Field 3-3" \ No newline at end of file diff --git a/framework/File_Csv/test/Horde/Csv/005.phpt b/framework/File_Csv/test/Horde/Csv/005.phpt new file mode 100644 index 000000000..d55a6f39d --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/005.phpt @@ -0,0 +1,67 @@ +--TEST-- +Horde_File_Csv Test Case 005: Mac EOL +--FILE-- + +--EXPECT-- +Format: +Array +( + [crlf] => + [fields] => 4 + [sep] => , + [quote] => " +) + +Data: +Array +( + [0] => Array + ( + [0] => Field 1-1 + [1] => Field 1-2 + [2] => Field 1-3 + [3] => Field 1-4 + ) + + [1] => Array + ( + [0] => Field 2-1 + [1] => Field 2-2 + [2] => Field 2-3 + [3] => I'm multiline +Field + ) + + [2] => Array + ( + [0] => Field 3-1 + [1] => Field 3-2 + [2] => Field 3-3 + [3] => + ) + +) diff --git a/framework/File_Csv/test/Horde/Csv/bug_3839.csv b/framework/File_Csv/test/Horde/Csv/bug_3839.csv new file mode 100644 index 000000000..7deda38f2 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_3839.csv @@ -0,0 +1,22 @@ +Subject~Start Date~Start Time~End Date~End Time~All day event~Reminder on/off~Reminder Date~Reminder Time~Category~Description~Priority +"Inservice on new resource: ""CPNP Toolkit"""~2004-11-08~10:30 AM~2004-11-08~11:30 AM~FALSE~FALSE~~~Training~"CPN Program ... +Inservice on new resource: ""CPNP Toolkit"" + +Registration Deadline: October 27, 2004, noon + + + Session Evaluation - Eligibility for Prize! + + + Dial In Numbers for Sites Registered + + + Poster and Registration Form + +Facilitator: Manager + +preblurb preblurb preblurb preblurb preblurb preblurb preblurb preblurb preblurb ""CPNP Toolkit"". postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb . + +postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb + +Come check out the new resource!"~Normal diff --git a/framework/File_Csv/test/Horde/Csv/bug_3839.phpt b/framework/File_Csv/test/Horde/Csv/bug_3839.phpt new file mode 100644 index 000000000..a7b3443f2 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_3839.phpt @@ -0,0 +1,110 @@ +--TEST-- +Horde_File_Csv: test for Bug #3839 +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + array(12) { + [0]=> + string(7) "Subject" + [1]=> + string(10) "Start Date" + [2]=> + string(10) "Start Time" + [3]=> + string(8) "End Date" + [4]=> + string(8) "End Time" + [5]=> + string(13) "All day event" + [6]=> + string(15) "Reminder on/off" + [7]=> + string(13) "Reminder Date" + [8]=> + string(13) "Reminder Time" + [9]=> + string(8) "Category" + [10]=> + string(11) "Description" + [11]=> + string(8) "Priority" + } + [1]=> + array(12) { + [0]=> + string(41) "Inservice on new resource: "CPNP Toolkit"" + [1]=> + string(10) "2004-11-08" + [2]=> + string(8) "10:30 AM" + [3]=> + string(10) "2004-11-08" + [4]=> + string(8) "11:30 AM" + [5]=> + string(5) "FALSE" + [6]=> + string(5) "FALSE" + [7]=> + string(0) "" + [8]=> + string(0) "" + [9]=> + string(8) "Training" + [10]=> + string(1109) "CPN Program ... +Inservice on new resource: "CPNP Toolkit" + +Registration Deadline: October 27, 2004, noon + + + Session Evaluation - Eligibility for Prize! + + + Dial In Numbers for Sites Registered + + + Poster and Registration Form + +Facilitator: Manager + +preblurb preblurb preblurb preblurb preblurb preblurb preblurb preblurb preblurb "CPNP Toolkit". postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb . + +postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb postblurb + +Come check out the new resource!" + [11]=> + string(6) "Normal" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/bug_4025.csv b/framework/File_Csv/test/Horde/Csv/bug_4025.csv new file mode 100644 index 000000000..cd65cc0c4 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_4025.csv @@ -0,0 +1,3 @@ +"Betreff","Beginnt am","Beginnt um","Endet am","Endet um","Ganztägiges Ereignis","Erinnerung Ein/Aus","Erinnerung am","Erinnerung um","Besprechungsplanung","Erforderliche Teilnehmer","Optionale Teilnehmer","Besprechungsressourcen","Abrechnungsinformationen","Beschreibung","Kategorien","Ort","Priorität","Privat","Reisekilometer","Vertraulichkeit","Zeitspanne zeigen als" +"Burger Download Session","2.5.2006","11:50:00","2.5.2006","13:00:00","Aus","Ein","2.5.2006","11:35:00","Haas, Jörg","Kuhl, Oliver",,,," +",,"Burger Upload Station (Burger King)","Normal","Aus",,"Normal","1" diff --git a/framework/File_Csv/test/Horde/Csv/bug_4025.phpt b/framework/File_Csv/test/Horde/Csv/bug_4025.phpt new file mode 100644 index 000000000..d12313bbf --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_4025.phpt @@ -0,0 +1,131 @@ +--TEST-- +Horde_File_Csv: test for Bug #4025 +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + array(22) { + [0]=> + string(7) "Betreff" + [1]=> + string(10) "Beginnt am" + [2]=> + string(10) "Beginnt um" + [3]=> + string(8) "Endet am" + [4]=> + string(8) "Endet um" + [5]=> + string(20) "Ganztägiges Ereignis" + [6]=> + string(18) "Erinnerung Ein/Aus" + [7]=> + string(13) "Erinnerung am" + [8]=> + string(13) "Erinnerung um" + [9]=> + string(19) "Besprechungsplanung" + [10]=> + string(24) "Erforderliche Teilnehmer" + [11]=> + string(20) "Optionale Teilnehmer" + [12]=> + string(22) "Besprechungsressourcen" + [13]=> + string(24) "Abrechnungsinformationen" + [14]=> + string(12) "Beschreibung" + [15]=> + string(10) "Kategorien" + [16]=> + string(3) "Ort" + [17]=> + string(9) "Priorität" + [18]=> + string(6) "Privat" + [19]=> + string(14) "Reisekilometer" + [20]=> + string(15) "Vertraulichkeit" + [21]=> + string(21) "Zeitspanne zeigen als" + } + [1]=> + array(22) { + [0]=> + string(23) "Burger Download Session" + [1]=> + string(8) "2.5.2006" + [2]=> + string(8) "11:50:00" + [3]=> + string(8) "2.5.2006" + [4]=> + string(8) "13:00:00" + [5]=> + string(3) "Aus" + [6]=> + string(3) "Ein" + [7]=> + string(8) "2.5.2006" + [8]=> + string(8) "11:35:00" + [9]=> + string(10) "Haas, Jörg" + [10]=> + string(12) "Kuhl, Oliver" + [11]=> + string(0) "" + [12]=> + string(0) "" + [13]=> + string(0) "" + [14]=> + string(1) " +" + [15]=> + string(0) "" + [16]=> + string(35) "Burger Upload Station (Burger King)" + [17]=> + string(6) "Normal" + [18]=> + string(3) "Aus" + [19]=> + string(0) "" + [20]=> + string(6) "Normal" + [21]=> + string(1) "1" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/bug_6311.csv b/framework/File_Csv/test/Horde/Csv/bug_6311.csv new file mode 100644 index 000000000..ef4f25f0e --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_6311.csv @@ -0,0 +1,5 @@ +"Title","First Name","Middle Name","Last Name","Suffix","Company","Department","Job Title","Business Street","Business Street 2","Business Street 3","Business City","Business State","Business Postal Code","Business Country/Region","Home Street","Home Street 2","Home Street 3","Home City","Home State","Home Postal Code","Home Country/Region","Other Street","Other Street 2","Other Street 3","Other City","Other State","Other Postal Code","Other Country/Region","Assistant's Phone","Business Fax","Business Phone","Business Phone 2","Callback","Car Phone","Company Main Phone","Home Fax","Home Phone","Home Phone 2","ISDN","Mobile Phone","Other Fax","Other Phone","Pager","Primary Phone","Radio Phone","TTY/TDD Phone","Telex","Account","Anniversary","Assistant's Name","Billing Information","Birthday","Business Address PO Box","Categories","Children","Directory Server","E-mail Address","E-mail Type","E-mail Display Name","E-mail 2 Address","E-mail 2 Type","E-mail 2 Display Name","E-mail 3 Address","E-mail 3 Type","E-mail 3 Display Name","Gender","Government ID Number","Hobby","Home Address PO Box","Initials","Internet Free Busy","Keywords","Language","Location","Manager's Name","Mileage","Notes","Office Location","Organizational ID Number","Other Address PO Box","Priority","Private","Profession","Referred By","Sensitivity","Spouse","User 1","User 2","User 3","User 4","Web Page" +"","John","","Smith","","International Inc","","","",,,"","","","","",,,"","","","","",,,"","","","","","(123) 555-1111","(123) 555-2222","","","","","","","","","(123) 555-3333","","","","","","","","","0/0/00","",,"0/0/00",,"Programming",,,"john@example.com","SMTP","John Smith (john@example.com)",,,,,,,"Unspecified","",,,"J.S.","","","","","",,"PHP +Perl +Python +","","",,"Normal","False","",,"Normal","","","","","","" diff --git a/framework/File_Csv/test/Horde/Csv/bug_6311.phpt b/framework/File_Csv/test/Horde/Csv/bug_6311.phpt new file mode 100644 index 000000000..216297969 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_6311.phpt @@ -0,0 +1,413 @@ +--TEST-- +Horde_File_Csv: test for Bug #6311 +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + array(92) { + [0]=> + string(5) "Title" + [1]=> + string(10) "First Name" + [2]=> + string(11) "Middle Name" + [3]=> + string(9) "Last Name" + [4]=> + string(6) "Suffix" + [5]=> + string(7) "Company" + [6]=> + string(10) "Department" + [7]=> + string(9) "Job Title" + [8]=> + string(15) "Business Street" + [9]=> + string(17) "Business Street 2" + [10]=> + string(17) "Business Street 3" + [11]=> + string(13) "Business City" + [12]=> + string(14) "Business State" + [13]=> + string(20) "Business Postal Code" + [14]=> + string(23) "Business Country/Region" + [15]=> + string(11) "Home Street" + [16]=> + string(13) "Home Street 2" + [17]=> + string(13) "Home Street 3" + [18]=> + string(9) "Home City" + [19]=> + string(10) "Home State" + [20]=> + string(16) "Home Postal Code" + [21]=> + string(19) "Home Country/Region" + [22]=> + string(12) "Other Street" + [23]=> + string(14) "Other Street 2" + [24]=> + string(14) "Other Street 3" + [25]=> + string(10) "Other City" + [26]=> + string(11) "Other State" + [27]=> + string(17) "Other Postal Code" + [28]=> + string(20) "Other Country/Region" + [29]=> + string(17) "Assistant's Phone" + [30]=> + string(12) "Business Fax" + [31]=> + string(14) "Business Phone" + [32]=> + string(16) "Business Phone 2" + [33]=> + string(8) "Callback" + [34]=> + string(9) "Car Phone" + [35]=> + string(18) "Company Main Phone" + [36]=> + string(8) "Home Fax" + [37]=> + string(10) "Home Phone" + [38]=> + string(12) "Home Phone 2" + [39]=> + string(4) "ISDN" + [40]=> + string(12) "Mobile Phone" + [41]=> + string(9) "Other Fax" + [42]=> + string(11) "Other Phone" + [43]=> + string(5) "Pager" + [44]=> + string(13) "Primary Phone" + [45]=> + string(11) "Radio Phone" + [46]=> + string(13) "TTY/TDD Phone" + [47]=> + string(5) "Telex" + [48]=> + string(7) "Account" + [49]=> + string(11) "Anniversary" + [50]=> + string(16) "Assistant's Name" + [51]=> + string(19) "Billing Information" + [52]=> + string(8) "Birthday" + [53]=> + string(23) "Business Address PO Box" + [54]=> + string(10) "Categories" + [55]=> + string(8) "Children" + [56]=> + string(16) "Directory Server" + [57]=> + string(14) "E-mail Address" + [58]=> + string(11) "E-mail Type" + [59]=> + string(19) "E-mail Display Name" + [60]=> + string(16) "E-mail 2 Address" + [61]=> + string(13) "E-mail 2 Type" + [62]=> + string(21) "E-mail 2 Display Name" + [63]=> + string(16) "E-mail 3 Address" + [64]=> + string(13) "E-mail 3 Type" + [65]=> + string(21) "E-mail 3 Display Name" + [66]=> + string(6) "Gender" + [67]=> + string(20) "Government ID Number" + [68]=> + string(5) "Hobby" + [69]=> + string(19) "Home Address PO Box" + [70]=> + string(8) "Initials" + [71]=> + string(18) "Internet Free Busy" + [72]=> + string(8) "Keywords" + [73]=> + string(8) "Language" + [74]=> + string(8) "Location" + [75]=> + string(14) "Manager's Name" + [76]=> + string(7) "Mileage" + [77]=> + string(5) "Notes" + [78]=> + string(15) "Office Location" + [79]=> + string(24) "Organizational ID Number" + [80]=> + string(20) "Other Address PO Box" + [81]=> + string(8) "Priority" + [82]=> + string(7) "Private" + [83]=> + string(10) "Profession" + [84]=> + string(11) "Referred By" + [85]=> + string(11) "Sensitivity" + [86]=> + string(6) "Spouse" + [87]=> + string(6) "User 1" + [88]=> + string(6) "User 2" + [89]=> + string(6) "User 3" + [90]=> + string(6) "User 4" + [91]=> + string(8) "Web Page" + } + [1]=> + array(92) { + [0]=> + string(0) "" + [1]=> + string(4) "John" + [2]=> + string(0) "" + [3]=> + string(5) "Smith" + [4]=> + string(0) "" + [5]=> + string(17) "International Inc" + [6]=> + string(0) "" + [7]=> + string(0) "" + [8]=> + string(0) "" + [9]=> + string(0) "" + [10]=> + string(0) "" + [11]=> + string(0) "" + [12]=> + string(0) "" + [13]=> + string(0) "" + [14]=> + string(0) "" + [15]=> + string(0) "" + [16]=> + string(0) "" + [17]=> + string(0) "" + [18]=> + string(0) "" + [19]=> + string(0) "" + [20]=> + string(0) "" + [21]=> + string(0) "" + [22]=> + string(0) "" + [23]=> + string(0) "" + [24]=> + string(0) "" + [25]=> + string(0) "" + [26]=> + string(0) "" + [27]=> + string(0) "" + [28]=> + string(0) "" + [29]=> + string(0) "" + [30]=> + string(14) "(123) 555-1111" + [31]=> + string(14) "(123) 555-2222" + [32]=> + string(0) "" + [33]=> + string(0) "" + [34]=> + string(0) "" + [35]=> + string(0) "" + [36]=> + string(0) "" + [37]=> + string(0) "" + [38]=> + string(0) "" + [39]=> + string(0) "" + [40]=> + string(14) "(123) 555-3333" + [41]=> + string(0) "" + [42]=> + string(0) "" + [43]=> + string(0) "" + [44]=> + string(0) "" + [45]=> + string(0) "" + [46]=> + string(0) "" + [47]=> + string(0) "" + [48]=> + string(0) "" + [49]=> + string(6) "0/0/00" + [50]=> + string(0) "" + [51]=> + string(0) "" + [52]=> + string(6) "0/0/00" + [53]=> + string(0) "" + [54]=> + string(11) "Programming" + [55]=> + string(0) "" + [56]=> + string(0) "" + [57]=> + string(16) "john@example.com" + [58]=> + string(4) "SMTP" + [59]=> + string(29) "John Smith (john@example.com)" + [60]=> + string(0) "" + [61]=> + string(0) "" + [62]=> + string(0) "" + [63]=> + string(0) "" + [64]=> + string(0) "" + [65]=> + string(0) "" + [66]=> + string(11) "Unspecified" + [67]=> + string(0) "" + [68]=> + string(0) "" + [69]=> + string(0) "" + [70]=> + string(4) "J.S." + [71]=> + string(0) "" + [72]=> + string(0) "" + [73]=> + string(0) "" + [74]=> + string(0) "" + [75]=> + string(0) "" + [76]=> + string(0) "" + [77]=> + string(16) "PHP +Perl +Python +" + [78]=> + string(0) "" + [79]=> + string(0) "" + [80]=> + string(0) "" + [81]=> + string(6) "Normal" + [82]=> + string(5) "False" + [83]=> + string(0) "" + [84]=> + string(0) "" + [85]=> + string(6) "Normal" + [86]=> + string(0) "" + [87]=> + string(0) "" + [88]=> + string(0) "" + [89]=> + string(0) "" + [90]=> + string(0) "" + [91]=> + string(0) "" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/bug_6370.csv b/framework/File_Csv/test/Horde/Csv/bug_6370.csv new file mode 100644 index 000000000..9a9690209 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_6370.csv @@ -0,0 +1,3 @@ +"Title","First Name","Middle Name","Last Name","Suffix","Company","Department","Job Title","Business Street","Business Street 2","Business Street 3","Business City","Business State","Business Postal Code","Business Country/Region","Home Street","Home Street 2","Home Street 3","Home City","Home State","Home Postal Code","Home Country/Region","Other Street","Other Street 2","Other Street 3","Other City","Other State","Other Postal Code","Other Country/Region","Assistant's Phone","Business Fax","Business Phone","Business Phone 2","Callback","Car Phone","Company Main Phone","Home Fax","Home Phone","Home Phone 2","ISDN","Mobile Phone","Other Fax","Other Phone","Pager","Primary Phone","Radio Phone","TTY/TDD Phone","Telex","Account","Anniversary","Assistant's Name","Billing Information","Birthday","Business Address PO Box","Categories","Children","Directory Server","E-mail Address","E-mail Type","E-mail Display Name","E-mail 2 Address","E-mail 2 Type","E-mail 2 Display Name","E-mail 3 Address","E-mail 3 Type","E-mail 3 Display Name","Gender","Government ID Number","Hobby","Home Address PO Box","Initials","Internet Free Busy","Keywords","Language","Location","Manager's Name","Mileage","Notes","Office Location","Organizational ID Number","Other Address PO Box","Priority","Private","Profession","Referred By","Sensitivity","Spouse","User 1","User 2","User 3","User 4","Web Page" +"","","","","","","","","Big Tower'"", 1"" Floor +123 Main Street",,,"","","","","",,,"","","","","",,,"","","","","","","","","","","","","","","","","","","","","","","","","0/0/00","",,"0/0/00",,,,,"","","",,,,,,,"Unspecified","",,,"","","","","","",,,"","",,"Normal","False","",,"Normal","","","","","","" diff --git a/framework/File_Csv/test/Horde/Csv/bug_6370.phpt b/framework/File_Csv/test/Horde/Csv/bug_6370.phpt new file mode 100644 index 000000000..0f58993cc --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_6370.phpt @@ -0,0 +1,411 @@ +--TEST-- +Horde_File_Csv: test for Bug #6370 +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + array(92) { + [0]=> + string(5) "Title" + [1]=> + string(10) "First Name" + [2]=> + string(11) "Middle Name" + [3]=> + string(9) "Last Name" + [4]=> + string(6) "Suffix" + [5]=> + string(7) "Company" + [6]=> + string(10) "Department" + [7]=> + string(9) "Job Title" + [8]=> + string(15) "Business Street" + [9]=> + string(17) "Business Street 2" + [10]=> + string(17) "Business Street 3" + [11]=> + string(13) "Business City" + [12]=> + string(14) "Business State" + [13]=> + string(20) "Business Postal Code" + [14]=> + string(23) "Business Country/Region" + [15]=> + string(11) "Home Street" + [16]=> + string(13) "Home Street 2" + [17]=> + string(13) "Home Street 3" + [18]=> + string(9) "Home City" + [19]=> + string(10) "Home State" + [20]=> + string(16) "Home Postal Code" + [21]=> + string(19) "Home Country/Region" + [22]=> + string(12) "Other Street" + [23]=> + string(14) "Other Street 2" + [24]=> + string(14) "Other Street 3" + [25]=> + string(10) "Other City" + [26]=> + string(11) "Other State" + [27]=> + string(17) "Other Postal Code" + [28]=> + string(20) "Other Country/Region" + [29]=> + string(17) "Assistant's Phone" + [30]=> + string(12) "Business Fax" + [31]=> + string(14) "Business Phone" + [32]=> + string(16) "Business Phone 2" + [33]=> + string(8) "Callback" + [34]=> + string(9) "Car Phone" + [35]=> + string(18) "Company Main Phone" + [36]=> + string(8) "Home Fax" + [37]=> + string(10) "Home Phone" + [38]=> + string(12) "Home Phone 2" + [39]=> + string(4) "ISDN" + [40]=> + string(12) "Mobile Phone" + [41]=> + string(9) "Other Fax" + [42]=> + string(11) "Other Phone" + [43]=> + string(5) "Pager" + [44]=> + string(13) "Primary Phone" + [45]=> + string(11) "Radio Phone" + [46]=> + string(13) "TTY/TDD Phone" + [47]=> + string(5) "Telex" + [48]=> + string(7) "Account" + [49]=> + string(11) "Anniversary" + [50]=> + string(16) "Assistant's Name" + [51]=> + string(19) "Billing Information" + [52]=> + string(8) "Birthday" + [53]=> + string(23) "Business Address PO Box" + [54]=> + string(10) "Categories" + [55]=> + string(8) "Children" + [56]=> + string(16) "Directory Server" + [57]=> + string(14) "E-mail Address" + [58]=> + string(11) "E-mail Type" + [59]=> + string(19) "E-mail Display Name" + [60]=> + string(16) "E-mail 2 Address" + [61]=> + string(13) "E-mail 2 Type" + [62]=> + string(21) "E-mail 2 Display Name" + [63]=> + string(16) "E-mail 3 Address" + [64]=> + string(13) "E-mail 3 Type" + [65]=> + string(21) "E-mail 3 Display Name" + [66]=> + string(6) "Gender" + [67]=> + string(20) "Government ID Number" + [68]=> + string(5) "Hobby" + [69]=> + string(19) "Home Address PO Box" + [70]=> + string(8) "Initials" + [71]=> + string(18) "Internet Free Busy" + [72]=> + string(8) "Keywords" + [73]=> + string(8) "Language" + [74]=> + string(8) "Location" + [75]=> + string(14) "Manager's Name" + [76]=> + string(7) "Mileage" + [77]=> + string(5) "Notes" + [78]=> + string(15) "Office Location" + [79]=> + string(24) "Organizational ID Number" + [80]=> + string(20) "Other Address PO Box" + [81]=> + string(8) "Priority" + [82]=> + string(7) "Private" + [83]=> + string(10) "Profession" + [84]=> + string(11) "Referred By" + [85]=> + string(11) "Sensitivity" + [86]=> + string(6) "Spouse" + [87]=> + string(6) "User 1" + [88]=> + string(6) "User 2" + [89]=> + string(6) "User 3" + [90]=> + string(6) "User 4" + [91]=> + string(8) "Web Page" + } + [1]=> + array(92) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" + [4]=> + string(0) "" + [5]=> + string(0) "" + [6]=> + string(0) "" + [7]=> + string(0) "" + [8]=> + string(37) "Big Tower'", 1" Floor +123 Main Street" + [9]=> + string(0) "" + [10]=> + string(0) "" + [11]=> + string(0) "" + [12]=> + string(0) "" + [13]=> + string(0) "" + [14]=> + string(0) "" + [15]=> + string(0) "" + [16]=> + string(0) "" + [17]=> + string(0) "" + [18]=> + string(0) "" + [19]=> + string(0) "" + [20]=> + string(0) "" + [21]=> + string(0) "" + [22]=> + string(0) "" + [23]=> + string(0) "" + [24]=> + string(0) "" + [25]=> + string(0) "" + [26]=> + string(0) "" + [27]=> + string(0) "" + [28]=> + string(0) "" + [29]=> + string(0) "" + [30]=> + string(0) "" + [31]=> + string(0) "" + [32]=> + string(0) "" + [33]=> + string(0) "" + [34]=> + string(0) "" + [35]=> + string(0) "" + [36]=> + string(0) "" + [37]=> + string(0) "" + [38]=> + string(0) "" + [39]=> + string(0) "" + [40]=> + string(0) "" + [41]=> + string(0) "" + [42]=> + string(0) "" + [43]=> + string(0) "" + [44]=> + string(0) "" + [45]=> + string(0) "" + [46]=> + string(0) "" + [47]=> + string(0) "" + [48]=> + string(0) "" + [49]=> + string(6) "0/0/00" + [50]=> + string(0) "" + [51]=> + string(0) "" + [52]=> + string(6) "0/0/00" + [53]=> + string(0) "" + [54]=> + string(0) "" + [55]=> + string(0) "" + [56]=> + string(0) "" + [57]=> + string(0) "" + [58]=> + string(0) "" + [59]=> + string(0) "" + [60]=> + string(0) "" + [61]=> + string(0) "" + [62]=> + string(0) "" + [63]=> + string(0) "" + [64]=> + string(0) "" + [65]=> + string(0) "" + [66]=> + string(11) "Unspecified" + [67]=> + string(0) "" + [68]=> + string(0) "" + [69]=> + string(0) "" + [70]=> + string(0) "" + [71]=> + string(0) "" + [72]=> + string(0) "" + [73]=> + string(0) "" + [74]=> + string(0) "" + [75]=> + string(0) "" + [76]=> + string(0) "" + [77]=> + string(1) "" + [78]=> + string(0) "" + [79]=> + string(0) "" + [80]=> + string(0) "" + [81]=> + string(6) "Normal" + [82]=> + string(5) "False" + [83]=> + string(0) "" + [84]=> + string(0) "" + [85]=> + string(6) "Normal" + [86]=> + string(0) "" + [87]=> + string(0) "" + [88]=> + string(0) "" + [89]=> + string(0) "" + [90]=> + string(0) "" + [91]=> + string(0) "" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/bug_6372.csv b/framework/File_Csv/test/Horde/Csv/bug_6372.csv new file mode 100644 index 000000000..ec31094f5 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_6372.csv @@ -0,0 +1,4 @@ +"Title","First Name","Middle Name","Last Name","Suffix","Company","Department","Job Title","Business Street","Business Street 2","Business Street 3","Business City","Business State","Business Postal Code","Business Country/Region","Home Street","Home Street 2","Home Street 3","Home City","Home State","Home Postal Code","Home Country/Region","Other Street","Other Street 2","Other Street 3","Other City","Other State","Other Postal Code","Other Country/Region","Assistant's Phone","Business Fax","Business Phone","Business Phone 2","Callback","Car Phone","Company Main Phone","Home Fax","Home Phone","Home Phone 2","ISDN","Mobile Phone","Other Fax","Other Phone","Pager","Primary Phone","Radio Phone","TTY/TDD Phone","Telex","Account","Anniversary","Assistant's Name","Billing Information","Birthday","Business Address PO Box","Categories","Children","Directory Server","E-mail Address","E-mail Type","E-mail Display Name","E-mail 2 Address","E-mail 2 Type","E-mail 2 Display Name","E-mail 3 Address","E-mail 3 Type","E-mail 3 Display Name","Gender","Government ID Number","Hobby","Home Address PO Box","Initials","Internet Free Busy","Keywords","Language","Location","Manager's Name","Mileage","Notes","Office Location","Organizational ID Number","Other Address PO Box","Priority","Private","Profession","Referred By","Sensitivity","Spouse","User 1","User 2","User 3","User 4","Web Page" +"","","","","","","","","123, 12th Floor, +Main Street",,,"","","","","",,,"","","","","",,,"","","","","","","","","","","","","","","","","","","","","","","","","0/0/00","",,"0/0/00",,"",,,"","","","","","",,,,"Unspecified","",,,"","","","","","",," +","","",,"Normal","False","",,"Normal","","","","","","" diff --git a/framework/File_Csv/test/Horde/Csv/bug_6372.phpt b/framework/File_Csv/test/Horde/Csv/bug_6372.phpt new file mode 100644 index 000000000..d1d28b004 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/bug_6372.phpt @@ -0,0 +1,412 @@ +--TEST-- +Horde_File_Csv: test for Bug #6372 +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + array(92) { + [0]=> + string(5) "Title" + [1]=> + string(10) "First Name" + [2]=> + string(11) "Middle Name" + [3]=> + string(9) "Last Name" + [4]=> + string(6) "Suffix" + [5]=> + string(7) "Company" + [6]=> + string(10) "Department" + [7]=> + string(9) "Job Title" + [8]=> + string(15) "Business Street" + [9]=> + string(17) "Business Street 2" + [10]=> + string(17) "Business Street 3" + [11]=> + string(13) "Business City" + [12]=> + string(14) "Business State" + [13]=> + string(20) "Business Postal Code" + [14]=> + string(23) "Business Country/Region" + [15]=> + string(11) "Home Street" + [16]=> + string(13) "Home Street 2" + [17]=> + string(13) "Home Street 3" + [18]=> + string(9) "Home City" + [19]=> + string(10) "Home State" + [20]=> + string(16) "Home Postal Code" + [21]=> + string(19) "Home Country/Region" + [22]=> + string(12) "Other Street" + [23]=> + string(14) "Other Street 2" + [24]=> + string(14) "Other Street 3" + [25]=> + string(10) "Other City" + [26]=> + string(11) "Other State" + [27]=> + string(17) "Other Postal Code" + [28]=> + string(20) "Other Country/Region" + [29]=> + string(17) "Assistant's Phone" + [30]=> + string(12) "Business Fax" + [31]=> + string(14) "Business Phone" + [32]=> + string(16) "Business Phone 2" + [33]=> + string(8) "Callback" + [34]=> + string(9) "Car Phone" + [35]=> + string(18) "Company Main Phone" + [36]=> + string(8) "Home Fax" + [37]=> + string(10) "Home Phone" + [38]=> + string(12) "Home Phone 2" + [39]=> + string(4) "ISDN" + [40]=> + string(12) "Mobile Phone" + [41]=> + string(9) "Other Fax" + [42]=> + string(11) "Other Phone" + [43]=> + string(5) "Pager" + [44]=> + string(13) "Primary Phone" + [45]=> + string(11) "Radio Phone" + [46]=> + string(13) "TTY/TDD Phone" + [47]=> + string(5) "Telex" + [48]=> + string(7) "Account" + [49]=> + string(11) "Anniversary" + [50]=> + string(16) "Assistant's Name" + [51]=> + string(19) "Billing Information" + [52]=> + string(8) "Birthday" + [53]=> + string(23) "Business Address PO Box" + [54]=> + string(10) "Categories" + [55]=> + string(8) "Children" + [56]=> + string(16) "Directory Server" + [57]=> + string(14) "E-mail Address" + [58]=> + string(11) "E-mail Type" + [59]=> + string(19) "E-mail Display Name" + [60]=> + string(16) "E-mail 2 Address" + [61]=> + string(13) "E-mail 2 Type" + [62]=> + string(21) "E-mail 2 Display Name" + [63]=> + string(16) "E-mail 3 Address" + [64]=> + string(13) "E-mail 3 Type" + [65]=> + string(21) "E-mail 3 Display Name" + [66]=> + string(6) "Gender" + [67]=> + string(20) "Government ID Number" + [68]=> + string(5) "Hobby" + [69]=> + string(19) "Home Address PO Box" + [70]=> + string(8) "Initials" + [71]=> + string(18) "Internet Free Busy" + [72]=> + string(8) "Keywords" + [73]=> + string(8) "Language" + [74]=> + string(8) "Location" + [75]=> + string(14) "Manager's Name" + [76]=> + string(7) "Mileage" + [77]=> + string(5) "Notes" + [78]=> + string(15) "Office Location" + [79]=> + string(24) "Organizational ID Number" + [80]=> + string(20) "Other Address PO Box" + [81]=> + string(8) "Priority" + [82]=> + string(7) "Private" + [83]=> + string(10) "Profession" + [84]=> + string(11) "Referred By" + [85]=> + string(11) "Sensitivity" + [86]=> + string(6) "Spouse" + [87]=> + string(6) "User 1" + [88]=> + string(6) "User 2" + [89]=> + string(6) "User 3" + [90]=> + string(6) "User 4" + [91]=> + string(8) "Web Page" + } + [1]=> + array(92) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" + [4]=> + string(0) "" + [5]=> + string(0) "" + [6]=> + string(0) "" + [7]=> + string(0) "" + [8]=> + string(28) "123, 12th Floor, +Main Street" + [9]=> + string(0) "" + [10]=> + string(0) "" + [11]=> + string(0) "" + [12]=> + string(0) "" + [13]=> + string(0) "" + [14]=> + string(0) "" + [15]=> + string(0) "" + [16]=> + string(0) "" + [17]=> + string(0) "" + [18]=> + string(0) "" + [19]=> + string(0) "" + [20]=> + string(0) "" + [21]=> + string(0) "" + [22]=> + string(0) "" + [23]=> + string(0) "" + [24]=> + string(0) "" + [25]=> + string(0) "" + [26]=> + string(0) "" + [27]=> + string(0) "" + [28]=> + string(0) "" + [29]=> + string(0) "" + [30]=> + string(0) "" + [31]=> + string(0) "" + [32]=> + string(0) "" + [33]=> + string(0) "" + [34]=> + string(0) "" + [35]=> + string(0) "" + [36]=> + string(0) "" + [37]=> + string(0) "" + [38]=> + string(0) "" + [39]=> + string(0) "" + [40]=> + string(0) "" + [41]=> + string(0) "" + [42]=> + string(0) "" + [43]=> + string(0) "" + [44]=> + string(0) "" + [45]=> + string(0) "" + [46]=> + string(0) "" + [47]=> + string(0) "" + [48]=> + string(0) "" + [49]=> + string(6) "0/0/00" + [50]=> + string(0) "" + [51]=> + string(0) "" + [52]=> + string(6) "0/0/00" + [53]=> + string(0) "" + [54]=> + string(0) "" + [55]=> + string(0) "" + [56]=> + string(0) "" + [57]=> + string(0) "" + [58]=> + string(0) "" + [59]=> + string(0) "" + [60]=> + string(0) "" + [61]=> + string(0) "" + [62]=> + string(0) "" + [63]=> + string(0) "" + [64]=> + string(0) "" + [65]=> + string(0) "" + [66]=> + string(11) "Unspecified" + [67]=> + string(0) "" + [68]=> + string(0) "" + [69]=> + string(0) "" + [70]=> + string(0) "" + [71]=> + string(0) "" + [72]=> + string(0) "" + [73]=> + string(0) "" + [74]=> + string(0) "" + [75]=> + string(0) "" + [76]=> + string(0) "" + [77]=> + string(1) " +" + [78]=> + string(0) "" + [79]=> + string(0) "" + [80]=> + string(0) "" + [81]=> + string(6) "Normal" + [82]=> + string(5) "False" + [83]=> + string(0) "" + [84]=> + string(0) "" + [85]=> + string(6) "Normal" + [86]=> + string(0) "" + [87]=> + string(0) "" + [88]=> + string(0) "" + [89]=> + string(0) "" + [90]=> + string(0) "" + [91]=> + string(0) "" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/columns.phpt b/framework/File_Csv/test/Horde/Csv/columns.phpt new file mode 100644 index 000000000..40edea29b --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/columns.phpt @@ -0,0 +1,98 @@ +--TEST-- +Horde_File_Csv: column count tests +--FILE-- + +--EXPECT-- +array(4) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + } + [1]=> + array(3) { + [0]=> + string(4) "four" + [1]=> + string(4) "five" + [2]=> + string(0) "" + } + [2]=> + array(3) { + [0]=> + string(3) "six" + [1]=> + string(5) "seven" + [2]=> + string(5) "eight" + } + [3]=> + array(3) { + [0]=> + string(4) "nine" + [1]=> + string(3) "ten" + [2]=> + string(6) "eleven" + } +} +array(2) { + [0]=> + string(54) "Wrong number of fields in line 2. Expected 3, found 2." + [1]=> + string(48) "More fields found in line 4 than the expected 3." +} +array(4) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + } + [1]=> + array(3) { + [0]=> + string(4) "four" + [1]=> + string(4) "five" + [2]=> + string(0) "" + } + [2]=> + array(3) { + [0]=> + string(3) "six" + [1]=> + string(5) "seven" + [2]=> + string(5) "eight" + } + [3]=> + array(3) { + [0]=> + string(4) "nine" + [1]=> + string(3) "ten" + [2]=> + string(6) "eleven" + } +} +array(2) { + [0]=> + string(54) "Wrong number of fields in line 2. Expected 3, found 2." + [1]=> + string(48) "More fields found in line 4 than the expected 3." +} diff --git a/framework/File_Csv/test/Horde/Csv/columns1.csv b/framework/File_Csv/test/Horde/Csv/columns1.csv new file mode 100644 index 000000000..be92c82ea --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/columns1.csv @@ -0,0 +1,4 @@ +one,two,three +four,five +six,seven,eight +nine,ten,eleven,twelve diff --git a/framework/File_Csv/test/Horde/Csv/columns2.csv b/framework/File_Csv/test/Horde/Csv/columns2.csv new file mode 100644 index 000000000..da81f1e07 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/columns2.csv @@ -0,0 +1,4 @@ +"one","two","three" +"four","five" +"six","seven","eight" +"nine","ten","eleven","twelve" diff --git a/framework/File_Csv/test/Horde/Csv/common.php b/framework/File_Csv/test/Horde/Csv/common.php new file mode 100644 index 000000000..2e36f2cfe --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/common.php @@ -0,0 +1,36 @@ + +--EXPECT-- +array(2) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + } + [1]=> + array(3) { + [0]=> + string(4) "four" + [1]=> + string(4) "five" + [2]=> + string(3) "six" + } +} +array(2) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + } + [1]=> + array(3) { + [0]=> + string(4) "four" + [1]=> + string(4) "five" + [2]=> + string(3) "six" + } +} +array(2) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + } + [1]=> + array(3) { + [0]=> + string(4) "four" + [1]=> + string(4) "five" + [2]=> + string(3) "six" + } +} +array(2) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + } + [1]=> + array(3) { + [0]=> + string(4) "four" + [1]=> + string(4) "five" + [2]=> + string(3) "six" + } +} +array(2) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + } + [1]=> + array(3) { + [0]=> + string(4) "four" + [1]=> + string(4) "five" + [2]=> + string(3) "six" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/multiline.phpt b/framework/File_Csv/test/Horde/Csv/multiline.phpt new file mode 100644 index 000000000..47c6c757f --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/multiline.phpt @@ -0,0 +1,52 @@ +--TEST-- +Horde_File_Csv: multiline tests +--FILE-- + +--EXPECT-- +array(4) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(10) "three +four" + } + [1]=> + array(3) { + [0]=> + string(4) "five" + [1]=> + string(9) "six +seven" + [2]=> + string(5) "eight" + } + [2]=> + array(3) { + [0]=> + string(4) "nine" + [1]=> + string(3) "ten" + [2]=> + string(14) "eleven +twelve" + } + [3]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(11) "three + four" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/multiline1.csv b/framework/File_Csv/test/Horde/Csv/multiline1.csv new file mode 100644 index 000000000..5e836a7df --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/multiline1.csv @@ -0,0 +1,8 @@ +"one","two","three +four" +"five","six +seven","eight" +"nine","ten","eleven +twelve" +"one","two","three + four" diff --git a/framework/File_Csv/test/Horde/Csv/notrailing_crlf.csv b/framework/File_Csv/test/Horde/Csv/notrailing_crlf.csv new file mode 100644 index 000000000..5b60c9cc4 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/notrailing_crlf.csv @@ -0,0 +1,2 @@ +one,two,three +four,five,six diff --git a/framework/File_Csv/test/Horde/Csv/notrailing_lf.csv b/framework/File_Csv/test/Horde/Csv/notrailing_lf.csv new file mode 100644 index 000000000..5b60c9cc4 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/notrailing_lf.csv @@ -0,0 +1,2 @@ +one,two,three +four,five,six diff --git a/framework/File_Csv/test/Horde/Csv/quote1.csv b/framework/File_Csv/test/Horde/Csv/quote1.csv new file mode 100644 index 000000000..e2fe57d10 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/quote1.csv @@ -0,0 +1,2 @@ +"one",two,"three" +four,"five six",seven diff --git a/framework/File_Csv/test/Horde/Csv/quote2.csv b/framework/File_Csv/test/Horde/Csv/quote2.csv new file mode 100644 index 000000000..e2fe57d10 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/quote2.csv @@ -0,0 +1,2 @@ +"one",two,"three" +four,"five six",seven diff --git a/framework/File_Csv/test/Horde/Csv/quote3.csv b/framework/File_Csv/test/Horde/Csv/quote3.csv new file mode 100644 index 000000000..c44409128 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/quote3.csv @@ -0,0 +1,3 @@ +"one two","three, four",five +six,"seven ",eight + diff --git a/framework/File_Csv/test/Horde/Csv/quote4.csv b/framework/File_Csv/test/Horde/Csv/quote4.csv new file mode 100644 index 000000000..c44409128 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/quote4.csv @@ -0,0 +1,3 @@ +"one two","three, four",five +six,"seven ",eight + diff --git a/framework/File_Csv/test/Horde/Csv/quote5.csv b/framework/File_Csv/test/Horde/Csv/quote5.csv new file mode 100644 index 000000000..0629c42b4 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/quote5.csv @@ -0,0 +1,2 @@ +"one two","three, four","five" +"six","seven ","eight" diff --git a/framework/File_Csv/test/Horde/Csv/quotes.phpt b/framework/File_Csv/test/Horde/Csv/quotes.phpt new file mode 100644 index 000000000..4fce81197 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/quotes.phpt @@ -0,0 +1,110 @@ +--TEST-- +Horde_File_Csv: quote tests +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + } + [1]=> + array(3) { + [0]=> + string(4) "four" + [1]=> + string(8) "five six" + [2]=> + string(5) "seven" + } +} +array(2) { + [0]=> + array(3) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + } + [1]=> + array(3) { + [0]=> + string(4) "four" + [1]=> + string(8) "five six" + [2]=> + string(5) "seven" + } +} +array(2) { + [0]=> + array(3) { + [0]=> + string(7) "one two" + [1]=> + string(11) "three, four" + [2]=> + string(4) "five" + } + [1]=> + array(3) { + [0]=> + string(3) "six" + [1]=> + string(6) "seven " + [2]=> + string(5) "eight" + } +} +array(2) { + [0]=> + array(3) { + [0]=> + string(7) "one two" + [1]=> + string(11) "three, four" + [2]=> + string(4) "five" + } + [1]=> + array(3) { + [0]=> + string(3) "six" + [1]=> + string(6) "seven " + [2]=> + string(5) "eight" + } +} +array(2) { + [0]=> + array(3) { + [0]=> + string(7) "one two" + [1]=> + string(11) "three, four" + [2]=> + string(4) "five" + } + [1]=> + array(3) { + [0]=> + string(3) "six" + [1]=> + string(6) "seven " + [2]=> + string(5) "eight" + } +} diff --git a/framework/File_Csv/test/Horde/Csv/simple_cr.csv b/framework/File_Csv/test/Horde/Csv/simple_cr.csv new file mode 100644 index 000000000..beb72ce15 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/simple_cr.csv @@ -0,0 +1 @@ +one,two,three four,five,six \ No newline at end of file diff --git a/framework/File_Csv/test/Horde/Csv/simple_crlf.csv b/framework/File_Csv/test/Horde/Csv/simple_crlf.csv new file mode 100644 index 000000000..5b60c9cc4 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/simple_crlf.csv @@ -0,0 +1,2 @@ +one,two,three +four,five,six diff --git a/framework/File_Csv/test/Horde/Csv/simple_lf.csv b/framework/File_Csv/test/Horde/Csv/simple_lf.csv new file mode 100644 index 000000000..5b60c9cc4 --- /dev/null +++ b/framework/File_Csv/test/Horde/Csv/simple_lf.csv @@ -0,0 +1,2 @@ +one,two,three +four,five,six