Example #1
0
     require_once 'classes/model/Content.php';
     $content = new Content();
     $value = $content->load($Category, '', $Id, $Lang);
     return $value;
 }
 //$oJSON = new Services_JSON();
 $stdObj = Bootstrap::json_decode($_POST['data']);
 if (isset($stdObj->pro_uid)) {
     $sProUid = $stdObj->pro_uid;
 } else {
     throw new Exception(G::LoadTranslation('ID_PROCESS_UID_NOT_DEFINED'));
 }
 /* Includes */
 G::LoadClass('processes');
 $oProcess = new Processes();
 $proFields = $oProcess->serializeProcess($sProUid);
 $Fields = $oProcess->saveSerializedProcess($proFields);
 $pathLength = strlen(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP);
 $length = strlen($Fields['PRO_TITLE']) + $pathLength;
 foreach ($Fields as $key => $value) {
     if ($key == 'PRO_TITLE') {
         $Fields[$key] = myTruncate($value, 65, ' ', '...');
     }
     if ($key == 'FILENAME') {
         $Fields[$key] = myTruncate($value, 60, '_', '...pm');
     }
     if ($length >= 250) {
         if ($key == 'FILENAME_LINK') {
             list($file, $rest) = explode('p=', $value);
             list($filenameLink, $rest) = explode('&', $rest);
             $Fields[$key] = myTruncate($filenameLink, 250 - $pathLength, '_', '');
try {
	if(empty($_GET)){
		$proUid = Bootstrap::json_decode( $_POST['data']);
		$_GET["pro_uid"] = $proUid->pro_uid;
	}
    if (\BpmnProject::exists($_GET["pro_uid"])) {
        $exporter = new ProcessMaker\Exporter\XmlExporter($_GET["pro_uid"]);
        $getProjectName = $exporter->truncateName($exporter->getProjectName(),false);

        $version = ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
        $outputFilename = sprintf("%s-%s.%s", str_replace(" ","_",$getProjectName), $version, "pmx");
        $outputFilename = $exporter->saveExport($outputDir.$outputFilename);
    } else {
        $oProcess = new Processes();
        $proFields = $oProcess->serializeProcess($_GET["pro_uid"]);
        $result = $oProcess->saveSerializedProcess($proFields);
        $outputFilename = $result["FILENAME"];

        rename($outputDir . $outputFilename . "tpm", $outputDir . $outputFilename);
    }
    $response->file_hash = base64_encode($outputFilename);
    $response->success = true;

    /* Render page */
    if (isset( $_REQUEST["processMap"] ) && $_REQUEST["processMap"] == 1) {
    	$link = parse_url($result['FILENAME_LINK']);
    	$result['FILENAME_LINK'] = $link['path'] . '?file_hash=' . $response->file_hash;

    	$G_PUBLISH = new Publisher();
    	$G_PUBLISH->AddContent( "xmlform", "xmlform", "processes/processes_Export", "", $result );