Skip to content
Snippets Groups Projects
Commit 301135c5 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

ci deployment gui - add html gui elements ... with first replacements

parent 78df00f0
No related branches found
No related tags found
No related merge requests found
Showing
with 481 additions and 97 deletions
......@@ -42,6 +42,7 @@ return array(
"page_cleanup",
"page_delete",
"page_deploy",
"page_htmltest",
"page_phase",
"page_setup",
......
<?php
/**
* html gui elements
* for bootstrap
* see http://dev.ci.iml.unibe.ch:8002/deployment/all/htmltest/
*
* $oHtml=new htmlguielements();
*
* echo $oHtml->getBox('error', 'errormessage');
* echo $oHtml->getIcon('fa-pencil');
*
* echo $oHtml->getLink(array(
* 'href'=>'https://www.axel-hahn.de',
* 'class'=>'btn btn-primary',
* 'icon'=>'fa-close',
* 'label'=>'linked text',
* ));
*
* echo $oHtml->getTabs(
* array(
* 'tab 1'=>'Inhalt #1',
* 'tab 2'=>'Inhalt #2',
* )
* );
*
*
* @author hahn
*/
class htmlguielements{
var $aCfg=array(
'buttons'=>array(
// bootstrap defaults
'primary'=>array('class'=>'btn-primary', 'icon'=>''),
'success'=>array('class'=>'btn-success', 'icon'=>''),
'info'=>array('class'=>'btn-info', 'icon'=>''),
'warning'=>array('class'=>'btn-warning', 'icon'=>''),
'danger'=>array('class'=>'btn-danger', 'icon'=>''),
// custom buttons
'close'=>array('class'=>'btn-danger', 'icon'=>'fa-close'),
'error'=>array('class'=>'btn-danger', 'icon'=>'fa-bolt'),
'ok'=>array('class'=>'btn-primary', 'icon'=>'fa-check'),
// deploy actions and buttons
'accept'=>array('class'=>'', 'icon'=>'glyphicon-forward'),
'build'=>array('class'=>'', 'icon'=>'glyphicon-equalizer'),
'cleanup'=>array('class'=>'', 'icon'=>'glyphicon-chevron-right'),
'deploy'=>array('class'=>'', 'icon'=>'glyphicon-forward'),
'new'=>array('class'=>'', 'icon'=>'glyphicon-star-empty'),
'overview'=>array('class'=>'', 'icon'=>'glyphicon-book'),
'phase'=>array('class'=>'', 'icon'=>'glyphicon-chevron-right'),
'rollback'=>array('class'=>'', 'icon'=>'glyphicon-forward'),
'setup'=>array('class'=>'', 'icon'=>'glyphicon-cog'),
),
'icons'=>array(
'branch'=>'glyphicon-bookmark',
'calendar'=>'glyphicon-calendar',
'comment'=>'glyphicon-comment',
'revision'=>'glyphicon-tag',
),
);
public function __construct() {
return true;
}
// ----------------------------------------------------------------------
// helper function
// ----------------------------------------------------------------------
/**
* add an html attribute if the attribute exists as a key
* @param string $sAttribute html attribute to add
* @param string $aData item array
* @param string $sDefault use default if key does not exists
* @return string
*/
public function addAttributeFromKey($sAttribute, $aData, $sDefault=''){
return (array_key_exists($sAttribute, $aData)
? $this->addAttribute($sAttribute, $aData[$sAttribute])
: $this->addAttribute($sAttribute, $sDefault)
);
}
/**
* add an html attribute if value is not empty
* @param string $sAttribute html attribute to add
* @param string $sValue value of attribute
* @return string
*/
public function addAttribute($sAttribute, $sValue){
return ($sValue ? ' '.$sAttribute.'="'.$sValue.'"' : '' );
}
// ----------------------------------------------------------------------
// low level
// ----------------------------------------------------------------------
/**
* get html code for icon; glypphicons and font-awesome is supported
*
* @param string $sLabel label of icon
* @return string
*/
public function getIcon($sLabel){
if(!$sLabel){
return '';
}
$sPrefix=(
strpos($sLabel, 'glyphicon-')===0 ? 'glyphicon'
: ( strpos($sLabel, 'fa-')===0 ? 'fa' : '')
);
if(!$sPrefix){
return '';
}
return '<i'.$this->addAttribute('class', ($sPrefix ? $sPrefix . ' ' : '').$sLabel).'></i> ';
}
/**
* get a default icon from config
* @param string $sType icon type
* @return array
*/
public function getIconByType($sType){
return (array_key_exists($sType, $this->aCfg['icons'])
? $this->getIcon($this->aCfg['icons'][$sType])
: ''
);
}
/**
* get html code for icon; glypphicons and font-awesome is supported
*
* @param array $aItem array with link attributes; href for target; "label" and "icon"
* @return string
*/
public function getLink($aItem){
$sHref=$this->addAttributeFromKey('href', $aItem, '#');
$sLabel=(array_key_exists('icon', $aItem) ? $this->getIcon($aItem['icon']): '')
.(array_key_exists('label', $aItem) ? $aItem['label'] : '');
foreach(array('href', 'icon', 'label') as $sKey){
if (array_key_exists($sKey, $aItem)){
unset($aItem[$sKey]);
}
}
$sReturn='<a'.$sHref;
foreach (array_keys($aItem) as $sKey){
$sReturn.=$this->addAttributeFromKey($sKey, $aItem);
}
$sReturn.='>'
.$sLabel
.'</a>';
return $sReturn;
}
/**
* add default css classes and colors based on $aItem['type']
* @param array $aItem
* @return array
*/
protected function _getButtonattributesByType($aItem){
$aReturn=$aItem;
if (array_key_exists($aItem['type'], $this->aCfg['buttons'])){
$sClass=$this->aCfg['buttons'][$aItem['type']]['class'];
$aReturn['class'].=$sClass ? ' '.$sClass : '';
$aReturn['icon']=$aReturn['icon'] ? $aReturn['icon'] : $this->aCfg['buttons'][$aItem['type']]['icon'];
}
return $aReturn;
}
/**
* get html code for icon; glypphicons and font-awesome is supported
*
* @param array $aItem array with link attributes; href for target; "label" and "icon"
* @return string
*/
public function getLinkButton($aItem){
foreach(array('class', 'icon') as $sKey){
if (!array_key_exists($sKey, $aItem)){
$aItem[$sKey]='';
}
}
$aItem['class'].='btn btn-default';
if (array_key_exists('type', $aItem)){
$aItem=$this->_getButtonattributesByType($aItem);
unset($aItem['type']);
}
return $this->getLink($aItem);
}
// ----------------------------------------------------------------------
// gui elements
// ----------------------------------------------------------------------
/**
* get html code of a div around a message
* @param string $sWarnlevel one of error|success|info|warning to get a colored box
* @param string $sMessage message text
* @return string
*/
public function getBox($sWarnlevel, $sMessage) {
$aCfg = array(
"error" => array("class" => "alert alert-danger", "prefix" => t("error")),
"success" => array("class" => "alert alert-success", "prefix" => t("success")),
"info" => array("class" => "alert alert-info", "prefix" => t("info")),
"warning" => array("class" => "alert alert-warning", "prefix" => t("warning")),
);
$sClass = "";
$sPrefix = "";
if (array_key_exists($sWarnlevel, $aCfg)) {
$sClass = $aCfg[$sWarnlevel]["class"];
$sPrefix = $aCfg[$sWarnlevel]["prefix"];
$sMessage = '<strong>' . $aCfg[$sWarnlevel]["prefix"] . '</strong> ' . $sMessage;
}
return '<div'.$this->addAttribute('class', $sClass).'>' . $sMessage . '</div>';
}
/**
* get html code for tabs with content
*
* @staticvar int $iCounter internal counter for tabs ans content
* @param array $aTabData tab data; key is the tab label; value the content of its tab
* @return string
*/
public function getNav($aTabData){
$sTabs='';
$sContent='';
static $iCounter=0;
$iTab=0;
if (!is_array($aTabData) || !count($aTabData)){
return false;
}
$sNavType=$aTabData['options']['type']; // "tabs" or "pills"
$sNavCss='nav nav-'.$sNavType;
if (array_key_exists('stacked', $aTabData['options']) && $aTabData['options']['stacked']){
$sNavCss.=' nav-stacked';
}
if (array_key_exists('justified', $aTabData['options']) && $aTabData['options']['justified']){
$sNavCss.=' nav-justified';
}
$sNavType=$aTabData['options']['justified'];
foreach ($aTabData['tabs'] as $sTabLabel=>$sTabContent){
$iCounter++;
$iTab++;
$sId="tab${iCounter}";
$sTabs.= ($iTab==1 ? '<li class="active"' : '<li')
. ' role="presentation">'
. '<a href="#'.$sId.'" data-toggle="tab">' . $sTabLabel . '</a></li>'
;
$sContent.='<div class="tab-pane'
.($iTab==1 ? ' active' : '')
.'" id="'.$sId.'">'
.$sTabContent
.'</div>'
;
}
return '<div class="tabbable">'
. '<ul class="'.$sNavCss.'">'. $sTabs.'</ul>'
. '<div class="tab-content">'.$sContent.'</div>'
. '</div>';
}
}
<?php
require_once 'base.class.php';
require_once 'htmlguielements.class.php';
/* ######################################################################
......@@ -1372,32 +1373,6 @@ class project extends base {
return file_exists($this->_sProcessTempOut);
}
/**
* get html code of a div around a message
* @param string $sWarnlevel one of error|success|info|warning to get a colored box
* @param string $sMessage message txt
* @return string
*/
public function getBox($sWarnlevel, $sMessage) {
$this->log(__FUNCTION__ . " start");
$aCfg = array(
"error" => array("class" => "alert alert-danger", "prefix" => t("error")),
"success" => array("class" => "alert alert-success", "prefix" => t("success")),
"info" => array("class" => "alert alert-info", "prefix" => t("info")),
"warning" => array("class" => "alert alert-warning", "prefix" => t("warning")),
);
$sClass = "";
$sPrefix = "";
if (array_key_exists($sWarnlevel, $aCfg)) {
$sClass = $aCfg[$sWarnlevel]["class"];
$sPrefix = $aCfg[$sWarnlevel]["prefix"];
$sMessage = '<strong>' . $aCfg[$sWarnlevel]["prefix"] . '</strong> ' . $sMessage;
}
return '
<div class="' . $sClass . '">
' . $sMessage . '
</div>';
}
/**
* get the name of the current branch (or default branch)
......@@ -1429,6 +1404,7 @@ class project extends base {
}
global $aParams;
$sReturn = false;
$oHtml=new htmlguielements();
$aActionList = array(
'iActive' => 0,
......@@ -1468,7 +1444,7 @@ class project extends base {
if (!$this->_oVcs) {
$sError = sprintf(t('class-project-error-build-type-not-supported'), $this->_aPrjConfig["build"]["type"]);
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
return $oHtml->getBox("error", $sError . $sReturn);
}
// --------------------------------------------------
......@@ -1491,7 +1467,7 @@ class project extends base {
$this->_TempDelete();
$sError = sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempDir);
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
return $oHtml->getBox("error", $sError . $sReturn);
}
// $this->_iRcAll = 0;
$aActionList['iActive'] ++;
......@@ -1509,7 +1485,7 @@ class project extends base {
$sCommitMsg = $aVersion["message"];
$sCommitMsg = str_replace("\n", "<br>", $sCommitMsg);
$sCommitMsg = str_replace('"', "&quot;", $sCommitMsg);
$sReturn.=$this->getBox("info", $sCommitMsg);
$sReturn.=$oHtml->getBox("info", $sCommitMsg);
$sReturn.=$this->_execAndSend("ls -lisa $sTempDir");
......@@ -1517,7 +1493,7 @@ class project extends base {
$this->_TempDelete();
$sError = sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError);
return $oHtml->getBox("error", $sError);
}
// --------------------------------------------------
......@@ -1527,7 +1503,7 @@ class project extends base {
$sReturn.=$this->_execAndSend('ls -l ' . $filename);
}
$sReturn.=$this->getBox("success", t('class-project-info-build-checkout-ok'));
$sReturn.=$oHtml->getBox("success", t('class-project-info-build-checkout-ok'));
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
......@@ -1545,7 +1521,7 @@ class project extends base {
$sError = sprintf(t('class-project-error-command-failed'), $sTempDir);
$this->_logaction($sError, __FUNCTION__, "error");
$this->_TempDelete();
return $this->getBox("error", $sError . $sReturn);
return $oHtml->getBox("error", $sError . $sReturn);
}
} else {
$sReturn.=t('skip') . '<br>';
......@@ -1581,7 +1557,7 @@ class project extends base {
$this->_TempDelete();
$sError = sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError);
return $oHtml->getBox("error", $sError);
}
} else {
$sReturn.=t('skip') . '<br>';
......@@ -1624,16 +1600,16 @@ class project extends base {
$this->_TempDelete();
$sError = t('class-project-error-build-docroot-not-found');
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
return $oHtml->getBox("error", $sError . $sReturn);
}
if (!$this->_iRcAll == 0) {
$this->_TempDelete();
$sError = sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError);
return $oHtml->getBox("error", $sError);
}
// $sReturn.=$this->getBox("success", "preparations ok - directory is ready for packaging now.");
// $sReturn.=$oHtml->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");
......@@ -1679,7 +1655,7 @@ class project extends base {
$this->_TempDelete();
$sError = sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempDir);
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
return $oHtml->getBox("error", $sError . $sReturn);
}
$this->_TempFill($sReturn, $aActionList);
......@@ -1710,7 +1686,7 @@ class project extends base {
$this->_TempDelete();
$sError = t('class-project-error-build-docroot-not-found');
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
return $oHtml->getBox("error", $sError . $sReturn);
}
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
......@@ -1722,7 +1698,7 @@ class project extends base {
$sInfo = t("class-project-info-build-successful");
$this->_logaction(t('finished') . ' ' . $sInfo, __FUNCTION__, "success");
$sReturn.=$this->getBox("success", $sInfo);
$sReturn.=$oHtml->getBox("success", $sInfo);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
......@@ -1754,11 +1730,12 @@ class project extends base {
$this->_logaction(t('starting') . " queue($sPhase, $sVersion)", __FUNCTION__);
$sReturn = "<h2> " . t("queue") . " " . $this->getLabel() . " :: $sPhase</h2>";
$this->_TempFill($sReturn, $aActionList);
$oHtml=new htmlguielements();
if (!$this->isActivePhase($sPhase)) {
$sError = sprintf(t("class-project-warning-phase-not-active"), $sPhase);
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
return $oHtml->getBox("error", $sError . $sReturn);
}
$sPlace = "onhold";
......@@ -1807,10 +1784,10 @@ class project extends base {
$this->_TempDelete();
$sError = t("class-project-error-command-failed");
$this->_logaction($sError, __FUNCTION__, "error");
return $this->getBox("error", $sError . $sReturn);
return $oHtml->getBox("error", $sError . $sReturn);
}
$this->_logaction(t('finished') . " queue($sPhase, $sVersion) " . t("class-project-info-queue-successful"), __FUNCTION__);
$sReturn.=$this->getBox("success", t("class-project-info-queue-successful"));
$sReturn.=$oHtml->getBox("success", t("class-project-info-queue-successful"));
$sReturn.=$this->deploy($sPhase);
$this->_TempDelete();
......@@ -1826,6 +1803,7 @@ class project extends base {
* @return boolean|string
*/
public function deploy($sPhase, $bIgnoreDeploytimes = false) {
$oHtml=new htmlguielements();
$this->log(__FUNCTION__ . " start");
if (!$this->oUser->hasPermission("project-action-deploy")
&& !$this->oUser->hasPermission("project-action-deploy-$sPhase")
......@@ -1848,7 +1826,7 @@ class project extends base {
if (!$this->isActivePhase($sPhase)) {
$sError = sprintf(t("class-project-warning-phase-not-active"), $sPhase);
$this->_logaction($sError, __FUNCTION__, "error");
return $sReturn . $this->getBox("error", $sError);
return $sReturn . $oHtml->getBox("error", $sError);
}
$sQueueLink = $this->_getFileBase($sPhase, "onhold");
......@@ -1880,7 +1858,7 @@ class project extends base {
if (!$bIgnoreDeploytimes) {
$sError = t("class-project-info-deploy-time-not-reached");
// $this->_logaction($sError, __FUNCTION__);
$sReturn.=$this->getBox("info", $sError);
$sReturn.=$oHtml->getBox("info", $sError);
$this->_TempDelete();
return $sReturn;
} else {
......@@ -1895,7 +1873,7 @@ class project extends base {
if (!file_exists($sQueueLink)) {
$sError = sprintf(t("class-project-info-deploy-nothing-in-queue"), $sQueueLink);
$this->_logaction($sError, __FUNCTION__, "error");
$sReturn.=$this->getBox("info", $sError);
$sReturn.=$oHtml->getBox("info", $sError);
$this->_TempDelete();
return $sReturn;
}
......@@ -1921,7 +1899,7 @@ class project extends base {
$this->_TempDelete();
$sError = t("class-project-error-command-failed");
$this->_logaction($sError, __FUNCTION__, "error");
$sReturn.=$this->getBox("error", $sError . $sReturn);
$sReturn.=$oHtml->getBox("error", $sError . $sReturn);
return $sReturn;
}
......@@ -2009,7 +1987,7 @@ class project extends base {
$this->_TempFill($sReturn, $aActionList);
$sReturn.="<br>";
$sReturn.=$this->getBox("success", t("class-project-info-deploy-successful"));
$sReturn.=$oHtml->getBox("success", t("class-project-info-deploy-successful"));
$this->_logaction(t('finished') . " deploy($sPhase, $bIgnoreDeploytimes) " . t("class-project-info-deploy-successful"), __FUNCTION__, "success");
$this->_TempDelete();
return $sReturn;
......@@ -2022,6 +2000,7 @@ class project extends base {
* @return type
*/
public function accept($sPhase) {
$oHtml=new htmlguielements();
$this->log(__FUNCTION__ . " start");
if (!$this->oUser->hasPermission("project-action-accept")
&& !$this->oUser->hasPermission("project-action-accept-$sPhase")
......@@ -2035,7 +2014,7 @@ class project extends base {
if (!$this->canAcceptPhase($sPhase)) {
$sError = sprintf(t("class-project-error-accept-impossible"), $sPhase);
$this->_logaction($sError, __FUNCTION__, "error");
return $sReturn . $this->getBox("error", $sError);
return $sReturn . $oHtml->getBox("error", $sError);
}
$sReturn.="<h3>" . sprintf(t("class-project-info-accept-overview"), $sPhase) . "</h3>";
......@@ -2046,7 +2025,7 @@ class project extends base {
// $sReturn.='<pre>' . print_r($aInfos["deployed"], true) . '</pre>';
$sReturn.=$this->getBox("info", sprintf(t("class-project-info-accept-version-and-next-phase"), $sVersion, $sNext));
$sReturn.=$oHtml->getBox("info", sprintf(t("class-project-info-accept-version-and-next-phase"), $sVersion, $sNext));
$this->_logaction(t('finished') . " accept($sPhase) " . sprintf(t("class-project-info-accept-version-and-next-phase"), $sVersion, $sNext), __FUNCTION__, "success");
$sReturn.=$this->queue($sNext, $sVersion);
$this->_TempFill($sReturn);
......@@ -2068,19 +2047,21 @@ class project extends base {
if (!$aData) {
$aData = $_POST;
}
if (!array_key_exists("id", $aData)) {
$this->_logaction(t('abortet') . " no id in \$_POST", __FUNCTION__, "error");
foreach(array('id', 'label', 'description', 'contact', 'build', 'fileprefix', 'phases') as $sKey){
if (!array_key_exists($sKey, $aData)){
$this->_logaction(t('abortet') . " missing key $sKey in savedata", __FUNCTION__, "error");
return false;
}
// if (!array_key_exists("setupaction", $_POST)) return false;
}
$sId = $aData["id"];
// remove unwanted items
foreach (array("setupaction", "prj", "id") as $s) {
if (array_key_exists($s, $aData))
if (array_key_exists($s, $aData)){
unset($aData[$s]);
}
}
// save json file
if ($this->_aConfig['projects']['json']['active']){
......@@ -2390,27 +2371,28 @@ class project extends base {
public function renderLink($sFunction, $sPhase = false, $sVersion = false) {
$sFirst = $this->getNextPhase();
$sNext = $this->getNextPhase($sPhase);
$oHtml=new htmlguielements();
$aLinkdata = array(
'default' => array('icon' => 'glyphicon glyphicon-forward', 'class' => ''),
'accept' => array('icon' => 'glyphicon glyphicon-forward', 'class' => $sNext,
'default' => array('class' => ''),
'accept' => array('class' => $sNext,
'hint' => sprintf(t("accept-hint"), $sPhase, $sNext),
'label' => t('accept'),
),
'build' => array('icon' => 'glyphicon glyphicon-equalizer', 'class' => $sFirst,
'build' => array('class' => $sFirst,
'hint' => sprintf(t("build-hint"), $sFirst),
'label' => t('build'),
'role' => 'buildProject'
),
'cleanup' => array('icon' => 'glyphicon glyphicon-chevron-right', 'class' => ''),
'deploy' => array('icon' => 'glyphicon glyphicon-forward', 'class' => $sPhase,
'cleanup' => array('class' => ''),
'deploy' => array('class' => $sPhase,
'hint' => sprintf(t("deploy-hint"), $sPhase),
'label' => t('deploy'),
),
'new' => array('icon' => 'glyphicon glyphicon-star-empty',
'new' => array(
'hint' => t("new-project-hint"),
'label' => t('new-project'),
),
'overview' => array('icon' => 'glyphicon glyphicon-book', 'class' => '',
'overview' => array('class' => '',
'hint' => t('menu-project-home') . ' [' . $this->getLabel() . ']',
'label' => $this->getLabel()
),
......@@ -2418,11 +2400,11 @@ class project extends base {
'hint' => sprintf(t('phase-details-hint'), $sPhase),
'label' => t('phase-details')
),
'rollback' => array('icon' => 'glyphicon glyphicon-forward', 'class' => $sPhase,
'rollback' => array('class' => $sPhase,
'hint' => sprintf(t('rollback-hint'), $sPhase, $sVersion),
'label' => t('rollback')
),
'setup' => array('icon' => 'glyphicon glyphicon-cog', 'class' => $sPhase,
'setup' => array('class' => $sPhase,
'hint' => sprintf(t('setup-hint'), $sPhase, $sVersion),
'label' => t('setup')
),
......@@ -2437,10 +2419,11 @@ class project extends base {
// fuer wen ist der Link
$sRole = '';
$sOnMouseover = '';
$sOnMouseout = '';
if ($sFunction == "build") {
$sRole = 'developer';
$sOnMouseover = 'onmouseover="$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').addClass(\'highlight\');"
onmouseout="$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').removeClass(\'highlight\');" ';
$sOnMouseover = '$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').addClass(\'highlight\');';
$sOnMouseout = '$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').removeClass(\'highlight\');';
}
if ($sFunction == "accept") {
$sRole = 'developer';
......@@ -2448,8 +2431,8 @@ class project extends base {
$sRole = 'pl';
// $aLinkdata[$sFunction]['icon']='glyphicon glyphicon-star';
}
$sOnMouseover = 'onmouseover="$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').addClass(\'highlight\');"
onmouseout="$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').removeClass(\'highlight\');" ';
$sOnMouseover = '$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').addClass(\'highlight\');';
$sOnMouseout ='$(\'.' . $sNext . '.td' . $this->_aConfig["id"] . '\').removeClass(\'highlight\');';
}
// $sClass = $sPhase;
......@@ -2482,7 +2465,16 @@ class project extends base {
return '<span title="no permission [project-action-'.$sFunction.'] for '.$this->oUser->getUsername().'">[ <i class="' . $sIconClass . '"></i> ' . $sLabel . ' ]</span>';
}
return '<a href="' . $sLink . '" ' . $sOnMouseover . ' title="' . $sHint . '" class="btn btn-default ' . $sClass . '"><i class="' . $sIconClass . '"></i> ' . $sLabel . '</a>';
return $oHtml->getLinkButton(array(
'href'=>$sLink,
'title'=>$sHint,
'class'=>'btn btn-default ' . $sClass,
'type'=>$sFunction,
'onmouseover'=>$sOnMouseover,
'onmouseout'=>$sOnMouseout,
'label'=>$sLabel,
));
// return '<a href="' . $sLink . '" ' . $sOnMouseover . ' title="' . $sHint . '" class="btn btn-default ' . $sClass . '"><i class="' . $sIconClass . '"></i> ' . $sLabel . '</a>';
}
/**
......@@ -2683,6 +2675,7 @@ class project extends base {
* @return string
*/
public function renderRepoInfo() {
$oHtml=new htmlguielements();
$sReturn = "";
switch ($this->_aPrjConfig["build"]["type"]) {
case "git":
......@@ -2694,14 +2687,14 @@ class project extends base {
$sReturn.= '<i class="glyphicon glyphicon-tag"></i> ' . t('revision') . ': ' . $aRepodata["revision"] . '<br>';
$sReturn.="<pre>" . strip_tags($aRepodata["message"], '<br>') . "</pre>";
} else {
$sReturn .= $this->getBox("error", sprintf(t('class-project-error-no-repoaccess'), $aRepodata["error"]))
$sReturn .= $oHtml->getBox("error", sprintf(t('class-project-error-no-repoaccess'), $aRepodata["error"]))
. $this->renderLink("setup") . '<br>';
}
break;
default:
$sReturn .= $this->getBox("error", sprintf(t('class-project-error-wrong-buildtype'), $this->_aPrjConfig["build"]["type"]));
$sReturn .= $oHtml->getBox("error", sprintf(t('class-project-error-wrong-buildtype'), $this->_aPrjConfig["build"]["type"]));
}
if (array_key_exists("url", $this->_aPrjConfig["build"])) {
$sReturn.=t('repository-url') . ': ' . $this->_aPrjConfig["build"]["url"] . '<br>';
......@@ -2738,6 +2731,7 @@ class project extends base {
public function renderInfoLink($aInfos, $aOptions = array()) {
$sReturn = '';
$bIsError = false;
$oHtml=new htmlguielements();
$sInfos.='';
if (array_key_exists("title", $aOptions) && $aOptions["title"]) {
......@@ -2747,10 +2741,10 @@ class project extends base {
$sLinktitle = t('infos');
if (array_key_exists("message", $aInfos)) {
$sInfos.=$this->_getChecksumDiv($aInfos["revision"])
. '<i class="glyphicon glyphicon-calendar"></i> ' . t('build-from') . ' ' . date("d.m.Y H:i:s", strtotime($aInfos["date"])) . '<br>'
. '<i class="glyphicon glyphicon-bookmark"></i> ' . t('branch') . ': ' . $aInfos["branch"] . '<br>'
. '<i class="glyphicon glyphicon-tag"></i> ' . t('revision') . ': ' . $this->_renderRevision($aInfos["revision"]) . '<br>'
. '<i class="glyphicon glyphicon-comment"></i> ' . t('commitmessage') . ':<br><span class="pre">' . strip_tags($aInfos["message"], '<br>') . '</span>';
. $oHtml->getIconByType('calendar') . t('build-from') . ' ' . date("d.m.Y H:i:s", strtotime($aInfos["date"])) . '<br>'
. $oHtml->getIconByType('branch') . t('branch') . ': ' . $aInfos["branch"] . '<br>'
. $oHtml->getIconByType('revision') . t('revision') . ': ' . $this->_renderRevision($aInfos["revision"]) . '<br>'
. $oHtml->getIconByType('comment') . t('commitmessage') . ':<br><span class="pre">' . strip_tags($aInfos["message"], '<br>') . '</span>';
if (array_key_exists("more", $aOptions)) {
$sInfos.=$aOptions["more"];
}
......@@ -2771,7 +2765,7 @@ class project extends base {
// render html
$sId='info'.md5($sInfos);
$sReturn = '<a href="#" class="infoAsModal btn '.($bIsError ? 'btn-danger': 'btn-default').'" onclick="showIdAsModalMessage(\''.$sId.'\'); return false;">'
$sReturn = '<a href="#" class="btn '.($bIsError ? 'btn-danger': 'btn-default').'" onclick="showIdAsModalMessage(\''.$sId.'\'); return false;">'
// . '<i class="fa fa-info"></i> '
. $sLinktitle
. '</a><div id="'.$sId.'" style="display: none;" ';
......@@ -2798,13 +2792,14 @@ class project extends base {
* @return string
*/
public function renderVersionUsage() {
$oHtml=new htmlguielements();
$sReturn = false;
$sRowHead1 = false;
$sRowHead2 = '';
$aAllVersions = $this->_getVersionUsage();
if (!count($aAllVersions)) {
return $this->getBox("info", t('class-project-info-no-package'));
return $oHtml->getBox("info", t('class-project-info-no-package'));
}
foreach ($this->getActivePhases() as $sPhase) {
......@@ -2958,7 +2953,7 @@ class project extends base {
if (!$this->oUser->hasPermission("project-action-setup")){
return $this->oUser->showDenied();
}
$oHtml=new htmlguielements();
$sMessages = '';
require_once ("formgen.class.php");
......@@ -2996,7 +2991,7 @@ class project extends base {
$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>';
$sMessages.=$this->getBox("error", sprintf(t('class-project-error-no-repoaccess'), $aRepodata["error"]));
$sMessages.=$oHtml->getBox("error", sprintf(t('class-project-error-no-repoaccess'), $aRepodata["error"]));
}
// generate datalist with exisating ssh keys for auth field
......@@ -3356,7 +3351,7 @@ class project extends base {
} else {
$aForms["setup"]["form"]['input' . $i++] = array(
'type' => 'markup',
'value' => '<br>'.$this->getBox("error", t("replacement-fields-not-found"))
'value' => '<br>'.$oHtml->getBox("error", t("replacement-fields-not-found"))
// . '<pre>'.print_r($aValues, 1).'</pre>'
);
}
......
......@@ -25,6 +25,8 @@ global $oCLog;
$oCLog = new logger();
$oCLog->enableDebugByIp($aConfig['showdebug']['ip']);
require_once("./inc_functions.php");
require_once("./classes/htmlguielements.class.php");
$oHtml=new htmlguielements();
$sPrj = "";
$sAction = "overview";
......
......@@ -24,7 +24,7 @@ if (array_key_exists("confirm", $aParams)) {
$sOut.=$oPrj->accept($sPhase);
} else {
if (!$sPhase) {
$sOut.=$oPrj->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);
......@@ -44,12 +44,12 @@ if (array_key_exists("confirm", $aParams)) {
if (
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));
$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"]
) {
$sOut.=$oPrj->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.='
<table>
......
......@@ -45,12 +45,12 @@ if (!array_key_exists("confirm", $aParams)) {
if (
array_key_exists("revision", $aPhaseData2["onhold"]) && $aPhaseData2["onhold"]["revision"] == $sRevison
) {
$sOut.=$oPrj->getBox("warning", "In der Queue von [$sNext] ist die Version bereits $sRevison vorhanden!");
$sOut.=$oHtml->getBox("warning", "In der Queue von [$sNext] ist die Version bereits $sRevison vorhanden!");
}
if (
array_key_exists("revision", $aPhaseData2["ready2install"]) && $aPhaseData2["ready2install"]["revision"] == $sRevison
) {
$sOut.=$oPrj->getBox("warning", "Im Repo von [$sNext] ist die Version $sRevison bereits vorhanden!");
$sOut.=$oHtml->getBox("warning", "Im Repo von [$sNext] ist die Version $sRevison bereits vorhanden!");
}
}
$sOut.='
......
......@@ -93,9 +93,9 @@ if (!array_key_exists("confirm", $aParams)) {
}
$sErrors=$oPrj->delete($aOptions);
if ($sErrors) {
$sOut.=$oPrj->getBox("error", t('page-delete-project-delete-failed') . $sErrors);
$sOut.=$oHtml->getBox("error", t('page-delete-project-delete-failed') . $sErrors);
} else {
$sOut.=$oPrj->getBox("success", t('page-delete-project-delete-success'));
$sOut.=$oHtml->getBox("success", t('page-delete-project-delete-success'));
}
}
......
......@@ -34,7 +34,7 @@ if (array_key_exists("confirm", $aParams)) {
$aPhaseData = $oPrj->getPhaseInfos($sPhase);
if (!array_key_exists('version', $aPhaseData['onhold'])){
$sOut.=$oPrj->getBox("error",
$sOut.=$oHtml->getBox("error",
sprintf(t("deploy-impossible"), $sPhase).'<br>'
. (array_key_exists('info', $aPhaseData['onhold']) ? $aPhaseData['onhold']['info'].'<br>' : '')
. (array_key_exists('warning', $aPhaseData['onhold']) ? $aPhaseData['onhold']['warning'].'<br>' : '')
......@@ -86,7 +86,7 @@ if (array_key_exists("confirm", $aParams)) {
$sOut .= $oForm->renderHtml("deploy");
}
} else {
$sOut.=$oPrj->getBox("error", t("error-no-phase"));
$sOut.=$oHtml->getBox("error", t("error-no-phase"));
}
}
......
......@@ -29,7 +29,7 @@ $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__));
$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"]);
......
<?php
/* ######################################################################
IML DEPLOYMENT
webgui - build a package
---------------------------------------------------------------------
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>
###################################################################### */
require_once("./classes/project.class.php");
/**
* helper: render 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;");
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('&gt;', '&gt;<br>',htmlentities($sOut))
. '</pre></td>'
. '</tr>';
}
// ----------------------------------------------------------------------
// MAIN
// ----------------------------------------------------------------------
$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');")
. addHtmltestTest("Icon - Glyphicon", "\$oHtml->getIcon('glyphicon-user');")
. addHtmltestTest("Link", "\$oHtml->getLink(array(
'href'=>'https://www.axel-hahn.de/',
'icon'=>'fa-globe',
'label'=>'Axels Webseite',
));")
. addHtmltestTest("Link als Button", "\$oHtml->getLinkButton(array(
'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("Tabs", "\$oHtml->getNav(
array(
'options' => array(
'type'=>'tabs',
'justified'=>1,
),
'tabs' => array(
'tab 1'=>'Inhalt #1',
'tab 2'=>'Inhalt #2',
),
)
);")
. addHtmltestTest("Tabs", "\$oHtml->getNav(
array(
'options' => array(
'type'=>'pills',
'stacked'=>1,
),
'tabs' => array(
'tab 1'=>'Inhalt #1',
'tab 2'=>'Inhalt #2',
),
)
);")
;
// ----------------------------------------------------------------------
echo '<table><thead>'
. '<tr>'
. '<th>Beschreibung</th>'
. '<th>PHP-Code</th>'
. '<th>Ausgabe</th>'
. '<th>Ausgabe-Code</th>'
. '</tr>'
. '</thead><tbody>'
.$sRows
. '</tbody></table>'
;
......@@ -83,7 +83,7 @@ if (!array_key_exists("prj", $aParams)) {
. $oPrj->renderPhaseInfo()
. $sPhaseTabs
. $sPhaseDetails
: $oPrj->getBox("info", t("page-overview-no-phase")) .$oPrj->renderLink("setup")
: $oHtml->getBox("info", t("page-overview-no-phase")) .$oPrj->renderLink("setup")
).'
</div>
</div>
......
......@@ -56,7 +56,7 @@ if ($sPhase) {
*
*/
} else {
$sOut.=$oPrj->getBox("error", t("error-no-phase"));
$sOut.=$oHtml->getBox("error", t("error-no-phase"));
}
$sOut.= '<div id="navbuttom">' . aPrjHome() . '</div>';
......
......@@ -29,7 +29,7 @@ if (array_key_exists("confirm", $aParams)) {
} else {
if (!$sPhase) {
$sOut.=$oPrj->getBox("error", t("error-no-phase"));
$sOut.=$oHtml->getBox("error", t("error-no-phase"));
} else {
/*
if (!$oPrj->canAcceptPhase($sPhase)){
......
......@@ -116,7 +116,7 @@ if ($aParams["prj"] == "all") {
}
}
if ($sError){
$sOut.=$oPrj->getBox("error", '<ul>'.$sError.'</ul>');
$sOut.=$oHtml->getBox("error", '<ul>'.$sError.'</ul>');
} else {
$oForm = new formgen($aForms);
// TODO: unhide after checkin
......@@ -140,7 +140,7 @@ if ($aParams["prj"] == "all") {
if (!$sError) {
header("location: /deployment/" . $aParams["id"] . "/setup/");
}
$sOut.=$oPrj->getBox("error", $sError);
$sOut.=$oHtml->getBox("error", $sError);
}
$sOut.=$oPrj->renderNewProject();
}
......@@ -258,9 +258,9 @@ if ($aParams["prj"] == "all") {
if (array_key_exists("setupaction", $aParams) && $aParams["setupaction"] == "save") {
if ($oPrj->saveConfig()) {
$sOut.=$oPrj->getBox("success", t("page-setup-info-settings-were-saved")) . aPrjHome() . '<br><br>';
$sOut.=$oHtml->getBox("success", t("page-setup-info-settings-were-saved")) . aPrjHome() . '<br><br>';
} else {
$sOut.=$oPrj->getBox("error", t("page-setup-error-settings-were-not-saved"));
$sOut.=$oHtml->getBox("error", t("page-setup-error-settings-were-not-saved"));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment