Completing UI integration for new Export methods and fixing some details
This commit is contained in:
@@ -21,16 +21,33 @@
|
|||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*/
|
*/
|
||||||
//add more security, and catch any error or exception
|
|
||||||
|
|
||||||
|
if (! isset($_GET["file_hash"])) {
|
||||||
$sFileName = $_GET['p'] . '.pm';
|
throw new Exception("Invalid Request, param 'file_hash' was not sent.");
|
||||||
$file = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName . 'tpm';
|
|
||||||
$filex = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
|
||||||
|
|
||||||
if (file_exists( $file )) {
|
|
||||||
rename( $file, $filex );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$realPath = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
||||||
G::streamFile( $realPath, true );
|
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
||||||
|
$filename = base64_decode($_GET["file_hash"]);
|
||||||
|
$fileExtension = pathinfo($outputDir . $filename, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
if (! file_exists($outputDir . $filename)) {
|
||||||
|
throw new Exception("Error, couldn't find request file: $filename");
|
||||||
|
}
|
||||||
|
|
||||||
|
$httpStream->loadFromFile($outputDir . $filename);
|
||||||
|
$httpStream->setHeader("Content-Type", "application/$fileExtension");
|
||||||
|
$httpStream->send();
|
||||||
|
|
||||||
|
// ************* DEPRECATED (it will be removed soon) *********************************
|
||||||
|
//add more security, and catch any error or exception
|
||||||
|
//$sFileName = $_GET['p'] . '.pm';
|
||||||
|
//$file = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName . 'tpm';
|
||||||
|
//$filex = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
||||||
|
//
|
||||||
|
//if (file_exists( $file )) {
|
||||||
|
// rename( $file, $filex );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//$realPath = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
||||||
|
//G::streamFile( $realPath, true );
|
||||||
|
|||||||
@@ -22,30 +22,33 @@
|
|||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
$response = new StdClass();
|
||||||
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
||||||
|
|
||||||
if (\BpmnProject::exists($_GET["pro_uid"])) {
|
try {
|
||||||
$exporter = new ProcessMaker\Exporter\XmlExporter($_GET["pro_uid"]);
|
if (\BpmnProject::exists($_GET["pro_uid"])) {
|
||||||
|
$exporter = new ProcessMaker\Exporter\XmlExporter($_GET["pro_uid"]);
|
||||||
|
|
||||||
$version = ProcessMaker\Util\Common::getLastVersion($outputDir . $exporter->getProjectName() ."-*.pmx") + 1;
|
$version = ProcessMaker\Util\Common::getLastVersion($outputDir . $exporter->getProjectName() . "-*.pmx") + 1;
|
||||||
$outputFilename = sprintf("%s-%s.%s", $exporter->getProjectName(), $version, "pmx");
|
$outputFilename = sprintf("%s-%s.%s", $exporter->getProjectName(), $version, "pmx");
|
||||||
$exporter->saveExport($outputDir . $outputFilename);
|
$exporter->saveExport($outputDir . $outputFilename);
|
||||||
|
} else {
|
||||||
|
$oProcess = new Processes();
|
||||||
|
$proFields = $oProcess->serializeProcess($_GET["pro_uid"]);
|
||||||
|
$result = $oProcess->saveSerializedProcess($proFields);
|
||||||
|
$outputFilename = $result["FILENAME"];
|
||||||
|
|
||||||
$httpStream->setHeader("Content-Type" , "application/pmx");
|
rename($outputDir . $outputFilename . "tpm", $outputDir . $outputFilename);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
$response->file_hash = base64_encode($outputFilename);
|
||||||
$oProcess = new Processes();
|
$response->success = true;
|
||||||
$proFields = $oProcess->serializeProcess($_GET["pro_uid"]);
|
} catch (Exception $e) {
|
||||||
$result = $oProcess->saveSerializedProcess($proFields);
|
$response->message = $e->getMessage();
|
||||||
$outputFilename = $outputDir . $result["FILENAME"];
|
$response->success = false;
|
||||||
|
|
||||||
rename($outputFilename . "tpm", $outputFilename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$httpStream->loadFromFile($outputFilename);
|
echo json_encode($response);
|
||||||
$httpStream->send();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ************* DEPRECATED (it will be removed soon) *********************************
|
// ************* DEPRECATED (it will be removed soon) *********************************
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ class HttpStream
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filename file to stream
|
* @param string $filename file to stream
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function loadFromFile($filename)
|
public function loadFromFile($filename)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -695,37 +695,24 @@ function exportProcess() {
|
|||||||
var record = processesGrid.getSelectionModel().getSelections();
|
var record = processesGrid.getSelectionModel().getSelections();
|
||||||
|
|
||||||
if(record.length == 1) {
|
if(record.length == 1) {
|
||||||
window.location = "../processes/processes_Export?pro_uid=" + record[0].get("PRO_UID");
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
var myMask = new Ext.LoadMask(Ext.getBody(), {msg: _("ID_LOADING")});
|
var myMask = new Ext.LoadMask(Ext.getBody(), {msg: _("ID_LOADING")});
|
||||||
|
var proUid = record[0].get("PRO_UID");
|
||||||
|
|
||||||
myMask.show();
|
myMask.show();
|
||||||
|
|
||||||
///////
|
|
||||||
var proUid = record[0].get("PRO_UID");
|
|
||||||
var proTitle = record[0].get("PRO_TITLE");
|
|
||||||
var titleLength = 60;
|
|
||||||
|
|
||||||
title = (titleLength - proTitle.length >= 0)? proTitle : proTitle.substring(0, (titleLength - 1) + 1) + "...";
|
|
||||||
|
|
||||||
///////
|
|
||||||
Ext.Ajax.request({
|
Ext.Ajax.request({
|
||||||
url: "../processes/processes_Ajax",
|
url: "../processes/processes_Export",
|
||||||
method: "POST",
|
method: "GET",
|
||||||
params: {
|
params: {"pro_uid": proUid},
|
||||||
"action": "process_Export",
|
success: function (response) {
|
||||||
"data": "{\"pro_uid\": \"" + proUid + "\"}",
|
var result = JSON.parse(response.responseText);
|
||||||
"processMap": 0
|
|
||||||
},
|
|
||||||
|
|
||||||
success: function (response, opts) {
|
|
||||||
myMask.hide();
|
myMask.hide();
|
||||||
|
|
||||||
var dataResponse = eval("(" + response.responseText + ")"); //json
|
if (result.success) {
|
||||||
var url = window.location.href;
|
window.location = "../processes/processes_DownloadFile?file_hash=" + result.file_hash;
|
||||||
|
} else {
|
||||||
window.location = url.substring(0, url.lastIndexOf("/") + 1) + dataResponse.FILENAME_LINK;
|
Ext.Msg.show({title: "", msg: result.message, icon: Ext.MessageBox.ERROR, buttons: Ext.MessageBox.OK});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
failure: function (response, opts) {
|
failure: function (response, opts) {
|
||||||
|
|||||||
Reference in New Issue
Block a user