Merge branch '2.0' of git.colosa.net:processmaker into 2.0
This commit is contained in:
@@ -541,8 +541,11 @@ class dynaFormHandler
|
|||||||
{
|
{
|
||||||
$array = false;
|
$array = false;
|
||||||
$array['__nodeName__'] = $node->nodeName;
|
$array['__nodeName__'] = $node->nodeName;
|
||||||
if ($node->hasAttributes()){
|
$text = simplexml_import_dom($node);
|
||||||
if( isset($attributes) ){
|
$array['__nodeText__'] = trim((string) $text);
|
||||||
|
|
||||||
|
if ($node->hasAttributes()) {
|
||||||
|
if( isset($attributes) ) {
|
||||||
foreach ($attributes as $attr) {
|
foreach ($attributes as $attr) {
|
||||||
if( $node->hasAttribute($attr) )
|
if( $node->hasAttribute($attr) )
|
||||||
$array[$attr] = $node->getAttribute($attr);
|
$array[$attr] = $node->getAttribute($attr);
|
||||||
@@ -559,10 +562,15 @@ class dynaFormHandler
|
|||||||
$return;
|
$return;
|
||||||
else {
|
else {
|
||||||
foreach ($node->childNodes as $childNode) {
|
foreach ($node->childNodes as $childNode) {
|
||||||
if ($childNode->nodeType != XML_TEXT_NODE && $childNode->nodeType != XML_CDATA_SECTION_NODE)
|
$childNode->normalize();
|
||||||
|
//if ($childNode->nodeType == XML_TEXT_NODE || $childNode->nodeType == XML_CDATA_SECTION_NODE) {
|
||||||
|
if ($childNode->nodeType == XML_ELEMENT_NODE) {
|
||||||
$array[$childNode->nodeName][] = $this->getArray($childNode);
|
$array[$childNode->nodeName][] = $this->getArray($childNode);
|
||||||
else
|
} else if ($childNode->nodeType == XML_TEXT_NODE || $childNode->nodeType == XML_CDATA_SECTION_NODE) {
|
||||||
$array[$childNode->nodeName] = $childNode->nodeValue;
|
//$array[$childNode->nodeName] = $childNode->textContent;
|
||||||
|
$text = simplexml_import_dom($childNode->parentNode);
|
||||||
|
$array['__nodeText__'] = trim((string) $text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,12 +101,14 @@ class languages {
|
|||||||
$oTranslation = new Translation();
|
$oTranslation = new Translation();
|
||||||
$countItems = 0;
|
$countItems = 0;
|
||||||
$countItemsSuccess = 0;
|
$countItemsSuccess = 0;
|
||||||
|
$errorMsg = '';
|
||||||
|
|
||||||
while( $rowTranslation = $POFile->getTranslation() ) {
|
while( $rowTranslation = $POFile->getTranslation() ) {
|
||||||
|
|
||||||
$countItems++;
|
$countItems++;
|
||||||
|
|
||||||
if ( ! isset($POFile->translatorComments[0]) || ! isset($POFile->translatorComments[1]) || ! isset($POFile->references[0]) ) {
|
if ( ! isset($POFile->translatorComments[0]) || ! isset($POFile->translatorComments[1]) || ! isset($POFile->references[0]) ) {
|
||||||
throw new Exception('The .po file has not valid directives for Processmaker!');
|
throw new Exception('The .po file doesn\'t have valid directives for Processmaker!');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($POFile->translatorComments as $a=>$aux){
|
foreach($POFile->translatorComments as $a=>$aux){
|
||||||
@@ -120,16 +122,17 @@ class languages {
|
|||||||
if ($var[0]=='JAVASCRIPT')
|
if ($var[0]=='JAVASCRIPT')
|
||||||
$context = $aux;
|
$context = $aux;
|
||||||
}
|
}
|
||||||
if (preg_match('/^([a-zA-Z_-]+)\/([a-zA-Z_-]+\.xml\?)/', $aux, $match))
|
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml\?)/', $aux, $match))
|
||||||
$identifier = $aux;
|
$identifier = $aux;
|
||||||
else{
|
else{
|
||||||
if (preg_match('/^([a-zA-Z_-]+)\/([a-zA-Z_-]+\.xml$)/', $aux, $match))
|
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml$)/', $aux, $match))
|
||||||
$context = $aux;
|
$context = $aux;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$reference = $POFile->references[0];
|
$reference = $POFile->references[0];
|
||||||
|
|
||||||
|
// it is a Sql insert on TRANSLATIONS TAble
|
||||||
if( $identifier == 'TRANSLATION') {
|
if( $identifier == 'TRANSLATION') {
|
||||||
if ($updateDB) {
|
if ($updateDB) {
|
||||||
list($category, $id) = explode('/', $context);
|
list($category, $id) = explode('/', $context);
|
||||||
@@ -139,18 +142,29 @@ class languages {
|
|||||||
$LOCALE,
|
$LOCALE,
|
||||||
trim(str_replace(chr(10), '', stripslashes($rowTranslation['msgstr'])))
|
trim(str_replace(chr(10), '', stripslashes($rowTranslation['msgstr'])))
|
||||||
);
|
);
|
||||||
if( $result['codError'] == 0 )
|
if( $result['codError'] == 0 ) {
|
||||||
$countItemsSuccess++;
|
$countItemsSuccess++;
|
||||||
|
} else {
|
||||||
|
$errorMsg .= $id .': ' . $result['message'] . "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if( $updateXml ){
|
}
|
||||||
|
// is a Xml update
|
||||||
|
else if( $updateXml ) {
|
||||||
|
|
||||||
$xmlForm = $context;
|
$xmlForm = $context;
|
||||||
//erik: expresion to prevent and hable correctly dropdown values like -1, -2 etc.
|
//erik: expresion to prevent and hable correctly dropdown values like -1, -2 etc.
|
||||||
preg_match('/^([\w_]+)\s-\s([\w_]+)\s*-*\s*([\w\W]*)$/', $reference, $match);
|
preg_match('/^([\w_]+)\s-\s([\w_]+)\s*-*\s*([\w\W]*)$/', $reference, $match);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if( ! file_exists(PATH_XMLFORM . $xmlForm) ) {
|
if( ! file_exists(PATH_XMLFORM . $xmlForm) ) {
|
||||||
|
echo 'file doesn\'t exist: ' . PATH_XMLFORM . $xmlForm;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
G::LoadSystem('dynaformhandler');
|
G::LoadSystem('dynaformhandler');
|
||||||
$dynaform = new dynaFormHandler(PATH_XMLFORM . $xmlForm);
|
$dynaform = new dynaFormHandler(PATH_XMLFORM . $xmlForm);
|
||||||
$fieldName = $match[2];
|
$fieldName = $match[2];
|
||||||
@@ -158,7 +172,7 @@ class languages {
|
|||||||
$codes = explode('-', $reference);
|
$codes = explode('-', $reference);
|
||||||
|
|
||||||
if( sizeof($codes) == 2 ) { //is a normal node
|
if( sizeof($codes) == 2 ) { //is a normal node
|
||||||
$dynaform->addChilds($fieldName, Array($LOCALE=>$rowTranslation['msgstr']));
|
$dynaform->addChilds($fieldName, Array($LOCALE=>stripslashes($rowTranslation['msgstr'])));
|
||||||
} else if( sizeof($codes) > 2 ) { //is a node child for a language node
|
} else if( sizeof($codes) > 2 ) { //is a node child for a language node
|
||||||
$name = $match[3] == "''" ? '' : $match[3];
|
$name = $match[3] == "''" ? '' : $match[3];
|
||||||
$childNode = Array(
|
$childNode = Array(
|
||||||
@@ -189,6 +203,7 @@ class languages {
|
|||||||
$results->recordsCountSuccess = $countItemsSuccess;
|
$results->recordsCountSuccess = $countItemsSuccess;
|
||||||
$results->lang = $languageID;
|
$results->lang = $languageID;
|
||||||
$results->headers = $POHeaders;
|
$results->headers = $POHeaders;
|
||||||
|
$results->errMsg = $errorMsg;
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ class Translation extends BaseTranslation {
|
|||||||
$msg = '';
|
$msg = '';
|
||||||
$validationFailuresArray = $tr->getValidationFailures();
|
$validationFailuresArray = $tr->getValidationFailures();
|
||||||
foreach($validationFailuresArray as $objValidationFailure) {
|
foreach($validationFailuresArray as $objValidationFailure) {
|
||||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
$msg .= $objValidationFailure->getMessage() . "\n";
|
||||||
}
|
}
|
||||||
return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,15 @@ G::LoadSystem('i18n_po');
|
|||||||
//$timer = new Benchmark_Timer();
|
//$timer = new Benchmark_Timer();
|
||||||
//$timer->start();
|
//$timer->start();
|
||||||
|
|
||||||
//creating the .po file
|
if (!defined('PM_VERSION')) {
|
||||||
|
if (file_exists ( PATH_METHODS . 'login/version-pmos.php')) {
|
||||||
|
include (PATH_METHODS . 'login/version-pmos.php');
|
||||||
|
} else {
|
||||||
|
define('PM_VERSION', 'Development Version');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//creating the .po file
|
||||||
if( ! isset($_GET['LOCALE']) )
|
if( ! isset($_GET['LOCALE']) )
|
||||||
throw new Exception('Language Target ID was not set!');
|
throw new Exception('Language Target ID was not set!');
|
||||||
|
|
||||||
@@ -72,7 +79,7 @@ if( ! isset($langRecord['LAN_NAME']) )
|
|||||||
$sLanguage = $langRecord['LAN_NAME'];
|
$sLanguage = $langRecord['LAN_NAME'];
|
||||||
|
|
||||||
//setting headers
|
//setting headers
|
||||||
$poFile->addHeader('Project-Id-Version' , '1.8');
|
$poFile->addHeader('Project-Id-Version' , 'ProcessMaker ' . PM_VERSION);
|
||||||
$poFile->addHeader('POT-Creation-Date' , '');
|
$poFile->addHeader('POT-Creation-Date' , '');
|
||||||
$poFile->addHeader('PO-Revision-Date' , date('Y-m-d H:i:s'));
|
$poFile->addHeader('PO-Revision-Date' , date('Y-m-d H:i:s'));
|
||||||
$poFile->addHeader('Last-Translator' , '');
|
$poFile->addHeader('Last-Translator' , '');
|
||||||
@@ -154,8 +161,8 @@ $aXMLForms = glob(PATH_XMLFORM . '*/*.xml');
|
|||||||
$aXMLForms2 = glob(PATH_XMLFORM . '*/*/*.xml');
|
$aXMLForms2 = glob(PATH_XMLFORM . '*/*/*.xml');
|
||||||
$aXMLForms = array_merge($aXMLForms, $aXMLForms2);
|
$aXMLForms = array_merge($aXMLForms, $aXMLForms2);
|
||||||
|
|
||||||
$aEnglishLabel = array();
|
$aEnglishLabel = array();
|
||||||
$aOptions = array();
|
$aOptions = array();
|
||||||
$nodesNames = Array();
|
$nodesNames = Array();
|
||||||
|
|
||||||
G::loadSystem('dynaformhandler');
|
G::loadSystem('dynaformhandler');
|
||||||
@@ -163,10 +170,7 @@ G::loadSystem('dynaformhandler');
|
|||||||
foreach ($aXMLForms as $xmlFormPath) {
|
foreach ($aXMLForms as $xmlFormPath) {
|
||||||
$xmlFormFile = str_replace( chr(92), '/', $xmlFormPath);
|
$xmlFormFile = str_replace( chr(92), '/', $xmlFormPath);
|
||||||
$xmlFormFile = str_replace( PATH_XMLFORM, '', $xmlFormPath);
|
$xmlFormFile = str_replace( PATH_XMLFORM, '', $xmlFormPath);
|
||||||
//$oForm = new Form( $sXmlForm, '', 'en');
|
|
||||||
//echo $xmlFormPath;
|
|
||||||
//echo '<br>';
|
|
||||||
//echo '<br>';
|
|
||||||
$dynaForm = new dynaFormHandler($xmlFormPath);
|
$dynaForm = new dynaFormHandler($xmlFormPath);
|
||||||
|
|
||||||
$dynaNodes = $dynaForm->getFields();
|
$dynaNodes = $dynaForm->getFields();
|
||||||
@@ -182,19 +186,13 @@ foreach ($aXMLForms as $xmlFormPath) {
|
|||||||
continue; //just continue with the next node
|
continue; //just continue with the next node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Getting the Base Origin Text
|
// Getting the Base Origin Text
|
||||||
if( ! is_array($arrayNode[$_BASE_LANG]) )
|
if( ! is_array($arrayNode[$_BASE_LANG]) )
|
||||||
$originNodeText = trim($arrayNode[$_BASE_LANG]);
|
$originNodeText = trim($arrayNode[$_BASE_LANG]);
|
||||||
else {
|
else {
|
||||||
$langNode = $arrayNode[$_BASE_LANG][0];
|
$langNode = $arrayNode[$_BASE_LANG][0];
|
||||||
$originNodeText = getTextValue($langNode);
|
$originNodeText = $langNode['__nodeText__'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if( strpos($xmlFormPath, 'patterns/patterns_GridParallelByEvaluationType.xml') !== false){
|
|
||||||
g::pr($arrayNode);
|
|
||||||
g::dump(getTextValue($langNode));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Getting the Base Target Text
|
// Getting the Base Target Text
|
||||||
if( isset($arrayNode[$_TARGET_LANG]) ) {
|
if( isset($arrayNode[$_TARGET_LANG]) ) {
|
||||||
@@ -202,7 +200,7 @@ foreach ($aXMLForms as $xmlFormPath) {
|
|||||||
$targetNodeText = trim($arrayNode[$_TARGET_LANG]);
|
$targetNodeText = trim($arrayNode[$_TARGET_LANG]);
|
||||||
else {
|
else {
|
||||||
$langNode = $arrayNode[$_TARGET_LANG][0];
|
$langNode = $arrayNode[$_TARGET_LANG][0];
|
||||||
$targetNodeText = getTextValue($langNode);
|
$targetNodeText = $langNode['__nodeText__'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$targetNodeText = $originNodeText;
|
$targetNodeText = $originNodeText;
|
||||||
@@ -210,11 +208,7 @@ foreach ($aXMLForms as $xmlFormPath) {
|
|||||||
|
|
||||||
$nodeName = $arrayNode['__nodeName__'];
|
$nodeName = $arrayNode['__nodeName__'];
|
||||||
$nodeType = $arrayNode['type'];
|
$nodeType = $arrayNode['type'];
|
||||||
/*echo 'NODENAME:'. $nodeName . '<br>';
|
|
||||||
echo 'ORIGIN text:'. $originNodeText.'<br>';
|
|
||||||
echo 'TARGET text:'. $targetNodeText.'<br>';
|
|
||||||
echo 'NODE TYPE'. $arrayNode['type'].'<br>';
|
|
||||||
*/
|
|
||||||
$msgid = $originNodeText;
|
$msgid = $originNodeText;
|
||||||
|
|
||||||
// if the nodeName already exists in the po file, we need to create other msgid
|
// if the nodeName already exists in the po file, we need to create other msgid
|
||||||
@@ -224,13 +218,7 @@ foreach ($aXMLForms as $xmlFormPath) {
|
|||||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName);
|
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName);
|
||||||
$poFile->addTranslatorComment($xmlFormFile);
|
$poFile->addTranslatorComment($xmlFormFile);
|
||||||
$poFile->addReference($nodeType . ' - ' . $nodeName);
|
$poFile->addReference($nodeType . ' - ' . $nodeName);
|
||||||
$poFile->addTranslation($msgid, stripslashes($targetNodeText));
|
$poFile->addTranslation(stripslashes($msgid), stripslashes($targetNodeText));
|
||||||
|
|
||||||
/*if( strpos($xmlFormPath, 'patterns/patterns_GridParallelByEvaluationType.xml') !== false){
|
|
||||||
echo 'msgstr: ' .$msgid, stripslashes($targetNodeText);
|
|
||||||
echo '<br>';
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
$aMsgids[$msgid] = true;
|
$aMsgids[$msgid] = true;
|
||||||
|
|
||||||
@@ -250,12 +238,12 @@ foreach ($aXMLForms as $xmlFormPath) {
|
|||||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $originOptionNode);
|
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $originOptionNode);
|
||||||
$poFile->addTranslatorComment($xmlFormFile);
|
$poFile->addTranslatorComment($xmlFormFile);
|
||||||
$poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $originOptionNode);
|
$poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $originOptionNode);
|
||||||
$poFile->addTranslation($msgid, stripslashes($originOptionNode));
|
$poFile->addTranslation(stripslashes($msgid), stripslashes($originOptionNode));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach( $originOptionNode as $optionNode ) {
|
foreach( $originOptionNode as $optionNode ) {
|
||||||
$optionName = $optionNode['name'];
|
$optionName = $optionNode['name'];
|
||||||
$originOptionValue = getTextValue($optionNode);
|
$originOptionValue = $optionNode['__nodeText__'];
|
||||||
|
|
||||||
if( $targetOptionExists ){
|
if( $targetOptionExists ){
|
||||||
|
|
||||||
@@ -266,17 +254,8 @@ foreach ($aXMLForms as $xmlFormPath) {
|
|||||||
} else {
|
} else {
|
||||||
$targetOptionValue = $originOptionValue;
|
$targetOptionValue = $originOptionValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$targetOptionValue = ($targetOptionValue != '') ? $targetOptionValue : "''";
|
|
||||||
//$optionName = ($optionName != '') ? $optionName : "''";
|
|
||||||
|
|
||||||
$msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
|
|
||||||
/*g::dump($xmlFormFile . '?' . $nodeName . '-'. $originOptionValue);
|
|
||||||
g::dump($xmlFormFile);
|
|
||||||
g::dump($nodeType . ' - ' . $nodeName . ' - ' . $originOptionValue);
|
|
||||||
g::dump($msgid);
|
|
||||||
g::dump($targetOptionValue);*/
|
|
||||||
|
|
||||||
|
$msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
|
||||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $optionName);
|
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $optionName);
|
||||||
$poFile->addTranslatorComment($xmlFormFile);
|
$poFile->addTranslatorComment($xmlFormFile);
|
||||||
$poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $optionName);
|
$poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $optionName);
|
||||||
@@ -287,9 +266,7 @@ foreach ($aXMLForms as $xmlFormPath) {
|
|||||||
} //end foreach
|
} //end foreach
|
||||||
|
|
||||||
}
|
}
|
||||||
//die;
|
|
||||||
//g::pr($aEnglishLabel); die;
|
|
||||||
/*******************/
|
|
||||||
//
|
//
|
||||||
//$timer->setMarker('end xml files processed');
|
//$timer->setMarker('end xml files processed');
|
||||||
//$profiling = $timer->getProfiling();
|
//$profiling = $timer->getProfiling();
|
||||||
@@ -300,17 +277,10 @@ foreach ($aXMLForms as $xmlFormPath) {
|
|||||||
|
|
||||||
G::streamFile($sPOFile, true);
|
G::streamFile($sPOFile, true);
|
||||||
|
|
||||||
function getTextValue($arrayNode){
|
|
||||||
return isset($arrayNode['#text']) ? $arrayNode['#text']: (isset($arrayNode['#cdata-section']) ? $arrayNode['#cdata-section']: '');
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMatchDropdownOptionValue($name, $options){
|
function getMatchDropdownOptionValue($name, $options){
|
||||||
foreach($options as $option){
|
foreach($options as $option){
|
||||||
//echo $name .'=='. $option['name'];
|
|
||||||
//echo '----------------------------<br>';
|
|
||||||
if($name == $option['name']){
|
if($name == $option['name']){
|
||||||
//echo '[[[[['.getTextValue($option).']]]]]';
|
return $option['__nodeText__'];
|
||||||
return getTextValue($option);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -75,7 +75,13 @@ try {
|
|||||||
|
|
||||||
$result->msg = G::LoadTranslation('IMPORT_LANGUAGE_SUCCESS') . "\n";
|
$result->msg = G::LoadTranslation('IMPORT_LANGUAGE_SUCCESS') . "\n";
|
||||||
$result->msg .= "PO File num. records: " . $importResults->recordsCount . "\n";
|
$result->msg .= "PO File num. records: " . $importResults->recordsCount . "\n";
|
||||||
$result->msg .= "Records registered successfully : " . $importResults->recordsCountSuccess . "\n";
|
$result->msg .= "Success Records: " . $importResults->recordsCountSuccess . "\n";
|
||||||
|
$result->msg .= "Failed Records: " . ($importResults->recordsCount-$importResults->recordsCountSuccess) . "\n";
|
||||||
|
|
||||||
|
if( $importResults->errMsg != '' ){
|
||||||
|
$result->msg .= "Errors registered: \n" . $importResults->errMsg . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
//$result->msg = htmlentities($result->msg);
|
//$result->msg = htmlentities($result->msg);
|
||||||
$result->success = true;
|
$result->success = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user