diff --git a/public_html/deployment/act_accept.php b/public_html/deployment/act_accept.php index 3e33dd0a3bd58b8f077d043461f618a605ed2e85..2778e853380fcb9eede1053a30c110092e3e699c 100644 --- a/public_html/deployment/act_accept.php +++ b/public_html/deployment/act_accept.php @@ -87,7 +87,9 @@ if (array_key_exists("confirm", $aParams)) { <form action="?" method="post" enctype="multipart/form-data"> <input type="hidden" name="confirm" value="1"> - <input type="submit" class="btn btn-primary btn-large" value="Accept ['.$sPhase.'] and put to ['.$sNext.']"> + <fieldset> + <button type="submit" class="btn btn-primary btn-large" >Accept ['.$sPhase.'] and put to ['.$sNext.']</button> + </fieldset> </form> '; } diff --git a/public_html/deployment/act_build.php b/public_html/deployment/act_build.php index 519c1789b005ae27f7c8c1e5dfb22563d4715f15..caece7b4b87cb80a5bb4abf885d11239a4283e3e 100644 --- a/public_html/deployment/act_build.php +++ b/public_html/deployment/act_build.php @@ -74,7 +74,9 @@ if (array_key_exists("confirm", $aParams)) { <!-- ' . enterDeployinfos() . ' <hr> --> - <input type="submit" class="btn btn-primary btn-large" value="Paket für ['.$sNext.'] erstellen"> + <fieldset> + <button type="submit" class="btn btn-primary btn-large" >Paket für ['.$sNext.'] erstellen</button> + </fieldset> </form> '; } diff --git a/public_html/deployment/act_deploy.php b/public_html/deployment/act_deploy.php index 49047fde34fb5bfb37dd8cc180afbff8671152dc..221c39f65ffae177653443947ddbcb7d7b1e1e77 100644 --- a/public_html/deployment/act_deploy.php +++ b/public_html/deployment/act_deploy.php @@ -35,7 +35,9 @@ if (array_key_exists("confirm", $aParams)) { <form action="?" method="post" enctype="multipart/form-data"> <input type="hidden" name="confirm" value="1"> - <input type="submit" class="btn btn-primary btn-large" value="Deploy"> + <fieldset> + <button type="submit" class="btn btn-primary btn-large" >Deploy</button> + </fieldset> </form> '; } else { diff --git a/public_html/deployment/act_setup.php b/public_html/deployment/act_setup.php new file mode 100644 index 0000000000000000000000000000000000000000..76cee75b455a7aab70e1438075d17bb66c359f34 --- /dev/null +++ b/public_html/deployment/act_setup.php @@ -0,0 +1,32 @@ +<?php + +require_once("./config/inc_projects_config.php"); +require_once("./classes/project.class.php"); +require_once("./inc_functions.php"); +$sOut=''; + + +$sOut.='<h2>Axels aktuelle Baustelle - Diese Seite noch ignorieren!!</h2>'; + +// --- Checks +$oPrj=new project(); + + +// $sOut.='<div style="float: right">aParams:<pre>'.print_r($aParams, true).'</pre></div>'; + +if (array_key_exists("setupaction", $aParams) && $aParams["setupaction"]=="save") { + if ($oPrj->saveConfig()){ + $sOut.=getBox("success", "OK, Projekteinstellungen wurden gespeichert") .aPrjHome().'<br><br>' ; + } else { + $sOut.=getBox("error", "Projekteinstellungen konnten nicht gespeichert werden :-/"); + } +} + +$oPrj=new project($aParams["prj"]); +$sOut.=$oPrj->renderSetup(); +$sOut.='<hr>'.aPrjHome(); + + +// -- Ausgabe +$sPhpOut=$sOut; +?> diff --git a/public_html/deployment/classes/formgen.class.php b/public_html/deployment/classes/formgen.class.php index f7751d1faad96730b3098269cc856faac4d3a395..fbc7bce60240503a67e49c8b424fe66641b1277f 100644 --- a/public_html/deployment/classes/formgen.class.php +++ b/public_html/deployment/classes/formgen.class.php @@ -1,266 +1,285 @@ -<?php - - -class formgen { - var $aForm=array(); - var $sRequired=' <span title="Eingabe ist erforderlich"><span style="color:#c00;">*</span></span>'; - - /** - * constructor - * @param array $aNewFormData - * @return boolean - */ - public function __construct($aNewFormData=array()) { - if (count($aNewFormData)) return $this->setFormarray($aNewFormData); - return true; - } - - /** - * set a new array - * @param array $aNewFormData - * @return boolean - */ - public function setFormarray($aNewFormData=array()){ - if (!is_array($aNewFormData) || !count($aNewFormData)){ - return false; - } - return $this->aForm=$aNewFormData; - } - - /** - * render a complete form - * @param string $sFormId - * @return string html output - */ - public function renderHtml($sFormId){ - $sReturn=false; - if (!array_key_exists($sFormId, $this->aForm)) { - die("ERROR: " . __CLASS__ . ":".__FUNCTION__ . " - form id " . $sFormId . " does not exist."); - } - foreach ($this->aForm[$sFormId]["form"] as $elementKey=>$elementData){ - $sReturn.=$this->renderHtmlElement($elementKey, $elementData); - } - - return $sReturn; - } - - /** - * add html attributes if they exist - * @param array $aAttributes list of attributes to search for - * @param array $elementData array of form element - * @return string - */ - private function _addHtmlAtrributes($aAttributes,$elementData){ - $sReturn=false; - foreach($aAttributes as $sAtrr){ - if (array_key_exists($sAtrr, $elementData) && $elementData[$sAtrr]){ - if ($sReturn) $sReturn.=' '; - $sReturn.=$sAtrr.'="'.$elementData[$sAtrr].'"'; - } - } - return $sReturn; - } - - - private function _addLabel($sLabel, $sFor, $sClass=false){ - $sReturn=false; - $sReturn='<label for="'.$sFor.'"'; - if ($sClass)$sReturn.=' class="'.$sClass.'"'; - $sReturn.='>'.$sLabel.'</label>'; - $sReturn.="\n"; - return $sReturn; - } - - private function _checkReqiredKeys($aArray, $aRequiredKeys, $sLabel=false){ - $bReturn=true; - foreach ($aRequiredKeys as $sKey){ - if (!array_key_exists($sKey, $aArray)){ - die("ERROR: $sLabel<br>Missing key \"$sKey\" in the array of a form element:<pre>" . print_r($aArray, true) . "</pre>"); - $bReturn=false; - } - } - return $bReturn; - } - - /** - * render a single form element - * @param string $sId id of a form element - * @param array $elementData array of form element - * @return string html output - */ - public function renderHtmlElement($sId, $elementData){ - $sReturn=false; - $aAllowedHtmlAttributes=array(); - $sDefaultAttributes="class,onclick,onmouseover,onmouseout,title"; - - if (!array_key_exists("type", $elementData)) { - print_r($elementData); - die("ERROR: " . __CLASS__ . ":".__FUNCTION__ . " - key "type" does not exist."); - } - - $sFormElement=false; - $sLabelText=''; - $sLabelElement=false; - - $sHtmlDefault=''; - $sHtmlTable=''; - - if (array_key_exists("label", $elementData)){ - $sLabelText=$elementData["label"]; - $sLabelText.=(array_key_exists("required", $elementData) && $elementData["required"])?$this->sRequired:''; - } - - switch ($elementData["type"]) { - case "button": - $this->_checkReqiredKeys($elementData, array("value")); - $sFormElement.=' <button id="'.$sId.'" '; - $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,checked,name"), $elementData); - $sFormElement.='>'.$elementData["value"].'</button>'; - $sFormElement.="\n"; - - $sHtmlDefault=$sFormElement; - break; - - case "checkbox": - $this->_checkReqiredKeys($elementData, array("name")); - foreach ($elementData["options"] as $idOption=>$aOptionData) { - $sFormElement.="\n"; - $s=preg_replace('/\W/iu', '', $sId.$idOption); - $sOptionId=preg_replace('/[äöüß]/i', '', $s); - $sFormElement.=' <input type="checkbox" id="'.$sOptionId.'" value="'.$idOption.'" '; - $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,checked"), $aOptionData); - $sFormElement.=' name="'.$elementData["name"].'[]"'; - $sFormElement.='/><label for="'.$sOptionId.'">' . $aOptionData["label"] . '</label>'; - - } - $sFormElement.="\n"; - $sLabelElement.='<span class="help-block">'.$sLabelText.'</span>'; - $sLabelElement.="\n"; - - $sHtmlDefault=$sLabelElement.$sFormElement; - $sHtmlTable='<td>'.$sLabelText.'</td><td>'.$sFormElement.'</td>'; - break; - - case "hidden": - $this->_checkReqiredKeys($elementData, array("value")); - $sFormElement.=' <input type="hidden" id="'.$sId.'" '; - $sFormElement.=$this->_addHtmlAtrributes(explode(",", "name,value"), $elementData); - $sFormElement.=" />"; - $sFormElement.="\n"; - - $sHtmlDefault=$sFormElement."\n"; - break; - - case "markup": - if (array_key_exists("value", $elementData)) - $sHtmlDefault=$elementData["value"]."\n"; - break; - - case "radio": - $this->_checkReqiredKeys($elementData, array("name")); - foreach ($elementData["options"] as $idOption=>$aOptionData) { - $sFormElement.="\n"; - $s=preg_replace('/\W/iu', '', $sId.$idOption); - $sOptionId=preg_replace('/[äöüß]/i', '', $s); - $sFormElement.=' <input type="radio" id="'.$sOptionId.'" value="'.$idOption.'" '; - $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,checked"), $aOptionData); - $sFormElement.=" ".$this->_addHtmlAtrributes(explode(",", "name"), $elementData); - $sFormElement.='/><label for="'.$sOptionId.'">' . $aOptionData["label"] . '</label>'; - - } - $sFormElement.="\n"; - - if ($sLabelText) { - $sLabelElement.='<span class="help-block">'.$sLabelText.'</span>'."\n"; - } - - $sHtmlTable='<td>'.$sLabelText.'</td><td>'.$sFormElement.'</td>'; - $sHtmlDefault=$sLabelElement.$sFormElement; - - // $sReturn.=$this->_addLabel($sFormElement,$sId,"checkbox"); - break; - - case "select": - // HINWEIS optgroups werden nicht unterstuezt - nur einfache Listen - $this->_checkReqiredKeys($elementData, array("name")); - $sFormElement.='<select id="'.$sId.'" ';; - $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,name"), $elementData); - $sFormElement.=">\n"; - foreach ($elementData["options"] as $idOption=>$aOptionData) { - $s=preg_replace('/\W/iu', '', $sId.$idOption); - $sOptionId=preg_replace('/[äöüß]/i', '', $s); - $sFormElement.=' <option value="'.$idOption.'" '; - $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes"), $aOptionData); - $sFormElement.='>'.$aOptionData["label"].'</option>'."\n"; - } - $sFormElement.="</select>\n"; - - if ($sLabelText) { - $sLabelElement.='<span class="help-block">'.$sLabelText.'</span>'."\n"; - } - - $sHtmlTable='<td>'.$sLabelText.'</td><td>'.$sFormElement.'</td>'; - $sHtmlDefault=$sLabelElement.$sFormElement; - - // $sReturn.=$this->_addLabel($sFormElement,$sId,"checkbox"); - break; - - - case "text": - $this->_checkReqiredKeys($elementData, array("name")); - $sFormElement.=' <input type="text" id="'.$sId.'" '; - $aAllowedHtmlAttributes["text"]=explode(",", ""); - $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,name,onkeyup,onkeydown,onchange,pattern,placeholder,required,size,value"), $elementData); - // $sFormElement.=$this->_addHtmlAtrributes(array("name", "value", "size", "placeholder", "required"), $elementData); - - // IE: Return abfangen lassen - $sFormElement.=' onkeypress="return checkKey(event);"'; - $sFormElement.=' />'; - $sFormElement.="\n"; - - $sLabelElement=$this->_addLabel($sLabelText,$sId, "control-label" ); - - $sHtmlDefault=$sLabelElement.'<div class="controls">'."\n".$sFormElement.'</div>'."\n"; - $sHtmlTable='<td>'.$sLabelText.'</td><td>'.$sFormElement.'</td>'; - - break; - - case "textarea": - $this->_checkReqiredKeys($elementData, array("name")); - $sFormElement.=' <textarea id="'.$sId.'" '; - $aAllowedHtmlAttributes["text"]=explode(",", ""); - $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,name,onkeyup,onkeydown,onchange,placeholder,required,cols,rows"), $elementData); - // $sFormElement.=$this->_addHtmlAtrributes(array("name", "value", "size", "placeholder", "required"), $elementData); - $sFormElement.='></textarea>'; - $sFormElement.="\n"; - - $sLabelElement=$this->_addLabel($sLabelText,$sId, "control-label" ); - - $sHtmlDefault=$sLabelElement.'<div class="controls">'."\n".$sFormElement.'</div>'."\n"; - $sHtmlTable='<td>'.$sLabelElement.'</td><td>'.$sFormElement.'</td>'; - - break; - - default: - die("ERROR: " . __CLASS__ . ":".__FUNCTION__ . " - formelement type ".$elementData["type"]." ist not supported (yet)."); - break; - } - - // Default or table mode? - if (array_key_exists("mode", $elementData) && $elementData["mode"]=='table' && $sHtmlTable) { - $sHtmlDefault=$sHtmlTable; - } else { - if ($elementData["type"]!="button" && $elementData["type"]!="fieldset" && $elementData["type"]!="markup"){ - $sHtmlDefault="<fieldset>". $sHtmlDefault."</fieldset>\n"; - } - } - - $sReturn.="<!-- " . $elementData["type"] ." -->\n"; - $sReturn.=$sHtmlDefault."\n"; - - return $sReturn; - } - -} - +<?php + + +class formgen { + var $aForm=array(); + var $sRequired=' <span title="Eingabe ist erforderlich"><span style="color:#c00;">*</span></span>'; + + /** + * constructor + * @param array $aNewFormData + * @return boolean + */ + public function __construct($aNewFormData=array()) { + if (count($aNewFormData)) return $this->setFormarray($aNewFormData); + return true; + } + + /** + * set a new array + * @param array $aNewFormData + * @return boolean + */ + public function setFormarray($aNewFormData=array()){ + if (!is_array($aNewFormData) || !count($aNewFormData)){ + return false; + } + return $this->aForm=$aNewFormData; + } + + /** + * render a complete form + * @param string $sFormId + * @return string html output + */ + public function renderHtml($sFormId){ + $sReturn=false; + if (!array_key_exists($sFormId, $this->aForm)) { + die("ERROR: " . __CLASS__ . ":".__FUNCTION__ . " - form id " . $sFormId . " does not exist."); + } + $sReturn.='<form '; + if (array_key_exists("meta", $this->aForm[$sFormId])){ + foreach (array("method","action","target","accept-charset") as $sAttr){ + if (array_key_exists($sAttr, $this->aForm[$sFormId]["meta"])){ + $sReturn.=$sAttr.'="'.$this->aForm[$sFormId]["meta"][$sAttr].'" '; + } + } + } + $sReturn.='>'; + foreach ($this->aForm[$sFormId]["form"] as $elementKey=>$elementData){ + $sReturn.=$this->renderHtmlElement($elementKey, $elementData); + } + $sReturn.='</form>'; + + return $sReturn; + } + + /** + * add html attributes if they exist + * @param array $aAttributes list of attributes to search for + * @param array $elementData array of form element + * @return string + */ + private function _addHtmlAtrributes($aAttributes,$elementData){ + $sReturn=false; + foreach($aAttributes as $sAtrr){ + if (array_key_exists($sAtrr, $elementData) && $elementData[$sAtrr]){ + if ($sReturn) $sReturn.=' '; + $sReturn.=$sAtrr.'="'.$elementData[$sAtrr].'"'; + } + } + return $sReturn; + } + + + private function _addLabel($sLabel, $sFor, $sClass=false){ + $sReturn=false; + $sReturn='<label for="'.$sFor.'"'; + if ($sClass)$sReturn.=' class="'.$sClass.'"'; + $sReturn.='>'.$sLabel.'</label>'; + $sReturn.="\n"; + return $sReturn; + } + + private function _checkReqiredKeys($aArray, $aRequiredKeys, $sLabel=false){ + $bReturn=true; + foreach ($aRequiredKeys as $sKey){ + if (!array_key_exists($sKey, $aArray)){ + die("ERROR: $sLabel<br>Missing key \"$sKey\" in the array of a form element:<pre>" . print_r($aArray, true) . "</pre>"); + $bReturn=false; + } + } + return $bReturn; + } + + /** + * render a single form element + * @param string $sId id of a form element + * @param array $elementData array of form element + * @return string html output + */ + public function renderHtmlElement($sId, $elementData){ + $sReturn=false; + $aAllowedHtmlAttributes=array(); + $sDefaultAttributes="class,onclick,onmouseover,onmouseout,title"; + + if (!array_key_exists("type", $elementData)) { + print_r($elementData); + die("ERROR: " . __CLASS__ . ":".__FUNCTION__ . " - key "type" does not exist."); + } + + $sFormElement=false; + $sLabelText=''; + $sLabelElement=false; + + $sHtmlDefault=''; + $sHtmlTable=''; + + if (array_key_exists("label", $elementData)){ + $sLabelText=$elementData["label"]; + $sLabelText.=(array_key_exists("required", $elementData) && $elementData["required"])?$this->sRequired:''; + } + + switch ($elementData["type"]) { + case "button": + $this->_checkReqiredKeys($elementData, array("value")); + $sFormElement.=' <button id="'.$sId.'" '; + $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,checked,name"), $elementData); + $sFormElement.='>'.$elementData["value"].'</button>'; + $sFormElement.="\n"; + + $sHtmlDefault=$sFormElement; + break; + + case "checkbox": + $this->_checkReqiredKeys($elementData, array("name")); + foreach ($elementData["options"] as $idOption=>$aOptionData) { + $sFormElement.="\n"; + $s=preg_replace('/\W/iu', '', $sId.$idOption); + $sOptionId=preg_replace('/[äöüß]/i', '', $s); + $sFormElement.=' <input type="checkbox" id="'.$sOptionId.'" value="'.$idOption.'" '; + $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,checked"), $aOptionData); + $sFormElement.=' name="'.$elementData["name"].'[]"'; + $sFormElement.='/><label for="'.$sOptionId.'">' . $aOptionData["label"] . '</label>'; + + } + $sFormElement.="\n"; + $sLabelElement.='<span class="help-block">'.$sLabelText.'</span>'; + $sLabelElement.="\n"; + + $sHtmlDefault=$sLabelElement.$sFormElement; + $sHtmlTable='<td>'.$sLabelText.'</td><td>'.$sFormElement.'</td>'; + break; + + case "hidden": + $this->_checkReqiredKeys($elementData, array("value")); + $sFormElement.=' <input type="hidden" id="'.$sId.'" '; + $sFormElement.=$this->_addHtmlAtrributes(explode(",", "name,value"), $elementData); + $sFormElement.=" />"; + $sFormElement.="\n"; + + $sHtmlDefault=$sFormElement."\n"; + break; + + case "markup": + if (array_key_exists("value", $elementData)) + $sHtmlDefault=$elementData["value"]."\n"; + break; + + case "radio": + $this->_checkReqiredKeys($elementData, array("name")); + foreach ($elementData["options"] as $idOption=>$aOptionData) { + $sFormElement.="\n"; + $s=preg_replace('/\W/iu', '', $sId.$idOption); + $sOptionId=preg_replace('/[äöüß]/i', '', $s); + $sFormElement.=' <input type="radio" id="'.$sOptionId.'" value="'.$idOption.'" '; + $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,checked"), $aOptionData); + $sFormElement.=" ".$this->_addHtmlAtrributes(explode(",", "name"), $elementData); + $sFormElement.='/><label for="'.$sOptionId.'">' . $aOptionData["label"] . '</label>'; + + } + $sFormElement.="\n"; + + if ($sLabelText) { + $sLabelElement.='<span class="help-block">'.$sLabelText.'</span>'."\n"; + } + + $sHtmlTable='<td>'.$sLabelText.'</td><td>'.$sFormElement.'</td>'; + $sHtmlDefault=$sLabelElement.$sFormElement; + + // $sReturn.=$this->_addLabel($sFormElement,$sId,"checkbox"); + break; + + case "select": + // HINWEIS optgroups werden nicht unterstuezt - nur einfache Listen + $this->_checkReqiredKeys($elementData, array("name")); + $sFormElement.='<select id="'.$sId.'" ';; + $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,name"), $elementData); + $sFormElement.=">\n"; + foreach ($elementData["options"] as $idOption=>$aOptionData) { + $s=preg_replace('/\W/iu', '', $sId.$idOption); + $sOptionId=preg_replace('/[äöüß]/i', '', $s); + $sFormElement.=' <option value="'.$idOption.'" '; + $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes"), $aOptionData); + $sFormElement.='>'.$aOptionData["label"].'</option>'."\n"; + } + $sFormElement.="</select>\n"; + + if ($sLabelText) { + $sLabelElement.='<span class="help-block">'.$sLabelText.'</span>'."\n"; + } + + $sHtmlTable='<td>'.$sLabelText.'</td><td>'.$sFormElement.'</td>'; + $sHtmlDefault=$sLabelElement.$sFormElement; + + // $sReturn.=$this->_addLabel($sFormElement,$sId,"checkbox"); + break; + + case "submit": + $this->_checkReqiredKeys($elementData, array("value")); + $sFormElement.=' <button id="'.$sId.'" class="btn btn-large btn-primary" type="submit" '; + $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes"), $elementData); + $sFormElement.='>'.$elementData["value"].'</button>'; + $sFormElement.="\n"; + + $sHtmlDefault=$sFormElement; + break; + + case "text": + $this->_checkReqiredKeys($elementData, array("name")); + $sFormElement.=' <input type="text" id="'.$sId.'" '; + $aAllowedHtmlAttributes["text"]=explode(",", ""); + $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,name,disabled,onkeyup,onkeydown,onchange,pattern,placeholder,required,size,value"), $elementData); + // $sFormElement.=$this->_addHtmlAtrributes(array("name", "value", "size", "placeholder", "required"), $elementData); + + // IE: Return abfangen lassen + $sFormElement.=' onkeypress="return checkKey(event);"'; + $sFormElement.=' />'; + $sFormElement.="\n"; + + $sLabelElement=$this->_addLabel($sLabelText,$sId, "control-label" ); + + $sHtmlDefault=$sLabelElement.'<div class="controls">'."\n".$sFormElement.'</div>'."\n"; + $sHtmlTable='<td>'.$sLabelText.'</td><td>'.$sFormElement.'</td>'; + + break; + + case "textarea": + $this->_checkReqiredKeys($elementData, array("name")); + $sFormElement.=' <textarea id="'.$sId.'" '; + $aAllowedHtmlAttributes["text"]=explode(",", ""); + $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,name,onkeyup,onkeydown,onchange,placeholder,required,cols,rows"), $elementData); + // $sFormElement.=$this->_addHtmlAtrributes(array("name", "value", "size", "placeholder", "required"), $elementData); + $sFormElement.='></textarea>'; + $sFormElement.="\n"; + + $sLabelElement=$this->_addLabel($sLabelText,$sId, "control-label" ); + + $sHtmlDefault=$sLabelElement.'<div class="controls">'."\n".$sFormElement.'</div>'."\n"; + $sHtmlTable='<td>'.$sLabelElement.'</td><td>'.$sFormElement.'</td>'; + + break; + + default: + die("ERROR: " . __CLASS__ . ":".__FUNCTION__ . " - formelement type ".$elementData["type"]." ist not supported (yet)."); + break; + } + + // Default or table mode? + if (array_key_exists("mode", $elementData) && $elementData["mode"]=='table' && $sHtmlTable) { + $sHtmlDefault=$sHtmlTable; + } else { + if ($elementData["type"]!="button" && $elementData["type"]!="fieldset" && $elementData["type"]!="markup"){ + $sHtmlDefault="<fieldset>". $sHtmlDefault."</fieldset>\n"; + } + } + + $sReturn.="<!-- " . $elementData["type"] ." -->\n"; + $sReturn.=$sHtmlDefault."\n"; + + return $sReturn; + } + +} + ?> \ No newline at end of file diff --git a/public_html/deployment/classes/html.tpl.php b/public_html/deployment/classes/html.tpl.php index 11deed00276d7745cd74b8ee4bc54d2a22c93caa..12e25770953ae8a4683ccae0385a85392931beb8 100644 --- a/public_html/deployment/classes/html.tpl.php +++ b/public_html/deployment/classes/html.tpl.php @@ -145,6 +145,15 @@ margin-top:0px } + + label.control-label{width: 300px; float: left; text-align: right; padding-right: 2em;} + + input, textarea { + width: 400px; /* passt so in modal Box */ + height: none !important; + padding: 1px 2px !important; + } + </style> <title>IML Deployment</title> <!-- diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 824ba59d408e13affad9a72b3d90efeb34f8640d..cac94c97667310dc935bd5851e9755bdc4149603 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -10,9 +10,15 @@ class project { /** * config file - * @var type + * @var string */ private $_sCfgfile = "../config/inc_projects_config.php"; + + /** + * directory for project configs + * @var string + */ + private $_sCfgdir = "../config/projects"; /** * configuration ($aConfig in the config file) @@ -99,8 +105,10 @@ class project { if (!file_exists($this->_aConfig["archiveDir"])) die("ERROR::CONFIG: archiveDir does not exist: "" . $this->_aConfig['archiveDir'] . ""."); - if (!array_key_exists("phases", $this->_aPrjConfig)) - die("ERROR::CONFIG: key "phases" was not found in config.<br><pre>" . print_r($this->_aPrjConfig, true) . "</pre>"); + foreach (array("fileprefix", "build", "phases") as $sKey) { + if (!array_key_exists($sKey, $this->_aPrjConfig)) + die("ERROR::CONFIG: key "$sKey" was not found in config.<br><pre>" . print_r($this->_aPrjConfig, true) . "</pre>"); + } // TODO: verify ausbauen return true; @@ -163,6 +171,10 @@ class project { // GETTER // ---------------------------------------------------------------------- + private function _getConfigFile($sId){ + if (!$sId) die("_getConfigFile requires an ID"); + return __dir__ . '/'.$this->_sCfgdir.'/'.$sId.".json"; + } /** * get a full ath for temp directory (for a build) * @return string @@ -630,7 +642,7 @@ class project { * @param array $aConfig * @return boolean */ - public function setProjectById($sId) { + public function setProjectById_OLD($sId) { $this->_aPrjConfig = array(); require(__dir__ . '/' . $this->_sCfgfile); if (!array_key_exists("$sId", $aProjects)) { @@ -642,6 +654,35 @@ class project { return true; } + /** + * apply a config + * @param array $aConfig + * @return boolean + */ + public function setProjectById($sId) { + $this->_aPrjConfig = array(); + require(__dir__ . '/' . $this->_sCfgfile); + $this->_aConfig["id"] = $sId; + + + /* + if (!array_key_exists("$sId", $aProjects)) { + die("ERROR: a project with ID $sId does not exist."); + } + $this->_aPrjConfig = $aProjects[$sId]; + if (file_exists($this->_getConfigFile($sId))) { + die("ERROR: a project with ID $sId does not exist."); + } + */ + + $this->_aPrjConfig=json_decode(file_get_contents($this->_getConfigFile($sId)), true); + // $aData=json_decode(file_get_contents($this->_getConfigFile($sId)), true); + // echo "<pre>" . print_r($aData, true) . "</pre>"; + + $this->_verifyConfig(); + return true; + } + // ---------------------------------------------------------------------- // ACTIONS // ---------------------------------------------------------------------- @@ -1064,7 +1105,28 @@ class project { return $sReturn; } - + + + /** + * save POSTed data as project config + * @return boolean + */ + public function saveConfig(){ + if (!$_POST) return false; + if (!array_key_exists("id", $_POST)) return false; + // if (!array_key_exists("setupaction", $_POST)) return false; + + $sId=$_POST["id"]; + $aData=$_POST; + + // remove unwanted items + foreach (array("setupaction", "prj", "id") as $s){ + if (array_key_exists($s, $aData)) unset ($aData[$s]); + } + // echo "SAVING: " . print_r($aData, true); + + return file_put_contents($this->_getConfigFile($sId), json_encode($aData)); + } // ---------------------------------------------------------------------- // RENDERING // ---------------------------------------------------------------------- @@ -1404,6 +1466,198 @@ class project { return $sReturn; } + /** + * Form Item + * @param string $sType one of text | ... + * @param id $sId id for form element + * @param string $sValue prefilled form value + * @param string $sLabel label + * @return string + */ + private function _renderFormitem($sType, $sId, $sValue, $sLabel=""){ + $sReturn=''; + switch ($sType) { + case "text": + $sReturn='<label for="'.$sId.'">'.$sLabel.'</label><input type="text" id="'.$sId.'" name="'.$sId.'" size="100" value="'.$sValue.'">'; + + break; + + default: + break; + } + return $sReturn; + } + public function renderSetup(){ + + require_once ("formgen.class.php"); + $i=0; + + + $aForms = array( + 'setup' => array( + 'meta' => array( + 'method' => 'POST', + 'action' => '?', + ), + 'validate' => array(), + 'form' => array( + 'input'.$i++ => array( + 'type' => 'hidden', + 'name' => 'setupaction', + 'value' => 'save', + ), + 'input'.$i++ => array( + 'type' => 'hidden', + 'name' => 'id', + 'value' => $this->_aConfig["id"], + ), + 'input'.$i++ => array( + 'type' => 'markup', + 'value' => '<div class="tabbable"> + <ul class="nav nav-tabs"> + <li class="active"><a href="#tab1" data-toggle="tab">allgemeine Metadaten</a></li> + <li><a href="#tab2" data-toggle="tab">Build</a></li> + <li><a href="#tab3" data-toggle="tab">Phasen</a></li> + </ul> + <div class="tab-content"> + <div class="tab-pane active" id="tab1"> + + ', + + ), + 'input'.$i++ => array( + 'type' => 'text', + 'name' => 'label', + 'label' => 'Label des Projekts', + 'value' => $this->_aPrjConfig["label"], + 'required' => 'required', + 'validate' => 'isastring', + 'size' => 100, + 'placeholder' => 'Projekt', + ), + 'input'.$i++ => array( + 'type' => 'text', + 'name' => 'description', + 'label' => 'Kurz-Beschreibung', + 'value' => $this->_aPrjConfig["description"], + 'required' => 'required', + 'validate' => 'isastring', + 'size' => 100, + 'placeholder' => '', + ), + 'input'.$i++ => array( + 'type' => 'text', + 'name' => 'contact', + 'label' => 'Ansprechpartner zum Projekt', + 'value' => $this->_aPrjConfig["contact"], + 'required' => 'required', + 'validate' => 'isastring', + 'size' => 100, + 'placeholder' => '', + ), + // -------------------------------------------------- + 'input'.$i++ => array( + 'type' => 'markup', + 'value' => ' </div><div class="tab-pane" id="tab2"> + <p> + Einstellungen zum Erstellen eines neuen Builds. + Es werden Zugriffsdaten auf das Repository benötigt.<br> + Der Fileprefix bestimmt einen Teil des Dateinamens + und wird auch in Puppet konfiguriert. Er darf nach + eingerichtetem Deployment nicht mehr geändert werden. + </p> + ', + ), + 'input'.$i++ => array( + 'type' => 'text', + 'name' => 'build[type]', + 'label' => 'Typ', + 'value' => $this->_aPrjConfig["build"]["type"], + 'required' => 'required', + 'validate' => 'isastring', + 'size' => 100, + 'placeholder' => '', + ), + 'input'.$i++ => array( + 'type' => 'text', + 'name' => 'build[ssh]', + 'label' => 'SSH-URL zum Repository', + 'value' => $this->_aPrjConfig["build"]["ssh"], + // 'required' => 'required', + 'validate' => 'isastring', + 'size' => 100, + 'placeholder' => '', + ), + 'input'.$i++ => array( + 'type' => 'text', + 'name' => 'build[keyfile]', + 'label' => 'Dateiname zum SSH-Private-Key', + 'value' => $this->_aPrjConfig["build"]["keyfile"], + // 'required' => 'required', + 'validate' => 'isastring', + 'size' => 100, + 'placeholder' => '', + ), + 'input'.$i++ => array( + 'type' => 'text', + 'name' => 'build[webaccess]', + 'label' => 'URL zur Web GUI des Repositorys', + 'value' => $this->_aPrjConfig["build"]["webaccess"], + // 'required' => 'required', + 'validate' => 'isastring', + 'size' => 100, + 'placeholder' => '', + ), + 'input'.$i++ => array( + 'type' => 'text', + 'name' => 'fileprefix', + // 'disabled' => 'disabled', + 'label' => 'File-Prefix <span class="error">(nachträglich NICHT mehr ändern!)</span>', + 'value' => $this->_aPrjConfig["fileprefix"], + 'required' => 'required', + 'validate' => 'isastring', + 'size' => 100, + 'placeholder' => '', + ), + // -------------------------------------------------- + + 'input'.$i++ => array( + 'type' => 'markup', + 'value' => ' </div><div class="tab-pane" id="tab3"> + <p>Gib die URLs der jeweiligen Phasen an. Wird keine URL eingetragen, ist die jeweilige Phase nicht aktiv.</p> + ', + ), + ), + ), + ); + foreach(array_keys($this->getPhases()) as $sPhase){ + $sUrl=array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase])?$this->_aPrjConfig["phases"][$sPhase]["url"]:""; + $aForms["setup"]["form"]['input'.$i++] = array( + 'type' => 'text', + 'name' => 'phases['.$sPhase.'][url]', + 'label' => 'Phase <span class="'.$sPhase.'">' . $sPhase . '</span> - URL der Webseite', + 'value' => $sUrl, + // 'required' => 'required', + 'validate' => 'isastring', + 'size' => 100, + 'placeholder' => '', + ); + } + $aForms["setup"]["form"]['input'.$i++] = array( + 'type' => 'markup', + 'value' => '</div></div><hr>', + ); + $aForms["setup"]["form"]['input'.$i++] = array( + 'type' => 'submit', + 'name' => 'btnsave', + 'label' => 'Speichern', + 'value' => 'Speichern', + ); + + $oForm=new formgen($aForms); + return $oForm->renderHtml("setup"); + } + } ?> \ No newline at end of file diff --git a/public_html/deployment/config/inc_projects_config.php b/public_html/deployment/config/inc_projects_config.php index dfd71ea9fafce22bef02426411b410139cf5dc58..bf1ff865557bc260cef4b773b9c75485009cca36 100644 --- a/public_html/deployment/config/inc_projects_config.php +++ b/public_html/deployment/config/inc_projects_config.php @@ -19,7 +19,7 @@ $aConfig=array( 'mirrorPackages'=>array( 'puppet'=>array( 'type'=>'rsync', - 'runas'=>'ladmin', + 'runas'=>'www-data', // nur fuer commandline 'target'=>'ladmin@calcium.iml.unibe.ch:/share/imldeployment', ), ), diff --git a/public_html/deployment/inc_functions.php b/public_html/deployment/inc_functions.php index f0e4a60fbaa4ceecb8e81471ef4646767dba092d..3fcf17150a24f977133d72124f900a560bcbd0fc 100644 --- a/public_html/deployment/inc_functions.php +++ b/public_html/deployment/inc_functions.php @@ -119,6 +119,7 @@ function getTopArea(){ <ul class="dropdown-menu"> <li><a href="'.$sBaseUrl.$aParams["prj"].'/build/">Build</a></li> <li><a href="'.$sBaseUrl.$aParams["prj"].'/cleanup/">Cleanup</a></li> + <li><a href="'.$sBaseUrl.$aParams["prj"].'/setup/">Projekteinstellungen</a></li> '; $sReturn.='</ul></li>';