From 652d9b45f7cb093eb8a252d3c72dff75ef623da2 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 3 Sep 2024 10:31:11 +0200
Subject: [PATCH] build page: replace hartcoded output text with language
 specific texts

---
 config/lang/de-de.json                     |  2 +
 config/lang/en-en.json                     |  2 +
 public_html/deployment/pages/act_build.php | 71 +++++++++++-----------
 3 files changed, 40 insertions(+), 35 deletions(-)

diff --git a/config/lang/de-de.json b/config/lang/de-de.json
index a3acebec..87765b90 100644
--- a/config/lang/de-de.json
+++ b/config/lang/de-de.json
@@ -177,6 +177,8 @@
     "page-build-reload-branches": "Branches neu laden",
     "page-build-branch-on-target": "Auf der Ziel-Phase ist Branch [%s] installiert.",
     "page-build-switch-to-target": "Setze [%s]",
+    "page-build-warning-version-exists": "Im der Queue f&uuml;r Phase [%s] ist die Version %s bereits vorhanden!",
+    "page-build-warning-version-is-installed": "Im der Phase [%s] ist die Version %s bereits vorhanden!",
     
     "page-cleanup-info-archives-deleted": "Folgende Verzeichnisse wurden gel&ouml;scht",
     "page-cleanup-info-archives-left": "Folgende Versionen sind derzeit vorhanden - mit Angabe, wo sie verwendet werden",
diff --git a/config/lang/en-en.json b/config/lang/en-en.json
index 6d53eaca..a909472a 100644
--- a/config/lang/en-en.json
+++ b/config/lang/en-en.json
@@ -178,6 +178,8 @@
     "page-build-branch-on-target": "On target phase the branch [%s] was installed.",
     "page-build-switch-to-target": "Set [%s]",
     "page-build-reload-branches": "Reload all branches",
+    "page-build-warning-version-exists": "In the queue of phase [%s] the version %s already exists!",
+    "page-build-warning-version-is-installed": "In the phase [%s] the version %s already exists!",
     
     "page-cleanup-info-archives-deleted": "The following directories have been deleted",
     "page-cleanup-info-archives-left": "This versions currently exist - with information of their usage",
diff --git a/public_html/deployment/pages/act_build.php b/public_html/deployment/pages/act_build.php
index 6d03699e..00c9cc94 100644
--- a/public_html/deployment/pages/act_build.php
+++ b/public_html/deployment/pages/act_build.php
@@ -27,7 +27,7 @@ if (array_key_exists("branchname", $aParams)) {
     $sBranchname = $aParams["branchname"];
     $oPrj->setBranchname($aParams["branchname"]);
 } else {
-    $sBranchname = $oPrj->getBranchname(true);
+    $sBranchname = $oPrj->getBranchname();
 }
 
 if (!array_key_exists("confirm", $aParams)) {
@@ -36,60 +36,60 @@ if (!array_key_exists("confirm", $aParams)) {
     // ------------------------------------------------------------
     $sNext = $oPrj->getNextPhase();
     $aPhaseData2 = $oPrj->getPhaseInfos($sNext);
-    $sBranchontarget=isset($aPhaseData2["ready2install"]["branch"]) ? $aPhaseData2["ready2install"]["branch"]: '';
+    $sBranchontarget = isset($aPhaseData2["ready2install"]["branch"]) ? $aPhaseData2["ready2install"]["branch"] : '';
     print_r($sBranchname);
     $bIgnoreCache = isset($aParams['reloadBranches']) ? $aParams['reloadBranches'] : false;
 
     // $sOut.='<p>Re-Read Branches (ignore caching) - '.($bIgnoreCache ? "JA" : "mein" ).'</p>';
 
-    $sOut.='<p>' . sprintf(t("page-build-info"), $sNext, $sNext) . '</p>';
+    $sOut .= '<p>' . sprintf(t("page-build-info"), $sNext, $sNext) . '</p>';
 
     $sRevison = false;
     $aRepodata = $oPrj->getRepoRevision(true);
     if (isset($aRepodata["revision"])) {
         $sRevison = $aRepodata["revision"];
         if (
-                array_key_exists("revision", $aPhaseData2["onhold"]) && $aPhaseData2["onhold"]["revision"] == $sRevison
+            array_key_exists("revision", $aPhaseData2["onhold"]) && $aPhaseData2["onhold"]["revision"] == $sRevison
         ) {
-            $sOut.=$oHtml->getBox("warning", "In der Queue von [$sNext] ist die Version bereits $sRevison vorhanden!");
+            $sOut .= $oHtml->getBox("warning", sprintf(t("page-build-warning-version-exists"), $sNext, $sRevison));
         }
         if (
-                array_key_exists("revision", $aPhaseData2["ready2install"]) && $aPhaseData2["ready2install"]["revision"] == $sRevison
+            array_key_exists("revision", $aPhaseData2["ready2install"]) && $aPhaseData2["ready2install"]["revision"] == $sRevison
         ) {
-            $sOut.=$oHtml->getBox("warning", "Im Repo von [$sNext] ist die Version $sRevison bereits vorhanden!");
+            $sOut .= $oHtml->getBox("warning", sprintf(t("page-build-warning-version-is-installed"), $sNext, $sRevison));
         }
     }
-    $sOut.='
+    $sOut .= '
         <table>
              <thead>
                  <tr>
-                     <th class="versioncontrol" colspan="3">' . $oHtml->getIcon('repository').t("versioncontrol") . '<br></th>
+                     <th class="versioncontrol" colspan="3">' . $oHtml->getIcon('repository') . t("versioncontrol") . '<br></th>
                      <th> </th>
-                     <th class="' . $sNext . '" colspan="2">' . $oHtml->getIcon('phase').$sNext . '</th>
+                     <th class="' . $sNext . '" colspan="2">' . $oHtml->getIcon('phase') . $sNext . '</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <td class="">
                          ' . $oPrj->renderSelectRemoteBranches(false, $bIgnoreCache) . '
-                         '.(
-                            $sBranchontarget && $sBranchontarget != $sBranchname
-                             ? '
+                         ' . (
+        $sBranchontarget && $sBranchontarget != $sBranchname
+        ? '
                              <form action="?" method="post" enctype="multipart/form-data">
                                  <input type="hidden" name="reloadBranches" value="1">
                                  <input type="hidden" name="branchname" value="' . $sBranchontarget . '">
-                                    '.sprintf(t('page-build-branch-on-target'), $sBranchontarget).'<br>
+                                    ' . sprintf(t('page-build-branch-on-target'), $sBranchontarget) . '<br>
                                      <button type="submit" class="btn btn-default">' . sprintf(t('page-build-switch-to-target'), $sBranchontarget) . '</button>
                              </form>
                              <br><hr>
                              '
-                             : ''
-                         ).'
+        : ''
+    ) . '
                           <form action="?" method="post" enctype="multipart/form-data">
                             <input type="hidden" name="reloadBranches" value="1">
                             <input type="hidden" name="branchname" value="' . $sBranchname . '">
                             <fieldset>
-                                <button type="submit" class="btn btn-default">' . $oHtml->getIcon('refresh').t("page-build-reload-branches") . '</button>
+                                <button type="submit" class="btn btn-default">' . $oHtml->getIcon('refresh') . t("page-build-reload-branches") . '</button>
                             </fieldset>
                         </form>
      
@@ -117,7 +117,7 @@ if (!array_key_exists("confirm", $aParams)) {
 
     // Eingabe Kommentare zum Deployment
     if ($sRevison) {
-        $sOut.='
+        $sOut .= '
                  <form action="?" method="post" enctype="multipart/form-data">
                     <input type="hidden" name="confirm" value="1">
                     <input type="hidden" name="branchname" value="' . $sBranchname . '">
@@ -125,20 +125,21 @@ if (!array_key_exists("confirm", $aParams)) {
                      <hr>
                     -->
                     <fieldset>
-                        '.aGoback().'
-                        <button type="submit" class="btn btn-large '.$sNext.'" >' . $oHtml->getIcon('build').sprintf(t("page-build-buttonlabel"), $sNext) . '</button>
+                        ' . aGoback() . '
+                        <button type="submit" class="btn btn-large ' . $sNext . '" >' . $oHtml->getIcon('build') . sprintf(t("page-build-buttonlabel"), $sNext) . '</button>
                     </fieldset>
                  </form>
                  ';
     }
-    $BODY=
+    $BODY =
         $renderAdminLTE->addRow(
             $renderAdminLTE->addCol(
                 $renderAdminLTE->getCard([
-                'type'=>'success',
-                'variant'=>'outline',
-                'text'=>$sOut,
-                ]), 12
+                    'type' => 'success',
+                    'variant' => 'outline',
+                    'text' => $sOut,
+                ]),
+                12
             )
         );
 
@@ -186,17 +187,17 @@ if (!array_key_exists("confirm", $aParams)) {
     $sAjaxFile = $aParams["prj"] . "_" . $aParams["action"];
     $sDivname = "outAjax";
     $sUrlStartAction = "/deployment/?"
-            . "&prj=" . $aParams["prj"]
-            . "&action=" . $aParams["action"]
-            . "&confirm=" . $aParams["confirm"]
-            . "&branchname=" . $aParams["branchname"]
-            . "&ajax=" . $sAjaxFile
-            . "&run=1"
+        . "&prj=" . $aParams["prj"]
+        . "&action=" . $aParams["action"]
+        . "&confirm=" . $aParams["confirm"]
+        . "&branchname=" . $aParams["branchname"]
+        . "&ajax=" . $sAjaxFile
+        . "&run=1"
     ;
-    $sUrlFile = "/webservice/getfile.php?". "&ajax=" . $sAjaxFile;
-    
-    $sOut.= '<div id="' . $sDivname . '"></div>'
-            . '<script>
+    $sUrlFile = "/webservice/getfile.php?" . "&ajax=" . $sAjaxFile;
+
+    $sOut .= '<div id="' . $sDivname . '"></div>'
+        . '<script>
                     var iRepeat=2000;
                     
                     // start build process
-- 
GitLab