From 846c75d96d8dae62b34978dc85b789f884752cdb Mon Sep 17 00:00:00 2001 From: hahn <hahn@AAE49.campus.unibe.ch> Date: Wed, 12 Mar 2014 14:36:02 +0100 Subject: [PATCH] - move included page actions to subdir pages - language texts put to a ./config/lang/[language].json - removed getBox function - some code formatting --- .../deployment/classes/project.class.php | 332 +++++++++--------- .../deployment/classes/projectlist.class.php | 105 +++--- .../deployment/config/inc_projects_config.php | 95 +++-- public_html/deployment/index.php | 24 +- public_html/deployment/main.css | 38 +- public_html/deployment/pages/act_accept.php | 79 ++--- public_html/deployment/pages/act_build.php | 41 +-- public_html/deployment/pages/act_cleanup.php | 12 +- public_html/deployment/pages/act_deploy.php | 14 +- public_html/deployment/pages/act_doc.php | 46 +-- public_html/deployment/pages/act_overview.php | 18 +- public_html/deployment/pages/act_phase.php | 16 +- public_html/deployment/pages/act_rollback.php | 172 ++++----- 13 files changed, 477 insertions(+), 515 deletions(-) diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index de5e16cf..dbaabf08 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -71,7 +71,7 @@ class project { "ready2install" => "Puppet", "deployed" => "Installiert", ); - + /** * collector for returncodes of multiple exec calls * @var int @@ -88,7 +88,7 @@ class project { */ public function __construct($sId = false) { $this->_readConfig(); - if ($sId){ + if ($sId) { $this->setProjectById($sId); } } @@ -118,19 +118,19 @@ class project { if (!array_key_exists("packageDir", $this->_aConfig)) { die(t("class-project-error-no-packagedir")); } - if (!$this->_aConfig["packageDir"]){ + if (!$this->_aConfig["packageDir"]) { die(t("class-project-error-packagedir-empty")); } - if (!file_exists($this->_aConfig["packageDir"])){ + if (!file_exists($this->_aConfig["packageDir"])) { die(sprintf(t("class-project-error-packagedir-does-not-exist"), $this->_aConfig['packageDir'])); } - if (!array_key_exists("archiveDir", $this->_aConfig)){ - die(t("class-project-error-no-archivedir")) ; + if (!array_key_exists("archiveDir", $this->_aConfig)) { + die(t("class-project-error-no-archivedir")); } - if (!$this->_aConfig["archiveDir"]){ + if (!$this->_aConfig["archiveDir"]) { die(t("class-project-error-archivedir-empty")); } - if (!file_exists($this->_aConfig["archiveDir"])){ + if (!file_exists($this->_aConfig["archiveDir"])) { die(sprintf(t("class-project-error-packagedir-does-not-exist"), $this->_aConfig['archiveDir'])); } @@ -153,7 +153,7 @@ class project { $sReturn = ''; $bUseHtml = $_SERVER ? true : false; - if ($bFlush){ + if ($bFlush) { ob_implicit_flush(true); } // ob_end_flush(); @@ -181,7 +181,7 @@ class project { } while ($s = fgets($pipes[2])) { $sErrors.=$s; - if ($bFlush){ + if ($bFlush) { flush(); } } @@ -192,7 +192,7 @@ class project { $oStatus = proc_get_status($process); $iRc = $oStatus['exitcode']; $this->_iRcAll += $iRc; - $sReturn.="[" . date("H:i:s d.m.Y") . "] ".t("exitcode")." " . $iRc; + $sReturn.="[" . date("H:i:s d.m.Y") . "] " . t("exitcode") . " " . $iRc; if ($bUseHtml) { if ($iRc == 0) { $sReturn = '<pre class="cli">' . $sReturn; @@ -202,7 +202,7 @@ class project { $sReturn.='</pre>'; } - if ($bFlush){ + if ($bFlush) { flush(); } return $sReturn; @@ -327,18 +327,18 @@ class project { die(t("class-project-error-_getArchiveInfos-requires-id")); } $sInfoFile = $this->_getArchiveDir($sTimestamp) . '/' . $this->_aPrjConfig["fileprefix"] . '.json'; - $aReturn['infofile']=$sInfoFile; + $aReturn['infofile'] = $sInfoFile; if (!file_exists($sInfoFile)) { - $aReturn['error']=sprintf(t("class-project-error-metafile-does-not-exist"), $sInfoFile); + $aReturn['error'] = sprintf(t("class-project-error-metafile-does-not-exist"), $sInfoFile); return $aReturn; } $aJson = json_decode(file_get_contents($sInfoFile), true); if (is_array($aJson) && array_key_exists("version", $aJson)) { - $aReturn=array_merge($aReturn, $aJson); - $aReturn['ok']=1; + $aReturn = array_merge($aReturn, $aJson); + $aReturn['ok'] = 1; return $aReturn; } - $aReturn['error']=sprintf(t("class-project-error-metafile-wrong-format"), $sInfoFile); + $aReturn['error'] = sprintf(t("class-project-error-metafile-wrong-format"), $sInfoFile); return $aReturn; } @@ -386,13 +386,13 @@ class project { * and a rollback ist possible or not * return array */ - private function _getVersionUsage(){ + private function _getVersionUsage() { $aVersionData = array(); $sLastVersion = false; if (!count($this->getVersions())) { return array(); } - + foreach ($this->getVersions() as $sVersion => $aData) { $aVersionData[$sVersion]["info"] = $this->_getArchiveInfos($sVersion); @@ -407,22 +407,21 @@ class project { $bFound = true; } } - $aVersionData[$sVersion]["usage"][$sPhase][$sPlace]=$bFound; + $aVersionData[$sVersion]["usage"][$sPhase][$sPlace] = $bFound; if ($bFound) { $bCanRollback = false; } else { $bCanRollback = true; if ( - $sLastVersion - && !$aVersionData[$sLastVersion]["rollback"][$sPhase] - ) { + $sLastVersion && !$aVersionData[$sLastVersion]["rollback"][$sPhase] + ) { $bCanRollback = false; } /* - if (!array_key_exists("ok", $aVersionData[$sVersion]["info"])){ - $bCanRollback = false; - } - */ + if (!array_key_exists("ok", $aVersionData[$sVersion]["info"])){ + $bCanRollback = false; + } + */ } $aVersionData[$sVersion]["rollback"][$sPhase] = $bCanRollback; } @@ -431,7 +430,7 @@ class project { } return $aVersionData; } - + /** * recursive delete * @param type $dir @@ -799,9 +798,9 @@ class project { "message" => $sReturn ); } else { - if (!$sReturn){ + if (!$sReturn) { // $sReturn=$this->_aPrjConfig["build"]["ssh"]; - $sReturn=$sGitCmd; + $sReturn = $sGitCmd; } $this->_aData["phases"]["source"] = array( "error" => $sReturn @@ -844,7 +843,7 @@ class project { $this->_aPrjConfig = array(); require(__dir__ . '/' . $this->_sCfgfile); if (!array_key_exists("$sId", $aProjects)) { - die(sprintf(t("class-project-error-project-id-does-not-exist"),$sId)); + die(sprintf(t("class-project-error-project-id-does-not-exist"), $sId)); } $this->_aPrjConfig = $aProjects[$sId]; $this->_aConfig["id"] = $sId; @@ -918,7 +917,7 @@ class project { * @return boolean */ private function _TempFill($sData, $aActions = array()) { - if (!$this->_sProcessTempOut){ + if (!$this->_sProcessTempOut) { return false; } $sActions = ''; @@ -988,14 +987,14 @@ class project { $this->_iRcAll = 0; // return $this->_execAndSend("bash --login -c 'ruby --version' " . $sTempDir); - $sReturn = "<h2>".t("build")." " . $this->getLabel() . "</h2>"; + $sReturn = "<h2>" . t("build") . " " . $this->getLabel() . "</h2>"; // -------------------------------------------------- // cleanup // -------------------------------------------------- $aDirs = $this->cleanupBuilds(); if (count($aDirs)) { - $sReturn.='<h3>'.t('class-project-build-label-cleanup-builds').'</h3><pre>' . print_r($aDirs, true) . '</pre>'; + $sReturn.='<h3>' . t('class-project-build-label-cleanup-builds') . '</h3><pre>' . print_r($aDirs, true) . '</pre>'; } $aActionList['iActive'] ++; $this->_TempFill($sReturn, $aActionList); @@ -1010,7 +1009,7 @@ class project { return false; } - $sReturn.='<h3>'.t('class-project-build-label-create-workdir').'</h3>'; + $sReturn.='<h3>' . t('class-project-build-label-create-workdir') . '</h3>'; if (!file_exists($sTempDir)) { $sReturn.=$this->_execAndSend("mkdir -p " . $sTempDir); } @@ -1029,7 +1028,7 @@ class project { switch ($this->_aPrjConfig["build"]["type"]) { case "git": - $sReturn.='<h3>'.t('class-project-build-label-get-sources-from-version-control').'</h3>'; + $sReturn.='<h3>' . t('class-project-build-label-get-sources-from-version-control') . '</h3>'; // $sReturn.=$this->_execAndSend("find " . $this->_aConfig["workDir"]); // SKIP $sReturn.=$this->_execAndSend("cd $sTempDir && git init"); @@ -1071,7 +1070,7 @@ class project { // execute hook postclone // -------------------------------------------------- $sHookfile = $this->_aConfig['hooks']['build-postclone']; - $sReturn.='<h3>' . t('class-project-build-label-execute-hook-postclone'). ' ('.$sHookfile.')</h3>'; + $sReturn.='<h3>' . t('class-project-build-label-execute-hook-postclone') . ' (' . $sHookfile . ')</h3>'; if (file_exists($sTempDir . '/' . $sHookfile)) { $sReturn.=$this->_execAndSend('cd ' . $sTempDir . ' && chmod 755 hooks/on*'); $sReturn.=$this->_execAndSend('bash --login -c \'' . $sTempDir . '/' . $sHookfile . '\''); @@ -1080,7 +1079,7 @@ class project { return $this->getBox("error", sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn); } } else { - $sReturn.=t('skip').'<br>'; + $sReturn.=t('skip') . '<br>'; } $aActionList['iActive'] ++; $this->_TempFill($sReturn, $aActionList); @@ -1089,13 +1088,13 @@ class project { // -------------------------------------------------- // copy default structure // -------------------------------------------------- - $sReturn.='<h3>'.t('class-project-build-label-copy-default-structure').'</h3>'; + $sReturn.='<h3>' . t('class-project-build-label-copy-default-structure') . '</h3>'; if ($this->_getDefaultsDir()) { $sReturn.=$this->_execAndSend("find " . $this->_getDefaultsDir() . " | head -15"); $sReturn.=$this->_execAndSend("rsync -r " . $this->_getDefaultsDir() . "/* $sTempDir"); // $sReturn.=$this->_execAndSend("find $sTempDir"); } else { - $sReturn.=t('skip').'<br>'; + $sReturn.=t('skip') . '<br>'; } $aActionList['iActive'] ++; $this->_TempFill($sReturn, $aActionList); @@ -1104,7 +1103,7 @@ class project { // execute hook // -------------------------------------------------- $sHookfile = $this->_aConfig['hooks']['build-precompress']; - $sReturn.='<h3>' .t('class-project-build-label-execute-hook-precompress').' ('. $sHookfile . ')</h3>'; + $sReturn.='<h3>' . t('class-project-build-label-execute-hook-precompress') . ' (' . $sHookfile . ')</h3>'; if (file_exists($sTempDir . '/' . $sHookfile)) { $sReturn.=$this->_execAndSend('cd ' . $sTempDir . ' && chmod 755 hooks/on*'); $sReturn.=$this->_execAndSend('bash --login -c \'' . $sTempDir . '/' . $sHookfile . '\''); @@ -1113,7 +1112,7 @@ class project { return $this->getBox("error", sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn); } } else { - $sReturn.=t('skip').'<br>'; + $sReturn.=t('skip') . '<br>'; } $aActionList['iActive'] ++; $this->_TempFill($sReturn, $aActionList); @@ -1123,7 +1122,7 @@ class project { // TODO: cleanup .git, .svn, ...? // wenn es kein .git gibt, bricht er ab... // -------------------------------------------------- - $sReturn.='<h3>'.t('class-project-build-label-cleanup-project').'</h3>'; + $sReturn.='<h3>' . t('class-project-build-label-cleanup-project') . '</h3>'; $sReturn.=$this->_execAndSend("cd $sTempDir && rm -rf .git"); // $sReturn.=$this->_execAndSend("cd $sTempDir && rm -rf .svn"); // $sReturn.=$this->_execAndSend("find $sTempDir -type d -name '.svn' -exec rm -rf {} \;"); @@ -1133,7 +1132,7 @@ class project { // -------------------------------------------------- // create package // -------------------------------------------------- - $sReturn.='<h3>'.t('class-project-build-label-create-package').'</h3>'; + $sReturn.='<h3>' . t('class-project-build-label-create-package') . '</h3>'; // public_html must exist $sWebroot = false; @@ -1156,7 +1155,6 @@ class project { return $this->getBox("error", sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn); } // $sReturn.=$this->getBox("success", "preparations ok - directory is ready for packaging now."); - // generate info file $sTs = date("Y-m-d H:i:s"); $sTs2 = date("Ymd_His"); @@ -1175,12 +1173,12 @@ class project { "remark": "' . $aParams["inputComment"] . '" */ - $sReturn.=t("class-project-info-build-write-meta-to-webroot")."<br>"; + $sReturn.=t("class-project-info-build-write-meta-to-webroot") . "<br>"; file_put_contents($sInfoFileWebroot, $sInfos); $sReturn.=$this->_execAndSend("ls -l $sInfoFileWebroot"); if (!file_exists(dirname($sPackageFileArchiv))) { - $sReturn.=sprintf(t("creating-directory"), dirname($sPackageFileArchiv))."<br>"; + $sReturn.=sprintf(t("creating-directory"), dirname($sPackageFileArchiv)) . "<br>"; mkdir(dirname($sPackageFileArchiv), 0775, true); } $sReturn.=$this->_execAndSend("ls -ld " . dirname($sPackageFileArchiv)); @@ -1192,24 +1190,24 @@ class project { // create tgz archive - $sReturn.=sprintf(t("creating-file"), $sPackageFileArchiv)."<br>"; + $sReturn.=sprintf(t("creating-file"), $sPackageFileArchiv) . "<br>"; $sReturn.=$this->_execAndSend("cd $sTempDir && tar -czf $sPackageFileArchiv ."); $this->_TempFill($sReturn, $aActionList); // write info file (.json) - $sReturn.=sprintf(t("creating-file"), $sInfoFileArchiv)."<br>"; + $sReturn.=sprintf(t("creating-file"), $sInfoFileArchiv) . "<br>"; file_put_contents($sInfoFileArchiv, $sInfos); // copy template files if (file_exists($sTempDir . '/hooks/templates/')) { - $sReturn.=t("class-project-info-build-write-templatefiles-to-archive")."<br>"; + $sReturn.=t("class-project-info-build-write-templatefiles-to-archive") . "<br>"; $sReturn.=$this->_execAndSend("cp $sTempDir/hooks/templates/* " . $this->_getArchiveDir($sTs2)); } else { - $sReturn.=t("class-project-info-build-write-templatefiles-to-archive-skipped")."<br>"; + $sReturn.=t("class-project-info-build-write-templatefiles-to-archive-skipped") . "<br>"; } $this->_TempFill($sReturn, $aActionList); - $sReturn.="<br>".t("info").":<br>"; + $sReturn.="<br>" . t("info") . ":<br>"; $sReturn.=$this->_execAndSend("ls -l " . $this->_getArchiveDir($sTs2)); if (!$this->_iRcAll == 0) { @@ -1219,7 +1217,7 @@ class project { $aActionList['iActive'] ++; $this->_TempFill($sReturn, $aActionList); - $sReturn.='<h3>'.t("class-project-build-label-remove-workdir").'</h3>'; + $sReturn.='<h3>' . t("class-project-build-label-remove-workdir") . '</h3>'; $sReturn.=$this->_execAndSend("rm -rf $sTempDir"); $sReturn.=t("class-project-info-build-remove-oldest-archives"); $sReturn.='<pre>' . print_r($this->cleanupArchive(), true) . '</pre>'; @@ -1253,7 +1251,7 @@ class project { array('label' => t("class-project-queue-label-deploy")), ), ); - $sReturn = "<h2> " . t("queue") ." " . $this->getLabel() . " :: $sPhase</h2>"; + $sReturn = "<h2> " . t("queue") . " " . $this->getLabel() . " :: $sPhase</h2>"; $this->_TempFill($sReturn, $aActionList); if (!$this->isActivePhase($sPhase)) { @@ -1285,7 +1283,7 @@ class project { // -------------------------------------------------- $this->_iRcAll = 0; if (file_exists($sLinkName)) { - $sReturn.=t("class-project-queue-label-remove-existing-version")."<br>"; + $sReturn.=t("class-project-queue-label-remove-existing-version") . "<br>"; $sReturn.=$this->_execAndSend("rm -f $sLinkName"); } $aActionList['iActive'] ++; @@ -1294,8 +1292,8 @@ class project { // -------------------------------------------------- // create the new link // -------------------------------------------------- - $sReturn.=t("class-project-queue-label-link-new-version")."<br>"; - + $sReturn.=t("class-project-queue-label-link-new-version") . "<br>"; + $sReturn.=$this->_execAndSend("ln -s $sLinkTarget $sLinkName"); $sReturn.=$this->_execAndSend("ls -l $sLinkName | fgrep $sLinkTarget"); $aActionList['iActive'] ++; @@ -1332,25 +1330,25 @@ class project { array('label' => t("class-project-deploy-label-install-on-target")), ), ); - $sReturn = "<h2>" .t("deploy") ." ". $this->getLabel() . " :: $sPhase</h2>"; + $sReturn = "<h2>" . t("deploy") . " " . $this->getLabel() . " :: $sPhase</h2>"; $this->_TempFill($sReturn, $aActionList); if (!$this->isActivePhase($sPhase)) { - return $sReturn . $this->getBox("error", sprintf(t("class-project-warning-phase-not-active"), $sPhase )); + return $sReturn . $this->getBox("error", sprintf(t("class-project-warning-phase-not-active"), $sPhase)); } $sQueueLink = $this->_getFileBase($sPhase, "onhold"); $sRepoLink = $this->_getFileBase($sPhase, "ready2install"); - $sReturn.="<h3>".t("class-project-deploy-label-checks")."</h3>"; + $sReturn.="<h3>" . t("class-project-deploy-label-checks") . "</h3>"; if (array_key_exists("deploytimes", $this->_aConfig["phases"][$sPhase])) { // check if the a deploy time is reached $sNow = date("D H:i:s"); - $sReturn.=sprintf(t("class-project-info-deploy-check-deployment-times"), $sNow)."<br>"; + $sReturn.=sprintf(t("class-project-info-deploy-check-deployment-times"), $sNow) . "<br>"; $bCanDeploy = false; foreach ($this->_aConfig["phases"][$sPhase]["deploytimes"] as $sRegex) { $sReturn.=sprintf(t("class-project-info-deploy-test-regex"), $sRegex); - + if (preg_match($sRegex, $sNow)) { $sReturn.=t("ok"); $bCanDeploy = true; @@ -1365,10 +1363,10 @@ class project { $this->_TempDelete(); return $sReturn; } else { - $sReturn.=t("class-project-info-deploy-time-not-reached-and-ignored")."<br>"; + $sReturn.=t("class-project-info-deploy-time-not-reached-and-ignored") . "<br>"; } } else { - $sReturn.=t("class-project-info-deploy-time-ok")."<br>"; + $sReturn.=t("class-project-info-deploy-time-ok") . "<br>"; } // if () } @@ -1387,24 +1385,24 @@ class project { // -------------------------------------------------- $this->_iRcAll = 0; if (file_exists($sRepoLink)) { - $sReturn.=t("class-project-info-deploy-removing-existing-version")."<br>"; + $sReturn.=t("class-project-info-deploy-removing-existing-version") . "<br>"; $sReturn.=$this->_execAndSend("rm -f $sRepoLink"); } $this->_TempFill($sReturn); - $sReturn.=t("class-project-info-deploy-moving-queue-to-repo")."<br>"; + $sReturn.=t("class-project-info-deploy-moving-queue-to-repo") . "<br>"; $sReturn.=$this->_execAndSend("mv $sQueueLink $sRepoLink"); if (!$this->_iRcAll == 0) { $this->_TempDelete(); - return $this->getBox("error", t("class-project-error-command-failed"). $sReturn); + return $this->getBox("error", t("class-project-error-command-failed") . $sReturn); } $this->_TempFill($sReturn); // $sReturn.=$this->_execAndSend("ln -s $sLinkTarget $sLinkName"); if (array_key_exists('mirrorPackages', $this->_aConfig) && count($this->_aConfig['mirrorPackages'])) { foreach ($this->_aConfig['mirrorPackages'] as $sLabel => $aTarget) { - $sReturn.=sprintf(t("class-project-info-deploy-synching-package"), $sLabel)."<br>"; + $sReturn.=sprintf(t("class-project-info-deploy-synching-package"), $sLabel) . "<br>"; if (array_key_exists('type', $aTarget)) { $sCmd = false; // $sSource=$this->_aConfig["packageDir"]."/$sPhase/*"; @@ -1415,7 +1413,7 @@ class project { $sCmd = "ls -l $sSource 2>/dev/null && /usr/bin/rsync --delete -rLv $sSource $sTarget"; break; default: - $sReturn.=sprintf(t("class-project-info-deploy-skip-sync"), $aTarget['type'])."<br>"; + $sReturn.=sprintf(t("class-project-info-deploy-skip-sync"), $aTarget['type']) . "<br>"; break; } // switch if ($sCmd) { @@ -1437,14 +1435,14 @@ class project { // TODO: run puppet agent on target server(s) - for preview only if (array_key_exists("puppethost", $this->_aPrjConfig["phases"][$sPhase]) && $this->_aPrjConfig["phases"][$sPhase]["puppethost"] ) { - $sReturn.=t("class-project-info-deploy-start-puppet")."<br>"; + $sReturn.=t("class-project-info-deploy-start-puppet") . "<br>"; $sCmd = 'ssh ' . $this->_aConfig["installPackages"]["user"] . '@' . $this->_aPrjConfig["phases"][$sPhase]["puppethost"] . ' ' . $this->_aConfig["installPackages"]["command"]; // $sReturn.=$this->_execAndSend("ssh imldeployment@" . $this->_aPrjConfig["phases"][$sPhase]["puppethost"] . " sudo puppet agent -t | fgrep -i Deploy"); $sReturn.=$this->_execAndSend("$sCmd"); } else { - $sReturn.=t("class-project-info-deploy-start-puppet-skip")."<br>"; + $sReturn.=t("class-project-info-deploy-start-puppet-skip") . "<br>"; } $aActionList['iActive'] ++; $this->_TempFill($sReturn, $aActionList); @@ -1462,12 +1460,12 @@ class project { * @return type */ public function accept($sPhase) { - $sReturn = "<h2>" . t("accept") ." ".$this->getLabel() . " :: $sPhase</h2>"; + $sReturn = "<h2>" . t("accept") . " " . $this->getLabel() . " :: $sPhase</h2>"; if (!$this->canAcceptPhase($sPhase)) { return $sReturn . $this->getBox("error", sprintf(t("class-project-error-accept-impossible"), $sPhase)); } - $sReturn.="<h3>".sprintf(s("class-project-info-accept-overview"), $sPhase)."</h3>"; + $sReturn.="<h3>" . sprintf(s("class-project-info-accept-overview"), $sPhase) . "</h3>"; $this->_TempFill($sReturn); $aInfos = $this->getPhaseInfos($sPhase); $sVersion = $aInfos["deployed"]["version"]; @@ -1648,11 +1646,11 @@ class project { 'label' => $this->getLabel() ), 'phase' => array('icon' => 'icon-chevron-right', 'class' => $sPhase, - 'hint' => sprintf(t('phase-details-hint'),$sPhase), + 'hint' => sprintf(t('phase-details-hint'), $sPhase), 'label' => t('phase-details') ), 'rollback' => array('icon' => 'icon-forward', 'class' => $sPhase, - 'hint' => sprintf(t('rollback-hint'),$sPhase, $sVersion), + 'hint' => sprintf(t('rollback-hint'), $sPhase, $sVersion), 'label' => t('rollback') ), ); @@ -1703,21 +1701,21 @@ class project { public function renderProjektInfos() { $sReturn = false; $sReturn.='<table><tbody>' - .'<tr><td>' . t('projectname') . ':</td><td>' . $this->_aPrjConfig['label'] . '</td></tr>' - .'<tr><td>' . t('description') . ':</td><td>' . $this->_aPrjConfig['description'] . '</td></tr>' - .'<tr><td>' . t('contact') . ':</td><td>' . $this->_aPrjConfig['contact'] . '</td></tr>' - ; - + . '<tr><td>' . t('projectname') . ':</td><td>' . $this->_aPrjConfig['label'] . '</td></tr>' + . '<tr><td>' . t('description') . ':</td><td>' . $this->_aPrjConfig['description'] . '</td></tr>' + . '<tr><td>' . t('contact') . ':</td><td>' . $this->_aPrjConfig['contact'] . '</td></tr>' + ; + if (array_key_exists("type", $this->_aPrjConfig["build"])) { - $sReturn.='<tr><td>'.t('repositoryinfos').':</td><td><strong>' . $this->_aPrjConfig["build"]["type"] . '</strong><br>'; + $sReturn.='<tr><td>' . t('repositoryinfos') . ':</td><td><strong>' . $this->_aPrjConfig["build"]["type"] . '</strong><br>'; if (array_key_exists("ssh", $this->_aPrjConfig["build"])) { - $sReturn.=t('repository-access-ssh').'<br><em>' . $this->_aPrjConfig["build"]["ssh"] . '</em><br>'; + $sReturn.=t('repository-access-ssh') . '<br><em>' . $this->_aPrjConfig["build"]["ssh"] . '</em><br>'; } - $sReturn.=t('repository-access-ssh').':<br>'; + $sReturn.=t('repository-access-ssh') . ':<br>'; if (array_key_exists("webaccess", $this->_aPrjConfig["build"])) { $sReturn.='<a href="' . $this->_aPrjConfig["build"]["webaccess"] . '">' . $this->_aPrjConfig["build"]["webaccess"] . '</a><br>'; } else { - $sReturn.=t("unknown").'<br>'; + $sReturn.=t("unknown") . '<br>'; } $sReturn.='</td></tr>'; } @@ -1737,8 +1735,8 @@ class project { foreach ($this->getActivePhases() as $sPhase) { $sRow1.='<th class="' . $sPhase . '">' . $sPhase . '</th>'; $sRow2.='<td class="' . $sPhase . '">' - . t('url').': <a href="' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '">' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '</a><br>' - . '<br>'.t('deploytimes').':<br>'; + . t('url') . ': <a href="' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '">' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '</a><br>' + . '<br>' . t('deploytimes') . ':<br>'; if (array_key_exists("deploytimes", $this->_aConfig["phases"][$sPhase])) { $sRow2.=implode("<br>", $this->_aConfig["phases"][$sPhase]["deploytimes"]); } else { @@ -1780,25 +1778,24 @@ class project { // TODO: getChecksumDiv anhand der Repo-Versionsnummer - dann kann man beim build auch die Farbe mit dem Repo HEAD vergleichen $sReturn .= ' ' . $this->_renderBar($sPhase, $sPlace) . ' - <i class="icon-calendar"></i> '.t('build-from').' ' . date("d.m.Y H:i:s", strtotime($aData["date"])); + <i class="icon-calendar"></i> ' . t('build-from') . ' ' . date("d.m.Y H:i:s", strtotime($aData["date"])); if ($bLong) { - $sReturn.='<br><i class="icon-tag"></i> '.t('revision').': ' . $aData["revision"] . '<br> - <i class="icon-comment"></i> '.t('commitmessage').':<br><pre>' . strip_tags($aData["message"], '<br>') . '</pre>'; + $sReturn.='<br><i class="icon-tag"></i> ' . t('revision') . ': ' . $aData["revision"] . '<br> + <i class="icon-comment"></i> ' . t('commitmessage') . ':<br><pre>' . strip_tags($aData["message"], '<br>') . '</pre>'; if ($sPlace == "deployed" && array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase])) { - $sReturn.='<i class="icon-globe"></i> '.t('url').': <a href="' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '">' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '</a><br>'; + $sReturn.='<i class="icon-globe"></i> ' . t('url') . ': <a href="' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '">' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '</a><br>'; } } else { if ($sPlace == "deployed" && array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase])) { - $sMore='<i class="icon-globe"></i> '.t('url').': ' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '<br>'; + $sMore = '<i class="icon-globe"></i> ' . t('url') . ': ' . $this->_aPrjConfig["phases"][$sPhase]["url"] . '<br>'; } - - $sReturn.=' '.$this->renderInfoLink( - $aData, - array( - 'title'=>$this->getLabel() . " :: $sPhase :: $sPlace", - 'more'=>$sMore, - ) - ); + + $sReturn.=' ' . $this->renderInfoLink( + $aData, array( + 'title' => $this->getLabel() . " :: $sPhase :: $sPlace", + 'more' => $sMore, + ) + ); } switch ($sPlace) { @@ -1806,7 +1803,7 @@ class project { if (array_key_exists("phases", $this->_aConfig) && array_key_exists($sPhase, $this->_aConfig["phases"])) { // $sReturn .= print_r($this->_aConfig["phases"][$sPhase], true); if (array_key_exists("deploytimes", $this->_aConfig["phases"][$sPhase])) { - $sReturn .= '<br><i class="icon-time"></i> '.t('deploytimes').':<br>' + $sReturn .= '<br><i class="icon-time"></i> ' . t('deploytimes') . ':<br>' . implode("<br>", array_values($this->_aConfig["phases"][$sPhase]["deploytimes"])) . '<br>'; } @@ -1833,11 +1830,11 @@ class project { // if ($bLong and true){ // $sReturn.= '<i class="icon-exclamation-sign"></i> FEHLER:<br>' . $aData["error"] . ''; // } else { - $sReturn.= '<a href="#" class="info"><i class="icon-exclamation-sign"></i> '.t('error').':<span>' . $aData["error"] . '</span></a>'; + $sReturn.= '<a href="#" class="info"><i class="icon-exclamation-sign"></i> ' . t('error') . ':<span>' . $aData["error"] . '</span></a>'; // } $sReturn.= '</div>'; } else if (array_key_exists("warning", $aData)) { - $sReturn.= '<div class="warning"><i class="icon-info-sign"></i> '.t('warning').':<br>' . $aData["warning"] . '</div>'; + $sReturn.= '<div class="warning"><i class="icon-info-sign"></i> ' . t('warning') . ':<br>' . $aData["warning"] . '</div>'; } else { $sReturn.= t('empty'); } @@ -1872,7 +1869,7 @@ class project { if (!$this->isActivePhase($sPhase)) { return ' <td class="' . $sPhase . ' tdphase ' . $this->_aConfig["id"] . '" colspan="' . count($this->_aPlaces) . '"> - <div class="versioninfo center inactive"><i class="icon-ban-circle"></i> '.t('inactive').'</div> + <div class="versioninfo center inactive"><i class="icon-ban-circle"></i> ' . t('inactive') . '</div> </td>'; } $sRow2 = false; @@ -1909,7 +1906,7 @@ class project { if (array_key_exists("revision", $aRepodata)) { $sRevision = $aRepodata["revision"]; $sReturn.=$this->_getChecksumDiv($sRevision); - $sReturn.= '<i class="icon-tag"></i> '.t('revision').': ' . $sRevision; + $sReturn.= '<i class="icon-tag"></i> ' . t('revision') . ': ' . $sRevision; $sReturn.="<pre>" . strip_tags($aRepodata["message"], '<br>') . "</pre>"; } else { return $this->getBox("error", sprintf(t('class-project-error-no-repoaccess'), $aRepodata["error"])) @@ -1917,7 +1914,7 @@ class project { } if (array_key_exists("webaccess", $this->_aPrjConfig["build"])) { - $sReturn.='<br>'.t('repository-access-browser').':<br><a href="' . $this->_aPrjConfig["build"]["webaccess"] . '">' . $this->_aPrjConfig["build"]["webaccess"] . '</a><br>'; + $sReturn.='<br>' . t('repository-access-browser') . ':<br><a href="' . $this->_aPrjConfig["build"]["webaccess"] . '">' . $this->_aPrjConfig["build"]["webaccess"] . '</a><br>'; } break; @@ -1938,59 +1935,58 @@ class project { * hpos - horizontal position; one of left|right; default: right * @return string */ - public function renderInfoLink($aInfos, $aOptions=array()){ - $sReturn=''; - $bIsError=false; - + public function renderInfoLink($aInfos, $aOptions = array()) { + $sReturn = ''; + $bIsError = false; + $sInfos.=''; if (array_key_exists("title", $aOptions) && $aOptions["title"]) { $sTitle.=$aOptions["title"]; } - if (array_key_exists("ok", $aInfos)){ - $sLinktitle=t('infos'); - if (array_key_exists("message", $aInfos)){ - $sInfos.='<i class="icon-calendar"></i> '.t('build-from').' ' . date("d.m.Y H:i:s", strtotime($aInfos["date"])).'<br>' - .'<i class="icon-tag"></i> '.t('revision').': ' . $aInfos["revision"] . '<br>' - .'<i class="icon-comment"></i> '.t('commitmessage').':<br><span class="pre">' . strip_tags($aInfos["message"],'<br>') . '</span>'; - if (array_key_exists("more", $aOptions)){ + if (array_key_exists("ok", $aInfos)) { + $sLinktitle = t('infos'); + if (array_key_exists("message", $aInfos)) { + $sInfos.='<i class="icon-calendar"></i> ' . t('build-from') . ' ' . date("d.m.Y H:i:s", strtotime($aInfos["date"])) . '<br>' + . '<i class="icon-tag"></i> ' . t('revision') . ': ' . $aInfos["revision"] . '<br>' + . '<i class="icon-comment"></i> ' . t('commitmessage') . ':<br><span class="pre">' . strip_tags($aInfos["message"], '<br>') . '</span>'; + if (array_key_exists("more", $aOptions)) { $sInfos.=$aOptions["more"]; } } - } else { - $bIsError=true; + $bIsError = true; if (!$sTitle) { - $sTitle.=' '.t('error'); + $sTitle.=' ' . t('error'); } - $sLinktitle='<i class="icon-exclamation-sign"></i> '.t('error'); - $sInfos=$aInfos["error"]; + $sLinktitle = '<i class="icon-exclamation-sign"></i> ' . t('error'); + $sInfos = $aInfos["error"]; } - + if (array_key_exists("label", $aOptions) && $aOptions["label"]) { $sLinktitle.=$aOptions["label"]; } // render html - $sReturn='<a href="#" class="info">' - .$sLinktitle - .'<span'; - if (array_key_exists("hpos", $aOptions)){ - $sReturn.=' class="'.$aOptions["hpos"].'"'; + $sReturn = '<a href="#" class="info">' + . $sLinktitle + . '<span'; + if (array_key_exists("hpos", $aOptions)) { + $sReturn.=' class="' . $aOptions["hpos"] . '"'; } $sReturn.='>'; - + if ($sTitle) { - $sReturn.='<span class="title">'.$sTitle.'</span><br><br>'; - } + $sReturn.='<span class="title">' . $sTitle . '</span><br><br>'; + } $sReturn.=$sInfos . '</span></a>'; - - if ($bIsError){ - $sReturn='<div class="error">'.$sReturn.'</div>'; + + if ($bIsError) { + $sReturn = '<div class="error">' . $sReturn . '</div>'; } - + return $sReturn; } - + /** * return html code for a list of all built packages and their usage * @return string @@ -1999,32 +1995,32 @@ class project { $sReturn = false; $sRowHead1 = false; $sRowHead2 = ''; - - $aAllVersions=$this->_getVersionUsage(); + + $aAllVersions = $this->_getVersionUsage(); if (!count($aAllVersions)) { return $this->getBox("info", t('class-project-info-no-package')); } - + foreach ($this->getActivePhases() as $sPhase) { $sRowHead1.='<th class="' . $sPhase . '" colspan="' . (count($this->_aPlaces) + 1) . '">' . $sPhase . '</th>'; $sRowHead2.='<td></td>' . $this->renderPlacesAsTd($sPhase); } // echo "<pre>" . print_r($aAllVersions, true) . "</pre>"; - + foreach ($aAllVersions as $sVersion => $aData) { $sReturn.='<tr>'; - $sInfos = $this->renderInfoLink($aData["info"], array('hpos'=>'left')); + $sInfos = $this->renderInfoLink($aData["info"], array('hpos' => 'left')); $sReturn.='<td>' . $sVersion . ' ' . $sInfos . '</td>'; - + foreach ($this->getActivePhases() as $sPhase) { $sTLine = ''; - $bCanRollback=$aData["rollback"][$sPhase]; - + $bCanRollback = $aData["rollback"][$sPhase]; + // $sReturn.=$aData["rollback"][$sPhase] ? '<td>'.$this->renderLink("rollback", $sPhase, $sVersion).'</td>' : '<td>Rollback NOT possible</td>'; $sReturn.=$aData["rollback"][$sPhase] ? '<td> Y </td>' : '<td> N </td>'; - + foreach (array_keys($this->_aPlaces) as $sPlace) { $bFound = false; $sReturn.=$aData["usage"][$sPhase][$sPlace] ? '<td class="' . $sPhase . '" style="text-align: center;">X</td>' : '<td> </td>'; @@ -2033,7 +2029,7 @@ class project { $sReturn.='</tr>'; } - $sReturn = t('class-project-info-table-packages').'<br><br>' + $sReturn = t('class-project-info-table-packages') . '<br><br>' . '<table>' . '<thead><tr><td>Version</td>' . $sRowHead1 @@ -2058,34 +2054,34 @@ class project { $i = 0; $aPrefixItem = count($this->getVersions()) ? - array( + array( 'type' => 'markup', 'value' => '<fieldset> - <label class="control-label">'.t('fileprefix').'</label> + <label class="control-label">' . t('fileprefix') . '</label> <div> <input id="inputprefix" type="hidden" name="fileprefix" value="' . $this->_aPrjConfig["fileprefix"] . '"> ' . $this->_aPrjConfig["fileprefix"] . ' </div> </fieldset> ', - ) : array( - 'type' => 'text', - 'name' => 'fileprefix', - // 'disabled' => 'disabled', - 'label' => t('fileprefix-label'), - 'value' => $this->_aPrjConfig["fileprefix"], - 'required' => 'required', - 'validate' => 'isastring', - 'pattern' => '[a-z0-9\-\_]*', - 'size' => 100, - 'placeholder' => '', - ); + ) : array( + 'type' => 'text', + 'name' => 'fileprefix', + // 'disabled' => 'disabled', + 'label' => t('fileprefix-label'), + 'value' => $this->_aPrjConfig["fileprefix"], + 'required' => 'required', + 'validate' => 'isastring', + 'pattern' => '[a-z0-9\-\_]*', + 'size' => 100, + 'placeholder' => '', + ); $aRepodata = $this->getRepoRevision(); if (is_array($aRepodata) && array_key_exists("message", $aRepodata)) { - $sRepoCheck = '<span class="ok">'.t('class-project-info-repoaccess').'</span>'; + $sRepoCheck = '<span class="ok">' . t('class-project-info-repoaccess') . '</span>'; } else { - $sRepoCheck = '<span class="error">'.sprintf(t('class-project-error-no-repoaccess'), $aRepodata["error"]).'</span>'; + $sRepoCheck = '<span class="error">' . sprintf(t('class-project-error-no-repoaccess'), $aRepodata["error"]) . '</span>'; $sMessages.=$this->getBox("error", sprintf(t('class-project-error-no-repoaccess'), $aRepodata["error"])); } @@ -2111,9 +2107,9 @@ class project { 'type' => 'markup', 'value' => '<div class="tabbable"> <ul class="nav nav-tabs"> - <li class="active"><a href="#tab1" data-toggle="tab">'.t('setup-metadata').'</a></li> - <li><a href="#tab2" data-toggle="tab">'.t('build').'</a></li> - <li><a href="#tab3" data-toggle="tab">'.t('phases').'</a></li> + <li class="active"><a href="#tab1" data-toggle="tab">' . t('setup-metadata') . '</a></li> + <li><a href="#tab2" data-toggle="tab">' . t('build') . '</a></li> + <li><a href="#tab3" data-toggle="tab">' . t('phases') . '</a></li> </ul> <div class="tab-content"> <div class="tab-pane active" id="tab1"> @@ -2154,7 +2150,7 @@ class project { 'input' . $i++ => array( 'type' => 'markup', 'value' => ' </div><div class="tab-pane" id="tab2"> - <p>'.t('setup-hint-build').'</p>', + <p>' . t('setup-hint-build') . '</p>', ), 'input' . $i++ => array( 'type' => 'text', @@ -2207,7 +2203,7 @@ class project { 'input' . $i++ => array( 'type' => 'markup', 'value' => ' </div><div class="tab-pane" id="tab3"> - <p>'. sprintf(t("class-project-info-setup-phaseinfos"), $this->getNextPhase()) . '</p>', + <p>' . sprintf(t("class-project-info-setup-phaseinfos"), $this->getNextPhase()) . '</p>', ), ), ), @@ -2215,7 +2211,7 @@ class project { foreach (array_keys($this->getPhases()) as $sPhase) { $aForms["setup"]["form"]['input' . $i++] = array( 'type' => 'markup', - 'value' => t("phase").' <span class="' . $sPhase . '">' . $sPhase . '</span>', + 'value' => t("phase") . ' <span class="' . $sPhase . '">' . $sPhase . '</span>', ); $sUrl = array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["url"] : ""; $aForms["setup"]["form"]['input' . $i++] = array( @@ -2247,7 +2243,7 @@ class project { $sMessages.=$this->getBox("error", sprintf(t("class-project-error-setup-sudo-pupet-agent-failed"), $sPhase, $sCmd, $sOut)); $sOut = '<span class="error" title="' . $sCmd . '">' . $sOut . '</span>'; } else { - $sOut = '<span class="ok">' .sprintf(t("class-project-info-setup-ssh-and-puppet-ok"), $sPuppethost) . '</span>'; + $sOut = '<span class="ok">' . sprintf(t("class-project-info-setup-ssh-and-puppet-ok"), $sPuppethost) . '</span>'; } $aForms["setup"]["form"]['input' . $i++] = array( 'type' => 'markup', diff --git a/public_html/deployment/classes/projectlist.class.php b/public_html/deployment/classes/projectlist.class.php index 1453fc6b..24c970d8 100644 --- a/public_html/deployment/classes/projectlist.class.php +++ b/public_html/deployment/classes/projectlist.class.php @@ -1,4 +1,5 @@ <?php + /* ###################################################################### IML DEPLOYMENT @@ -15,7 +16,6 @@ require_once 'project.class.php'; * class for project overview */ class projectlist { - // ---------------------------------------------------------------------- // CONFIG // ---------------------------------------------------------------------- @@ -28,21 +28,18 @@ class projectlist { * @param array $aProjects array with all projects (overrides config data) */ public function __construct($aProjects = false) { + } // ---------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------- - - // ---------------------------------------------------------------------- // GETTER // ---------------------------------------------------------------------- - // ---------------------------------------------------------------------- // SETTER // ---------------------------------------------------------------------- - // ---------------------------------------------------------------------- // ACTIONS // ---------------------------------------------------------------------- @@ -55,56 +52,56 @@ class projectlist { $sOut = ''; // table $sOut2 = ''; // tiles $oPrj = false; - $sTrClass="trproject"; - $sColClass="tdphase"; + $sTrClass = "trproject"; + $sColClass = "tdphase"; $oPrj1 = new project(); - - $sPrjFilter=''; - $sPhaseFilter=''; - $sPrjFilter.='<option value="'.$sTrClass.'">'.t("all").'</option>'; - $sPhaseFilter.='<option value="'.$sColClass.'">'.t("all").'</option>'; + + $sPrjFilter = ''; + $sPhaseFilter = ''; + $sPrjFilter.='<option value="' . $sTrClass . '">' . t("all") . '</option>'; + $sPhaseFilter.='<option value="' . $sColClass . '">' . t("all") . '</option>'; // foreach (array_keys($this->_aPhases) as $sPhase) { foreach (array_keys($oPrj1->getPhases()) as $sPhase) { - $sPhaseFilter.='<option value="'.$sPhase.'" >'.$sPhase.'</option>'; + $sPhaseFilter.='<option value="' . $sPhase . '" >' . $sPhase . '</option>'; } foreach ($oPrj1->getProjects() as $sPrj) { $oPrj = new project($sPrj); - $sPrjFilter.='<option value="'.$sPrj.'">'.$oPrj->getLabel().'</option>'; + $sPrjFilter.='<option value="' . $sPrj . '">' . $oPrj->getLabel() . '</option>'; $sOutPhases = ''; $sOutPhases2 = ''; // loop over phases ... foreach (array_keys($oPrj->getPhases()) as $sPhase) { - $sOutPhases.=$oPrj->renderAllPhaseDetails($sPhase,true,false); - if ($oPrj->canAcceptPhase($sPhase)){ + $sOutPhases.=$oPrj->renderAllPhaseDetails($sPhase, true, false); + if ($oPrj->canAcceptPhase($sPhase)) { // $sOutPhases2.=' <span class="'.$sPhase.'" style="padding: 1em 0.5em 0.5em;">'.$oPrj->renderLink("accept", $sPhase).'</span>'; - $sOutPhases2.=' '.$oPrj->renderLink("accept", $sPhase); + $sOutPhases2.=' ' . $oPrj->renderLink("accept", $sPhase); } } - $sOut2 .= '<div class="'.$sPrj.' '.$sTrClass.' prjbox"><div class="title">' - . '<a href="" onclick="$(\'#prjfilter\').val(\''.$sPrj.'\'); window.setTimeout(\'filterOverviewTable();\', 10);setview(\'extended\'); return false;" ' + $sOut2 .= '<div class="' . $sPrj . ' ' . $sTrClass . ' prjbox"><div class="title">' + . '<a href="" onclick="$(\'#prjfilter\').val(\'' . $sPrj . '\'); window.setTimeout(\'filterOverviewTable();\', 10);setview(\'extended\'); return false;" ' . 'style="float: right;" ' - . 'title="'.t("overview-filter-hint").'"><i class="icon-filter"></i> '.t("overview-filter").'</a>' + . 'title="' . t("overview-filter-hint") . '"><i class="icon-filter"></i> ' . t("overview-filter") . '</a>' . '<strong>' - . '<a href="/deployment/'.$sPrj.'/" title="'.t("menu-project-home").' '.$oPrj->getLabel().'"><i class=" icon-book"></i> '.$oPrj->getLabel().'</a>' + . '<a href="/deployment/' . $sPrj . '/" title="' . t("menu-project-home") . ' ' . $oPrj->getLabel() . '"><i class=" icon-book"></i> ' . $oPrj->getLabel() . '</a>' . '</strong>' . '</div><div class="box">' . $oPrj->getDescription() . '<br>' . ''; - + // render output $sOut.=' - <tr class="'.$sPrj.' '.$sTrClass.'"> + <tr class="' . $sPrj . ' ' . $sTrClass . '"> <td class="prj"> <strong> - <a href="/deployment/'.$sPrj.'/" ><i class=" icon-book"></i> '.$oPrj->getLabel().'</a> + <a href="/deployment/' . $sPrj . '/" ><i class=" icon-book"></i> ' . $oPrj->getLabel() . '</a> </strong><br> ' . $oPrj->getDescription() . '</td><td class="prj">'; - if ($oPrj->canAcceptPhase()){ + if ($oPrj->canAcceptPhase()) { $sOut .=$oPrj->renderLink("build"); $sOut2.=$oPrj->renderLink("build"); // $sOut.='<a href="/deployment/'.$sPrj.'/build/" class="btn '.$sNext.'"><i class=" icon-forward"></i> Build für ['.$sNext.']</a><br>'; @@ -115,14 +112,14 @@ class projectlist { $sOut2.=$sOutPhases2 . '</div></div>'; } if ($sOut) { - $sRowHead1=''; - $sRowHead2=''; - - foreach (array_keys($oPrj1->getPhases()) as $sPhase){ + $sRowHead1 = ''; + $sRowHead2 = ''; + + foreach (array_keys($oPrj1->getPhases()) as $sPhase) { // Anzahl colspan ist hartcodiert :-/ - $sRowHead1.='<th class="'.$sPhase.' '.$sColClass.'" colspan="3">'.$sPhase.'</th>'; + $sRowHead1.='<th class="' . $sPhase . ' ' . $sColClass . '" colspan="3">' . $sPhase . '</th>'; $sRowHead2.=$oPrj->renderPlacesAsTd($sPhase); - } + } $sOut = ' <script> @@ -134,8 +131,8 @@ class projectlist { var sPhase=$("#phasefilter").val(); localStorage.setItem("selectedPrj", sPrj); localStorage.setItem("selectedPhase", sPhase); - $(\'.'.$sTrClass.'\').hide(); $(\'.\' + sPrj).show(); - $(\'.'.$sColClass.'\').hide(); $(\'.\' + sPhase).show(); + $(\'.' . $sTrClass . '\').hide(); $(\'.\' + sPrj).show(); + $(\'.' . $sColClass . '\').hide(); $(\'.\' + sPhase).show(); showResetbtn(); } @@ -211,8 +208,8 @@ class projectlist { */ function showResetbtn(){ sVisible=($("#efilter").val())?"visible":"hidden"; - if ($("#prjfilter").val()!="'.$sTrClass.'")sVisible="visible"; - if ($("#phasefilter").val()!="'.$sColClass.'")sVisible="visible"; + if ($("#prjfilter").val()!="' . $sTrClass . '")sVisible="visible"; + if ($("#phasefilter").val()!="' . $sColClass . '")sVisible="visible"; if ($("#rolefilter").val())sVisible="visible"; $("#btnresetfilter").css("visibility", sVisible); return false; @@ -235,52 +232,52 @@ class projectlist { </script> <div class="filterbar"> - <a href="#" class="view viewextended" onclick="setview(\'simple\');"><i class="icon-th-large"></i> '.t("overview-simpleview").'</a> - <a href="#" class="view viewsimple" onclick="setview(\'extended\');" ><i class="icon-th-list"></i> '.t("overview-extview").'</a> + <a href="#" class="view viewextended" onclick="setview(\'simple\');"><i class="icon-th-large"></i> ' . t("overview-simpleview") . '</a> + <a href="#" class="view viewsimple" onclick="setview(\'extended\');" ><i class="icon-th-list"></i> ' . t("overview-extview") . '</a> | <i class="icon-filter"></i> - '.t("overview-textsearch").': + ' . t("overview-textsearch") . ': <input type="text" id="efilter" name="efilter" style="width: 150px;" onchange="filterTable();" onKeypress="filterTable(); " onKeyup="filterTable(); " - title="'.t("overview-textsearch-hint").'" + title="' . t("overview-textsearch-hint") . '" > <span class="view viewextended"> - '.t("overview-filterprj").': + ' . t("overview-filterprj") . ': <select id="prjfilter" onchange="filterOverviewTable(); return false;"> - '.$sPrjFilter.' + ' . $sPrjFilter . ' </select> <span style="display: none;"> Phasen: <select id="phasefilter" onchange="filterOverviewTable(); return false;"> - '.$sPhaseFilter.' + ' . $sPhaseFilter . ' </select> </span> </span> - '.t("overview-filterrole").': + ' . t("overview-filterrole") . ': <select id="rolefilter" onchange="setrole(); return false;"> - <option value="">'.t("all").'</option> - <option value="developer">'.t("developer").'</option> - <option value="pl">'.t("projectmanager").'</option> + <option value="">' . t("all") . '</option> + <option value="developer">' . t("developer") . '</option> + <option value="pl">' . t("projectmanager") . '</option> </select> <a href="#" class="btn" id="btnresetfilter" - title="'.t("overview-filterreset-hint").'" + title="' . t("overview-filterreset-hint") . '" style="background:#fcc;" - onclick="resetFilter();"><i class="icon-remove"></i> '.t("overview-filterreset").'</a> + onclick="resetFilter();"><i class="icon-remove"></i> ' . t("overview-filterreset") . '</a> </div> <div class="view viewsimple"> - '.$sOut2.' + ' . $sOut2 . ' <div style="clear: both;"></div> <br> </div> @@ -288,21 +285,21 @@ class projectlist { <table class="table view viewextended" id="tbloverview"> <thead> <tr> - <th class="prj" rowspan="2">'.t("project").'<br><br></th> + <th class="prj" rowspan="2">' . t("project") . '<br><br></th> <th class="prj" rowspan="2"></th> - '.$sRowHead1.' + ' . $sRowHead1 . ' </tr> <tr> - '.$sRowHead2.' + ' . $sRowHead2 . ' </tr> </thead> <tbody> ' . $sOut . '</tbody></table>' . '<script>window.setTimeout("setDefaultView();", 50);</script>'; } else { - $sOut =t("class-pl-error-no-project").'<br><br>' + $sOut = t("class-pl-error-no-project") . '<br><br>' . $oPrj1->renderLink("setup") - ; + ; } return $sOut; } diff --git a/public_html/deployment/config/inc_projects_config.php b/public_html/deployment/config/inc_projects_config.php index c16ea4df..b10a641c 100644 --- a/public_html/deployment/config/inc_projects_config.php +++ b/public_html/deployment/config/inc_projects_config.php @@ -1,64 +1,57 @@ <?php - // ---------------------------------------------------------------------- // fetch status infos von den einzelnen Phasen // ---------------------------------------------------------------------- -$aConfig=array( - +$aConfig = array( // Basispfad: - 'workDir'=>'/var/imldeployment', - 'versionsToKeep'=>10, // for cleanup: keep n unused versions - 'builtsToKeep'=>3, // for cleanup: keep n failed builds - 'hooks'=>array( - 'build-postclone'=>'hooks/onbuild-postclone', - 'build-precompress'=>'hooks/onbuild', + 'workDir' => '/var/imldeployment', + 'versionsToKeep' => 10, // for cleanup: keep n unused versions + 'builtsToKeep' => 3, // for cleanup: keep n failed builds + 'hooks' => array( + 'build-postclone' => 'hooks/onbuild-postclone', + 'build-precompress' => 'hooks/onbuild', ), - - 'lang'=>'de', - + 'lang' => 'de', // for available languages see ./config/lang/*.json // rsync of archives - 'mirrorPackages'=>array(), - + 'mirrorPackages' => array(), // ssh install - if a host is given - 'installPackages'=>array( - 'user'=>'imldeployment', - 'testcommand'=>'sudo puppet --version', + 'installPackages' => array( + 'user' => 'imldeployment', + 'testcommand' => 'sudo puppet --version', // puppet agent liefert 0 oder 2 zurueck, wenn OK // http://docs.puppetlabs.com/references/3.4.0/man/apply.html // 'command'=>'sudo puppet agent -t | fgrep -i Deploy', // 'command'=>'sudo puppet agent -t --detailed-exitcodes ; echo rc=$? | egrep -v "^rc=(0|2)$" ; typeset -i rc=(1-$?); exit $rc', - 'command'=>'sudo puppet agent -t --detailed-exitcodes ; rc=$?; if [ $rc -eq 2 ]; then rc=0; fi ; exit $rc', + 'command' => 'sudo puppet agent -t --detailed-exitcodes ; rc=$?; if [ $rc -eq 2 ]; then rc=0; fi ; exit $rc', ), - - - 'phases'=>array( - "preview"=>array( - 'css'=>array( - 'bgdark'=>'background:#358; background: linear-gradient(#ddd,#358,#358); ', - 'bglight'=>'background:#f4f8ff; color:#333; background: rgba(210,220,255, 0.4);', - 'bgbutton'=>'background:#ccf;', + 'phases' => array( + "preview" => array( + 'css' => array( + 'bgdark' => 'background:#358; background: linear-gradient(#ddd,#358,#358); ', + 'bglight' => 'background:#f4f8ff; color:#333; background: rgba(210,220,255, 0.4);', + 'bgbutton' => 'background:#ccf;', ), ), - "stage"=>array( - 'css'=>array( - 'bgdark'=>'background:#388; background: linear-gradient(#ddd,#388,#388); ', - 'bglight'=>'background:#f4ffff; color:#333; background: rgba(180,230,230, 0.4);', - 'bgbutton'=>'background:#cff;', + "stage" => array( + 'css' => array( + 'bgdark' => 'background:#388; background: linear-gradient(#ddd,#388,#388); ', + 'bglight' => 'background:#f4ffff; color:#333; background: rgba(180,230,230, 0.4);', + 'bgbutton' => 'background:#cff;', ), ), - "live"=>array( - 'css'=>array( - 'bgdark'=>'background:#3a3; background: linear-gradient(#ddd,#3a3,#3a3);', - 'bglight'=>'background:#f0fff0; color:#333; background: rgba(180,255,180, 0.4);', - 'bgbutton'=>'background:#cfc;', + "live" => array( + 'css' => array( + 'bgdark' => 'background:#3a3; background: linear-gradient(#ddd,#3a3,#3a3);', + 'bglight' => 'background:#f0fff0; color:#333; background: rgba(180,255,180, 0.4);', + 'bgbutton' => 'background:#cfc;', ), // wenn deploytimes existiert, dann wird nach dem Deploy das Paket // in einer Queue zurueckgehalten - "deploytimes"=>array('/(Mon|Tue|Wed|Thu)\ 14\:/'), + "deploytimes" => array('/(Mon|Tue|Wed|Thu)\ 14\:/'), ), - ), + ), ); // ---------------------------------------------------------------------- @@ -70,27 +63,27 @@ switch (php_uname("n")) { case "USER": case "AAE49": case "dev.ci.iml.unibe.ch": - $aConfig['workDir']="D:\imldeployment"; + $aConfig['workDir'] = "D:\imldeployment"; break; case "ci.iml.unibe.ch": // synch der Pakete nur auf dem Livesystem - $aConfig['mirrorPackages']=array( - 'puppet'=>array( - 'type'=>'rsync', - 'runas'=>'www-data', // nur fuer commandline - 'target'=>'ladmin@calcium.iml.unibe.ch:/share/imldeployment', - )); + $aConfig['mirrorPackages'] = array( + 'puppet' => array( + 'type' => 'rsync', + 'runas' => 'www-data', // nur fuer commandline + 'target' => 'ladmin@calcium.iml.unibe.ch:/share/imldeployment', + )); break; default: break; } -$aConfig=array_merge($aConfig, array( - 'buildDir'=>$aConfig['workDir'].'/build', - 'buildDefaultsDir'=>$aConfig['workDir'].'/defaults', - 'packageDir'=>$aConfig['workDir'].'/packages', - 'archiveDir'=>$aConfig['workDir'].'/packages/_files', -)); +$aConfig = array_merge($aConfig, array( + 'buildDir' => $aConfig['workDir'] . '/build', + 'buildDefaultsDir' => $aConfig['workDir'] . '/defaults', + 'packageDir' => $aConfig['workDir'] . '/packages', + 'archiveDir' => $aConfig['workDir'] . '/packages/_files', + )); diff --git a/public_html/deployment/index.php b/public_html/deployment/index.php index bc3985fe..71343fc2 100644 --- a/public_html/deployment/index.php +++ b/public_html/deployment/index.php @@ -5,13 +5,13 @@ IML DEPLOYMENT webgui - index file - controller like - ensure that you activated the rewrite rules - - RewriteEngine on - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_URI} !^/server-status$ - RewriteRule ^(.*)$ index.php [QSA,L] - + ensure that you activated the rewrite rules + + RewriteEngine on + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_URI} !^/server-status$ + RewriteRule ^(.*)$ index.php [QSA,L] + --------------------------------------------------------------------- 2013-11-08 Axel <axel.hahn@iml.unibe.ch> ###################################################################### */ @@ -47,11 +47,11 @@ ob_end_clean(); // ------ Ausgabe -$sHeader='<style>'; -foreach ($aConfig["phases"] as $sPhase => $aData){ - $sHeader.=array_key_exists("bgdark", $aData["css"])?'th.'.$sPhase.'{'.$aData["css"]["bgdark"].'}':''; - $sHeader.=array_key_exists("bglight", $aData["css"])?'td.'.$sPhase.'{'.$aData["css"]["bglight"].'}':''; - $sHeader.=array_key_exists("bgbutton", $aData["css"])?'.'.$sPhase.'{'.$aData["css"]["bgbutton"].'}':''; +$sHeader = '<style>'; +foreach ($aConfig["phases"] as $sPhase => $aData) { + $sHeader.=array_key_exists("bgdark", $aData["css"]) ? 'th.' . $sPhase . '{' . $aData["css"]["bgdark"] . '}' : ''; + $sHeader.=array_key_exists("bglight", $aData["css"]) ? 'td.' . $sPhase . '{' . $aData["css"]["bglight"] . '}' : ''; + $sHeader.=array_key_exists("bgbutton", $aData["css"]) ? '.' . $sPhase . '{' . $aData["css"]["bgbutton"] . '}' : ''; } $sHeader.='</style>'; diff --git a/public_html/deployment/main.css b/public_html/deployment/main.css index 8215e22d..c9f262ed 100644 --- a/public_html/deployment/main.css +++ b/public_html/deployment/main.css @@ -29,12 +29,12 @@ body, label, input, button, select, textarea, p, .btn { .description{font-weight:bold; color:#ccc; font-size: 150%; font-style: italic;} .navbar .brand {color:#a33;} .navbar .version {float: right; position: fixed; top: 0px; right: 0;padding: 0 0.5em; - transform: rotate(0deg); - -webkit-transform: rotate(0deg); - border-bottom: 1px solid #fff; - border-left: 1px solid #fff; - box-shadow: 0 0 5px #888; - border-bottom-left-radius: 10px; + transform: rotate(0deg); + -webkit-transform: rotate(0deg); + border-bottom: 1px solid #fff; + border-left: 1px solid #fff; + box-shadow: 0 0 5px #888; + border-bottom-left-radius: 10px; } #content{ margin-top: 2em; @@ -121,19 +121,19 @@ a.info>span.left{margin-left: 0;} a.info:hover span{ display: block; text-decoration: none;} a.info span span.title{ background: #888; color:#f8f8f8; margin-top: -1em; padding: 0.5em 0.5em; float: left; box-shadow: 0 0 5px #ccc; border: 2px solid #fff;} a.info span span.pre{ - line-height: 1.2em; - padding: 5px; - background-color: #F5F5F5; - border: 1px solid rgba(0, 0, 0, 0.15); - border-radius: 4px; - display: block; - font-size: 13px; - line-height: 20px; - margin: 0 0 10px; - padding: 9.5px; - color: #333333; - font-family: Monaco,Menlo,Consolas,"Courier New",monospace; - } + line-height: 1.2em; + padding: 5px; + background-color: #F5F5F5; + border: 1px solid rgba(0, 0, 0, 0.15); + border-radius: 4px; + display: block; + font-size: 13px; + line-height: 20px; + margin: 0 0 10px; + padding: 9.5px; + color: #333333; + font-family: Monaco,Menlo,Consolas,"Courier New",monospace; +} .infobox{ diff --git a/public_html/deployment/pages/act_accept.php b/public_html/deployment/pages/act_accept.php index ae1220d8..cd41e4fa 100644 --- a/public_html/deployment/pages/act_accept.php +++ b/public_html/deployment/pages/act_accept.php @@ -1,4 +1,5 @@ <?php + /* ###################################################################### IML DEPLOYMENT @@ -11,91 +12,83 @@ require_once("./classes/project.class.php"); - // --- Checks -$oPrj=new project($aParams["prj"]); +$oPrj = new project($aParams["prj"]); -if (array_key_exists("par3", $aParams)){ - $sPhase=$aParams["par3"]; +if (array_key_exists("par3", $aParams)) { + $sPhase = $aParams["par3"]; } - -$sOut=''; +$sOut = ''; if (array_key_exists("confirm", $aParams)) { - $sOut.=$oPrj->accept($sPhase); + $sOut.=$oPrj->accept($sPhase); } else { - - if (!$sPhase){ + if (!$sPhase) { $sOut.=$oPrj->getBox("error", t("error-no-phase")); - } else { - if (!$oPrj->canAcceptPhase($sPhase)){ + } else { + if (!$oPrj->canAcceptPhase($sPhase)) { $sOut.= sprintf(t("page-accept-error-cannot-accept-phase"), $sPhase); } else { - $aPhaseData=$oPrj->getPhaseInfos($sPhase); - $aConfigPrj=$oPrj->getConfig(); - $sUrl=$aConfigPrj["phases"][$sPhase]["url"]; - - $sNext=$oPrj->getNextPhase($sPhase); - $aPhaseData2=$oPrj->getPhaseInfos($sNext); + $aPhaseData = $oPrj->getPhaseInfos($sPhase); + $aConfigPrj = $oPrj->getConfig(); + $sUrl = $aConfigPrj["phases"][$sPhase]["url"]; + + $sNext = $oPrj->getNextPhase($sPhase); + $aPhaseData2 = $oPrj->getPhaseInfos($sNext); $sOut.=' <p> - '.t("url").': <a href="'.$sUrl.'">'.$sUrl.'</a><br> - '.sprintf(t("page-accept-info"), $sPhase, $sPhase, $sNext, $sNext).' + ' . t("url") . ': <a href="' . $sUrl . '">' . $sUrl . '</a><br> + ' . sprintf(t("page-accept-info"), $sPhase, $sPhase, $sNext, $sNext) . ' </p>'; 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.=$oPrj->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.=$oPrj->getBox("warning", sprintf(t("page-accept-warning-version-exists-in-next-repo"), $sNext, $sPhase)); } $sOut.=' <table> <thead> <tr> - <th class="'.$sPhase.'">'.$sPhase.'</th> + <th class="' . $sPhase . '">' . $sPhase . '</th> <th> </th> - <th class="'.$sNext.'" colspan="2">'.$sNext.'</th> + <th class="' . $sNext . '" colspan="2">' . $sNext . '</th> </tr> </thead> <tbody> <tr> - <td class="'.$sPhase.'"> - '.t("deployed").':<br> - '.$oPrj->renderPhaseDetail($sPhase, "deployed", false).' + <td class="' . $sPhase . '"> + ' . t("deployed") . ':<br> + ' . $oPrj->renderPhaseDetail($sPhase, "deployed", false) . ' </td> <td style="vertical-align: middle;"> <img src="/deployment/images/nuvola64x64/apps/noatun.png"> </td> - <td class="'.$sNext.'"> - '.t("onhold").':<br> - '.$oPrj->renderPhaseDetail($sNext, "onhold", false).' + <td class="' . $sNext . '"> + ' . t("onhold") . ':<br> + ' . $oPrj->renderPhaseDetail($sNext, "onhold", false) . ' </td> - <td class="'.$sNext.'"> - '.t("ready2install").':<br> - '.$oPrj->renderPhaseDetail($sNext, "ready2install", false).' + <td class="' . $sNext . '"> + ' . t("ready2install") . ':<br> + ' . $oPrj->renderPhaseDetail($sNext, "ready2install", false) . ' </td> </tr> </tbody> </table> <br> '; - - - + // Eingabe Kommentare zum Deployment $sOut.=' - <form action="?" method="post" enctype="multipart/form-data"> <input type="hidden" name="confirm" value="1"> <fieldset> - <button type="submit" class="btn btn-primary btn-large" >'.sprintf(t("page-accept-buttonlabel"), $sPhase, $sNext).'</button> + <button type="submit" class="btn btn-primary btn-large" >' . sprintf(t("page-accept-buttonlabel"), $sPhase, $sNext) . '</button> </fieldset> </form> '; @@ -103,9 +96,7 @@ if (array_key_exists("confirm", $aParams)) { } } - -$sOut.= '<hr>' .aPrjHome(); - +$sOut.= '<hr>' . aPrjHome(); // -- Ausgabe echo $sOut; diff --git a/public_html/deployment/pages/act_build.php b/public_html/deployment/pages/act_build.php index fd87cb60..5517c24e 100644 --- a/public_html/deployment/pages/act_build.php +++ b/public_html/deployment/pages/act_build.php @@ -14,11 +14,9 @@ require_once("./classes/project.class.php"); require_once("./classes/formgen.class.php"); - // --- Checks $oPrj = new project($aParams["prj"]); - $sOut = ''; if (!array_key_exists("confirm", $aParams)) { @@ -27,7 +25,7 @@ if (!array_key_exists("confirm", $aParams)) { // ------------------------------------------------------------ $sNext = $oPrj->getNextPhase(); $aPhaseData2 = $oPrj->getPhaseInfos($sNext); - $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(); if (array_key_exists("revision", $aRepodata)) { @@ -47,7 +45,7 @@ if (!array_key_exists("confirm", $aParams)) { <table> <thead> <tr> - <th class="versioncontrol">'.t("versioncontrol").'</th> + <th class="versioncontrol">' . t("versioncontrol") . '</th> <th> </th> <th class="' . $sNext . '" colspan="2">' . $sNext . '</th> </tr> @@ -61,11 +59,11 @@ if (!array_key_exists("confirm", $aParams)) { <img src="/deployment/images/nuvola64x64/apps/noatun.png" alt="arrow to the right"> </td> <td class="' . $sNext . '"> - '.t("onhold").':<br> + ' . t("onhold") . ':<br> ' . $oPrj->renderPhaseDetail($sNext, "onhold", false) . ' </td> <td class="' . $sNext . '"> - '.t("ready2install").':<br> + ' . t("ready2install") . ':<br> ' . $oPrj->renderPhaseDetail($sNext, "ready2install", false) . ' </td> </tr> @@ -83,7 +81,7 @@ if (!array_key_exists("confirm", $aParams)) { <hr> --> <fieldset> - <button type="submit" class="btn btn-primary btn-large" >'.sprintf(t("page-build-buttonlabel"), $sNext) . '</button> + <button type="submit" class="btn btn-primary btn-large" >' . sprintf(t("page-build-buttonlabel"), $sNext) . '</button> </fieldset> </form> '; @@ -105,28 +103,27 @@ if (!array_key_exists("confirm", $aParams)) { // the ajax polling request reads tmpfile // read produced content from tempfile if (array_key_exists("ajax", $aParams)) { - $sLine="<h2 class=\"warning\">".t("page-build-info-processing")."</h2>"; - $sProcesses=t("page-build-info-load").": " - .shell_exec("uptime") - ."<br>".t("page-build-info-processes").":<pre>" - .shell_exec("ps -f | fgrep -v apache | fgrep -v 'ps -f' | fgrep -v fgrep") - ."</pre>"; - $sTmpFile=$sOutDir."/".$aParams["ajax"]; - $sOut=file_exists($sTmpFile)?file_get_contents($sTmpFile):""; - - echo $sLine. "/" . $sProcesses; - if ($sOut){ + $sLine = "<h2 class=\"warning\">" . t("page-build-info-processing") . "</h2>"; + $sProcesses = t("page-build-info-load") . ": " + . shell_exec("uptime") + . "<br>" . t("page-build-info-processes") . ":<pre>" + . shell_exec("ps -f | fgrep -v apache | fgrep -v 'ps -f' | fgrep -v fgrep") + . "</pre>"; + $sTmpFile = $sOutDir . "/" . $aParams["ajax"]; + $sOut = file_exists($sTmpFile) ? file_get_contents($sTmpFile) : ""; + + echo $sLine . "/" . $sProcesses; + if ($sOut) { echo '<div style="margin-left: 3em; border-left: 5px dotted #eee; padding-left: 1em;">' - .$sOut.'</div><div style="clear: both;"></div>' . $sLine; + . $sOut . '</div><div style="clear: both;"></div>' . $sLine; } die(); } // html code after pressing build button: // initiate one request to start the build and one to fetch preocess output - // $sTmpFile = basename(tempnam("", "out_".$aParams["prj"]."_".$aParams["action"])."_"); - $sTmpFile = $aParams["prj"]."_".$aParams["action"]; + $sTmpFile = $aParams["prj"] . "_" . $aParams["action"]; $sDivname = "outAjax"; $sUrl = "/deployment/?" . "&prj=" . $aParams["prj"] @@ -164,10 +161,8 @@ if (!array_key_exists("confirm", $aParams)) { </script>'; } - $sOut.='<hr>' . aPrjHome(); - // -- Ausgabe echo $sOut; ?> diff --git a/public_html/deployment/pages/act_cleanup.php b/public_html/deployment/pages/act_cleanup.php index 263d1887..2a84487b 100644 --- a/public_html/deployment/pages/act_cleanup.php +++ b/public_html/deployment/pages/act_cleanup.php @@ -1,4 +1,5 @@ <?php + /* ###################################################################### IML DEPLOYMENT @@ -18,18 +19,17 @@ $oPrj = new project($sPrj); $sOut = ' - <h3>'.t("dir-archive").': ' . $aConfig['archiveDir'] . '</h3> - '.t("page-cleanup-info-archives-deleted").':<br> + <h3>' . t("dir-archive") . ': ' . $aConfig['archiveDir'] . '</h3> + ' . t("page-cleanup-info-archives-deleted") . ':<br> <pre>' . print_r($oPrj->cleanupArchive(), true) . '</pre> - '.t("page-cleanup-info-archives-left").':<br> + ' . t("page-cleanup-info-archives-left") . ':<br> <pre>' . print_r($oPrj->getVersions(), true) . '</pre> - <h3>'.t("dir-builds").': ' . $aConfig['buildDir'] . '/[project]/</h3> - '.t("page-cleanup-info-builds-left").':<br> + <h3>' . t("dir-builds") . ': ' . $aConfig['buildDir'] . '/[project]/</h3> + ' . t("page-cleanup-info-builds-left") . ':<br> <pre>' . print_r($oPrj->cleanupBuilds(), true) . '</pre> <hr>' . aPrjHome(); // -- Ausgabe echo $sOut; - ?> diff --git a/public_html/deployment/pages/act_deploy.php b/public_html/deployment/pages/act_deploy.php index 85b92dc1..f244994b 100644 --- a/public_html/deployment/pages/act_deploy.php +++ b/public_html/deployment/pages/act_deploy.php @@ -13,17 +13,14 @@ require_once("./classes/project.class.php"); require_once("./inc_functions.php"); - // --- Checks $oPrj = new project($aParams["prj"]); - $sOut = ''; if (array_key_exists("par3", $aParams)) { $sPhase = $aParams["par3"]; } - if (array_key_exists("confirm", $aParams)) { $bIgnoreDeploytimes = false; if (array_key_exists("bIgnoreDeploytimes", $aParams)) { @@ -38,22 +35,21 @@ if (array_key_exists("confirm", $aParams)) { $sOut.=' <p> - '.t("onhold").':<br> + ' . t("onhold") . ':<br> ' . $oPrj->renderPhaseDetail($sPhase, "onhold", false) . ' </p> '; // Eingabe Kommentare zum Deployment $sOut.=' - <form action="?" method="post" enctype="multipart/form-data"> <input type="hidden" name="confirm" value="1"> <fieldset> - <strong>'.t("page-deploy-info-emergeny-only").'</strong><br> - <input type="checkbox" name="bIgnoreDeploytimes" value="1"> '.t("page-deploy-info-ignore-deploytime").'<br> + <strong>' . t("page-deploy-info-emergeny-only") . '</strong><br> + <input type="checkbox" name="bIgnoreDeploytimes" value="1"> ' . t("page-deploy-info-ignore-deploytime") . '<br> </fieldset><br> <fieldset> - <button type="submit" class="btn btn-primary btn-large" >'.t("deploy").'</button> + <button type="submit" class="btn btn-primary btn-large" >' . t("deploy") . '</button> </fieldset> </form> '; @@ -62,10 +58,8 @@ if (array_key_exists("confirm", $aParams)) { } } - $sOut.='<hr>' . aPrjHome(); - // -- Ausgabe echo $sOut; ?> diff --git a/public_html/deployment/pages/act_doc.php b/public_html/deployment/pages/act_doc.php index 79e02a2a..6734850e 100644 --- a/public_html/deployment/pages/act_doc.php +++ b/public_html/deployment/pages/act_doc.php @@ -1,4 +1,5 @@ <?php + /* ###################################################################### IML DEPLOYMENT @@ -10,42 +11,41 @@ ###################################################################### */ require_once("./classes/classinfos.class.php"); -$aClasses=array( - "project"=>array("name"=>"project"), - "projectlist"=>array("name"=>"projectlist"), - "page"=>array("name"=>"Page"), - "formgen"=>array("name"=>"formgen"), - ); - -$sOut=''; +$aClasses = array( + "project" => array("name" => "project"), + "projectlist" => array("name" => "projectlist"), + "page" => array("name" => "Page"), + "formgen" => array("name" => "formgen"), +); + +$sOut = ''; $sOut.='<a href="/deployment/all/doc/">Start</a> | '; -foreach ($aClasses as $sClassfile=>$aInfos){ - $sOut.='<a href="/deployment/all/doc/'.$sClassfile.'/">'.$sClassfile.'</a> | '; +foreach ($aClasses as $sClassfile => $aInfos) { + $sOut.='<a href="/deployment/all/doc/' . $sClassfile . '/">' . $sClassfile . '</a> | '; } $sOut.= '<hr>'; if (array_key_exists("par3", $aParams)) { - $sClass=$aParams["par3"]; - if (!array_key_exists($sClass, $aClasses)){ - $sOut.= $oPrj->getBox("error", sprintf(t("page-doc-error-class-not-configured"), $sClass, __FILE__ )); + $sClass = $aParams["par3"]; + if (!array_key_exists($sClass, $aClasses)) { + $sOut.= $oPrj->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"]); + $o = new classinfos($aClasses[$sClass]["name"]); $sOut.=t("page-doc-info-" . $sClass) . $o->render(); } } else { - $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.='</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.='</ul>'; } // -- Ausgabe echo $sOut; - ?> diff --git a/public_html/deployment/pages/act_overview.php b/public_html/deployment/pages/act_overview.php index 96031a57..cf3956ba 100644 --- a/public_html/deployment/pages/act_overview.php +++ b/public_html/deployment/pages/act_overview.php @@ -1,11 +1,12 @@ <?php + /* ###################################################################### IML DEPLOYMENT webgui - overview - * for all projects - * for a single project + * for all projects + * for a single project --------------------------------------------------------------------- 2013-11-08 Axel <axel.hahn@iml.unibe.ch> @@ -24,29 +25,28 @@ if (!array_key_exists("prj", $aParams)) { $oPrj = new project($aParams["prj"]); $sOut = ' <div class="infobox" style="float: right;"> - <h3>'.t("page-overview-characteristics").'</h3> + <h3>' . t("page-overview-characteristics") . '</h3> ' . $oPrj->renderProjektInfos() . ' </div> - - <h3>'.t("phases").'</h3>'; + <h3>' . t("phases") . '</h3>'; if ($oPrj->getActivePhases()) { $sOut.=' <div class="tabbable"> <ul class="nav nav-tabs" style="float: left; width: 50%;"> - <li class="active"><a href="#tab1" data-toggle="tab">'.t("phases").'</a></li> - <li><a href="#tab2" data-toggle="tab">'.t("packages").'</a></li> + <li class="active"><a href="#tab1" data-toggle="tab">' . t("phases") . '</a></li> + <li><a href="#tab2" data-toggle="tab">' . t("packages") . '</a></li> </ul> <div class="tab-content" style="clear: left;"> <div class="tab-pane active" id="tab1"> - <p>'.t("page-overview-phase-infos").'</p> + <p>' . t("page-overview-phase-infos") . '</p> ' . $oPrj->renderPhaseInfo() . '<br> ' . $oPrj->renderLink("build") . '<br><br> </div> <div class="tab-pane" id="tab2"> - ' . $oPrj->renderVersionUsage().' + ' . $oPrj->renderVersionUsage() . ' </div> </div> </div>'; diff --git a/public_html/deployment/pages/act_phase.php b/public_html/deployment/pages/act_phase.php index 14af003c..1df3f425 100644 --- a/public_html/deployment/pages/act_phase.php +++ b/public_html/deployment/pages/act_phase.php @@ -4,7 +4,7 @@ IML DEPLOYMENT - webgui - shows build versions in all places (onhold, ready2install, deployed) + webgui - shows build versions in all places (onhold, ready2install, deployed) of a given phase. --------------------------------------------------------------------- @@ -18,19 +18,17 @@ require_once("./inc_functions.php"); // --- Checks $oPrj = new project($aParams["prj"]); - $sOut = ''; if (array_key_exists("par3", $aParams)) { $sPhase = $aParams["par3"]; } - if ($sPhase) { $sPhase = $aParams["par3"]; $sFirst = $oPrj->getNextPhase(); $sOut.=' - <h3>'.t("versions").'</h3> + <h3>' . t("versions") . '</h3> <table> <thead> <tr> @@ -46,18 +44,16 @@ if ($sPhase) { </table> '; /* - if ($sFirst == $sPhase) { - $sOut.='<br><h3>weitere Aktionen</h3>' . $oPrj->renderLink("build"); - } + if ($sFirst == $sPhase) { + $sOut.='<br><h3>weitere Aktionen</h3>' . $oPrj->renderLink("build"); + } * */ } else { $sOut.=$oPrj->getBox("error", t("error-no-phase")); } - -$sOut.= '<hr>' .aPrjHome(); - +$sOut.= '<hr>' . aPrjHome(); // -- Ausgabe echo $sOut; diff --git a/public_html/deployment/pages/act_rollback.php b/public_html/deployment/pages/act_rollback.php index 864be82c..55cedbdd 100644 --- a/public_html/deployment/pages/act_rollback.php +++ b/public_html/deployment/pages/act_rollback.php @@ -1,4 +1,5 @@ <?php + /* ###################################################################### IML DEPLOYMENT @@ -13,105 +14,104 @@ require_once("./classes/project.class.php"); // --- Checks -$oPrj=new project($aParams["prj"]); +$oPrj = new project($aParams["prj"]); -if (array_key_exists("par3", $aParams)){ - $sPhase=$aParams["par3"]; +if (array_key_exists("par3", $aParams)) { + $sPhase = $aParams["par3"]; } -if (array_key_exists("par4", $aParams)){ - $sVersion=$aParams["par4"]; +if (array_key_exists("par4", $aParams)) { + $sVersion = $aParams["par4"]; } - -$sOut='<h2>Rollback was not implemented yet</h2><a href="javascript: history.back();">zurück</a>'; +$sOut = '<h2>Rollback was not implemented yet</h2><a href="javascript: history.back();">zurück</a>'; if (array_key_exists("confirm", $aParams)) { - $sOut.=$oPrj->queue($sPhase, $sVersion); + $sOut.=$oPrj->queue($sPhase, $sVersion); } else { - - if (!$sPhase){ + + if (!$sPhase) { $sOut.=$oPrj->getBox("error", t("error-no-phase")); - } else { + } else { /* - if (!$oPrj->canAcceptPhase($sPhase)){ - $sOut.="ERROR: the phase $sPhase cannot be accepted."; - } else { - $aPhaseData=$oPrj->getPhaseInfos($sPhase); - $aConfigPrj=$oPrj->getConfig(); - $sUrl=$aConfigPrj["phases"][$sPhase]["url"]; - - $sNext=$oPrj->getNextPhase($sPhase); - $aPhaseData2=$oPrj->getPhaseInfos($sNext); - - $sOut.=' - <p> - URL: <a href="'.$sUrl.'">'.$sUrl.'</a><br> - Die Software wurde erfolgreich <span class="'.$sPhase.'">'.$sPhase.'</span> getestet und soll auf die nächste - Phase <span class="'.$sNext.'">'.$sNext.'</span> ausgerollt werden?<br> - </p>'; - if ( - array_key_exists("revision", $aPhaseData2["onhold"]) - && $aPhaseData2["onhold"]["revision"]==$aPhaseData["deployed"]["revision"] - ){ - $sOut.=getBox("warning", "In der Queue von [$sNext] ist die Version von [$sPhase] bereits vorhanden!"); - } - if ( - array_key_exists("revision", $aPhaseData2["ready2install"]) - && $aPhaseData2["ready2install"]["revision"]==$aPhaseData["deployed"]["revision"] - ){ - $sOut.=getBox("warning", "Im Repo von [$sNext] ist die Version von [$sPhase] bereits vorhanden!"); - } - $sOut.=' - <table> - <thead> - <tr> - <th class="'.$sPhase.'">'.$sPhase.'</th> - <th> </th> - <th class="'.$sNext.'" colspan="2">'.$sNext.'</th> - </tr> - </thead> - <tbody> - <tr> - <td class="'.$sPhase.'"> - auf dem Server ist installiert:<br> - '.$oPrj->renderPhaseDetail($sPhase, "deployed", false).' - </td> - <td style="vertical-align: middle;"> - <img src="/deployment/images/nuvola64x64/apps/noatun.png"> - </td> - <td class="'.$sNext.'"> - in der Queue:<br> - '.$oPrj->renderPhaseDetail($sNext, "onhold", false).' - </td> - <td class="'.$sNext.'"> - im Repo:<br> - '.$oPrj->renderPhaseDetail($sNext, "ready2install", false).' - </td> - </tr> - </tbody> - </table> - <br> - '; - - - - // Eingabe Kommentare zum Deployment - $sOut.=' - - <form action="?" method="post" enctype="multipart/form-data"> - <input type="hidden" name="confirm" value="1"> - <fieldset> - <button type="submit" class="btn btn-primary btn-large" >Accept ['.$sPhase.'] and put to ['.$sNext.']</button> - </fieldset> - </form> - '; - } + if (!$oPrj->canAcceptPhase($sPhase)){ + $sOut.="ERROR: the phase $sPhase cannot be accepted."; + } else { + $aPhaseData=$oPrj->getPhaseInfos($sPhase); + $aConfigPrj=$oPrj->getConfig(); + $sUrl=$aConfigPrj["phases"][$sPhase]["url"]; + + $sNext=$oPrj->getNextPhase($sPhase); + $aPhaseData2=$oPrj->getPhaseInfos($sNext); + + $sOut.=' + <p> + URL: <a href="'.$sUrl.'">'.$sUrl.'</a><br> + Die Software wurde erfolgreich <span class="'.$sPhase.'">'.$sPhase.'</span> getestet und soll auf die nächste + Phase <span class="'.$sNext.'">'.$sNext.'</span> ausgerollt werden?<br> + </p>'; + if ( + array_key_exists("revision", $aPhaseData2["onhold"]) + && $aPhaseData2["onhold"]["revision"]==$aPhaseData["deployed"]["revision"] + ){ + $sOut.=getBox("warning", "In der Queue von [$sNext] ist die Version von [$sPhase] bereits vorhanden!"); + } + if ( + array_key_exists("revision", $aPhaseData2["ready2install"]) + && $aPhaseData2["ready2install"]["revision"]==$aPhaseData["deployed"]["revision"] + ){ + $sOut.=getBox("warning", "Im Repo von [$sNext] ist die Version von [$sPhase] bereits vorhanden!"); + } + $sOut.=' + <table> + <thead> + <tr> + <th class="'.$sPhase.'">'.$sPhase.'</th> + <th> </th> + <th class="'.$sNext.'" colspan="2">'.$sNext.'</th> + </tr> + </thead> + <tbody> + <tr> + <td class="'.$sPhase.'"> + auf dem Server ist installiert:<br> + '.$oPrj->renderPhaseDetail($sPhase, "deployed", false).' + </td> + <td style="vertical-align: middle;"> + <img src="/deployment/images/nuvola64x64/apps/noatun.png"> + </td> + <td class="'.$sNext.'"> + in der Queue:<br> + '.$oPrj->renderPhaseDetail($sNext, "onhold", false).' + </td> + <td class="'.$sNext.'"> + im Repo:<br> + '.$oPrj->renderPhaseDetail($sNext, "ready2install", false).' + </td> + </tr> + </tbody> + </table> + <br> + '; + + + + // Eingabe Kommentare zum Deployment + $sOut.=' + + <form action="?" method="post" enctype="multipart/form-data"> + <input type="hidden" name="confirm" value="1"> + <fieldset> + <button type="submit" class="btn btn-primary btn-large" >Accept ['.$sPhase.'] and put to ['.$sNext.']</button> + </fieldset> + </form> + '; + } * */ } } - -$sOut.= '<hr>' .aPrjHome(); + +$sOut.= '<hr>' . aPrjHome(); // -- Ausgabe -- GitLab