PM-947
This commit is contained in:
2
Rakefile
2
Rakefile
@@ -385,6 +385,7 @@ def getJsIncludeFiles
|
||||
"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/addon/hint/sql-hint.js",
|
||||
"gulliver/js/codemirror/mode/javascript/javascript.js",
|
||||
"gulliver/js/codemirror/addon/edit/matchbrackets.js",
|
||||
"gulliver/js/codemirror/mode/htmlmixed/htmlmixed.js",
|
||||
@@ -392,6 +393,7 @@ def getJsIncludeFiles
|
||||
"gulliver/js/codemirror/mode/css/css.js",
|
||||
"gulliver/js/codemirror/mode/clike/clike.js",
|
||||
"gulliver/js/codemirror/mode/php/php.js",
|
||||
"gulliver/js/codemirror/mode/sql/sql.js"
|
||||
]
|
||||
|
||||
return includeFiles
|
||||
|
||||
@@ -14,26 +14,20 @@ class pmDynaform
|
||||
public $fields = null;
|
||||
public $record = null;
|
||||
public $credentials = null;
|
||||
public $data = array();
|
||||
|
||||
public function __construct($fields)
|
||||
{
|
||||
$this->fields = $fields;
|
||||
if (count($fields) && count($fields['APP_DATA'])) {
|
||||
$this->getDynaform();
|
||||
$this->getCredentials();
|
||||
}
|
||||
$this->getDynaform();
|
||||
$this->getCredentials();
|
||||
if (isset($this->fields["APP_UID"])) {
|
||||
//current
|
||||
$cases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$this->data = $cases->getCaseVariables($this->fields["APP_UID"]);
|
||||
} else {
|
||||
//history
|
||||
$this->fields["APP_UID"] = null;
|
||||
if (isset($this->fields["APP_DATA"]))
|
||||
$this->data = $this->fields["APP_DATA"];
|
||||
if (isset($this->data["DYN_CONTENT_HISTORY"]))
|
||||
$this->record["DYN_CONTENT"] = $this->data["DYN_CONTENT_HISTORY"];
|
||||
if (isset($this->fields["APP_DATA"]["DYN_CONTENT_HISTORY"]))
|
||||
$this->record["DYN_CONTENT"] = $this->fields["APP_DATA"]["DYN_CONTENT_HISTORY"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,8 +81,8 @@ class pmDynaform
|
||||
$prefixs = array("@@", "@#", "@%", "@?", "@$", "@=");
|
||||
if (is_string($value) && in_array(substr($value, 0, 2), $prefixs)) {
|
||||
$triggerValue = substr($value, 2);
|
||||
if (isset($this->app_data[$triggerValue])) {
|
||||
$json->$key = $this->app_data[$triggerValue];
|
||||
if (isset($this->fields["APP_DATA"][$triggerValue])) {
|
||||
$json->$key = $this->fields["APP_DATA"][$triggerValue];
|
||||
}
|
||||
}
|
||||
//query & options
|
||||
@@ -107,16 +101,18 @@ class pmDynaform
|
||||
$json->options = array();
|
||||
else {
|
||||
//convert stdClass to array
|
||||
$option = array();
|
||||
foreach ($json->options as $valueOptions) {
|
||||
array_push($option, array(
|
||||
"value" => $valueOptions->value,
|
||||
"label" => $valueOptions->label
|
||||
));
|
||||
if (is_array($json->options)) {
|
||||
$option = array();
|
||||
foreach ($json->options as $valueOptions) {
|
||||
array_push($option, array(
|
||||
"value" => $valueOptions->value,
|
||||
"label" => isset($valueOptions->label) ? $valueOptions->label : ""
|
||||
));
|
||||
}
|
||||
$json->options = $option;
|
||||
}
|
||||
$json->options = $option;
|
||||
}
|
||||
if ($json->dbConnection !== "none" && $json->sql !== "") {
|
||||
if ($json->dbConnection !== "" && $json->dbConnection !== "none" && $json->sql !== "") {
|
||||
$cnn = Propel::getConnection($json->dbConnection);
|
||||
$stmt = $cnn->createStatement();
|
||||
$rs = $stmt->executeQuery(strtoupper($json->sql), \ResultSet::FETCHMODE_NUM);
|
||||
@@ -136,21 +132,21 @@ class pmDynaform
|
||||
//data
|
||||
if ($key === "type" && ($value === "text" || $value === "textarea" || $value === "suggest" || $value === "dropdown" || $value === "checkbox" || $value === "radio" || $value === "datetime")) {
|
||||
$json->data = array(
|
||||
"value" => isset($this->data[$json->name]) ? $this->data[$json->name] : $json->data["value"],
|
||||
"label" => isset($this->data[$json->name . "_label"]) ? $this->data[$json->name . "_label"] : $json->data["label"]
|
||||
"value" => isset($this->fields["APP_DATA"][$json->name]) ? $this->fields["APP_DATA"][$json->name] : (is_array($json->data) ? $json->data["value"] : $json->data->value),
|
||||
"label" => isset($this->fields["APP_DATA"][$json->name . "_label"]) ? $this->fields["APP_DATA"][$json->name . "_label"] : (is_array($json->data) ? $json->data["label"] : $json->data->label)
|
||||
);
|
||||
}
|
||||
if ($key === "type" && ($value === "checkbox")) {
|
||||
$json->data = array(
|
||||
"value" => isset($this->data[$json->name]) ? $this->data[$json->name] : array(),
|
||||
"label" => isset($this->data[$json->name . "_label"]) ? $this->data[$json->name . "_label"] : "[]"
|
||||
"value" => isset($this->fields["APP_DATA"][$json->name]) ? $this->fields["APP_DATA"][$json->name] : array(),
|
||||
"label" => isset($this->fields["APP_DATA"][$json->name . "_label"]) ? $this->fields["APP_DATA"][$json->name . "_label"] : "[]"
|
||||
);
|
||||
}
|
||||
if ($key === "type" && ($value === "file") && isset($this->app_data["APPLICATION"])) {
|
||||
if ($key === "type" && ($value === "file") && isset($this->fields["APP_DATA"]["APPLICATION"])) {
|
||||
$oCriteria = new Criteria("workflow");
|
||||
$oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
|
||||
$oCriteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);
|
||||
$oCriteria->add(AppDocumentPeer::APP_UID, $this->app_data["APPLICATION"]);
|
||||
$oCriteria->add(AppDocumentPeer::APP_UID, $this->fields["APP_DATA"]["APPLICATION"]);
|
||||
$oCriteria->add(AppDocumentPeer::APP_DOC_FIELDNAME, $json->name);
|
||||
$rs = AppDocumentPeer::doSelectRS($oCriteria);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
@@ -161,14 +157,14 @@ class pmDynaform
|
||||
}
|
||||
$json->data = array(
|
||||
"value" => $links,
|
||||
"label" => isset($this->data[$json->name . "_label"]) ? $this->data[$json->name . "_label"] : "[]"
|
||||
"label" => isset($this->fields["APP_DATA"][$json->name . "_label"]) ? $this->fields["APP_DATA"][$json->name . "_label"] : "[]"
|
||||
);
|
||||
}
|
||||
//grid
|
||||
if ($key === "type" && ($value === "grid")) {
|
||||
if (isset($this->data[$json->name])) {
|
||||
if (isset($this->fields["APP_DATA"][$json->name])) {
|
||||
//rows
|
||||
$rows = $this->data[$json->name];
|
||||
$rows = $this->fields["APP_DATA"][$json->name];
|
||||
foreach ($rows as $keyRow => $row) {
|
||||
//cells
|
||||
$cells = array();
|
||||
@@ -244,10 +240,6 @@ class pmDynaform
|
||||
$file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/pmdynaform.html');
|
||||
$file = str_replace("{javascript}", $javascrip, $file);
|
||||
echo $file;
|
||||
echo "<pre>";
|
||||
//echo print_r($this->fields, true);
|
||||
// echo print_r($this->data, true);
|
||||
echo "</pre>";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ class DynaformMapBuilder
|
||||
|
||||
$tMap->addColumn('DYN_CONTENT', 'DynContent', 'string', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
$tMap->addColumn('DYN_LABEL', 'DynLabel', 'string', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
$tMap->addColumn('DYN_VERSION', 'DynVersion', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addValidator('DYN_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'xmlform|grid', 'Please select a valid dynaform type.');
|
||||
|
||||
@@ -57,6 +57,12 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
*/
|
||||
protected $dyn_content;
|
||||
|
||||
/**
|
||||
* The value for the dyn_label field.
|
||||
* @var string
|
||||
*/
|
||||
protected $dyn_label;
|
||||
|
||||
/**
|
||||
* The value for the dyn_version field.
|
||||
* @var int
|
||||
@@ -132,6 +138,17 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
return $this->dyn_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [dyn_label] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDynLabel()
|
||||
{
|
||||
|
||||
return $this->dyn_label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [dyn_version] column value.
|
||||
*
|
||||
@@ -253,6 +270,28 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
|
||||
} // setDynContent()
|
||||
|
||||
/**
|
||||
* Set the value of [dyn_label] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDynLabel($v)
|
||||
{
|
||||
|
||||
// Since the native PHP type for this column is string,
|
||||
// we will cast the input to a string (if it is not).
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->dyn_label !== $v) {
|
||||
$this->dyn_label = $v;
|
||||
$this->modifiedColumns[] = DynaformPeer::DYN_LABEL;
|
||||
}
|
||||
|
||||
} // setDynLabel()
|
||||
|
||||
/**
|
||||
* Set the value of [dyn_version] column.
|
||||
*
|
||||
@@ -302,14 +341,16 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
|
||||
$this->dyn_content = $rs->getString($startcol + 4);
|
||||
|
||||
$this->dyn_version = $rs->getInt($startcol + 5);
|
||||
$this->dyn_label = $rs->getString($startcol + 5);
|
||||
|
||||
$this->dyn_version = $rs->getInt($startcol + 6);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 6; // 6 = DynaformPeer::NUM_COLUMNS - DynaformPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
return $startcol + 7; // 7 = DynaformPeer::NUM_COLUMNS - DynaformPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating Dynaform object", $e);
|
||||
@@ -529,6 +570,9 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
return $this->getDynContent();
|
||||
break;
|
||||
case 5:
|
||||
return $this->getDynLabel();
|
||||
break;
|
||||
case 6:
|
||||
return $this->getDynVersion();
|
||||
break;
|
||||
default:
|
||||
@@ -556,7 +600,8 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
$keys[2] => $this->getDynType(),
|
||||
$keys[3] => $this->getDynFilename(),
|
||||
$keys[4] => $this->getDynContent(),
|
||||
$keys[5] => $this->getDynVersion(),
|
||||
$keys[5] => $this->getDynLabel(),
|
||||
$keys[6] => $this->getDynVersion(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
@@ -604,6 +649,9 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
$this->setDynContent($value);
|
||||
break;
|
||||
case 5:
|
||||
$this->setDynLabel($value);
|
||||
break;
|
||||
case 6:
|
||||
$this->setDynVersion($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -650,7 +698,11 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
}
|
||||
|
||||
if (array_key_exists($keys[5], $arr)) {
|
||||
$this->setDynVersion($arr[$keys[5]]);
|
||||
$this->setDynLabel($arr[$keys[5]]);
|
||||
}
|
||||
|
||||
if (array_key_exists($keys[6], $arr)) {
|
||||
$this->setDynVersion($arr[$keys[6]]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -684,6 +736,10 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
$criteria->add(DynaformPeer::DYN_CONTENT, $this->dyn_content);
|
||||
}
|
||||
|
||||
if ($this->isColumnModified(DynaformPeer::DYN_LABEL)) {
|
||||
$criteria->add(DynaformPeer::DYN_LABEL, $this->dyn_label);
|
||||
}
|
||||
|
||||
if ($this->isColumnModified(DynaformPeer::DYN_VERSION)) {
|
||||
$criteria->add(DynaformPeer::DYN_VERSION, $this->dyn_version);
|
||||
}
|
||||
@@ -750,6 +806,8 @@ abstract class BaseDynaform extends BaseObject implements Persistent
|
||||
|
||||
$copyObj->setDynContent($this->dyn_content);
|
||||
|
||||
$copyObj->setDynLabel($this->dyn_label);
|
||||
|
||||
$copyObj->setDynVersion($this->dyn_version);
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ abstract class BaseDynaformPeer
|
||||
const CLASS_DEFAULT = 'classes.model.Dynaform';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 6;
|
||||
const NUM_COLUMNS = 7;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
@@ -46,6 +46,9 @@ abstract class BaseDynaformPeer
|
||||
/** the column name for the DYN_CONTENT field */
|
||||
const DYN_CONTENT = 'DYNAFORM.DYN_CONTENT';
|
||||
|
||||
/** the column name for the DYN_LABEL field */
|
||||
const DYN_LABEL = 'DYNAFORM.DYN_LABEL';
|
||||
|
||||
/** the column name for the DYN_VERSION field */
|
||||
const DYN_VERSION = 'DYNAFORM.DYN_VERSION';
|
||||
|
||||
@@ -60,10 +63,10 @@ abstract class BaseDynaformPeer
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DynUid', 'ProUid', 'DynType', 'DynFilename', 'DynContent', 'DynVersion', ),
|
||||
BasePeer::TYPE_COLNAME => array (DynaformPeer::DYN_UID, DynaformPeer::PRO_UID, DynaformPeer::DYN_TYPE, DynaformPeer::DYN_FILENAME, DynaformPeer::DYN_CONTENT, DynaformPeer::DYN_VERSION, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('DYN_UID', 'PRO_UID', 'DYN_TYPE', 'DYN_FILENAME', 'DYN_CONTENT', 'DYN_VERSION', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DynUid', 'ProUid', 'DynType', 'DynFilename', 'DynContent', 'DynLabel', 'DynVersion', ),
|
||||
BasePeer::TYPE_COLNAME => array (DynaformPeer::DYN_UID, DynaformPeer::PRO_UID, DynaformPeer::DYN_TYPE, DynaformPeer::DYN_FILENAME, DynaformPeer::DYN_CONTENT, DynaformPeer::DYN_LABEL, DynaformPeer::DYN_VERSION, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('DYN_UID', 'PRO_UID', 'DYN_TYPE', 'DYN_FILENAME', 'DYN_CONTENT', 'DYN_LABEL', 'DYN_VERSION', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -73,10 +76,10 @@ abstract class BaseDynaformPeer
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DynUid' => 0, 'ProUid' => 1, 'DynType' => 2, 'DynFilename' => 3, 'DynContent' => 4, 'DynVersion' => 5, ),
|
||||
BasePeer::TYPE_COLNAME => array (DynaformPeer::DYN_UID => 0, DynaformPeer::PRO_UID => 1, DynaformPeer::DYN_TYPE => 2, DynaformPeer::DYN_FILENAME => 3, DynaformPeer::DYN_CONTENT => 4, DynaformPeer::DYN_VERSION => 5, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('DYN_UID' => 0, 'PRO_UID' => 1, 'DYN_TYPE' => 2, 'DYN_FILENAME' => 3, 'DYN_CONTENT' => 4, 'DYN_VERSION' => 5, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DynUid' => 0, 'ProUid' => 1, 'DynType' => 2, 'DynFilename' => 3, 'DynContent' => 4, 'DynLabel' => 5, 'DynVersion' => 6, ),
|
||||
BasePeer::TYPE_COLNAME => array (DynaformPeer::DYN_UID => 0, DynaformPeer::PRO_UID => 1, DynaformPeer::DYN_TYPE => 2, DynaformPeer::DYN_FILENAME => 3, DynaformPeer::DYN_CONTENT => 4, DynaformPeer::DYN_LABEL => 5, DynaformPeer::DYN_VERSION => 6, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('DYN_UID' => 0, 'PRO_UID' => 1, 'DYN_TYPE' => 2, 'DYN_FILENAME' => 3, 'DYN_CONTENT' => 4, 'DYN_LABEL' => 5, 'DYN_VERSION' => 6, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -187,6 +190,8 @@ abstract class BaseDynaformPeer
|
||||
|
||||
$criteria->addSelectColumn(DynaformPeer::DYN_CONTENT);
|
||||
|
||||
$criteria->addSelectColumn(DynaformPeer::DYN_LABEL);
|
||||
|
||||
$criteria->addSelectColumn(DynaformPeer::DYN_VERSION);
|
||||
|
||||
}
|
||||
|
||||
@@ -459,6 +459,7 @@
|
||||
<column name="DYN_TYPE" type="VARCHAR" size="20" required="true" default="xmlform"/>
|
||||
<column name="DYN_FILENAME" type="VARCHAR" size="100" required="true" default=""/>
|
||||
<column name="DYN_CONTENT" type="LONGVARCHAR"/>
|
||||
<column name="DYN_LABEL" type="LONGVARCHAR"/>
|
||||
<column name="DYN_VERSION" type="INTEGER" required="true"/>
|
||||
<validator column="DYN_TYPE">
|
||||
<rule name="validValues" value="xmlform|grid" message="Please select a valid dynaform type."/>
|
||||
|
||||
@@ -205,6 +205,7 @@ CREATE TABLE `DYNAFORM`
|
||||
`DYN_TYPE` VARCHAR(20) default 'xmlform' NOT NULL,
|
||||
`DYN_FILENAME` VARCHAR(100) default '' NOT NULL,
|
||||
`DYN_CONTENT` MEDIUMTEXT,
|
||||
`DYN_LABEL` MEDIUMTEXT,
|
||||
`DYN_VERSION` INTEGER NOT NULL,
|
||||
PRIMARY KEY (`DYN_UID`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Forms required';
|
||||
|
||||
@@ -1134,5 +1134,218 @@ class DynaForm
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* download file *.po
|
||||
*
|
||||
* @param string $projectUid Unique id of Project
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
*
|
||||
* return
|
||||
*/
|
||||
public function downloadLanguage($projectUid, $dynaFormUid, $lang)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \Dynaform();
|
||||
$arraydata = $dynaForm->Load($dynaFormUid);
|
||||
$data = \G::json_decode($arraydata["DYN_LABEL"]);
|
||||
$string = "";
|
||||
$string = $string . "msgid \"\"\n";
|
||||
$string = $string . "msgstr \"\"\n";
|
||||
foreach ($data->{$lang} as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$string = $string . "\"" . $key . ":" . $value . "\\n\"\n";
|
||||
}
|
||||
}
|
||||
$string = $string . "\n";
|
||||
foreach ($data->{$lang}->Labels as $key => $value) {
|
||||
$string = $string . "msgid \"" . $value->msgid . "\"\n";
|
||||
$string = $string . "msgstr \"" . $value->msgstr . "\"\n\n";
|
||||
}
|
||||
return array("labels" => $string, "lang" => $lang);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* upload file *.po
|
||||
*
|
||||
* @param string $projectUid Unique id of Project
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
*
|
||||
* return
|
||||
*/
|
||||
public function uploadLanguage($projectUid, $dynaFormUid)
|
||||
{
|
||||
try {
|
||||
if (isset($_FILES["LANGUAGE"]) && pathinfo($_FILES["LANGUAGE"]["name"], PATHINFO_EXTENSION) == "po") {
|
||||
$translation = array();
|
||||
\G::LoadSystem('i18n_po');
|
||||
$i18n = new \i18n_PO($_FILES["LANGUAGE"]["tmp_name"]);
|
||||
$i18n->readInit();
|
||||
while ($rowTranslation = $i18n->getTranslation()) {
|
||||
array_push($translation, $rowTranslation);
|
||||
}
|
||||
$name = $_FILES["LANGUAGE"]["name"];
|
||||
$name = explode(".", $name);
|
||||
$content = $i18n->getHeaders();
|
||||
$content["File-Name"] = $name;
|
||||
$content["Labels"] = $translation;
|
||||
|
||||
$dynaForm = new \Dynaform();
|
||||
$arraydata = $dynaForm->Load($dynaFormUid);
|
||||
|
||||
if ($arraydata["DYN_LABEL"] !== null && $arraydata["DYN_LABEL"] !== "") {
|
||||
$dyn_labels = \G::json_decode($arraydata["DYN_LABEL"]);
|
||||
$dyn_labels->$name[count($name) - 2] = $content;
|
||||
} else {
|
||||
$dyn_labels = array();
|
||||
}
|
||||
|
||||
$arraydata["DYN_LABEL"] = \G::json_encode($dyn_labels);
|
||||
$dynaForm->update($arraydata);
|
||||
return $dyn_labels;
|
||||
} else {
|
||||
throw new \Exception(\G::LoadTranslation("ID_DYNAFORM_INCORRECT_FILE_NAME"));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list file .po
|
||||
*
|
||||
* @param string $projectUid Unique id of Project
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
*
|
||||
* return
|
||||
*/
|
||||
public function listLanguage($projectUid, $dynaFormUid)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \Dynaform();
|
||||
$arraydata = $dynaForm->Load($dynaFormUid);
|
||||
|
||||
$dyn_labels = \G::json_decode($arraydata["DYN_LABEL"]);
|
||||
$list = array();
|
||||
foreach ($dyn_labels as $key => $value) {
|
||||
array_push($list, array(
|
||||
"Lang" => $key,
|
||||
"File-Name" => isset($value->{"File-Name"}) ? $value->{"File-Name"} : "",
|
||||
"Project-Id-Version" => isset($value->{"Project-Id-Version"}) ? $value->{"Project-Id-Version"} : "",
|
||||
"POT-Creation-Date" => isset($value->{"POT-Creation-Date"}) ? $value->{"POT-Creation-Date"} : "",
|
||||
"PO-Revision-Date" => isset($value->{"PO-Revision-Date"}) ? $value->{"PO-Revision-Date"} : "",
|
||||
"Last-Translator" => isset($value->{"Last-Translator"}) ? $value->{"Last-Translator"} : "",
|
||||
"Language-Team" => isset($value->{"Language-Team"}) ? $value->{"Language-Team"} : "",
|
||||
"MIME-Version" => isset($value->{"MIME-Version"}) ? $value->{"MIME-Version"} : "",
|
||||
"Content-Type" => isset($value->{"Content-Type"}) ? $value->{"Content-Type"} : "",
|
||||
"Content-Transfer_Encoding" => isset($value->{"Content-Transfer_Encoding"}) ? $value->{"Content-Transfer_Encoding"} : "",
|
||||
"X-Poedit-Language" => isset($value->{"X-Poedit-Language"}) ? $value->{"X-Poedit-Language"} : "",
|
||||
"X-Poedit-Country" => isset($value->{"X-Poedit-Country"}) ? $value->{"X-Poedit-Country"} : "",
|
||||
"X-Poedit-SourceCharset" => isset($value->{"X-Poedit-SourceCharset"}) ? $value->{"X-Poedit-SourceCharset"} : "",
|
||||
"Content-Transfer-Encoding" => isset($value->{"Content-Transfer-Encoding"}) ? $value->{"Content-Transfer-Encoding"} : ""
|
||||
));
|
||||
}
|
||||
return $list;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list file .po
|
||||
*
|
||||
* @param string $projectUid Unique id of Project
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
*
|
||||
* return
|
||||
*/
|
||||
public function downloadLabels($projectUid, $dynaFormUid)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \Dynaform();
|
||||
$arraydata = $dynaForm->Load($dynaFormUid);
|
||||
$json = \G::json_decode($arraydata["DYN_CONTENT"]);
|
||||
$this->jsonr($json);
|
||||
$string = "";
|
||||
$string = $string . "msgid \"\"\n";
|
||||
$string = $string . "msgstr \"\"\n";
|
||||
$string = $string . "\"Project-Id-Version: PM 4.0.1\\n\"\n";
|
||||
$string = $string . "\"POT-Creation-Date: \\n\"\n";
|
||||
$string = $string . "\"PO-Revision-Date: 2010-12-02 11:44+0100 \\n\"\n";
|
||||
$string = $string . "\"Last-Translator: Colosa<colosa@colosa.com>\\n\"\n";
|
||||
$string = $string . "\"Language-Team: Colosa Developers Team <developers@colosa.com>\\n\"\n";
|
||||
$string = $string . "\"MIME-Version: 1.0\\n\"\n";
|
||||
$string = $string . "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
|
||||
$string = $string . "\"Content-Transfer_Encoding: 8bit\\n\"\n";
|
||||
$string = $string . "\"X-Poedit-Language: English\\n\"\n";
|
||||
$string = $string . "\"X-Poedit-Country: United States\\n\"\n";
|
||||
$string = $string . "\"X-Poedit-SourceCharset: utf-8\\n\"\n";
|
||||
$string = $string . "\"Content-Transfer-Encoding: 8bit\\n\"\n\n";
|
||||
|
||||
$n = count($this->dyn_conten_labels);
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$string = $string . "msgid \"" . $this->dyn_conten_labels[$i] . "\"\n";
|
||||
$string = $string . "msgstr \"" . $this->dyn_conten_labels[$i] . "\"\n\n";
|
||||
}
|
||||
return array("labels" => $string, "lang" => "en");
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private $dyn_conten_labels = array();
|
||||
|
||||
/**
|
||||
* labels in dyn_content
|
||||
*
|
||||
* @param array $dyn_content
|
||||
*/
|
||||
private function jsonr(&$json)
|
||||
{
|
||||
foreach ($json as $key => $value) {
|
||||
$sw1 = is_array($value);
|
||||
$sw2 = is_object($value);
|
||||
if ($sw1 || $sw2) {
|
||||
$this->jsonr($value);
|
||||
}
|
||||
if (!$sw1 && !$sw2) {
|
||||
if ($key === "label") {
|
||||
$json->label;
|
||||
array_push($this->dyn_conten_labels, $json->label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete labels
|
||||
*
|
||||
* @param string $projectUid Unique id of Project
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
*
|
||||
* return
|
||||
*/
|
||||
public function deleteLanguage($projectUid, $dynaFormUid, $lang)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \Dynaform();
|
||||
$arraydata = $dynaForm->Load($dynaFormUid);
|
||||
|
||||
if ($arraydata["DYN_LABEL"] !== null && $arraydata["DYN_LABEL"] !== "") {
|
||||
$dyn_labels = \G::json_decode($arraydata["DYN_LABEL"]);
|
||||
unset($dyn_labels->{$lang});
|
||||
}
|
||||
|
||||
$arraydata["DYN_LABEL"] = \G::json_encode($dyn_labels);
|
||||
$dynaForm->update($arraydata);
|
||||
return;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -112,5 +112,97 @@ class DynaForm extends Api
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:prj_uid/dynaform/:dyn_uid/download-language/:lang
|
||||
*
|
||||
* @param string $dyn_uid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetDynaFormLanguage($dyn_uid, $prj_uid, $lang)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
$dynaForm->setFormatFieldNameInUppercase(false);
|
||||
$response = $dynaForm->downloadLanguage($prj_uid, $dyn_uid, $lang);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /:prj_uid/dynaform/:dyn_uid/upload-language
|
||||
*
|
||||
* @param string $dyn_uid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doPostDynaFormLanguage($dyn_uid, $prj_uid)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
$dynaForm->setFormatFieldNameInUppercase(false);
|
||||
$response = $dynaForm->uploadLanguage($prj_uid, $dyn_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /:prj_uid/dynaform/:dyn_uid/delete-language/:lang
|
||||
*
|
||||
* @param string $dyn_uid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doDeleteDynaFormLanguage($dyn_uid, $prj_uid, $lang)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
$dynaForm->setFormatFieldNameInUppercase(false);
|
||||
$response = $dynaForm->deleteLanguage($prj_uid, $dyn_uid, $lang);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:prj_uid/dynaform/:dyn_uid/list-language
|
||||
*
|
||||
* @param string $dyn_uid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetListDynaFormLanguage($dyn_uid, $prj_uid)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
$dynaForm->setFormatFieldNameInUppercase(false);
|
||||
$response = $dynaForm->listLanguage($prj_uid, $dyn_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:prj_uid/dynaform/:dyn_uid/download-labels
|
||||
*
|
||||
* @param string $dyn_uid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetListDynaFormLabels($dyn_uid, $prj_uid)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
$dynaForm->setFormatFieldNameInUppercase(false);
|
||||
$response = $dynaForm->downloadLabels($prj_uid, $dyn_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user