$count++;
}
- header('Content-Type: application/json');
- echo CRM_Utils_JSON::encodeDataTable($searchRows, $iTotal, $iFilteredTotal, $selectorElements);
-
- CRM_Utils_System::civiExit();
+ $dupePairs = array(
+ 'data' => $searchRows,
+ 'recordsTotal' => $iTotal,
+ 'recordsFiltered' => $iFilteredTotal,
+ );
+ CRM_Utils_JSON::output($dupePairs);
}
/**
return $sOutput;
}
- /**
- * This function is used to encode data for new dataTable plugin v1.10 and greater
- * @return string
- *
- */
- public static function encodeDataTable($params, $iTotal, $iFilteredTotal, $selectorElements) {
- $sOutput = '{';
- $sOutput .= '"recordsTotal": ' . $iTotal . ', ';
- $sOutput .= '"recordsFiltered": ' . $iFilteredTotal . ', ';
- $sOutput .= '"data": [ ';
- foreach ($params as $key => $value) {
- $addcomma = FALSE;
- $sOutput .= "{";
- foreach ($selectorElements as $element) {
- if ($addcomma) {
- $sOutput .= ",";
- }
- //CRM-7130 --lets addslashes to only double quotes,
- //since we are using it to quote the field value.
- //str_replace helps to provide a break for new-line
- $sOutput .= '"' . $element . '":' . '"' . addcslashes(str_replace(array("\r\n", "\n", "\r"), '<br />', $value[$element]), '"\\') . '"';
-
- //remove extra spaces and tab character that breaks dataTable CRM-12551
- $sOutput = preg_replace("/\s+/", " ", $sOutput);
- $addcomma = TRUE;
- }
- $sOutput .= "},";
- }
- $sOutput = substr_replace($sOutput, "", -1);
- $sOutput .= '] }';
-
- return $sOutput;
- }
-
}