From 0bbede2d35a4f803037f64e3dff402b0741c1d2e Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Thu, 3 Aug 2017 16:10:59 -0400 Subject: [PATCH] HOR-3568 --- workflow/engine/bin/tasks/cliWorkspaces.php | 70 ++++++++++++++++----- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/workflow/engine/bin/tasks/cliWorkspaces.php b/workflow/engine/bin/tasks/cliWorkspaces.php index a7002f62a..56e94b189 100644 --- a/workflow/engine/bin/tasks/cliWorkspaces.php +++ b/workflow/engine/bin/tasks/cliWorkspaces.php @@ -162,6 +162,8 @@ CLI::taskDescription(<<xssFilterHard($opts); - $args = $filter->xssFilterHard($args); - $workspaces = get_workspaces_from_args($args); - $first = true; - foreach ($workspaces as $workspace) { - try { - G::outRes( "Upgrading translation for " . pakeColor::colorize($workspace->name, "INFO") . "\n" ); - $workspace->upgradeTranslation($first, $first); - $first = false; - } catch (Exception $e) { - G::outRes( "Errors upgrading translation of workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n" ); + $noXml = array_key_exists('noxml', $opts) ? '--no-xml' : ''; + $noMafe = array_key_exists('nomafe', $opts) ? '--no-mafe' : ''; + if (!empty($noXml)) { + $noMafe = ' ' . $noMafe; + } + //Check if the command is executed by a specific workspace + if (count($args) === 1) { + translation_upgrade($args, $opts); + } else { + $workspaces = get_workspaces_from_args($args); + foreach ($workspaces as $workspace) { + passthru('./processmaker translation-repair ' . $noXml . $noMafe . ' ' . $workspace->name); + } + } +} + +/** + * This function will regenerate the translation for a workspace + * This function is executed only for one workspace + * @param array $args, workspaceName that we will to apply the command + * @param array $opts, noxml and nomafe flags + * + * @return void + */ +function translation_upgrade($args, $opts) +{ + try { + //Load the attributes for the workspace + $arrayWorkspace = get_workspaces_from_args($args); + //Loop, read all the attributes related to the one workspace + $wsName = $arrayWorkspace[key($arrayWorkspace)]->name; + Bootstrap::setConstantsRelatedWs($wsName); + $workspaces = get_workspaces_from_args($args); + $flagUpdateXml = (!array_key_exists('noxml', $opts)); + $flagUpdateMafe = (!array_key_exists('nomafe', $opts)); + foreach ($workspaces as $workspace) { + try { + G::outRes("Upgrading translation for " . pakeColor::colorize($workspace->name, "INFO") . "\n"); + $workspace->upgradeTranslation($flagUpdateXml, $flagUpdateMafe); + } catch (Exception $e) { + G::outRes("Errors upgrading translation of workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"); + } + } + } catch (Exception $e) { + G::outRes(CLI::error($e->getMessage()) . "\n"); } - } } function run_cacheview_upgrade($args, $opts) {