From e3213357902c7ab3facacc3af5391c218e24490f Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Tue, 12 Mar 2013 16:44:17 -0400 Subject: [PATCH 1/6] Improvement options to processmaker - Add plugins-translation-update - Add plugins-translation-create --- workflow/engine/bin/tasks/cliPlugins.php | 85 ++++++ workflow/engine/classes/model/Language.php | 261 ++++++++++++++++++ workflow/engine/classes/model/Translation.php | 75 +++++ 3 files changed, 421 insertions(+) create mode 100644 workflow/engine/bin/tasks/cliPlugins.php diff --git a/workflow/engine/bin/tasks/cliPlugins.php b/workflow/engine/bin/tasks/cliPlugins.php new file mode 100644 index 000000000..f94e1bdce --- /dev/null +++ b/workflow/engine/bin/tasks/cliPlugins.php @@ -0,0 +1,85 @@ +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + * @package workflow-engine-bin-tasks + */ + +G::LoadClass("system"); +G::LoadClass("wsTools"); + +//------------------------------------------------------------------------------------------- +CLI::taskName('plugins-translation-update'); +CLI::taskDescription(<<createLanguagePlugin($command[0], $command[1]); + CLI::logging("Creating successful\n"); + +} + +function run_update($command, $args) +{ + CLI::logging("Updating...\n"); + + $language = new Language(); + $language->updateLanguagePlugin($command[0], $command[1]); + CLI::logging("Update successful\n"); + +} diff --git a/workflow/engine/classes/model/Language.php b/workflow/engine/classes/model/Language.php index c2f7427d1..ec718d196 100755 --- a/workflow/engine/classes/model/Language.php +++ b/workflow/engine/classes/model/Language.php @@ -541,6 +541,267 @@ class Language extends BaseLanguage } G::streamFile( $sPOFile, true ); } + function updateLanguagePlugin ($plugin, $idLanguage) + { + if (!file_exists(PATH_PLUGINS . $plugin)) { + throw new Exception( 'The plugin ' . $plugin . ' not exist' ); + die(); + } + if (!file_exists(PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po')) { + throw new Exception( 'The not exist the file ' . $plugin . '.' . $idLanguage . '.po' ); + die(); + } + $languageFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po' ;//PATH_LANGUAGECONT . $plugin . '.' . $idLanguage; + try { + G::LoadSystem( 'i18n_po' ); + $POFile = new i18n_PO( $languageFile ); + $POFile->readInit(); + $POHeaders = $POFile->getHeaders(); + + $oTranslation = new Translation(); + $countItems = 0; + $countItemsSuccess = 0; + $errorMsg = ''; + + while ($rowTranslation = $POFile->getTranslation()) { + $countItems ++; + if (! isset( $POFile->translatorComments[0] ) || ! isset( $POFile->translatorComments[1] ) || ! isset( $POFile->references[0] )) { + throw new Exception( 'The .po file doesn\'t have valid directives for Processmaker!' ); + } + + foreach ($POFile->translatorComments as $a => $aux) { + $identifier = ''; + $context = ''; + $aux = trim( $aux ); + if ($aux == 'TRANSLATION') { + $identifier = $aux; + } else { + $var = explode( '/', $aux ); + if ($var[0] == 'LABEL') { + $context = $aux; + } + if ($var[0] == 'JAVASCRIPT') { + $context = $aux; + } + } + if ($identifier == '' && $context == '') { + $context = $aux; + } + if (preg_match( '/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml\?)/', $aux, $match )) { + $identifier = $aux; + } else { + if (preg_match( '/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml$)/', $aux, $match )) { + $context = $aux; + } + } + } + + $reference = $POFile->references[0]; + + if ($identifier != 'TRANSLATION') { + $xmlForm = $context; + //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 ); + + if (! file_exists( PATH_PLUGINS . $plugin . PATH_SEP . $xmlForm )) { + $errorMsg .= 'file doesn\'t exist: ' . PATH_PLUGINS . $plugin . $xmlForm . "\n"; + continue; + } + + if (count( $match ) < 4) { + $near = isset( $rowTranslation['msgid'] ) ? $rowTranslation['msgid'] : (isset( $rowTranslation['msgstr'] ) ? $rowTranslation['msgstr'] : ''); + $errorMsg .= "Invalid Translation reference: \"$reference\", near -> " . strip_tags($near) . "\n"; + continue; + } + + G::LoadSystem( 'dynaformhandler' ); + $dynaform = new dynaFormHandler( PATH_PLUGINS . $plugin . PATH_SEP . $xmlForm ); + $fieldName = $match[2]; + + $codes = explode( '-', $reference ); + + if (sizeof( $codes ) == 2) { + //is a normal node + $dynaform->addChilds( $fieldName, Array ($idLanguage => stripcslashes( str_replace( chr( 10 ), '', $rowTranslation['msgstr'] ) ) + ) ); + } elseif (sizeof( $codes ) > 2) { + //is a node child for a language node + $name = $match[3] == "''" ? '' : $match[3]; + $childNode = Array ( + Array ('name' => 'option','value' => $rowTranslation['msgstr'],'attributes' => + Array ('name' => $name) + ) + ); + + $dynaform->addChilds( $fieldName, Array ($idLanguage => null + ), $childNode ); + } + $countItemsSuccess ++; + } + } + + $trn = new Translation(); + $trn->generateFileTranslationPlugin( $plugin, $idLanguage ); + $trn->addTranslationEnvironmentPlugins( $plugin, $idLanguage, $POHeaders, $countItemsSuccess ); + + //fill the results + $results = new stdClass(); + $results->recordsCount = $countItems; + $results->recordsCountSuccess = $countItemsSuccess; + $results->lang = $languageID; + $results->headers = $POHeaders; + $results->errMsg = $errorMsg; + + return $results; + } catch (Exception $oError) { + throw ($oError); + } + } + + function createLanguagePlugin ($plugin, $idLanguage) + { + G::LoadSystem( 'i18n_po' ); + G::LoadClass( "system" ); + + //creating the .po file + //$sPOFile = PATH_LANGUAGECONT . $plugin . '.' . $idLanguage . '.po'; + $sPOFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po'; + $poFile = new i18n_PO( $sPOFile ); + $poFile->buildInit(); + + $language = new Language(); + + $locale = $language; + $_TARGET_LANG = $idLanguage; + $_BASE_LANG = 'en'; + + //setting headers + $poFile->addHeader( 'Project-Id-Version', $plugin ); + $poFile->addHeader( 'POT-Creation-Date', '' ); + $poFile->addHeader( 'PO-Revision-Date', date( 'Y-m-d H:i:s' ) ); + $poFile->addHeader( 'Last-Translator', '' ); + $poFile->addHeader( 'Language-Team', 'Colosa Developers Team ' ); + $poFile->addHeader( 'MIME-Version', '1.0' ); + $poFile->addHeader( 'Content-Type', 'text/plain; charset=utf-8' ); + $poFile->addHeader( 'Content-Transfer_Encoding', '8bit' ); + $poFile->addHeader( 'X-Poedit-Language', ucwords( $idLanguage ) ); + $poFile->addHeader( 'X-Poedit-SourceCharset', 'utf-8' ); + $poFile->addHeader( 'Content-Transfer-Encoding', '8bit' ); + + $aLabels = array (); + $aMsgids = array ('' => true + ); + //global $translations; + include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translation.php'; + + foreach ($translations as $id => $translation) { + $msgid = trim( $translation); + $msgstr = trim( $translation ); + $poFile->addTranslatorComment( 'TRANSLATION' ); + $poFile->addTranslatorComment( 'LABEL/' . $id ); + $poFile->addReference( 'LABEL/'. $id ); + + $poFile->addTranslation( stripcslashes( $msgid ), stripcslashes( $msgstr ) ); + $aMsgids[$msgid] = true; + } + + //now find labels in xmlforms + $aExceptionFields = array ('','javascript','hidden','phpvariable','private','toolbar','xmlmenu','toolbutton','cellmark','grid','CheckboxTable' + ); + $aXMLForms = glob( PATH_PLUGINS . $plugin . PATH_SEP . '*.xml' ); + $aXMLForms2 = glob( PATH_PLUGINS . $plugin . PATH_SEP . '*/*.xml' ); + $aXMLForms = array_merge( $aXMLForms, $aXMLForms2 ); + $aXMLForms3 = glob( PATH_PLUGINS . $plugin . PATH_SEP . '*/*/*.xml' ); + $aXMLForms = array_merge( $aXMLForms, $aXMLForms3 ); + $aEnglishLabel = array (); + $aOptions = array (); + $nodesNames = Array (); + + G::loadSystem( 'dynaformhandler' ); + + foreach ($aXMLForms as $xmlFormPath) { + $xmlFormFile = str_replace( chr( 92 ), '/', $xmlFormPath ); + $xmlFormFile = str_replace( PATH_PLUGINS . $plugin . PATH_SEP , '', $xmlFormPath ); + $dynaForm = new dynaFormHandler( $xmlFormPath ); + $dynaNodes = $dynaForm->getFields(); + //get all fields of each xmlform + foreach ($dynaNodes as $oNode) { + $sNodeName = $oNode->nodeName; + $arrayNode = $dynaForm->getArray( $oNode ); + //if has not native language translation + if (! isset( $arrayNode[$_BASE_LANG] ) || ! isset( $arrayNode['type'] ) || (isset( $arrayNode['type'] ) && in_array( $arrayNode['type'], $aExceptionFields ))) { + continue; //just continue with the next node + } + // Getting the Base Origin Text + if (! is_array( $arrayNode[$_BASE_LANG] )) { + $originNodeText = trim( $arrayNode[$_BASE_LANG] ); + } else { + $langNode = $arrayNode[$_BASE_LANG][0]; + $originNodeText = $langNode['__nodeText__']; + } + // Getting the Base Target Text + if (isset( $arrayNode[$_TARGET_LANG] )) { + if (! is_array( $arrayNode[$_TARGET_LANG] )) { + $targetNodeText = trim( $arrayNode[$_TARGET_LANG] ); + } else { + $langNode = $arrayNode[$_TARGET_LANG][0]; + $targetNodeText = $langNode['__nodeText__']; + } + } else { + $targetNodeText = $originNodeText; + } + $nodeName = $arrayNode['__nodeName__']; + $nodeType = $arrayNode['type']; + $msgid = $originNodeText; + // if the nodeName already exists in the po file, we need to create other msgid + if (isset( $aMsgids[$msgid] )) { + $msgid = '[' . $xmlFormFile . '?' . $nodeName . '] ' . $originNodeText; + } + $poFile->addTranslatorComment( $xmlFormFile . '?' . $nodeName ); + $poFile->addTranslatorComment( $xmlFormFile ); + $poFile->addReference( $nodeType . ' - ' . $nodeName ); + $poFile->addTranslation( stripslashes( $msgid ), stripslashes( $targetNodeText ) ); + + $aMsgids[$msgid] = true; + //if this node has options child nodes + if (isset( $arrayNode[$_BASE_LANG] ) && isset( $arrayNode[$_BASE_LANG][0] ) && isset( $arrayNode[$_BASE_LANG][0]['option'] )) { + $originOptionNode = $arrayNode[$_BASE_LANG][0]['option']; //get the options + $targetOptionExists = false; + if (isset( $arrayNode[$_TARGET_LANG] ) && isset( $arrayNode[$_TARGET_LANG][0] ) && isset( $arrayNode[$_TARGET_LANG][0]['option'] )) { + $targetOptionNode = $arrayNode[$_TARGET_LANG][0]['option']; + $targetOptionExists = true; + } + if (! is_array( $originOptionNode )) { + if (is_string( $originOptionNode )) { + $poFile->addTranslatorComment( $xmlFormFile . '?' . $nodeName . '-' . $originOptionNode ); + $poFile->addTranslatorComment( $xmlFormFile ); + $poFile->addReference( $nodeType . ' - ' . $nodeName . ' - ' . $originOptionNode ); + $poFile->addTranslation( stripslashes( $msgid ), stripslashes( $originOptionNode ) ); + } + } else { + foreach ($originOptionNode as $optionNode) { + $optionName = $optionNode['name']; + $originOptionValue = $optionNode['__nodeText__']; + if ($targetOptionExists) { + $targetOptionValue = getMatchDropdownOptionValue( $optionName, $targetOptionNode ); + if ($targetOptionValue === false) { + $targetOptionValue = $originOptionValue; + } + } else { + $targetOptionValue = $originOptionValue; + } + $msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']'; + $poFile->addTranslatorComment( $xmlFormFile . '?' . $nodeName . '-' . $optionName ); + $poFile->addTranslatorComment( $xmlFormFile ); + $poFile->addReference( $nodeType . ' - ' . $nodeName . ' - ' . $optionName ); + $poFile->addTranslation( $msgid, stripslashes( $targetOptionValue ) ); + } + } + } + } //end foreach + } + //G::streamFile( $sPOFile, true ); + } } // Language diff --git a/workflow/engine/classes/model/Translation.php b/workflow/engine/classes/model/Translation.php index ea9b82719..96be1469d 100755 --- a/workflow/engine/classes/model/Translation.php +++ b/workflow/engine/classes/model/Translation.php @@ -225,6 +225,81 @@ class Translation extends BaseTranslation //to do: uniform coderror structures for all classes } + /* Load strings from plugin translation.php . + * @parameter $languageId (es|en|...). + */ + public function generateFileTranslationPlugin ($plugin, $languageId = '') + { + $translation = Array (); + $translationJS = Array (); + + if ($languageId === '') { + $languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; + } + global $translations; + include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translation.php'; + + $cacheFile = PATH_LANGUAGECONT . $plugin . "." . $languageId; + $cacheFileJS = PATH_CORE . 'js' . PATH_SEP . 'labels' . PATH_SEP . $languageId . ".js"; + + foreach ($translations as $key => $row) { + $translation[$key] = $row; + } + + try { + if (! is_dir( dirname( $cacheFile ) )) { + G::mk_dir( dirname( $cacheFile ) ); + } + if (! is_dir( dirname( $cacheFileJS ) )) { + G::mk_dir( dirname( $cacheFileJS ) ); + } + $f = fopen( $cacheFile, 'w+' ); + fwrite( $f, "" ); + fclose( $f ); + + $f = fopen( $cacheFileJS, 'w' ); + fwrite( $f, "var G_STRINGS =" . Bootstrap::json_encode( $translationJS ) . ";\n" ); + fclose( $f ); + + $res['cacheFile'] = $cacheFile; + $res['cacheFileJS'] = $cacheFileJS; + $res['rows'] = count( $translation ); + $res['rowsJS'] = count( $translationJS ); + return $res; + } catch (Exception $e) { + echo $e->getMessage(); + } + } + + public function addTranslationEnvironmentPlugins ($plugin, $locale, $headers, $numRecords) + { + $filePath = PATH_DATA . "META-INF" . PATH_SEP . $plugin . ".env"; + $environments = Array (); + + if (file_exists( $filePath )) { + $environments = unserialize( file_get_contents( $filePath ) ); + } + + $environment['LOCALE'] = $locale; + $environment['HEADERS'] = $headers; + $environment['DATE'] = date( 'Y-m-d H:i:s' ); + $environment['NUM_RECORDS'] = $numRecords; + $environment['LANGUAGE'] = $headers['X-Poedit-Language']; + + if (strpos( $locale, self::$localeSeparator ) !== false) { + list ($environment['LAN_ID'], $environment['IC_UID']) = explode( self::$localeSeparator, strtoupper( $locale ) ); + $environments[$environment['LAN_ID']][$environment['IC_UID']] = $environment; + } else { + $environment['LAN_ID'] = strtoupper( $locale ); + $environment['IC_UID'] = ''; + $environments[$locale]['__INTERNATIONAL__'] = $environment; + } + + file_put_contents( $filePath, serialize( $environments ) ); + } + public function remove ($sCategory, $sId, $sLang) { $oTranslation = TranslationPeer::retrieveByPK( $sCategory, $sId, $sLang ); From 109d7a1e21c9275717a1edf89fc02b7138da30b5 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Tue, 12 Mar 2013 16:51:08 -0400 Subject: [PATCH 2/6] Improvement options of processmaker - Add plugins-translation-update - Add plugins-translation-create --- workflow/engine/bin/tasks/cliPlugins.php | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/workflow/engine/bin/tasks/cliPlugins.php b/workflow/engine/bin/tasks/cliPlugins.php index f94e1bdce..8ba6ca975 100644 --- a/workflow/engine/bin/tasks/cliPlugins.php +++ b/workflow/engine/bin/tasks/cliPlugins.php @@ -27,43 +27,27 @@ G::LoadClass("system"); G::LoadClass("wsTools"); -//------------------------------------------------------------------------------------------- CLI::taskName('plugins-translation-update'); CLI::taskDescription(<< Date: Wed, 13 Mar 2013 12:34:23 -0400 Subject: [PATCH 3/6] Improvement add options processmaker - Add plugins-translation-create. - Add plugins-translation-update --- workflow/engine/bin/tasks/cliPlugins.php | 8 ++-- workflow/engine/classes/model/Language.php | 44 +++++++------------ workflow/engine/classes/model/Translation.php | 5 +-- 3 files changed, 23 insertions(+), 34 deletions(-) diff --git a/workflow/engine/bin/tasks/cliPlugins.php b/workflow/engine/bin/tasks/cliPlugins.php index 8ba6ca975..139fe001d 100644 --- a/workflow/engine/bin/tasks/cliPlugins.php +++ b/workflow/engine/bin/tasks/cliPlugins.php @@ -29,7 +29,7 @@ G::LoadClass("wsTools"); CLI::taskName('plugins-translation-update'); CLI::taskDescription(<<createLanguagePlugin($command[0], $command[1]); - CLI::logging("Creating successful\n"); + CLI::logging("Create successful\n"); } diff --git a/workflow/engine/classes/model/Language.php b/workflow/engine/classes/model/Language.php index ec718d196..c139f0a46 100755 --- a/workflow/engine/classes/model/Language.php +++ b/workflow/engine/classes/model/Language.php @@ -44,6 +44,7 @@ */ class Language extends BaseLanguage { + private $exceptionFields = array ('','javascript','hidden','phpvariable','private','toolbar','xmlmenu','toolbutton','cellmark','grid','CheckboxTable'); public function load ($sLanUid) { @@ -423,11 +424,6 @@ class Language extends BaseLanguage //$timer->setMarker('end making 1th .po from db'); - - //now find labels in xmlforms - $aExceptionFields = array ('','javascript','hidden','phpvariable','private','toolbar','xmlmenu','toolbutton','cellmark','grid','CheckboxTable' - ); - //find all xml files into PATH_XMLFORM $aXMLForms = glob( PATH_XMLFORM . '*/*.xml' ); //from a sublevel to @@ -455,7 +451,7 @@ class Language extends BaseLanguage //$arrayNode = $dynaForm->getArray($oNode, Array('type', $_BASE_LANG, $_BASE_LANG)); $arrayNode = $dynaForm->getArray( $oNode ); //if has not native language translation - if (! isset( $arrayNode[$_BASE_LANG] ) || ! isset( $arrayNode['type'] ) || (isset( $arrayNode['type'] ) && in_array( $arrayNode['type'], $aExceptionFields ))) { + if (! isset( $arrayNode[$_BASE_LANG] ) || ! isset( $arrayNode['type'] ) || (isset( $arrayNode['type'] ) && in_array( $arrayNode['type'], $this->exceptionFields ))) { continue; //just continue with the next node } @@ -548,7 +544,7 @@ class Language extends BaseLanguage die(); } if (!file_exists(PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po')) { - throw new Exception( 'The not exist the file ' . $plugin . '.' . $idLanguage . '.po' ); + throw new Exception( 'The file ' . $plugin . '.' . $idLanguage . '.po not exists' ); die(); } $languageFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po' ;//PATH_LANGUAGECONT . $plugin . '.' . $idLanguage; @@ -664,7 +660,6 @@ class Language extends BaseLanguage G::LoadClass( "system" ); //creating the .po file - //$sPOFile = PATH_LANGUAGECONT . $plugin . '.' . $idLanguage . '.po'; $sPOFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po'; $poFile = new i18n_PO( $sPOFile ); $poFile->buildInit(); @@ -672,8 +667,8 @@ class Language extends BaseLanguage $language = new Language(); $locale = $language; - $_TARGET_LANG = $idLanguage; - $_BASE_LANG = 'en'; + $targetLang = $idLanguage; + $baseLang = 'en'; //setting headers $poFile->addHeader( 'Project-Id-Version', $plugin ); @@ -691,7 +686,6 @@ class Language extends BaseLanguage $aLabels = array (); $aMsgids = array ('' => true ); - //global $translations; include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translation.php'; foreach ($translations as $id => $translation) { @@ -705,9 +699,6 @@ class Language extends BaseLanguage $aMsgids[$msgid] = true; } - //now find labels in xmlforms - $aExceptionFields = array ('','javascript','hidden','phpvariable','private','toolbar','xmlmenu','toolbutton','cellmark','grid','CheckboxTable' - ); $aXMLForms = glob( PATH_PLUGINS . $plugin . PATH_SEP . '*.xml' ); $aXMLForms2 = glob( PATH_PLUGINS . $plugin . PATH_SEP . '*/*.xml' ); $aXMLForms = array_merge( $aXMLForms, $aXMLForms2 ); @@ -729,22 +720,22 @@ class Language extends BaseLanguage $sNodeName = $oNode->nodeName; $arrayNode = $dynaForm->getArray( $oNode ); //if has not native language translation - if (! isset( $arrayNode[$_BASE_LANG] ) || ! isset( $arrayNode['type'] ) || (isset( $arrayNode['type'] ) && in_array( $arrayNode['type'], $aExceptionFields ))) { + if (! isset( $arrayNode[$baseLang] ) || ! isset( $arrayNode['type'] ) || (isset( $arrayNode['type'] ) && in_array( $arrayNode['type'], $this->exceptionFields ))) { continue; //just continue with the next node } // Getting the Base Origin Text - if (! is_array( $arrayNode[$_BASE_LANG] )) { - $originNodeText = trim( $arrayNode[$_BASE_LANG] ); + if (! is_array( $arrayNode[$baseLang] )) { + $originNodeText = trim( $arrayNode[$baseLang] ); } else { - $langNode = $arrayNode[$_BASE_LANG][0]; + $langNode = $arrayNode[$baseLang][0]; $originNodeText = $langNode['__nodeText__']; } // Getting the Base Target Text - if (isset( $arrayNode[$_TARGET_LANG] )) { - if (! is_array( $arrayNode[$_TARGET_LANG] )) { - $targetNodeText = trim( $arrayNode[$_TARGET_LANG] ); + if (isset( $arrayNode[$targetLang] )) { + if (! is_array( $arrayNode[$targetLang] )) { + $targetNodeText = trim( $arrayNode[$targetLang] ); } else { - $langNode = $arrayNode[$_TARGET_LANG][0]; + $langNode = $arrayNode[$targetLang][0]; $targetNodeText = $langNode['__nodeText__']; } } else { @@ -764,11 +755,11 @@ class Language extends BaseLanguage $aMsgids[$msgid] = true; //if this node has options child nodes - if (isset( $arrayNode[$_BASE_LANG] ) && isset( $arrayNode[$_BASE_LANG][0] ) && isset( $arrayNode[$_BASE_LANG][0]['option'] )) { - $originOptionNode = $arrayNode[$_BASE_LANG][0]['option']; //get the options + if (isset( $arrayNode[$baseLang] ) && isset( $arrayNode[$baseLang][0] ) && isset( $arrayNode[$baseLang][0]['option'] )) { + $originOptionNode = $arrayNode[$baseLang][0]['option']; //get the options $targetOptionExists = false; - if (isset( $arrayNode[$_TARGET_LANG] ) && isset( $arrayNode[$_TARGET_LANG][0] ) && isset( $arrayNode[$_TARGET_LANG][0]['option'] )) { - $targetOptionNode = $arrayNode[$_TARGET_LANG][0]['option']; + if (isset( $arrayNode[$targetLang] ) && isset( $arrayNode[$targetLang][0] ) && isset( $arrayNode[$targetLang][0]['option'] )) { + $targetOptionNode = $arrayNode[$targetLang][0]['option']; $targetOptionExists = true; } if (! is_array( $originOptionNode )) { @@ -800,7 +791,6 @@ class Language extends BaseLanguage } } //end foreach } - //G::streamFile( $sPOFile, true ); } } // Language diff --git a/workflow/engine/classes/model/Translation.php b/workflow/engine/classes/model/Translation.php index 96be1469d..65e39c8f1 100755 --- a/workflow/engine/classes/model/Translation.php +++ b/workflow/engine/classes/model/Translation.php @@ -225,7 +225,7 @@ class Translation extends BaseTranslation //to do: uniform coderror structures for all classes } - /* Load strings from plugin translation.php . + /* Load strings from plugin translation.php. * @parameter $languageId (es|en|...). */ public function generateFileTranslationPlugin ($plugin, $languageId = '') @@ -236,7 +236,6 @@ class Translation extends BaseTranslation if ($languageId === '') { $languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; } - global $translations; include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translation.php'; $cacheFile = PATH_LANGUAGECONT . $plugin . "." . $languageId; @@ -255,7 +254,7 @@ class Translation extends BaseTranslation } $f = fopen( $cacheFile, 'w+' ); fwrite( $f, "" ); fclose( $f ); From f7a5cfd05dfc441bd78290efa5dcd065ebb481a6 Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Wed, 13 Mar 2013 17:33:12 -0400 Subject: [PATCH 4/6] Improvement in the pdf generation with TCPDF --- workflow/engine/classes/model/OutputDocument.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/workflow/engine/classes/model/OutputDocument.php b/workflow/engine/classes/model/OutputDocument.php index cc372f1ea..d4b1468ae 100755 --- a/workflow/engine/classes/model/OutputDocument.php +++ b/workflow/engine/classes/model/OutputDocument.php @@ -882,6 +882,9 @@ class OutputDocument extends BaseOutputDocument // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. //$pdf->SetFont('dejavusans', '', 14, '', true); + if (preg_match('/[\x{30FF}\x{3040}-\x{309F}\x{4E00}-\x{9FFF}\x{0E00}-\x{0E7F}]/u', $sContent, $matches)) {// Detect chinese, japanese, thai + $pdf->SetFont('kozminproregular'); + } // Add a page // This method has several options, check the source code documentation for more information. @@ -893,10 +896,11 @@ class OutputDocument extends BaseOutputDocument // Print text using writeHTMLCell() // $pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true); if (mb_detect_encoding($sContent) == 'UTF-8') { - $sContent = utf8_decode($sContent); + $sContent = mb_convert_encoding($sContent, 'HTML-ENTITIES', 'UTF-8'); } $doc = new DOMDocument('1.0', 'UTF-8'); $doc->loadHtml($sContent); + $doc->encoding='UTF-8'; $pdf->writeHTML($doc->saveXML(), false, false, false, false, ''); // --------------------------------------------------------- From c73f8f3a2de491475cc27712f2e583134df2dadf Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Wed, 13 Mar 2013 17:50:48 -0400 Subject: [PATCH 5/6] BUG 11007 Error al cambiar la configuracion del evento en Action SOLVED - Inmediatly after create a proces and create a event, dbarray filled incorrectly - Fill dbarray correctly the first time --- workflow/engine/methods/events/eventsEdit.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/workflow/engine/methods/events/eventsEdit.php b/workflow/engine/methods/events/eventsEdit.php index 5454afc8b..564b40429 100755 --- a/workflow/engine/methods/events/eventsEdit.php +++ b/workflow/engine/methods/events/eventsEdit.php @@ -58,7 +58,8 @@ foreach ($aAux1 as $aAux2) { $oProcessMap = new processMap( new DBConnection() ); $aTriggersList = $oProcessMap->getTriggers( $_SESSION['PROCESS'] ); -$aTriggersFileds = Array ('TRI_UID' => 'char','TRI_TITLE' => 'char'); +$aTriggersFileds = array (); +$aTriggersFileds[] = array ('TRI_UID' => 'char','TRI_TITLE' => 'char'); foreach ($aTriggersList as $i => $v) { unset( $aTriggersList[$i]['PRO_UID'] ); From c74b4a0b54e01e19cc79f5f785c11c65b1e12e98 Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Wed, 13 Mar 2013 18:14:14 -0400 Subject: [PATCH 6/6] BUG 10829 Paginacion en documents no muetsra documentos en la pagina siguiente SOLVED - Recargas sucesivas del grid de documentos y seteandose a root. - Validation documents grid when resized --- .../engine/templates/cases/casesDocuments.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/workflow/engine/templates/cases/casesDocuments.js b/workflow/engine/templates/cases/casesDocuments.js index fefb29a5b..1c201a22f 100755 --- a/workflow/engine/templates/cases/casesDocuments.js +++ b/workflow/engine/templates/cases/casesDocuments.js @@ -31,6 +31,7 @@ catch(z){ rc=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/; } +itemSelected = ""; var conn = new Ext.data.Connection(); streamFilefromPM=function(fileStream) { @@ -235,6 +236,7 @@ function expandNode( node, dir ) { function handleNodeClick( sm, node ) { if( node && node.id ) { // console.log("Node Clicked: "+node); + itemSelected = node.id; chDir( node.id ); } } @@ -840,13 +842,13 @@ datastore.paramNames["sort"] = "order"; datastore.on("beforeload", function(ds, options) { - options.params.dir = options.params.dir ? options.params.dir - : ds.directory; + options.params.dir = options.params.dir ? options.params.dir : ds.directory; options.params.node = options.params.dir ? options.params.dir : ds.directory; options.params.option = "gridDocuments"; options.params.action = "expandNode"; options.params.sendWhat = datastore.sendWhat; }); + datastore.on("loadexception", function(proxy, options, response, e) { try { @@ -1955,13 +1957,18 @@ var documentsTab = { // console.log("tree editor created"); // console.log("before the first chdir"); - chDir(''); + // chDir(''); + chDir(itemSelected); // console.log("starting locatiobar first time"); Ext.getCmp("locationbarcmp").tree = Ext.getCmp("dirTreePanel"); Ext.getCmp("locationbarcmp").initComponent(); - var node = dirTree.getNodeById("root"); + + if (itemSelected == "") { + itemSelected = "root"; + } + var node = dirTree.getNodeById(itemSelected); node.select(); - datastore.directory = 'root'; + datastore.directory = itemSelected; // console.log("location abr started first time"); }