Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection'); // Session Initializations ini_set('session.auto_start', '1'); // The register_globals feature has been DEPRECATED as of PHP 5.3.0. default value Off. // ini_set( 'register_globals', 'Off' ); //session_start(); ob_start(); // Rebuild the base Workflow translations if not exists if (!is_file(PATH_LANGUAGECONT . 'translation.en')) { require_once "classes/model/Translation.php"; $fields = Translation::generateFileTranslation('en'); } // TODO: Verify if the language set into url is defined in translations env. if (SYS_LANG != 'en' && !is_file(PATH_LANGUAGECONT . 'translation.' . SYS_LANG)) { require_once "classes/model/Translation.php"; $fields = Translation::generateFileTranslation(SYS_LANG); } // Setup plugins $oPluginRegistry->setupPlugins(); //get and setup enabled plugins $avoidChangedWorkspaceValidation = false; // Load custom Classes and Model from Plugins. G::LoadAllPluginModelClasses(); // jump to php file in methods directory $collectionPlugin = ''; if ($oPluginRegistry->isRegisteredFolder(SYS_COLLECTION)) { $phpFile = PATH_PLUGINS . SYS_COLLECTION . PATH_SEP . SYS_TARGET . '.php'; $targetPlugin = explode('/', SYS_TARGET); $collectionPlugin = $targetPlugin[0]; $avoidChangedWorkspaceValidation = true; } else {
* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ require_once "classes/model/Translation.php"; $t = new Translation(); $fields = Translation::generateFileTranslation('en'); $G_MAIN_MENU = 'tools'; $G_SUB_MENU = 'toolsTranslations'; $G_ID_MENU_SELECTED = 'TRANSLATION'; $G_ID_SUB_MENU_SELECTED = 'TRANSLATION_REBUILD'; $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'tools/updateTranslation', '', $fields); if (isset($_SESSION['TOOLS_VIEWTYPE']) && $_SESSION['TOOLS_VIEWTYPE'] == 'blank') { G::RenderPage('publishBlank', 'green-submenu'); } else { G::RenderPage('publish'); }
public function import($sLanguageFile, $updateXml = true, $updateDB = true, $generateMafe = true) { try { //get labels MichelangeloFE try { $oTranslation = new Translation(); $MichelangeloFE = PATH_HOME . "../workflow/public_html/lib/js"; if (file_exists($MichelangeloFE)) { $labels = self::readLabelsDirectory($MichelangeloFE, true); foreach ($labels as $label) { $oTranslation->addTranslation('LABEL', 'ID_MAFE_' . G::encryptOld($label), 'en', $label); } } } catch (Exception $e) { error_log($e->getMessage()); } G::LoadSystem('i18n_po'); $POFile = new i18n_PO($sLanguageFile); $POFile->readInit(); $POHeaders = $POFile->getHeaders(); /*getting the PO Language definition*/ $langName = $POHeaders['X-Poedit-Language']; //find the lang id $language = new Language(); $langRecord = $language->findByLanName($langName); if (!isset($langRecord['LAN_ID'])) { $langRecord = $language->findById($langName); if (!isset($langRecord['LAN_ID'])) { //if the language doesn't exist abort throw new Exception('The .po file has a invalid X-Poedit-Language definition!'); } } $languageID = $langRecord['LAN_ID']; /*getting the PO Language definition*/ $countryName = $POHeaders['X-Poedit-Country']; if ($countryName != '.') { $isoCountry = new IsoCountry(); $countryRecord = $isoCountry->findByIcName($countryName); if (!isset($countryRecord['IC_UID'])) { //if the language doesn't exist abort throw new Exception('The .po file has a invalid X-Poedit-Country definition!'); } $countryID = $countryRecord['IC_UID']; //define locale $LOCALE = "{$languageID}-{$countryID}"; } else { $LOCALE = $languageID; } $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) { $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 (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]; // it is a Sql insert on TRANSLATIONS TAble if ($identifier == 'TRANSLATION') { if ($updateDB) { list($category, $id) = explode('/', $context); $result = $oTranslation->addTranslation($category, $id, $LOCALE, trim(stripcslashes(str_replace(chr(10), '', $rowTranslation['msgstr'])))); if ($result['codError'] == 0) { $countItemsSuccess++; } else { $errorMsg .= $id . ': ' . $result['message'] . "\n"; } } } elseif ($updateXml) { $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_XMLFORM . $xmlForm)) { $errorMsg .= 'file doesn\'t exist: ' . PATH_XMLFORM . $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_XMLFORM . $xmlForm); $fieldName = $match[2]; $codes = explode('-', $reference); if (sizeof($codes) == 2) { //is a normal node $dynaform->addChilds($fieldName, array($LOCALE => 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($LOCALE => null), $childNode); } $countItemsSuccess++; } } $oLanguage = new Language(); $oLanguage->update(array('LAN_ID' => $languageID, 'LAN_ENABLED' => '1')); if ($updateXml) { $trn = new Translation(); $trn->generateFileTranslation($LOCALE); $trn->addTranslationEnvironment($LOCALE, $POHeaders, $countItemsSuccess); } if ($generateMafe) { $trn = new Translation(); $trn->generateFileTranslationMafe(); } //fill the results $results = new stdClass(); $results->recordsCount = $countItems; $results->recordsCountSuccess = $countItemsSuccess; $results->lang = $languageID; $results->headers = $POHeaders; $results->errMsg = $errorMsg; G::auditLog("UploadLanguage", "Language: " . $languageID); return $results; } catch (Exception $oError) { throw $oError; } }
public function rebuild() { try { $t = new Translation(); $result = Translation::generateFileTranslation('en'); $result['success'] = true; } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } print G::json_encode($result); }
function rebuild() { try { require_once "classes/model/Translation.php"; $t = new Translation(); $result = Translation::generateFileTranslation('en'); $result['success'] = true; } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } print G::json_encode($result); }
$pathFile = $filter->validateInput(PATH_CLASSES . "model" . PATH_SEP . "Translation.php", "path"); require_once ($pathFile); $pmTranslation = new Translation(); $fields = $pmTranslation->generateFileTranslation("en"); } // TODO: Verify if the language set into url is defined in translations env. if (SYS_LANG != 'en' && ! is_file( PATH_LANGUAGECONT . 'translation.' . SYS_LANG )) { $pathFile = $filter->validateInput(PATH_CLASSES . "model" . PATH_SEP . "Translation.php", "path"); require_once ($pathFile); $pmTranslation = new Translation(); $fields = $pmTranslation->generateFileTranslation(SYS_LANG); } // Setup plugins $oPluginRegistry->setupPlugins(); //get and setup enabled plugins $avoidChangedWorkspaceValidation = false; // Load custom Classes and Model from Plugins. Bootstrap::LoadAllPluginModelClasses(); // jump to php file in methods directory $collectionPlugin = ''; if ($oPluginRegistry->isRegisteredFolder( SYS_COLLECTION )) { $phpFile = PATH_PLUGINS . SYS_COLLECTION . PATH_SEP . SYS_TARGET . '.php'; $targetPlugin = explode( '/', SYS_TARGET ); $collectionPlugin = $targetPlugin[0];
return; } if ($query->count() > 1) { echo "The {$cat}:{$node}:{$lang} in table '{$table}' is not unique"; return; } $res = $query->read(); echo htmlspecialchars($res['TRN_VALUE']); break; break; } G::LoadClass("translation"); $dbc = new DBConnection(); $obj = new Translation(); $obj->SetTo($dbc); $translation2 = $obj->generateFileTranslation(); break; case "listLanguage": $query = $ses->execute("select distinct TRN_LANG from {$table}", false); $template = new TemplatePower(PATH_CORE . 'templates/tools/translationsTP.html'); $template->prepare(); $template->newBlock("languageList"); $template->assign("ajaxDelLang", ajax_event("onclick", "translationsAjax", "showSpace", "'function=delLanguage&lang='+encodeURI(getElementById('language').value)", 'hideLangBar')); for ($r = 1; $r <= $query->count(); $r++) { $res = $query->read(); $template->newBlock("languageItem"); $template->assign("langIdRadio", $res['TRN_LANG']); } $template->printToScreen(); break; case "show":