diff --git a/Rakefile b/Rakefile index 920ab3a8f..6794d1e2e 100644 --- a/Rakefile +++ b/Rakefile @@ -383,6 +383,8 @@ def getJsIncludeFiles "gulliver/js/tinymce/jscripts/tiny_mce/plugins/nonbreaking/editor_plugin.js", "gulliver/js/codemirror/lib/codemirror.js", + "gulliver/js/codemirror/addon/hint/show-hint.js", + "gulliver/js/codemirror/addon/hint/javascript-hint.js", "gulliver/js/codemirror/mode/javascript/javascript.js", "gulliver/js/codemirror/addon/edit/matchbrackets.js", "gulliver/js/codemirror/mode/htmlmixed/htmlmixed.js", @@ -398,6 +400,7 @@ end def getCssIncludeFiles return [ "gulliver/js/codemirror/lib/codemirror.css", + "gulliver/js/codemirror/addon/hint/show-hint.css", # DEPRECATED # "gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/ui.css", # "gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css", diff --git a/workflow/engine/classes/model/Process.php b/workflow/engine/classes/model/Process.php index af2643395..32d67cc4d 100755 --- a/workflow/engine/classes/model/Process.php +++ b/workflow/engine/classes/model/Process.php @@ -568,7 +568,7 @@ class Process extends BaseProcess return (is_object( $oPro ) && get_class( $oPro ) == 'Process'); } - public static function existsByProTitle ($PRO_TITLE) + public static function existsByProTitle ($proTitle) { $oCriteria = new Criteria("workflow"); @@ -576,7 +576,7 @@ class Process extends BaseProcess $oCriteria->add( ContentPeer::CON_CATEGORY, 'PRO_TITLE' ); $oCriteria->add( ContentPeer::CON_LANG, SYS_LANG ); - $oCriteria->add( ContentPeer::CON_VALUE, $PRO_TITLE ); + $oCriteria->add( ContentPeer::CON_VALUE, $proTitle ); $oDataset = ContentPeer::doSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); @@ -586,6 +586,51 @@ class Process extends BaseProcess return ((int)($aRow["NUM_REC"]) > 0)? true : false; } + public static function getByProTitle($proTitle) { + $oCriteria = new Criteria("workflow"); + + $oCriteria->addSelectColumn(ContentPeer::CON_ID); + + $oCriteria->add(ContentPeer::CON_CATEGORY, 'PRO_TITLE'); + $oCriteria->add(ContentPeer::CON_LANG, SYS_LANG); + $oCriteria->add(ContentPeer::CON_VALUE, $proTitle); + $oDataset = ContentPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro')); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + + $oDataset->next(); + $aRow = $oDataset->getRow(); + $oProcess = new Process(); + return isset($aRow["CON_ID"]) ? $oProcess->load($aRow["CON_ID"]) : null; + } + + public static function getNextTitle($proTitle) { + $oCriteria = new Criteria('workflow'); + + $oCriteria->addSelectColumn(ContentPeer::CON_VALUE); + + $oCriteria->add(ContentPeer::CON_CATEGORY, 'PRO_TITLE'); + $oCriteria->add(ContentPeer::CON_LANG, SYS_LANG); + $oCriteria->add(ContentPeer::CON_VALUE, $proTitle . '-%', Criteria::LIKE); + $oCriteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE); + + $oDataset = ContentPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro')); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + + $data = array(); + $may = 0; + while ($oDataset->next()) { + $row = $oDataset->getRow(); + $number = explode("-", $row["CON_VALUE"]); + $number = $number[count($number) - 1] + 0; + if ($number > $may) { + $may = $number; + } + $row["CON_VALUE"] = $number; + $data[] = $row; + } + return $proTitle . "-" . ($may + 1); + } + public function getAllProcessesCount () { $c = $this->tmpCriteria; diff --git a/workflow/engine/controllers/designer.php b/workflow/engine/controllers/designer.php index f76fbb5e2..a861a3bb5 100644 --- a/workflow/engine/controllers/designer.php +++ b/workflow/engine/controllers/designer.php @@ -26,6 +26,7 @@ class Designer extends Controller $proUid = isset($httpData->prj_uid) ? $httpData->prj_uid : ''; $appUid = isset($httpData->app_uid) ? $httpData->app_uid : ''; $proReadOnly = isset($httpData->prj_readonly) ? $httpData->prj_readonly : 'false'; + $stringBpmn = isset($httpData->stringBpmn) ? '' : ''; $client = $this->getClientCredentials(); $authCode = $this->getAuthorizationCode($client); $debug = false; //System::isDebugMode(); @@ -56,6 +57,7 @@ class Designer extends Controller $this->setVar('prj_uid', $proUid); $this->setVar('app_uid', $appUid); + $this->setVar('stringBpmn', $stringBpmn); $this->setVar('prj_readonly', $proReadOnly); $this->setVar('credentials', base64_encode(json_encode($clientToken))); $this->setVar('isDebugMode', $debug); diff --git a/workflow/engine/methods/processes/processes_Import_Ajax.php b/workflow/engine/methods/processes/processes_Import_Ajax.php index b5e6bb253..5e163570d 100644 --- a/workflow/engine/methods/processes/processes_Import_Ajax.php +++ b/workflow/engine/methods/processes/processes_Import_Ajax.php @@ -184,6 +184,47 @@ if (isset($_POST["PRO_FILENAME"]) && exit(0); } +if (isset($_FILES["PROCESS_FILENAME"]) && + pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_EXTENSION) == "bpmn" +) { + $createMode = $_REQUEST["createMode"]; + $name = pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_FILENAME); + $data = array( + "type" => "bpmnProject", + "PRO_TITLE" => $name, + "PRO_DESCRIPTION" => "", + "PRO_CATEGORY" => "", + "PRO_CREATE_USER" => $_SESSION['USER_LOGGED'] + ); + $stringBpmn = base64_encode(file_get_contents($_FILES["PROCESS_FILENAME"]["tmp_name"])); + try { + if ($createMode === "overwrite") { + $process = Process::getByProTitle($data["PRO_TITLE"]); + if ($process !== null) { + $oProcess = new Process(); + $oProcess->remove($process["PRO_UID"]); + } + } + if ($createMode === "rename") { + $data["PRO_TITLE"] = Process::getNextTitle($data["PRO_TITLE"]); + } + $project = new \ProcessMaker\Project\Adapter\WorkflowBpmn($data); + $result = array( + "success" => true, + "catchMessage" => "", + "prj_uid" => $project->getUid(), + "stringBpmn" => $stringBpmn + ); + } catch (Exception $e) { + $result = array( + "success" => true, + "catchMessage" => $e->getMessage() + ); + } + echo G::json_encode($result); + exit(0); +} + $action = isset( $_REQUEST['ajaxAction'] ) ? $_REQUEST['ajaxAction'] : null; $importer = new XmlImporter(); diff --git a/workflow/engine/templates/designer/index.html b/workflow/engine/templates/designer/index.html index 61424ceee..b38e943b2 100644 --- a/workflow/engine/templates/designer/index.html +++ b/workflow/engine/templates/designer/index.html @@ -76,7 +76,7 @@ - +{$stringBpmn}