Example #1
0
/**
 *  Parses POST stream from chart and builds an array containing
 *  export data and parameters in a format readable by other functions.
 *
 *  @param	$exportRequestStream 	All POST data (array) from chart
 *  @return	An array of processed export data and parameters
 */
function parseExportRequestStream($exportRequestStream)
{
    // Check for SVG
    $exportData['streamtype'] = strtoupper(@$exportRequestStream['stream_type']);
    // backward compatible SVG stream type detection
    if (!$exportData['streamtype']) {
        if (@$exportRequestStream['svg']) {
            $exportData['streamtype'] = "SVG";
        } else {
            $exportData['streamtype'] = "RLE";
        }
    }
    // get string of compressed/encoded image data
    // halt with error message  if stream is not found
    if (strtolower($exportData['streamtype']) === "svg") {
        $exportData['stream'] = (string) @$exportRequestStream['stream'] or $exportData['stream'] = (string) @$exportRequestStream['svg'] or raise_error(100, true);
    } else {
        if (!isset($exportRequestStream['stream'])) {
            raise_error(100, true);
        }
        // if stream-type is not SVG then this section will execute
        $exportData['stream'] = str_replace(' ', '+', $exportRequestStream['stream']);
        $exportData['stream'] = base64_decode(substr($exportData['stream'], strpos($exportData['stream'], ",") + 1));
    }
    // get all export related parameters and parse to validate and process these
    // add notice if 'parameters' is not retrieved. In that case default values would be taken
    if (!@$exportRequestStream['parameters']) {
        raise_error(102);
    }
    // parse parameters
    $exportData['parameters'] = parseExportParams(@$exportRequestStream['parameters'], @$exportRequestStream);
    $exportData['parameters']["exportformat"] = strtoupper(@$exportData['parameters']["exportformat"]);
    // get width and height of the chart
    // halt with error message  if width/height is/are not retrieved
    $exportData['meta']['width'] = (int) @$exportRequestStream['meta_width'] or $exportData['meta']['width'] = (int) @$exportRequestStream['width'] or raise_error(101);
    $exportData['meta']['height'] = (int) @$exportRequestStream['meta_height'] or raise_error(101);
    // get background color of chart
    // add notice if background color is not retrieved
    $exportData['meta']['bgColor'] = @$exportRequestStream['meta_bgColor'];
    // chart DOMId
    $exportData['meta']['DOMId'] = @$exportRequestStream['meta_DOMId'];
    // get the encoded images if any And temporarily create them inside the the temp
    // folder
    $exportData['encodedImageData'] = @$exportRequestStream['encodedImgData'];
    // return collected and processed data
    return $exportData;
}
Example #2
0
/**
 *  Parses POST stream from chart and builds an array containing
 *  export data and parameters in a format readable by other functions.
 *
 *  @param	$exportRequestStream 	All POST data (array) from chart
 *  @return	An array of processed export data and parameters
 */
function parseExportRequestStream($exportRequestStream)
{
    // Check for SVG
    $exportData['streamtype'] = strtoupper(@$exportRequestStream['stream_type']);
    // backward compatible SVG stream type detection
    if (!$exportData['streamtype']) {
        if (@$exportRequestStream['svg']) {
            $exportData['streamtype'] = "SVG";
        } else {
            //raise error as this export handler only accepts SVG as the input stream.
            raise_error("Invalid input stream type. Only SVG is accepted.");
        }
    }
    // get string of compressed/encoded image data
    // halt with error message  if stream is not found
    $exportData['stream'] = (string) @$exportRequestStream['stream'] or $exportData['stream'] = (string) @$exportRequestStream['svg'] or raise_error(100, true);
    // get all export related parameters and parse to validate and process these
    // add notice if 'parameters' is not retrieved. In that case default values would be taken
    if (!@$exportRequestStream['parameters']) {
        raise_error(102);
    }
    // parse parameters
    $exportData['parameters'] = parseExportParams(@$exportRequestStream['parameters'], @$exportRequestStream);
    $exportData['parameters']["exportformat"] = strtoupper(@$exportData['parameters']["exportformat"]);
    // get width and height of the chart
    // halt with error message  if width/height is/are not retrieved
    $exportData['meta']['width'] = (int) @$exportRequestStream['meta_width'] or $exportData['meta']['width'] = (int) @$exportRequestStream['width'] or raise_error(101);
    $exportData['meta']['height'] = (int) @$exportRequestStream['meta_height'] or raise_error(101);
    // get background color of chart
    // add notice if background color is not retrieved
    $exportData['meta']['bgColor'] = @$exportRequestStream['meta_bgColor'];
    // chart DOMId
    $exportData['meta']['DOMId'] = @$exportRequestStream['meta_DOMId'];
    // return collected and processed data
    return $exportData;
}
Example #3
0
/**
 *  Parses POST stream from chart and builds an array containing
 *  export data and parameters in a format readable by other functions.
 *
 *  @param	$exportRequestStream 	All POST data (array) from chart         
 *  @return	An array of processed export data and parameters
 */
function parseExportRequestStream($exportRequestStream)
{
    // get string of compressed/encoded image data
    // halt with error message  if stream is not found
    $exportData['stream'] = @$exportRequestStream['stream'] or raise_error(100, true);
    // get all export related parameters and parse to validate and process these
    // add notice if 'parameters' is not retrieved. In that case default values would be taken
    if (!@$exportRequestStream['parameters']) {
        raise_error(102);
    }
    // parse parameters
    $exportData['parameters'] = parseExportParams(@$exportRequestStream['parameters']);
    // get width and height of the chart
    // halt with error message  if width/height is/are not retrieved
    $exportData['meta']['width'] = (int) @$exportRequestStream['meta_width'] or raise_error(101, true);
    $exportData['meta']['height'] = (int) @$exportRequestStream['meta_height'] or raise_error(101, true);
    // get background color of chart
    // add notice if background color is not retrieved
    $exportData['meta']['bgColor'] = @$exportRequestStream['meta_bgColor'] or raise_error(" Background color not specified. Taking White (FFFFF) as default background color.");
    // chart DOMId
    $exportData['meta']['DOMId'] = @$exportRequestStream['meta_DOMId'];
    // return collected and processed data
    return $exportData;
}