private function generateComplex($generator, $data, $stripWhitespace)
{
$content = "";
if ($generator->isFirstBatch()) {
$quotedCols = Utils::enquoteArray($data["colData"]);
if ($stripWhitespace) {
$cols = implode(",", $quotedCols);
$content .= "{\"cols\":[{$cols}],\"data\":[";
} else {
$cols = implode(",\n\t\t", $quotedCols);
$content .= "{\n\t\"cols\": [\n\t\t{$cols}\n\t],\n\t\"data\": [\n";
}
}
$numCols = count($data["colData"]);
$numRows = count($data["rowData"]);
for ($i = 0; $i < $numRows; $i++) {
$rowValsArr = array();
for ($j = 0; $j < $numCols; $j++) {
if ($this->numericFields[$j] && is_numeric($data["rowData"][$i][$j])) {
$rowValsArr[] = $data["rowData"][$i][$j];
} else {
$rowValsArr[] = "\"" . $data["rowData"][$i][$j] . "\"";
}
}
if ($stripWhitespace) {
$rowVals = implode(",", $rowValsArr);
$content .= "[{$rowVals}]";
if ($i < $numRows - 1) {
$content .= ",";
}
} else {
$rowVals = implode(",\n\t\t\t", $rowValsArr);
$content .= "\t\t[\n\t\t\t{$rowVals}\n\t\t]";
if ($i < $numRows - 1) {
$content .= ",\n";
} else {
if (!$generator->isLastBatch()) {
$content .= ",\n";
}
}
}
}
if ($generator->isLastBatch()) {
if ($stripWhitespace) {
$content .= "]}";
} else {
$content .= "\n\t]\n}";
}
}
return $content;
}