From 46065582296a47d6c28887e8c939c57083f70476 Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Wed, 7 Aug 2013 20:43:23 +0530 Subject: [PATCH] CRM-12926 : convert the flash to image and upload the image --- CRM/Report/Form.php | 30 ++++++++++++++++++++++ CRM/Report/xml/Menu/Report.xml | 5 ++++ templates/CRM/Report/Form.tpl | 4 ++- templates/CRM/Report/Form/Layout/Graph.tpl | 21 ++++++--------- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 3b72580d73..a6b4b9c495 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -3361,5 +3361,35 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a } } } + + /* function used for showing charts on print screen */ + static function uploadChartImage() { + // upload strictly for '.png' images + $name = CRM_Utils_Request::retrieve('name', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); + if (preg_match('/\.png$/', trim($name))) { + // + // POST data is usually string data, but we are passing a RAW .png + // so PHP is a bit confused and $_POST is empty. But it has saved + // the raw bits into $HTTP_RAW_POST_DATA + // + $httpRawPostData = $GLOBALS['HTTP_RAW_POST_DATA']; + + // prepare the directory + $config = CRM_Core_Config::singleton(); + $defaultPath = str_replace('/persist/contribute/' , '/persist/', $config->imageUploadDir) . '/openFlashChart/'; + if (!file_exists($defaultPath)) { + mkdir($defaultPath, 0777, TRUE); + } + + // full path to the saved image including filename + $destination = $defaultPath . basename($name); + + //write and save + $jfh = fopen($destination, 'w') or die("can't open file"); + fwrite($jfh, $httpRawPostData); + fclose($jfh); + CRM_Utils_System::civiExit(); + } + } } diff --git a/CRM/Report/xml/Menu/Report.xml b/CRM/Report/xml/Menu/Report.xml index 4fe4972bf0..a338fc124b 100644 --- a/CRM/Report/xml/Menu/Report.xml +++ b/CRM/Report/xml/Menu/Report.xml @@ -70,4 +70,9 @@ CiviReport admin/small/report_list.gif + + civicrm/report/chart + CRM_Report_Form::uploadChartImage + access CiviReport + diff --git a/templates/CRM/Report/Form.tpl b/templates/CRM/Report/Form.tpl index a1fa5f6a0b..3a701bedab 100644 --- a/templates/CRM/Report/Form.tpl +++ b/templates/CRM/Report/Form.tpl @@ -23,7 +23,9 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{include file="CRM/common/crmeditable.tpl"} +{if $outputMode neq 'print'} + {include file="CRM/common/crmeditable.tpl"} +{/if} {* this div is being used to apply special css *} {if $section eq 1}
diff --git a/templates/CRM/Report/Form/Layout/Graph.tpl b/templates/CRM/Report/Form/Layout/Graph.tpl index 628e501ed8..dd340e8d80 100644 --- a/templates/CRM/Report/Form/Layout/Graph.tpl +++ b/templates/CRM/Report/Form/Layout/Graph.tpl @@ -48,21 +48,16 @@ {literal}