function quant_process in Quant 6
Process quants and convert them to charts with data plotted
Parameters
&$quant: A quant object
$period: A timestamp representing a date in which data should reach back to, can also be an accepted format for strtotime(), or an array with the first value being a timestamp representing the 'from' date and the second value being a timestamp representing the 'to' date. If an array of two values is given, accept formats for strtotime() can be used in place of timestamps.
Return value
A complete chart ready for display
1 call to quant_process()
- quant_page in includes/
pages.inc - The analytics page callback
File
- ./
quant.module, line 165
Code
function quant_process(&$quant, $period) {
quant_include('chart');
$chart = '';
// Check if period is in string form
if (is_string($period)) {
// Convert to a timestamp
$period = strtotime($period);
// Make sure the format was correct
if (!is_numeric($period)) {
return FALSE;
}
}
else {
if (is_numeric($period)) {
// Determine the amount of days in period
$days = ceil((time() - $period) / 86400);
}
else {
if (is_array($period)) {
// Check if the values are strings
foreach ($period as $i => $date) {
if (is_string($date)) {
// If they are, try to convert to timestamps
$date = strtotime($date);
if (!is_numeric($date)) {
// Invalid format, end here
return FALSE;
}
else {
$period[$i] = $date;
}
}
}
// Determine the amount of days in period
$days = ceil(($period[1] - $period[0]) / 86400);
}
}
}
// Add the information we need to the quant
$quant->period = $period;
$quant->days = $days;
// Generate and execute a database query
quant_execute_query($quant);
// Build the data for the chart
quant_build_data($quant);
// Generate the chart
quant_generate_chart($quant);
return $quant->render ? $quant->render : FALSE;
}