From 0628da58499c6612c9d2cea74e2fa744fd68b997 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Tue, 3 Sep 2024 11:29:06 +0200 Subject: [PATCH] update all page files --- ...ollback.php => __unused__act_rollback.php} | 1 - public_html/deployment/pages/act_about.php | 71 ++-- public_html/deployment/pages/act_accept.php | 55 +-- public_html/deployment/pages/act_checkssh.php | 61 ++-- public_html/deployment/pages/act_cleanup.php | 1 - public_html/deployment/pages/act_delete.php | 72 ++-- public_html/deployment/pages/act_deploy.php | 41 ++- public_html/deployment/pages/act_doc.php | 63 ++-- public_html/deployment/pages/act_htmltest.php | 171 ++++----- public_html/deployment/pages/act_login.php | 152 ++++---- public_html/deployment/pages/act_overview.php | 106 +++--- public_html/deployment/pages/act_phase.php | 15 +- public_html/deployment/pages/act_setup.php | 343 +++++++++--------- .../deployment/pages/act_valuestore.php | 30 +- 14 files changed, 604 insertions(+), 578 deletions(-) rename public_html/deployment/pages/{act_rollback.php => __unused__act_rollback.php} (96%) diff --git a/public_html/deployment/pages/act_rollback.php b/public_html/deployment/pages/__unused__act_rollback.php similarity index 96% rename from public_html/deployment/pages/act_rollback.php rename to public_html/deployment/pages/__unused__act_rollback.php index e61539d8..d776bca8 100644 --- a/public_html/deployment/pages/act_rollback.php +++ b/public_html/deployment/pages/__unused__act_rollback.php @@ -116,4 +116,3 @@ if (array_key_exists("confirm", $aParams)) { // -- Ausgabe echo $sOut; -?> diff --git a/public_html/deployment/pages/act_about.php b/public_html/deployment/pages/act_about.php index 612929da..330c26a0 100644 --- a/public_html/deployment/pages/act_about.php +++ b/public_html/deployment/pages/act_about.php @@ -8,43 +8,46 @@ --------------------------------------------------------------------- 2023-12-19 Axel <axel.hahn@unibe.ch> + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ -$oHtml = new htmlguielements($sPrj); +$oHtml = new htmlguielements(); -$BODY= -$renderAdminLTE->addRow( - $renderAdminLTE->addCol( - $renderAdminLTE->getCard([ - 'type'=>'dark', - 'variant'=>'outline', - 'text'=>'<h3>IML CI server</h3>' - .$oHtml->getTable([ - 'body'=>[ - [t('page-about-version'), getVersioninfo()], - [t('page-about-author'), 'Institute for Medical Education * University of Bern'], - [t('page-about-license'), 'GNU GPL 3.0'], - [t('page-about-source'), '<a href="https://git-repo.iml.unibe.ch/iml-open-source/imldeployment/">https://git-repo.iml.unibe.ch/iml-open-source/imldeployment/</a>'], - [t('page-about-php'), phpversion()], - ] +$BODY = + $renderAdminLTE->addRow( + $renderAdminLTE->addCol( + $renderAdminLTE->getCard([ + 'type' => 'dark', + 'variant' => 'outline', + 'text' => '<h3>IML CI server</h3>' + . $oHtml->getTable([ + 'body' => [ + [t('page-about-version'), getVersioninfo()], + [t('page-about-author'), 'Institute for Medical Education * University of Bern'], + [t('page-about-license'), 'GNU GPL 3.0'], + [t('page-about-source'), '<a href="https://git-repo.iml.unibe.ch/iml-open-source/imldeployment/">https://git-repo.iml.unibe.ch/iml-open-source/imldeployment/</a>'], + [t('page-about-php'), phpversion()], + ] + ]), ]), - ]), 8 - ) - .$renderAdminLTE->addCol( - $renderAdminLTE->getCard([ - 'type'=>'dark', - 'variant'=>'outline', - 'text'=>'<h3>Components</h3>' - .$oHtml->getTable([ - 'body'=>[ - ['AdminLTE', '<a href="https://adminlte.io/">https://adminlte.io/</a>'], - ['jquery 3.6.1', '<a href="https://jquery.com/">https://jquery.com/</a>'], - ['font-awesome 6.4.0', '<a href="https://fontawesome.com/">https://fontawesome.com/</a>'], - ['visjs 4.21.0', '<a href="https://visjs.org">https://visjs.org</a>'], - ['winbox 0.2.82', '<a href="https://nextapps-de.github.io/winbox/">https://nextapps-de.github.io/winbox/</a>'], - ] + 8 + ) + . $renderAdminLTE->addCol( + $renderAdminLTE->getCard([ + 'type' => 'dark', + 'variant' => 'outline', + 'text' => '<h3>Components</h3>' + . $oHtml->getTable([ + 'body' => [ + ['AdminLTE', '<a href="https://adminlte.io/">https://adminlte.io/</a>'], + ['jquery 3.6.1', '<a href="https://jquery.com/">https://jquery.com/</a>'], + ['font-awesome 6.4.0', '<a href="https://fontawesome.com/">https://fontawesome.com/</a>'], + ['visjs 4.21.0', '<a href="https://visjs.org">https://visjs.org</a>'], + ['winbox 0.2.82', '<a href="https://nextapps-de.github.io/winbox/">https://nextapps-de.github.io/winbox/</a>'], + ] + ]), ]), - ]), 4 - ) -); + 4 + ) + ); diff --git a/public_html/deployment/pages/act_accept.php b/public_html/deployment/pages/act_accept.php index 67fe0384..1a0175e3 100644 --- a/public_html/deployment/pages/act_accept.php +++ b/public_html/deployment/pages/act_accept.php @@ -8,6 +8,8 @@ --------------------------------------------------------------------- 2013-11-08 Axel <axel.hahn@iml.unibe.ch> + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ require_once("./classes/project_gui.class.php"); @@ -21,13 +23,13 @@ if (array_key_exists("par3", $aParams)) { $sOut = ''; if (array_key_exists("confirm", $aParams)) { - $sOut.=$oPrj->accept($sPhase); + $sOut .= $oPrj->accept($sPhase); } else { if (!$sPhase) { - $sOut.=$oHtml->getBox("error", t("error-no-phase")); + $sOut .= $oHtml->getBox("error", t("error-no-phase")); } else { if (!$oPrj->canAcceptPhase($sPhase)) { - $sOut.= sprintf(t("page-accept-error-cannot-accept-phase"), $sPhase); + $sOut .= sprintf(t("page-accept-error-cannot-accept-phase"), $sPhase); } else { $aPhaseData = $oPrj->getPhaseInfos($sPhase); $aConfigPrj = $oPrj->getConfig(); @@ -37,16 +39,16 @@ if (array_key_exists("confirm", $aParams)) { $aPhaseData2 = $oPrj->getPhaseInfos($sNext); if ( - array_key_exists("revision", $aPhaseData2["onhold"]) && $aPhaseData2["onhold"]["revision"] == $aPhaseData["deployed"]["revision"] + array_key_exists("revision", $aPhaseData2["onhold"]) && $aPhaseData2["onhold"]["revision"] == $aPhaseData["deployed"]["revision"] ) { - $sOut.=$oHtml->getBox("warning", sprintf(t("page-accept-warning-version-exists-in-next-queue"), $sNext, $sPhase)); + $sOut .= $oHtml->getBox("warning", sprintf(t("page-accept-warning-version-exists-in-next-queue"), $sNext, $sPhase)); } if ( - array_key_exists("revision", $aPhaseData2["ready2install"]) && $aPhaseData2["ready2install"]["revision"] == $aPhaseData["deployed"]["revision"] + array_key_exists("revision", $aPhaseData2["ready2install"]) && $aPhaseData2["ready2install"]["revision"] == $aPhaseData["deployed"]["revision"] ) { - $sOut.=$oHtml->getBox("warning", sprintf(t("page-accept-warning-version-exists-in-next-repo"), $sNext, $sPhase)); + $sOut .= $oHtml->getBox("warning", sprintf(t("page-accept-warning-version-exists-in-next-repo"), $sNext, $sPhase)); } - $sOut.=' + $sOut .= ' <table> <thead> <tr> @@ -79,35 +81,36 @@ if (array_key_exists("confirm", $aParams)) { '; // Eingabe Kommentare zum Deployment - $sOut.=' + $sOut .= ' <hr> <p> ' . t("url") . ': <a href="' . $sUrl . '">' . $sUrl . '</a><br> ' . sprintf(t("page-accept-info"), $sPhase, $sPhase, $sNext, $sNext) . ' </p>'; - $sOut.=' + $sOut .= ' <form action="?" method="post" enctype="multipart/form-data"> <input type="hidden" name="confirm" value="1"> <fieldset> - '.aGoback() - // .$oPrj->renderLink('accept', $sPhase) - .'<button type="submit" class="btn btn-large '.$sNext.'" title="'.sprintf(t("accept-hint"), $sPhase, $sNext).'"' - .'>' . $oHtml->getIcon('accept') . sprintf(t("accept"), $sPhase, $sNext) . '</button>' - .' + ' . aGoback() + // .$oPrj->renderLink('accept', $sPhase) + . '<button type="submit" class="btn btn-large ' . $sNext . '" title="' . sprintf(t("accept-hint"), $sPhase, $sNext) . '"' + . '>' . $oHtml->getIcon('accept') . sprintf(t("accept"), $sPhase, $sNext) . '</button>' + . ' </fieldset> </form> '; - $BODY= - $renderAdminLTE->addRow( - $renderAdminLTE->addCol( - $renderAdminLTE->getCard([ - 'type'=>'success', - 'variant'=>'outline', - 'text'=>$sOut, - ]), 12 - ) - ); - + $BODY = + $renderAdminLTE->addRow( + $renderAdminLTE->addCol( + $renderAdminLTE->getCard([ + 'type' => 'success', + 'variant' => 'outline', + 'text' => $sOut, + ]), + 12 + ) + ); + } } } diff --git a/public_html/deployment/pages/act_checkssh.php b/public_html/deployment/pages/act_checkssh.php index 49c0aa76..c7048af3 100644 --- a/public_html/deployment/pages/act_checkssh.php +++ b/public_html/deployment/pages/act_checkssh.php @@ -8,18 +8,17 @@ --------------------------------------------------------------------- 2018-02-01 Axel <axel.hahn@iml.unibe.ch> + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ -$sOK='<span class="ok">' . t('ok') . '</span>'; -$sFAILED='<span class="error">' . t('error') . '</span>'; -$aErrors=array(); +$sOK = '<span class="ok">' . t('ok') . '</span>'; +$sFAILED = '<span class="error">' . t('error') . '</span>'; +$aErrors = []; global $sOK; global $sFAILED; global $aErrors; -// test only -// $aConfig['mirrorPackages']=array('puppet' => array('target' => 'ladmin@calcium.iml.unibe.ch:/share/imldeployment'),); - // ---------------------------------------------------------------------- // functions // ---------------------------------------------------------------------- @@ -29,19 +28,21 @@ global $aErrors; * * @global string $sOK * @global string $sFAILED + * * @param string $sCmd command to execute * @return string */ -function myExec($sCmd){ +function myExec(string $sCmd): string +{ global $sOK, $sFAILED, $aErrors; - $sReturn=''; - + $sReturn = ''; + exec($sCmd . " 2>&1 && echo '$sOK' || echo '$sFAILED' ", $aOut); $sReturn .= "<pre><strong>\$ $sCmd</strong><br>" - . implode('<br>', $aOut)."<br>" - . "</pre>"; - if (strpos($sReturn, $sFAILED)){ - $aErrors[]=$sCmd; + . implode('<br>', $aOut) . "<br>" + . "</pre>"; + if (strpos($sReturn, $sFAILED)) { + $aErrors[] = $sCmd; } return $sReturn; } @@ -52,15 +53,15 @@ function myExec($sCmd){ $sOut = '<h2>SSH</h2>'; -if(isset($aConfig['mirrorPackages']) && count($aConfig['mirrorPackages'])){ +if (isset($aConfig['mirrorPackages']) && count($aConfig['mirrorPackages'])) { // test puppet $sOut = '<h3>Puppet</h3>' - . '<ul>'; - foreach ($aConfig['mirrorPackages'] as $sServer=>$aSettings) { - $sCmd = 'ssh ' . preg_replace('#\:\/.*#', '' , $aSettings['target']) . ' echo "hello from \`hostname -f\`"'; + . '<ul>'; + foreach ($aConfig['mirrorPackages'] as $sServer => $aSettings) { + $sCmd = 'ssh ' . preg_replace('#\:\/.*#', '', $aSettings['target']) . ' echo "hello from \`hostname -f\`"'; $sOut .= '<li><strong>' . $sServer . '</strong> ' . myExec($sCmd); } - $sOut.='</ul>'; + $sOut .= '</ul>'; } // ... then loop over all projects ... @@ -69,36 +70,36 @@ foreach ($oPrj1->getProjects() as $sPrj) { $oPrj = new project($sPrj); $aPrjConfig = $oPrj->getConfig(); $sOut .= '<h3>' . $oPrj->getLabel() . '</h3>' - // . '<pre>'.print_r($aPrjConfig, 1).'</pre>' - . '<ul>'; + // . '<pre>'.print_r($aPrjConfig, 1).'</pre>' + . '<ul>'; // test repository - $sOut .= '<li>'.t('repositoryinfos').' <strong>' . $aPrjConfig['build']['url'] . '</strong> - '; - if($oPrj->getRepoRevision()){ + $sOut .= '<li>' . t('repositoryinfos') . ' <strong>' . $aPrjConfig['build']['url'] . '</strong> - '; + if ($oPrj->getRepoRevision()) { $sOut .= $sOK; } else { $sOut .= $sFAILED; $aErrors[] = $aPrjConfig['build']['url']; } - + // loop over phases ... foreach (array_keys($oPrj->getPhases()) as $sPhase) { - $sOut .= '<li>'.t('phase').' <strong>' . $sPhase . '</strong><ul>'; + $sOut .= '<li>' . t('phase') . ' <strong>' . $sPhase . '</strong><ul>'; $sDeployhosts = array_key_exists("hosts", $aPrjConfig["phases"][$sPhase]) ? $aPrjConfig["phases"][$sPhase]["hosts"] : ""; if ($sDeployhosts) { - foreach(explode(',', $sDeployhosts) as $sSingleSshTarget){ + foreach (explode(',', $sDeployhosts) as $sSingleSshTarget) { $sOut .= '<li>' . $sSingleSshTarget . '<br>'; $sCmd = 'ssh ' . $aConfig["installPackages"]["user"] . '@' . $sSingleSshTarget . ' echo "hello from \`hostname -f\`"'; - $sOut.= myExec($sCmd); + $sOut .= myExec($sCmd); } } - $sOut.='</ul>'; + $sOut .= '</ul>'; } - $sOut.='</ul>'; + $sOut .= '</ul>'; } -if(count($aErrors)){ - echo $oHtml->getBox('error', '<ol><li>'.implode('<li>', $aErrors), '</ol>'); +if (count($aErrors)) { + echo $oHtml->getBox('error', '<ol><li>' . implode('<li>', $aErrors). '</ol>'); } echo $sOut; diff --git a/public_html/deployment/pages/act_cleanup.php b/public_html/deployment/pages/act_cleanup.php index 33d53bff..9acf3782 100644 --- a/public_html/deployment/pages/act_cleanup.php +++ b/public_html/deployment/pages/act_cleanup.php @@ -36,4 +36,3 @@ $sOut = ' // -- Ausgabe echo $sOut; -?> diff --git a/public_html/deployment/pages/act_delete.php b/public_html/deployment/pages/act_delete.php index cbd4d97c..b2d9ada3 100644 --- a/public_html/deployment/pages/act_delete.php +++ b/public_html/deployment/pages/act_delete.php @@ -11,6 +11,8 @@ --------------------------------------------------------------------- 2014-03-24 Axel <axel.hahn@iml.unibe.ch> + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ require_once("./classes/project_gui.class.php"); @@ -26,80 +28,80 @@ if (!array_key_exists("confirm", $aParams)) { // ----- form to confirm deletion $sOut .= '<p>' . t('page-delete-project-introtext') . '</p>' - . $oPrj->renderVersionUsage() . '<br><br>'; + . $oPrj->renderVersionUsage() . '<br><br>'; $i = 0; - $aForms = array( - 'setup' => array( - 'meta' => array( + $aForms = [ + 'setup' => [ + 'meta' => [ 'method' => 'POST', 'action' => '?', - ), - 'validate' => array(), - 'form' => array( - 'input' . $i++ => array( + ], + 'validate' => [], + 'form' => [ + 'input' . $i++ => [ 'type' => 'hidden', 'name' => 'confirm', 'value' => '1', - ), - 'input' . $i++ => array( + ], + 'input' . $i++ => [ 'type' => 'checkbox', 'name' => 'removeOptions', 'label' => t("page-delete-remove-options"), 'validate' => 'isastring', 'value' => 1, - 'options' => array( - 'bRemoveRepolinks' => array( + 'options' => [ + 'bRemoveRepolinks' => [ 'label' => t("page-delete-cb-label-remove-links-for-repo"), 'checked' => false, - ), - 'bRemoveArchive' => array( + ], + 'bRemoveArchive' => [ 'label' => t("page-delete-cb-label-remove-archive"), 'checked' => false, - ), - 'bRemoveConfig' => array( + ], + 'bRemoveConfig' => [ 'label' => t("page-delete-cb-label-remove-config"), 'checked' => true, - ), - ), - ), - 'markup' . $i++ => array( + ], + ], + ], + 'markup' . $i++ => [ 'type' => 'markup', 'value' => '<hr>', - ), - 'button' . $i++ => array( + ], + 'button' . $i++ => [ 'type' => 'submit', 'class' => 'btn-danger', 'value' => $oHtml->getIcon('delete') . t("page-delete-project-buttonlabel"), - ), - ), - ), - ); + ], + ], + ], + ]; $oForm = new formgen($aForms); $sOut .= $oForm->renderHtml("setup"); - $sHome= aPrjHome(); - + $sHome = aPrjHome(); + } else { // ----- delete the project - $sHome= aHome(); + $sHome = aHome(); - $aOptions = array(); - foreach (array("bRemoveRepolinks", "bRemoveArchive", "bRemoveConfig") as $sOption) { + $aOptions = []; + foreach (["bRemoveRepolinks", "bRemoveArchive", "bRemoveConfig"] as $sOption) { if (array_search($sOption, $aParams["removeOptions"]) !== false) { $aOptions[$sOption] = 1; } } - $sErrors=$oPrj->delete($aOptions); + $sErrors = $oPrj->delete($aOptions); if ($sErrors) { - $sOut.=$oHtml->getBox("error", t('page-delete-project-delete-failed') . $sErrors); + $sOut .= $oHtml->getBox("error", t('page-delete-project-delete-failed') . $sErrors); } else { - $sOut.=$oHtml->getBox("success", t('page-delete-project-delete-success')); + $sOut .= $oHtml->getBox("success", t('page-delete-project-delete-success')); } } // $sOut.= '<div id="navbuttom">' . $sHome . '</div>'; - // -- Ausgabe +// -- Ausgabe echo $sOut; diff --git a/public_html/deployment/pages/act_deploy.php b/public_html/deployment/pages/act_deploy.php index 6d0b5df9..60044b4b 100644 --- a/public_html/deployment/pages/act_deploy.php +++ b/public_html/deployment/pages/act_deploy.php @@ -8,6 +8,8 @@ --------------------------------------------------------------------- 2013-11-08 Axel <axel.hahn@iml.unibe.ch> + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ require_once("./classes/project_gui.class.php"); @@ -50,39 +52,39 @@ if (array_key_exists("confirm", $aParams)) { // Eingabe Kommentare zum Deployment $i = 0; - $aForms = array( - 'deploy' => array( - 'meta' => array( + $aForms = [ + 'deploy' => [ + 'meta' => [ 'method' => 'POST', 'action' => '?', - ), - 'validate' => array(), - 'form' => array( - 'input' . $i++ => array( + ], + 'validate' => [], + 'form' => [ + 'input' . $i++ => [ 'type' => 'hidden', 'name' => 'confirm', 'value' => '1', - ), - 'input' . $i++ => array( + ], + 'input' . $i++ => [ 'type' => 'checkbox', 'name' => 'aIgnore', 'label' => t("deploy-settings"), 'validate' => 'isastring', - 'options' => array( - 'bIgnoreDeploytimes' => array( + 'options' => [ + 'bIgnoreDeploytimes' => [ 'label' => t("page-deploy-info-ignore-deploytime"), 'checked' => false, - ), - ), - ), - 'button' . $i++ => array( + ], + ], + ], + 'button' . $i++ => [ 'type' => 'submit', 'class' => $sPhase, 'value' => $oHtml->getIcon('deploy').t("deploy"), - ), - ), - ), - ); + ], + ], + ], + ]; $oForm = new formgen($aForms); $sOut .= $oForm->renderHtml("deploy"); @@ -107,4 +109,3 @@ if (array_key_exists("confirm", $aParams)) { // -- Ausgabe echo $sOut; -?> diff --git a/public_html/deployment/pages/act_doc.php b/public_html/deployment/pages/act_doc.php index 806a54da..79faa328 100644 --- a/public_html/deployment/pages/act_doc.php +++ b/public_html/deployment/pages/act_doc.php @@ -8,57 +8,56 @@ --------------------------------------------------------------------- 2013-11-19 Axel <axel.hahn@iml.unibe.ch> + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ require_once("./classes/classinfos.class.php"); -$aClasses = array( - "actionlog" => array("name" => "actionLog"), - "cache" => array("name" => "AhCache"), - "config-replacement" => array("name" => "configreplacement"), - "deploy-foreman" => array("name" => "deployForeman"), - "foremanapi" => array("name" => "ForemanApi"), - "formgen" => array("name" => "formgen"), - "htmlguielements" => array("name" => "htmlguielements"), - "ldap" => array("name" => "imlldap"), - "logger" => array("name" => "logger"), - "messenger" => array("name" => "messenger"), - "page" => array("name" => "Page"), - "project" => array("name" => "project"), - "projectlist" => array("name" => "projectlist"), - "rollout_base" => array("name" => "rollout_base"), - "user" => array("name" => "user"), - "vcs.git" => array("name" => "vcs"), - -); +$aClasses = [ + "actionlog" => ["name" => "actionLog"], + // "cache" => ["name" => "AhCache"), + "config-replacement" => ["name" => "configreplacement"], + "foremanapi" => ["name" => "ForemanApi"], + "formgen" => ["name" => "formgen"], + "htmlguielements" => ["name" => "htmlguielements"], + "ldap" => ["name" => "imlldap"], + "logger" => ["name" => "logger"], + "messenger" => ["name" => "messenger"], + "page" => ["name" => "Page"], + "project" => ["name" => "project"], + "projectlist" => ["name" => "projectlist"], + "rollout_base" => ["name" => "rollout_base"], + "user" => ["name" => "user"], + "vcs.git" => ["name" => "vcs"], + +]; $sOut = ''; -$sOut.='<a href="/deployment/all/doc/">Start</a> | '; +$sOut .= '<a href="/deployment/all/doc/">Start</a> | '; foreach ($aClasses as $sClassfile => $aInfos) { - $sOut.='<a href="/deployment/all/doc/' . $sClassfile . '/">' . $sClassfile . '</a> | '; + $sOut .= '<a href="/deployment/all/doc/' . $sClassfile . '/">' . $sClassfile . '</a> | '; } -$sOut.= '<hr>'; +$sOut .= '<hr>'; if (array_key_exists("par3", $aParams)) { $sClass = $aParams["par3"]; if (!array_key_exists($sClass, $aClasses)) { - $sOut.= $oHtml->getBox("error", sprintf(t("page-doc-error-class-not-configured"), $sClass, __FILE__)); + $sOut .= $oHtml->getBox("error", sprintf(t("page-doc-error-class-not-configured"), $sClass, __FILE__)); } else { require_once("./classes/$sClass.class.php"); $o = new classinfos($aClasses[$sClass]["name"]); - $sOut.=t("page-doc-info-" . $sClass) . $o->render(); + $sOut .= t("page-doc-info-" . $sClass) . $o->render(); } } else { - $sOut.=t("page-doc-info-select-class") . '<ul>'; + $sOut .= t("page-doc-info-select-class") . '<ul>'; foreach (array_keys($aClasses) as $sClassfile) { - $sOut.='<li>' - . '<a href="/deployment/all/doc/' . $sClassfile . '/">' . $sClassfile . '</a>' - . ' ' . t("page-doc-info-" . $sClassfile) - . '</li>'; + $sOut .= '<li>' + . '<a href="/deployment/all/doc/' . $sClassfile . '/">' . $sClassfile . '</a>' + . ' ' . t("page-doc-info-" . $sClassfile) + . '</li>'; } - $sOut.='</ul>'; + $sOut .= '</ul>'; } // -- Ausgabe echo $sOut; -?> - diff --git a/public_html/deployment/pages/act_htmltest.php b/public_html/deployment/pages/act_htmltest.php index d6a63a25..31e7f583 100644 --- a/public_html/deployment/pages/act_htmltest.php +++ b/public_html/deployment/pages/act_htmltest.php @@ -4,138 +4,143 @@ IML DEPLOYMENT - webgui - build a package + webgui - html tester --------------------------------------------------------------------- - 2014-11-14 Axel <axel.hahn@iml.unibe.ch> selector for branches - 2014-02-14 Axel <axel.hahn@iml.unibe.ch> build was "ajaxified" - 2013-11-08 Axel <axel.hahn@iml.unibe.ch> + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ require_once("./classes/project.class.php"); /** - * helper: render html code for a table row + * helper: get html code for a table row * @global htmlguielements $oHtml * @param string $sDescr description * @param string $sCode php code * @return string */ -function addHtmltestTest($sDescr, $sCode){ - $oHtml=new htmlguielements(); - $sOut='??'; - eval("\$sOut=$sCode;"); - +function addHtmltestTest(string $sDescr, string $sCode): string +{ + $oHtml = new htmlguielements(); + $sOut = '??'; + eval ("\$sOut=$sCode;"); + return '<tr>' - . '<td>' - . $sDescr - . '</td>' - . '<td style="padding: 0 1em;"><pre>' - . htmlentities($sCode) - . '</pre></td>' - . '<td style="padding: 0 1em;">' - .$sOut - . '</td>' - . '<td style="padding: 0 1em;"><pre>' - .str_replace('>', '><br>',htmlentities($sOut)) - . '</pre></td>' - . '</tr>'; + . '<td>' + . $sDescr + . '</td>' + . '<td style="padding: 0 1em;"><pre>' + . htmlentities($sCode) + . '</pre></td>' + . '<td style="padding: 0 1em;">' + . $sOut + . '</td>' + . '<td style="padding: 0 1em;"><pre>' + . str_replace('>', '><br>', htmlentities($sOut)) + . '</pre></td>' + . '</tr>'; } // ---------------------------------------------------------------------- // MAIN // ---------------------------------------------------------------------- -$oHtml=new htmlguielements(); +$oHtml = new htmlguielements(); // generate a List of al icons -$sIconlist=''; -$sIconlist.='<strong>Buttons</strong><br>'; -foreach ($oHtml->aCfg['buttons'] as $sLabel=>$aItems){ - $sIconlist.=$oHtml->getIcon($aItems['icon']).' - '.$sLabel.' - '.$aItems['icon'].'<br>'; +$sIconlist = ''; +$sIconlist .= '<strong>Buttons</strong><br>'; + + + +foreach ($oHtml->aCfg['buttons'] as $sLabel => $aItems) { + $sIconlist .= $oHtml->getIcon((string)$aItems['icon']) . ' - ' . $sLabel . ' - ' . $aItems['icon'] . '<br>'; } -$sIconlist.='<br><strong>Icons</strong><br>'; -foreach ($oHtml->aCfg['icons'] as $sLabel=>$sIcon){ - $sIconlist.=$oHtml->getIcon($sIcon).' - '.$sLabel.': '.$sIcon.'<br>'; +$sIconlist .= '<br><strong>Icons</strong><br>'; +foreach ($oHtml->aCfg['icons'] as $sLabel => $sIcon) { + $sIconlist .= $oHtml->getIcon($sIcon) . ' - ' . $sLabel . ': ' . $sIcon . '<br>'; } -$sRows='' - . addHtmltestTest("Box zeichnen - Fehler", "\$oHtml->getBox('error', 'errormessage')") - . addHtmltestTest("Box zeichnen - Warnung", "\$oHtml->getBox('warning', 'Message')") - . addHtmltestTest("Box zeichnen - Info", "\$oHtml->getBox('info', 'Message')") - . addHtmltestTest("Box zeichnen - OK", "\$oHtml->getBox('success', 'Message')") - - . addHtmltestTest("Icon - Fontawesome", "\$oHtml->getIcon('fa-close');") - - . '<tr>' - . '<td>pre-defined icons</td>' - . '<td>-</td>' - . '<td>'.$sIconlist.'</td>' - . '<td>-</td>' - . '</tr>' - - . addHtmltestTest("Link", "\$oHtml->getLink(array( +$sRows = '' + . addHtmltestTest("Box zeichnen - Fehler", "\$oHtml->getBox('error', 'errormessage')") + . addHtmltestTest("Box zeichnen - Warnung", "\$oHtml->getBox('warning', 'Message')") + . addHtmltestTest("Box zeichnen - Info", "\$oHtml->getBox('info', 'Message')") + . addHtmltestTest("Box zeichnen - OK", "\$oHtml->getBox('success', 'Message')") + + . addHtmltestTest("Icon - Fontawesome", "\$oHtml->getIcon('fa-close');") + + . '<tr>' + . '<td>pre-defined icons</td>' + . '<td>-</td>' + . '<td>' . $sIconlist . '</td>' + . '<td>-</td>' + . '</tr>' + + . addHtmltestTest("Link", "\$oHtml->getLink([ 'href'=>'https://www.axel-hahn.de/', 'icon'=>'fa-globe', 'label'=>'Axels Webseite', -));") - . addHtmltestTest("Link als Button", "\$oHtml->getLinkButton(array( +]);") + . addHtmltestTest("Link als Button", "\$oHtml->getLinkButton([ 'href'=>'https://www.axel-hahn.de/', 'target'=>'_blank', 'icon'=>'fa-globe', 'label'=>'Axels Webseite', -));") - . addHtmltestTest("Link als Button mit Type OK", "\$oHtml->getLinkButton(array('type'=>'ok',));") - . addHtmltestTest("Link als Button mit Type close", "\$oHtml->getLinkButton(array('type'=>'close',));") - . addHtmltestTest("Link als Button mit Type error", "\$oHtml->getLinkButton(array('type'=>'error','label'=>'Fehler'));") +]);") + . addHtmltestTest("Link als Button mit Type OK", "\$oHtml->getLinkButton(['type'=>'ok',]);") + . addHtmltestTest("Link als Button mit Type close", "\$oHtml->getLinkButton(['type'=>'close',]);") + . addHtmltestTest("Link als Button mit Type error", "\$oHtml->getLinkButton(['type'=>'error','label'=>'Fehler']);") -// . addHtmltestTest("Tabs", "\$oHtml->getNav( -// array( -// 'options' => array( + // . addHtmltestTest("Tabs", "\$oHtml->getNav( +// [ +// 'options' => [ // 'type'=>'tabs', // 'justified'=>1, -// ), -// 'tabs' => array( +// ], +// 'tabs' => [ // 'tab 1'=>'Inhalt #1', // 'tab 2'=>'Inhalt #2', -// ), -// ) +// ], +// ] // );") // . addHtmltestTest("Tabs", "\$oHtml->getNav( -// array( -// 'options' => array( +// [ +// 'options' => [ // 'type'=>'pills', // 'stacked'=>1, -// ), -// 'tabs' => array( +// ], +// 'tabs' => [ // 'tab 1'=>'Inhalt #1', // 'tab 2'=>'Inhalt #2', -// ), -// ) +// ], +// ] // );") - . addHtmltestTest("Tabelle", "\$oHtml->getTable( - array( - 'header'=>array('A', 'B'), - 'body'=>array( - array('Zelle A 1', 'Zelle B 1'), - array('Zelle A 2', 'Zelle B 2'), - array('Zelle A 3', 'Zelle B 3'), - ), -));" -) + . addHtmltestTest( + "Tabelle", + "\$oHtml->getTable( + [ + 'header'=>['A', 'B'], + 'body'=>[ + ['Zelle A 1', 'Zelle B 1'], + ['Zelle A 2', 'Zelle B 2'], + ['Zelle A 3', 'Zelle B 3'], + ], + ]);" + ) ; // ---------------------------------------------------------------------- echo '<table><thead>' . '<tr>' - . '<th>Beschreibung</th>' - . '<th>PHP-Code</th>' - . '<th>Ausgabe</th>' - . '<th>Ausgabe-Code</th>' + . '<th>Beschreibung</th>' + . '<th>PHP-Code</th>' + . '<th>Ausgabe</th>' + . '<th>Ausgabe-Code</th>' . '</tr>' -. '</thead><tbody>' - .$sRows -. '</tbody></table>' + . '</thead><tbody>' + . $sRows + . '</tbody></table>' ; diff --git a/public_html/deployment/pages/act_login.php b/public_html/deployment/pages/act_login.php index 288dbe47..577102c6 100644 --- a/public_html/deployment/pages/act_login.php +++ b/public_html/deployment/pages/act_login.php @@ -8,6 +8,8 @@ --------------------------------------------------------------------- 2015-04-21 Axel <axel.hahn@iml.unibe.ch> + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ require_once("./inc_functions.php"); @@ -31,16 +33,16 @@ if (!$oUser->getUsername() && array_key_exists('user', $aParams)) { $oUser->authenticate(); } - // if user is logged in and credentials were sent: reload to remove post vars - if ($oUser->getUsername() && array_key_exists('user', $aParams)) { - if (array_key_exists("goback", $_SESSION)){ - $sUrl=$_SESSION["goback"]; - unset($_SESSION["goback"]); - } else { - $sUrl='/deployment'; - } - header("location: $sUrl"); +// if user is logged in and credentials were sent: reload to remove post vars +if ($oUser->getUsername() && array_key_exists('user', $aParams)) { + if (array_key_exists("goback", $_SESSION)) { + $sUrl = $_SESSION["goback"]; + unset($_SESSION["goback"]); + } else { + $sUrl = '/deployment'; } + header("location: $sUrl"); +} // ---------------------------------------------------------------------- // show infos or login form @@ -52,63 +54,63 @@ if ($oUser->getUsername()) { // ------------------------------------------------------------ // show user and roles + logoff // ------------------------------------------------------------ - $sGrouplist=''; - foreach ($oUser->getUserGroups() as $sGroupname){ - $sGrouplist.=$oHtml->getIcon('user-group').$sGroupname . '<br>'; + $sGrouplist = ''; + foreach ($oUser->getUserGroups() as $sGroupname) { + $sGrouplist .= $oHtml->getIcon('user-group') . $sGroupname . '<br>'; } - $sPermlist=''; - foreach ($oUser->getUserPermission() as $sPerm){ - $sPermlist.=$oHtml->getIcon('user-permission').$sPerm . '<br>'; + $sPermlist = ''; + foreach ($oUser->getUserPermission() as $sPerm) { + $sPermlist .= $oHtml->getIcon('user-permission') . $sPerm . '<br>'; } - - $sOut.='' - . '<h2>' . t("page-login-profile") . '</h2>' - .'<table> + + $sOut .= '' + . '<h2>' . t("page-login-profile") . '</h2>' + . '<table> <tr> - <td>'.t("page-login-userloggedin") . '</td> + <td>' . t("page-login-userloggedin") . '</td> <td><strong>' . $oUser->getUsername() . '</strong></td> </tr> <tr> - <td>'.t("page-login-usergroups").'</td> - <td>'.$sGrouplist . '</td> + <td>' . t("page-login-usergroups") . '</td> + <td>' . $sGrouplist . '</td> </tr> <tr> - <td>'.t("page-login-userperms").'</td> - <td>'.$sPermlist . '</td> + <td>' . t("page-login-userperms") . '</td> + <td>' . $sPermlist . '</td> </tr> </table>' - . '<div style="clear: both; margin-bottom: 1em;"></div>' - . ' ' . aPrjHome() . ' ' - . '<a href="?logoff=1" class="btn btn-danger">' . $oHtml->getIcon('poweroff') . t('logoff') . '</a>' - - // . '<br><br>INFO: <pre style="">roles:<br>' . print_r($oUser->getUserPermission(), true) . '</pre>' - . '</p>' - ; + . '<div style="clear: both; margin-bottom: 1em;"></div>' + . ' ' . aPrjHome() . ' ' + . '<a href="?logoff=1" class="btn btn-danger">' . $oHtml->getIcon('poweroff') . t('logoff') . '</a>' + + // . '<br><br>INFO: <pre style="">roles:<br>' . print_r($oUser->getUserPermission(), true) . '</pre>' + . '</p>' + ; } else { // ------------------------------------------------------------ // login page // ------------------------------------------------------------ - if (!isset($_SESSION['goback']) || true){ - $sUrlback=$_SERVER["HTTP_REFERER"]; - if( - strpos($sUrlback, $_SERVER["SERVER_NAME"])>0 - && !strpos($sUrlback, '/all/login/') - ){ - $_SESSION["goback"]=$sUrlback; + if (!isset($_SESSION['goback']) || true) { + $sUrlback = $_SERVER["HTTP_REFERER"]; + if ( + strpos($sUrlback, $_SERVER["SERVER_NAME"]) > 0 + && !strpos($sUrlback, '/all/login/') + ) { + $_SESSION["goback"] = $sUrlback; } } $i = 0; - require_once ("./classes/formgen.class.php"); + require_once("./classes/formgen.class.php"); - $aForms = array( - 'login' => array( - 'meta' => array( + $aForms = [ + 'login' => [ + 'meta' => [ 'method' => 'POST', 'action' => '?', - ), - 'validate' => array(), - 'form' => array( - 'input' . $i++ => array( + ], + 'validate' => [], + 'form' => [ + 'input' . $i++ => [ 'type' => 'text', 'name' => 'user', 'label' => t('page-login-username'), @@ -119,8 +121,8 @@ if ($oUser->getUsername()) { 'placeholder' => t('page-login-username'), 'autofocus' => 'autofocus', // 'inline' => '1', - ), - 'input' . $i++ => array( + ], + 'input' . $i++ => [ 'type' => 'password', 'name' => 'password', 'label' => t('page-login-password'), @@ -130,41 +132,41 @@ if ($oUser->getUsername()) { 'value' => $aParams['password'], 'placeholder' => t('page-login-password'), // 'inline' => '1', - ), - 'input' . $i++ => array( + ], + 'input' . $i++ => [ 'type' => 'submit', - 'label' => "", 'name' => 'btnsave', 'label' => t("login"), 'value' => $oHtml->getIcon('sign-ok') . t("login"), - ), - ), - ) - ); + ], + ], + ] + ]; $oForm = new formgen($aForms); - $sOut.='' - . '<h2>' . t("page-login-info") . '</h2>' - . '<p>' . t("page-login-info-introtext") . '</p>' - . (array_key_exists('user', $aParams) - ? '<div class="alert alert-danger" role="alert">'.t('page-login-auth-failed').'</div>' - : '' - ) - .$oForm->renderHtml("login"); + $sOut .= '' + . '<h2>' . t("page-login-info") . '</h2>' + . '<p>' . t("page-login-info-introtext") . '</p>' + . (array_key_exists('user', $aParams) + ? '<div class="alert alert-danger" role="alert">' . t('page-login-auth-failed') . '</div>' + : '' + ) + . $oForm->renderHtml("login"); } // $sOut.= '<div id="navbuttom">' . aPrjHome() . '</div>'; // -- Ausgabe // echo $sOut; -$BODY= -$renderAdminLTE->addRow( - $renderAdminLTE->addCol('',3) - .$renderAdminLTE->addCol( - $renderAdminLTE->getCard([ - 'type'=>'', - 'variant'=>'outline', - 'text'=>$sOut, - ]),5 - ) - .$renderAdminLTE->addCol('',4) -); +$BODY = + $renderAdminLTE->addRow( + $renderAdminLTE->addCol('', 3) + . $renderAdminLTE->addCol( + $renderAdminLTE->getCard([ + 'type' => '', + 'variant' => 'outline', + 'text' => $sOut, + ]), + 5 + ) + . $renderAdminLTE->addCol('', 4) + ); diff --git a/public_html/deployment/pages/act_overview.php b/public_html/deployment/pages/act_overview.php index d96cbb83..b6d0f860 100644 --- a/public_html/deployment/pages/act_overview.php +++ b/public_html/deployment/pages/act_overview.php @@ -9,10 +9,12 @@ * for a single project --------------------------------------------------------------------- - 2014-11-17 Axel <axel.hahn@iml.unibe.ch> added tags and branches + 2013-11-08 Axel <axel.hahn@iml.unibe.ch> 2014-04-24 Axel <axel.hahn@iml.unibe.ch> new visual; sortorder in project overview - 2013-11-08 Axel <axel.hahn@iml.unibe.ch> + 2014-11-17 Axel <axel.hahn@iml.unibe.ch> added tags and branches + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ @@ -24,79 +26,80 @@ if (!array_key_exists("prj", $aParams)) { require_once("./classes/projectlist.class.php"); $oPrjList = new projectlist(); - $BODY_END='<script type="text/javascript" src="/deployment/js/functions_overview.js"></script>'; + $BODY_END = '<script type="text/javascript" src="/deployment/js/functions_overview.js"></script>'; $BODY = $oPrjList->renderOverview(); } else { - + // ---------------------------------------------------------------------- // overview of a single project // ---------------------------------------------------------------------- require_once("./classes/project_gui.class.php"); $oPrj = new projectgui($aParams["prj"]); - - $iCountOfBranches=0; - $iCountOfBuildErrors=count($oPrj->getBuildErrors()); - $iCountOfpackages=count($oPrj->getVersions()); - $iCountOfPhases=count($oPrj->getActivePhases()); - - $sBuildErrorContent='<p>'.t('build-failes-hint').'</p>'; - if($iCountOfBuildErrors){ - $aTabdata=array(); - $aErrorfiles=$oPrj->getBuildErrors(); + + $iCountOfBranches = 0; + $iCountOfBuildErrors = count($oPrj->getBuildErrors()); + $iCountOfpackages = count($oPrj->getVersions()); + $iCountOfPhases = count($oPrj->getActivePhases()); + + $sBuildErrorContent = '<p>' . t('build-failes-hint') . '</p>'; + if ($iCountOfBuildErrors) { + $aTabdata = []; + $aErrorfiles = $oPrj->getBuildErrors(); rsort($aErrorfiles); - foreach ($aErrorfiles as $sNumber=>$sErrorfile){ - $aTabdata[$oHtml->getIcon('file-any').' '.$sErrorfile]='' - // . 'file: ' . $oHtml->getIcon('file-target'). ''.$sErrorfile.'<br>' - // . 'date: ' . .'<br>' - // . 'age: ' . .'<br>' - . $oPrj->getBuildErrorContent($sErrorfile); + foreach ($aErrorfiles as $sNumber => $sErrorfile) { + $aTabdata[$oHtml->getIcon('file-any') . ' ' . $sErrorfile] = '' + // . 'file: ' . $oHtml->getIcon('file-target'). ''.$sErrorfile.'<br>' + // . 'date: ' . .'<br>' + // . 'age: ' . .'<br>' + . $oPrj->getBuildErrorContent($sErrorfile); } /* - $sBuildErrorContent.=$oHtml->getNav(array( - 'options' => array( + $sBuildErrorContent.=$oHtml->getNav([ + 'options' => [ 'type'=>'pills', 'justified'=>0, - ), - 'tabs'=>$aTabdata) + ], + 'tabs'=>$aTabdata + ] ); */ - $sBuildErrorContent.=$renderAdminLTE->getTabbedContent(['tabs'=>$aTabdata]); + $sBuildErrorContent .= $renderAdminLTE->getTabbedContent(['tabs' => $aTabdata]); } else { - $sBuildErrorContent=$oHtml->getBox('info', t('build-failes-none')); + $sBuildErrorContent = $oHtml->getBox('info', t('build-failes-none')); } - $sListOfBranches=''; - foreach($oPrj->getRemoteBranches() as $aBranch){ - $sListOfBranches.='<li title="'.$aBranch['revision'].'">'.$aBranch['label'] . '</li>'; + $sListOfBranches = ''; + foreach ($oPrj->getRemoteBranches() as $aBranch) { + $sListOfBranches .= '<li title="' . $aBranch['revision'] . '">' . $aBranch['label'] . '</li>'; $iCountOfBranches++; } - if($sListOfBranches){ - $sListOfBranches='<h4>'.t('branch-select').'</h4><ol>'.$sListOfBranches.'</ol>'; + if ($sListOfBranches) { + $sListOfBranches = '<h4>' . t('branch-select') . '</h4><ol>' . $sListOfBranches . '</ol>'; } // --- generate tabs: - $aTabdata=[]; + $aTabdata = []; $aTabdata[$oHtml->getIcon('workflow') . t("way-of-packages")] = $oPrj->renderVisual(); - if($iCountOfBuildErrors){ - $aTabdata[$oHtml->getIcon('sign-error') . t("build-failes") . ($iCountOfBuildErrors ? ' <span class="badge badge-danger">'.$iCountOfBuildErrors.'</span>' : '' )]='<br>'.$sBuildErrorContent; + if ($iCountOfBuildErrors) { + $aTabdata[$oHtml->getIcon('sign-error') . t("build-failes") . ($iCountOfBuildErrors ? ' <span class="badge badge-danger">' . $iCountOfBuildErrors . '</span>' : '')] = '<br>' . $sBuildErrorContent; } - if($iCountOfpackages){ - $aTabdata[$oHtml->getIcon('package') . t("archive") . ($iCountOfpackages ? ' <span class="badge badge-secondary">'.$iCountOfpackages.'</span>' : '' )] = '<br>'.$oPrj->renderVersionUsage(); + if ($iCountOfpackages) { + $aTabdata[$oHtml->getIcon('package') . t("archive") . ($iCountOfpackages ? ' <span class="badge badge-secondary">' . $iCountOfpackages . '</span>' : '')] = '<br>' . $oPrj->renderVersionUsage(); } - if($iCountOfPhases){ - $aTabdata[$oHtml->getIcon('phase') . t('phases') .' '. ($iCountOfPhases ? '<span class="badge badge-secondary">'.$iCountOfPhases.'</span>' : '<span class="badge badge-danger">0</span>' )]='<br>' - .'<p>' - . t("page-overview-phase-infos") - . '</p>' + if ($iCountOfPhases) { + $aTabdata[$oHtml->getIcon('phase') . t('phases') . ' ' . ($iCountOfPhases ? '<span class="badge badge-secondary">' . $iCountOfPhases . '</span>' : '<span class="badge badge-danger">0</span>')] = '<br>' + . '<p>' + . t("page-overview-phase-infos") + . '</p>' . $oPrj->renderPhaseInfo() ; } $sOut = '' - .'<h3>'.t('overview-label').' '.$oPrj->renderLink("setup").'</h3><br>' - .$renderAdminLTE->getTabbedContent(['tabs'=>$aTabdata]) - ; + . '<h3>' . t('overview-label') . ' ' . $oPrj->renderLink("setup") . '</h3><br>' + . $renderAdminLTE->getTabbedContent(['tabs' => $aTabdata]) + ; /* $sPhaselinks=''; @@ -110,15 +113,16 @@ if (!array_key_exists("prj", $aParams)) { } */ - - $BODY= + + $BODY = $renderAdminLTE->addRow( $renderAdminLTE->addCol( $renderAdminLTE->getCard([ - 'type'=>'gray', - 'variant'=>'outline', - 'text'=>$sOut, - ]), 12 + 'type' => 'gray', + 'variant' => 'outline', + 'text' => $sOut, + ]), + 12 ) /* $renderAdminLTE->addCol( @@ -146,7 +150,7 @@ if (!array_key_exists("prj", $aParams)) { ) */ ); - // $sOut.='<div id="navbuttom">' . aGotop() . aHome() . '</div>'; + // $sOut.='<div id="navbuttom">' . aGotop() . aHome() . '</div>'; } // echo $sOut; diff --git a/public_html/deployment/pages/act_phase.php b/public_html/deployment/pages/act_phase.php index bbebeddb..947583b5 100644 --- a/public_html/deployment/pages/act_phase.php +++ b/public_html/deployment/pages/act_phase.php @@ -10,6 +10,7 @@ --------------------------------------------------------------------- 2013-11-08 Axel <axel.hahn@iml.unibe.ch> 2024-02-28 Axel <axel.hahn@unibe.ch> remove foreman; update replacements + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ require_once("./classes/project_gui.class.php"); @@ -25,7 +26,7 @@ if (isset($aParams["par3"])) { } if ($sPhase) { - $aWarnings=array(); + $aWarnings=[]; $sOutReplace=''; // ---------------------------------------------------------------------- @@ -65,14 +66,14 @@ if ($sPhase) { // open all/ close all if(count($aReplacements)>1){ - $sOutReplace.=$oHtml->getLinkButton(array( + $sOutReplace.=$oHtml->getLinkButton([ 'onclick'=>'$(\'.divfileinfos\').slideDown(); $(\'.expandable\').removeClass(\'closed\'); this.blur(); return false;', 'icon'=>$oHtml->getIconClass('box-down'), - )) - .$oHtml->getLinkButton(array( + ]) + .$oHtml->getLinkButton([ 'onclick'=>'$(\'.divfileinfos\').slideUp(); $(\'.expandable\').addClass(\'closed\'); this.blur(); return false;', 'icon'=>$oHtml->getIconClass('box-up'), - )) + ]) ; } @@ -86,12 +87,12 @@ if ($sPhase) { $sOutReplace.='<h4>' . // --- link filename of template to toggle details. - $oHtml->getLink(array( + $oHtml->getLink([ 'onclick'=>'$(\'#'.$sDivIdFile.'\').slideToggle(); $(this).toggleClass(\'closed\'); return false;', 'class'=>'expandable closed', 'icon'=>'templatefile', 'label'=>$tTplFile, - )) . '</h4>' + ]) . '</h4>' . '<div id="'.$sDivIdFile.'" class="divfileinfos" style="display: none;">' ; diff --git a/public_html/deployment/pages/act_setup.php b/public_html/deployment/pages/act_setup.php index e3c8df85..602bad1c 100644 --- a/public_html/deployment/pages/act_setup.php +++ b/public_html/deployment/pages/act_setup.php @@ -10,62 +10,67 @@ --------------------------------------------------------------------- 2013-11-08 Axel <axel.hahn@iml.unibe.ch> + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ require_once("./classes/project_gui.class.php"); require_once("./inc_functions.php"); $sOut = ''; -$sFakePassword='********************'; +$sFakePassword = '********************'; // items to mask -$aMask=array( - 'auth'=>array( - 'ldap'=>array( - 'PwLdapUser'=>$sFakePassword - ) - ), - 'foreman'=>array( - 'password'=>$sFakePassword - ), - 'projects'=>array( - 'ldap'=>array( - 'PwLdapUser'=>$sFakePassword - ) - ), -); +$aMask = [ + 'auth' => [ + 'ldap' => [ + 'PwLdapUser' => $sFakePassword + ] + ], + 'foreman' => [ + 'password' => $sFakePassword + ], + 'projects' => [ + 'ldap' => [ + 'PwLdapUser' => $sFakePassword + ] + ], +]; /** * hide entries in config array * @param array $aMask * @param array $aConfig - * @return type + * @return array */ -function maskEntries($aMask, $aConfig){ - foreach ($aMask as $sKey=>$aValue){ - - if (array_key_exists($sKey, $aConfig)){ - $aConfig[$sKey]=(is_array($aValue) - ? maskEntries($aMask[$sKey], $aConfig[$sKey]) - : $aMask[$sKey] +function maskEntries(array $aMask, array $aConfig): array +{ + $aReturn = $aConfig; + foreach ($aMask as $sKey => $aValue) { + + if (array_key_exists($sKey, $aReturn)) { + $aReturn[$sKey] = (is_array($aValue) + ? maskEntries($aMask[$sKey], $aReturn[$sKey]) + : $aMask[$sKey] ) ; } } - return $aConfig; + return $aReturn; } /** - * recursive replace of values in a hash + * Recursive replace of values in a hash * source: https://www.w3schools.in/php-script/recursive-array-replace-by-Key-or-Value/ * FIX: 3x "=" in if($Key === $Find) * * @param array $Array Array * @param string $Find key to scan for - * @param strin $Replace new value + * @param string $Replace new value * @return array */ -function ArrayReplace($Array, $Find, $Replace) { +function ArrayReplace(array $Array, string $Find, string $Replace): array +{ if (is_array($Array)) { foreach ($Array as $Key => $Val) { if (is_array($Array[$Key])) { @@ -85,119 +90,114 @@ function ArrayReplace($Array, $Find, $Replace) { // --------------------------------------------------------------------- if ($aParams["prj"] == "all") { - + // ------------------------------------------------------------ // general setup - overview // ------------------------------------------------------------ if (!array_key_exists("par3", $aParams)) { $oPrj = new project(); // $aTmp=maskEntries($aMask, $aConfig); - $aTmp=$aConfig; - $aTmp=ArrayReplace($aTmp, "password", $sFakePassword); - $aTmp=ArrayReplace($aTmp, "PwLdapUser", $sFakePassword); - $TITLE=t('menu-settings'); + $aTmp = $aConfig; + $aTmp = ArrayReplace($aTmp, "password", $sFakePassword); + $aTmp = ArrayReplace($aTmp, "PwLdapUser", $sFakePassword); + $TITLE = t('menu-settings'); + + $sOut .= '<pre>' . print_r($aTmp, 1) . '</pre>'; - $sOut.= '<pre>'.print_r($aTmp, 1).'</pre>'; - // print_r($aConfig); - + // ----- from HERE: generate form (experimental) $i = 0; - require_once ("./classes/formgen.class.php"); - + require_once("./classes/formgen.class.php"); + // define editable options - $aMapping=array( - 'general'=>array( - '["workDir"]'=>array('type'=>'text'), - '["versionsToKeep"]'=>array('type'=>'text', 'validate'=>'isinteger'), - '["builtsToKeep"]'=>array('type'=>'text', 'validate'=>'isinteger'), - '["lang"]'=>array('type'=>'text'), - ), - ); - foreach ($aConfig['phases'] as $sPhase => $aPhaseData){ - $aMapping['phase-'.$sPhase]=array( - '["phases"]["'.$sPhase.'"]["css"]["bgdark"]'=>array('type'=>'text'), - '["phases"]["'.$sPhase.'"]["css"]["bglight"]'=>array('type'=>'text'), - '["phases"]["'.$sPhase.'"]["css"]["bgbutton"]'=>array('type'=>'text'), - ); - /* - if (array_key_exists("deploytimes", $aConfig["phases"][$sPhase])){ - $aMapping['phase-'.$sPhase]['["phases"]["'.$sPhase.'"]["deploytimes"]']=array('type'=>'text'); - } - * - */ + $aMapping = [ + 'general' => [ + '["workDir"]' => ['type' => 'text'], + '["versionsToKeep"]' => ['type' => 'text', 'validate' => 'isinteger'], + '["builtsToKeep"]' => ['type' => 'text', 'validate' => 'isinteger'], + '["lang"]' => ['type' => 'text'], + ], + ]; + foreach ($aConfig['phases'] as $sPhase => $aPhaseData) { + $aMapping['phase-' . $sPhase] = [ + '["phases"]["' . $sPhase . '"]["css"]["bgdark"]' => ['type' => 'text'], + '["phases"]["' . $sPhase . '"]["css"]["bglight"]' => ['type' => 'text'], + '["phases"]["' . $sPhase . '"]["css"]["bgbutton"]' => ['type' => 'text'], + ]; + } - - $aForms = array( - 'setup' => array( - 'meta' => array( + + $aForms = [ + 'setup' => [ + 'meta' => [ 'method' => 'POST', 'action' => '?', - ), - 'validate' => array(), - 'form' => array( - 'input' . $i++ => array( + ], + 'validate' => [], + 'form' => [ + 'input' . $i++ => [ 'type' => 'hidden', 'name' => 'setupaction', 'value' => 'save', - ), - ), - ) - ); - foreach ($aMapping as $sPartname=>$aPartData){ - + ], + ], + ] + ]; + foreach ($aMapping as $sPartname => $aPartData) { + // add a headline - $aForms['setup']['form']['input' . $i++] = array( + $aForms['setup']['form']['input' . $i++] = [ 'type' => 'markup', - 'value' => '<h3>'.t('setup-deployment-'.$sPartname).'</h3>', - ); - + 'value' => '<h3>' . t('setup-deployment-' . $sPartname) . '</h3>', + ]; + // add input items - foreach ($aPartData as $sName=>$aFormOptions){ - - $sEval='$sCfgVal=$aConfig'.$sName.';'; - eval($sEval); - + foreach ($aPartData as $sName => $aFormOptions) { + + $sEval = '$sCfgVal=$aConfig' . $sName . ';'; + eval ($sEval); + // checks - if (!$sCfgVal){ - $sError.='<li>configration variable $sConfig'.$sName.' does not exist.</li>'; + if (!$sCfgVal) { + $sError .= '<li>configration variable $sConfig' . $sName . ' does not exist.</li>'; } // echo $sEval . ' .. ' . $sName . " :: " . $sCfgVar."<br>"; - $sFormname=str_replace('"', '' , 'aConfig'.$sName); + $sFormname = str_replace('"', '', 'aConfig' . $sName); + - - $aForms['setup']['form']['input' . $i++] = array( - 'value' => '<h3>'.t('setup-deployment-'.$sPartname).'</h3>', + $aForms['setup']['form']['input' . $i++] = [ + // 'value' => '<h3>' . t('setup-deployment-' . $sPartname) . '</h3>', 'type' => $aFormOptions['type'], 'name' => $sFormname, - 'label' => 'aConfig'.$sName, + 'label' => 'aConfig' . $sName, 'value' => $sCfgVal, // 'required' => 'required', 'validate' => 'isastring', 'title' => htmlentities($sCfgVal), 'size' => 100, 'placeholder' => htmlentities($sCfgVal), - ); + ]; } } - if ($sError){ - $sOut.=$oHtml->getBox("error", '<ul>'.$sError.'</ul>'); + if ($sError) { + $sOut .= $oHtml->getBox("error", '<ul>' . $sError . '</ul>'); } else { $oForm = new formgen($aForms); // TODO to enable form uncomment the next line // $sOut.=$oForm->renderHtml("setup"); } - + } - + if (array_key_exists("par3", $aParams)) { - + // ------------------------------------------------------------ // setup a new project // ------------------------------------------------------------ - if ($aParams["par3"]=="new") { - $TITLE=t("menu-new-project"); - $sOut.= '<p>'.t("page-setup-info-new-project-introtext").'</p><hr>'; + if ($aParams["par3"] == "new") { + $TITLE = t("menu-new-project"); + $sOut .= '<p>' . t("page-setup-info-new-project-introtext") . '</p><hr>'; $oPrj = new projectgui(); if (array_key_exists("setupaction", $aParams) && $aParams["setupaction"] == "create") { @@ -205,20 +205,21 @@ if ($aParams["prj"] == "all") { if (!$sError) { header("location: /deployment/" . $aParams["id"] . "/setup/"); } - $sOut.=$oHtml->getBox("error", $sError); + $sOut .= $oHtml->getBox("error", $sError); } - $sOut.=$oPrj->renderNewProject(); - $BODY= - $renderAdminLTE->addRow( - $renderAdminLTE->addCol( - $renderAdminLTE->getCard([ - 'type'=>'primary', - 'variant'=>'outline', - 'text'=>$sOut, - ]), 12 - ) - ); - + $sOut .= $oPrj->renderNewProject(); + $BODY = + $renderAdminLTE->addRow( + $renderAdminLTE->addCol( + $renderAdminLTE->getCard([ + 'type' => 'primary', + 'variant' => 'outline', + 'text' => $sOut, + ]), + 12 + ) + ); + } // ------------------------------------------------------------ // users and roles @@ -232,7 +233,7 @@ if ($aParams["prj"] == "all") { $aUser2Roles=$oUserCfg->getUser2Roles(); // $aUser2Projects=$oUserCfg->getUser2Projects(); - $aUsers=array(); + $aUsers=[]; $sOut.=print_r($aUser2Roles,1).'<br>'; $sRoles=''; foreach ($aUser2Roles as $sRole=>$aUserlist){ @@ -260,84 +261,85 @@ if ($aParams["prj"] == "all") { // ------------------------------------------------------------ // check lang-texts // ------------------------------------------------------------ - if ($aParams["par3"]=="checklang") { - $TITLE=t("menu-checklang"); - $sOut.='<p>'.t("page-setup-info-check-lang-intro").'</p>'; + if ($aParams["par3"] == "checklang") { + $TITLE = t("menu-checklang"); + $sOut .= '<p>' . t("page-setup-info-check-lang-intro") . '</p>'; // $sOut.=print_r($aConfig, true); - $aTmp=array(); - $aLangs=array(); - + $aTmp = []; + $aLangs = []; // --- fetch data foreach (glob($aConfig["configDir"] . '/lang/*.json') as $filename) { - $sLang=basename($filename); - $aLangs[]=$sLang; - foreach (json_decode(file_get_contents($filename), true) as $skey => $sText){ - $aTmp[$skey][$sLang]=$sText; + $sLang = basename($filename); + $aLangs[] = $sLang; + foreach (json_decode(file_get_contents($filename), true) as $skey => $sText) { + $aTmp[$skey][$sLang] = $sText; } } - + // --- generate output - $sWarnings=''; - $sErrors=''; - $sTable.='<table class="table"><thead><tr>' - . '<th>key</th>'; - foreach ($aLangs as $sLang) { - $sTable.='<th>'.$sLang.'</th>'; - } - $sTable.='</tr></thead><tbody>'; - - foreach ($aTmp as $sKey => $aTexts){ - $trid='tr'.md5($sKey); - $sTable.='<tr id="'.$trid.'"><td>'.$sKey.'</td>'; + $sWarnings = ''; + $sErrors = ''; + $sTable .= '<table class="table"><thead><tr>' + . '<th>key</th>'; + foreach ($aLangs as $sLang) { + $sTable .= '<th>' . $sLang . '</th>'; + } + $sTable .= '</tr></thead><tbody>'; + + foreach ($aTmp as $sKey => $aTexts) { + $trid = 'tr' . md5($sKey); + $sTable .= '<tr id="' . $trid . '"><td>' . $sKey . '</td>'; foreach ($aLangs as $sLang) { - if (array_key_exists($sLang, $aTmp[$sKey])){ - if (!$aTmp[$sKey][$sLang]){ - $sWarnings.='<li><a href="#'.$trid.'">'.$sLang.': key <em>'.$sKey.'</em> is empty.</a></li>'; - $sTable.='<td>'.t("empty").'</td>'; + if (array_key_exists($sLang, $aTmp[$sKey])) { + if (!$aTmp[$sKey][$sLang]) { + $sWarnings .= '<li><a href="#' . $trid . '">' . $sLang . ': key <em>' . $sKey . '</em> is empty.</a></li>'; + $sTable .= '<td>' . t("empty") . '</td>'; } else { - $sTable.='<td>'.htmlentities($aTmp[$sKey][$sLang]).'</td>'; + $sTable .= '<td>' . htmlentities($aTmp[$sKey][$sLang]) . '</td>'; } } else { - $sErrors.='<li><a href="#'.$trid.'">'.$sLang.': key <em>'.$sKey.'</em> does not exist.</a></li>'; - $sTable.='<td class="error">!!! MISS !!!</td>'; + $sErrors .= '<li><a href="#' . $trid . '">' . $sLang . ': key <em>' . $sKey . '</em> does not exist.</a></li>'; + $sTable .= '<td class="error">!!! MISS !!!</td>'; } } - $sTable.='</tr>'; + $sTable .= '</tr>'; } - $sTable.='</tbody></table>'; - if ($sWarnings)$sWarnings='<ol class="warning">'.$sWarnings.'</ol>'; - if ($sErrors)$sErrors='<ol class="error">'.$sErrors.'</ol>'; - $sOut.=$sErrors.$sWarnings.$sTable; + $sTable .= '</tbody></table>'; + if ($sWarnings) + $sWarnings = '<ol class="warning">' . $sWarnings . '</ol>'; + if ($sErrors) + $sErrors = '<ol class="error">' . $sErrors . '</ol>'; + $sOut .= $sErrors . $sWarnings . $sTable; } // ------------------------------------------------------------ // logoanalyzer // ------------------------------------------------------------ - if ($aParams["par3"]=="actionlog") { + if ($aParams["par3"] == "actionlog") { // $oPrj = new project(); - $TITLE=t("menu-logs"); + $TITLE = t("menu-logs"); require_once("./classes/actionlog.class.php"); - $oLog=new Actionlog(''); - - $sOut.=$oLog->renderLogs(array(), true); - + $oLog = new Actionlog(''); + + $sOut .= $oLog->renderLogs([], true); + } // ------------------------------------------------------------ // stats // ------------------------------------------------------------ // - if ($aParams["par3"]=="stats") { + if ($aParams["par3"] == "stats") { // $oPrj = new project(); require_once("./classes/actionlog.class.php"); - $oLog=new Actionlog(''); - - $sOut.='TODO' - //. $oLog->renderStats(array(), true) - ; - + $oLog = new Actionlog(''); + + $sOut .= 'TODO' + //. $oLog->renderStats([], true) + ; + } - + } - + } else { // ------------------------------------------------------------ @@ -354,21 +356,22 @@ if ($aParams["prj"] == "all") { */ if (array_key_exists("setupaction", $aParams) && $aParams["setupaction"] == "save") { if ($oPrj->saveConfig()) { - $sOut.=$oHtml->getBox("success", t("page-setup-info-settings-were-saved")); + $sOut .= $oHtml->getBox("success", t("page-setup-info-settings-were-saved")); } else { - $sOut.=$oHtml->getBox("error", t("page-setup-error-settings-were-not-saved")); + $sOut .= $oHtml->getBox("error", t("page-setup-error-settings-were-not-saved")); } } - $sErrors=$oPrj->renderErrorBoxes(); - $sOut.= $sErrors ? $sErrors : $oPrj->renderProjectSetup(); - $BODY= + $sErrors = $oPrj->renderErrorBoxes(); + $sOut .= $sErrors ? $sErrors : $oPrj->renderProjectSetup(); + $BODY = $renderAdminLTE->addRow( $renderAdminLTE->addCol( $renderAdminLTE->getCard([ - 'type'=>'primary', - 'variant'=>'outline', - 'text'=>$sOut, - ]), 12 + 'type' => 'primary', + 'variant' => 'outline', + 'text' => $sOut, + ]), + 12 ) ); diff --git a/public_html/deployment/pages/act_valuestore.php b/public_html/deployment/pages/act_valuestore.php index 3a35881f..df3c733b 100644 --- a/public_html/deployment/pages/act_valuestore.php +++ b/public_html/deployment/pages/act_valuestore.php @@ -6,38 +6,42 @@ VALUESTORE + TODO: use queryparam.class.php + --------------------------------------------------------------------- 2023-11-24 Axel <axel.hahn@unibe.ch> + ... + 2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax ###################################################################### */ -$TITLE=t('menu-valuestore'); +$TITLE = t('menu-valuestore'); // ---------------------------------------------------------------------- // functions // ---------------------------------------------------------------------- /** - * show an error message and quit with http status code 400 (Bad request) + * Show an error message and quit with http status code 400 (Bad request) * @param string $sMessage message to show - * @return boolean + * @return void */ -function quit($sMessage) +function quit(string $sMessage): void { $sProtocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'); header("$sProtocol 400: Bad request"); - die("<h1>Bad request</h1>" . $sMessage); - return false; + die("<h1>Bad request</h1>$sMessage"); } /** - * get a request param from GET and POST scope (POST has priority) and + * Get a request param from GET and POST scope (POST has priority) and * verify it with execution of a cleanup array + * * @param string $sKey key to search for in GET or POST * @param string $sRegex4Cleanup regex for filtering - * @return type + * @return bool|string */ -function getParam($sKey, $sRegex4Cleanup = false) +function getParam(string $sKey, string $sRegex4Cleanup = ''): bool|string { $sValue = false; if (array_key_exists($sKey, $_GET)) { @@ -65,7 +69,7 @@ if (!$_GET || !count($_GET)) { quit("no parameter was found."); } -foreach (array("action", "project") as $sKey) { +foreach (["action", "project"] as $sKey) { if (!array_key_exists($sKey, $_GET)) { quit("value required: $sKey="); } @@ -100,8 +104,8 @@ $sValue = getParam('value', ''); $sOut = ''; $sHeader = ''; $sOut .= '' - .'<p>'.t('page-valuestore-hint').'</p>' - ; + . '<p>' . t('page-valuestore-hint') . '</p>' +; require './../valuestore/classes/valuestore.class.php'; $oVersion = new valuestore(); @@ -122,7 +126,7 @@ if (is_array($aData) && count($aData)) { // $sTable.='<td class="'.$sKey.'"><a href="'.$sUrl.'">'.$sValue.'</a></td>'; $sOnclick = ''; $sLabel = strstr($sValue, '"') - ? '<small>'.htmlentities($sValue).'</small>' + ? '<small>' . htmlentities($sValue) . '</small>' : '<a href="#" onclick="$(\'#eFilter\').val(\'' . $sValue . '\');filterTable();" title="click to filter by [' . $sValue . ']">' . htmlentities($sValue) . '</a>'; $sTable .= '<td class="' . $sKey . '" ' . $sOnclick . '>' . $sLabel . '</td>' . "\n"; } -- GitLab