diff --git a/public_html/deployment/classes/actionlog.class.php b/public_html/deployment/classes/actionlog.class.php index 6dff441fbbe1178d77c8311672d9106599d0ef1c..990f71c306d6441399cac40db47e65be7c0cdd5f 100644 --- a/public_html/deployment/classes/actionlog.class.php +++ b/public_html/deployment/classes/actionlog.class.php @@ -37,6 +37,9 @@ class Actionlog { $this->_dbfile = $aConfig['appRootDir'] . '/database/logs.db'; if (!file_exists($this->_dbfile)) { $this->_createDb(); + if (!file_exists($this->_dbfile)) { + die("ERROR: unable to create sqlite database " . $this->_dbfile); + } } $this->_sProject = $sProject; @@ -148,7 +151,7 @@ class Actionlog { * 'limit' - limit clausel - part behind "LIMIT " * @return string */ - public function renderLogs($aFilter = array()) { + public function renderLogs($aFilter = array(), $bIsFullsearch=false) { $sReturn = ""; static $bWasShown; @@ -174,7 +177,7 @@ class Actionlog { $sReturn.='</tr>'; } $sReturn.='</tbody>'; - $sReturn = ' + $sReturn .= ' <i class="icon-filter"></i> ' . t("overview-textsearch") . ': <input type="text" id="efilterlogs" name="efilterlogs" @@ -183,11 +186,26 @@ class Actionlog { onKeypress="filterLogTable(); " onKeyup="filterLogTable(); " title="' . t("overview-textsearch-hint") . '" - > - + >'; + if ($bIsFullsearch){ + $sSelect=''; + $sSql='SELECT DISTINCT(project) from `logs`'; + foreach ($this->_makeQuery($sSql) as $row) { + $sSelect.='<option value="'.$row[0].'"'; + $sSelect.='>' . $row[0] . '</option>'; + } + if ($sSelect){ + $sReturn .= ' '. t('project') . ': <select id="selproject" name="project">' + . '<option value="">'.t("all").'</option>' + . $sSelect + . '</select>'; + } + } else { + $sReturn .= ' <i class="icon-list-alt"></i> - <a href="/deployment/all/setup/actionlog/">all</a><br> - + <a href="/deployment/all/setup/actionlog/">all</a>'; + } + $sReturn = '<br> <table class="table">' . $sReturn . '</table>'; } diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 23ff91116f758419d04770a8820051140f2bd5dd..6fa8de9fbe41d6c3f603dc5df8164e4571070eb0 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -186,6 +186,7 @@ class project { $sReturn = '<pre class="cli">' . $sReturn; } else { $sReturn = '<pre class="cli error">' . $sReturn; + $this->_logaction("command failed: $sCommand<br>output:<pre>$sReturn</pre>", "exec", "error"); } $sReturn.='</pre>'; } @@ -1064,7 +1065,8 @@ class project { $sHookfile = $this->_aConfig['hooks']['build-postclone']; $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('chmod 755 '.$sTempDir.'/hooks/on*'); + $this->_iRcAll = 0; $sReturn.=$this->_execAndSend('bash --login -c \'' . $sTempDir . '/' . $sHookfile . '\''); if (!$this->_iRcAll == 0) { $this->_TempDelete(); @@ -1099,7 +1101,8 @@ class project { $sHookfile = $this->_aConfig['hooks']['build-precompress']; $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('chmod 755 '.$sTempDir.'/hooks/on*'); + $this->_iRcAll = 0; $sReturn.=$this->_execAndSend('bash --login -c \'' . $sTempDir . '/' . $sHookfile . '\''); if (!$this->_iRcAll == 0) { $this->_TempDelete(); diff --git a/public_html/deployment/classes/sws.class.php b/public_html/deployment/classes/sws.class.php index 6637546675c731c038671852c1381a180b5d3225..7296b3d1be27cc31d6fc9b18a635fb73487edeb8 100644 --- a/public_html/deployment/classes/sws.class.php +++ b/public_html/deployment/classes/sws.class.php @@ -14,6 +14,7 @@ * <br> * * --- HISTORY:<br> + * 2014-04-06 0.3 enable/ disable gui; detect class parameters * 2014-04-05 0.2 * 2014-04-05 0.1 first public beta * @@ -31,7 +32,7 @@ * - configuration: option area * - configuration: examples of a class + of actions * - * @version 0.02 + * @version 0.03 * @author Axel Hahn * @link http://www.axel-hahn.de/php_sws * @license GPL @@ -94,7 +95,7 @@ class sws { * version * @var string */ - private $_sVersion = "0.02 (beta)"; + private $_sVersion = "0.03 (beta)"; /** * title @@ -102,6 +103,10 @@ class sws { */ private $_sTitle = "SWS :: simple web service"; + private $_aOptions = array( + 'enableGui'=>true + ); + /** * url for documentation * @var string @@ -143,6 +148,10 @@ class sws { $this->_aKnownClasses = array(); if (is_array($aKnownClasses)) { $this->_aKnownClasses = $aKnownClasses; + + if (array_key_exists("options", $aKnownClasses)){ + $this->_aOptions=array_merge($this->_aOptions, $aKnownClasses["options"]); + } return true; } return false; @@ -244,15 +253,6 @@ class sws { "see", "since", "static", "staticvar", "subpackage", "todo", "tutorial", "uses", "var", "version" ); - /* - $aTagsFollowedByKeyword=array( - "access", "global", - "method", "param", "property", "return", - "see", "since", "static", "staticvar", "subpackage", "todo", "tutorial", - "uses", "var" - ); - * - */ $sReturn = preg_replace('@[\ \t][\ \t]*@', ' ', $sReturn); // remove multiple spaces @@ -298,7 +298,7 @@ class sws { private function showClasshelp() { $sReturn = ''; - '<a href="help">help</a>'; + $sReturn .= '<h2>Explore</h2>' . '<p>allowed classes are:</p><ul class="classes">'; foreach (array_keys($this->_aKnownClasses["classes"]) as $sMyClass) { @@ -306,6 +306,7 @@ class sws { require_once($this->_sClassDir . $this->_aKnownClasses["classes"][$sMyClass]["file"]); $oRefClass = new ReflectionClass($sMyClass); $sComment = $this->_parseComment($oRefClass->getDocComment()); + $sComment2 = $this->_parseComment($oRefClass->getMethod("__construct")->getDocComment()); $sIdDescription = "help-" . $sMyClass . ""; $sStyle = ' style="display: none;"'; @@ -322,7 +323,9 @@ class sws { . '<a href="?class=' . $sMyClass . '">' . $sMyClass . '</a>' . '</h3>' . '<div id="' . $sIdDescription . '"' . $sStyle . '>' - . $sComment + . $sComment + . '<p>__constructor:</p>' + . $sComment2 . $this->showActionhelp($sMyClass) . '</div>' . '</li>'; @@ -367,6 +370,7 @@ class sws { . '</h4>' . '<div id="' . $sIdDescription . '"' . $sStyle . '>' . $sComment + . $this->_showMethodInputForm($oMethod) . '<br>try it ... ' . '' . $sClass . '->' . $sAction . '() ... <br><br>as '; foreach (array("raw", "json") as $sType) { @@ -387,6 +391,52 @@ class sws { return $sReturn; } + private function _showMethodInputForm($oMethod){ + $sHtml=''; + $iCount=0; + $aParams=array(); + $iRequired=$oMethod->getNumberOfRequiredParameters(); + foreach($oMethod->getParameters() as $oParam){ + preg_match('@Parameter\ \#.*\[\ (.*)\ \]@', $oParam->__toString(), $aTmp); + preg_match('@(.*)=\ (.*)@', $aTmp[1], $aTmp1); + if (count($aTmp1)){ + $aParams[$iCount]["varname"]=$aTmp1[1]; + $aParams[$iCount]["value"]=$aTmp1[2]; + } else { + $aParams[$iCount]["varname"]=$aTmp[1]; + $aParams[$iCount]["value"]=false; + } + $aParams[$iCount]["required"]=$iCount<$iRequired ? true:false; + $iCount++; + } + + // + if (count($aParams )) { + $sHtml.='<br>parameters (<span class="error">not active yet - this feature to enter parameter values is coming soon</span>):<br><br>'; + if ($iRequired){ + if ($iCount==$iRequired) { + $sHtml.=' ... all param(s) required<br>'; + } else { + $sHtml.=' ... '.$iRequired . ' of '.$iCount.' param(s) required<br>'; + } + } + foreach($aParams as $aParam){ + $sHtml.='<label for="">'.$aParam["varname"].' = </label>'; + $sHtml.='<input type="text" name="" size="30" value="'.$aParam["value"].'"/>'; + if ($aParam["required"]){ + $sHtml.=' (*)'; + } else { + $sHtml.=' « optional; default is <span class="defaultvalue">'.$aParam["value"].'</span>'; + } + $sHtml.='<br>'; + } + } else { + $sHtml.='(no parameters)<br>'; + } + + return $sHtml; + } + /** * render output as html page * @param string $sBody html body @@ -433,7 +483,7 @@ class sws { . '<title>' . $this->_sTitle . '</title>' . '<meta http-equiv="content-type" content="text/html; charset=UTF-8" />' . '<style>' - . 'body{background:#aaa; color: #ccc; font-family: verdana,arial; margin: 0;}' + . 'body{background:#aaa; color: #ddd; font-family: verdana,arial; margin: 0;}' . '#content{padding: 2em; color: #444; background:#f8f8f8;}' . '#footer{padding: 0 2em; border-top: 0.5em solid #999;}' . 'a,a:visited{text-decoration: none; color: #000;}' @@ -441,14 +491,12 @@ class sws { . 'a.try{background:#080; border-color: #0c0;}' . 'a.try:hover{background:#0b0; border-color: #0c0;}' . 'button{ width: 2em; height: 2em; background: #44a; border-radius: 0.3em; color:#eee; border: 3px solid #338; font-size: 110%;}' - . 'h1{background:#222; color:#ccc; padding: 0.3em; margin: 0; }' + . 'h1{background:#222; color:#ccc; padding: 0.3em; margin: 0; border-bottom: 0.2em solid #999;}' . 'h1 a, h1 a:visited{color:#888;}' - // . 'h1:before{content: "░▒▓█ "}' . 'h1 a span{color:#666; font-size: 45%;}' . 'h2{margin: 3em 0 1em; }' - //. 'h2:before{content: "░▒ "}' - //. 'h2:after{content: " ▒░"}' . 'h3,h4{margin: 0;}' + . 'label{width: 10em; float: left; text-align: right;}' . 'ul{padding-left: 0; margin: 0; border-radius: 0.5em;}' . 'ul ul{margin: 1em;}' . '.classes li{list-style: none; border-radius: 0.3em; padding: 0.3em; margin-bottom: 0.3em;}' @@ -465,6 +513,7 @@ class sws { . '.doctag{ color:#080; }' . '.error{ color:#800; background:#fcc; padding: 0.5em; margin-bottom: 2em; border-left: 4px solid;}' . '.warning{ color:#a96; background:#fc8; padding: 0.5em; margin-bottom: 2em; border-left: 4px solid;}' + . '.defaultvalue{color: #33c;}' . '</style>' . '<script>' . 'function toggleDesciption(sId, a){' @@ -479,15 +528,16 @@ class sws { . '}' . '</script>' . '</head>' - . '<body>' - . '<h1><a href="?">' . $this->_sTitle . ' <span>'.$this->_sVersion.'</span></a></h1>' + . '<body>'; + + if($this->_aOptions["enableGui"]){ + $sReturn.= + '<h1><a href="?">' . $this->_sTitle . ' <span>'.$this->_sVersion.'</span></a></h1>' . '<div id="content">' . $sError . $sBody . '<h2>Syntax</h2>' - . '<p>' . $sSyntax - . '</p>' . '</div><div id="footer">' . '<h2>About</h2>' . '<p>' @@ -498,14 +548,22 @@ class sws { . '</p>' . '<p>' . 'GNU 3.0;<br>'; - if ($this->_sUrlDoc) { - $sReturn.='<a href="' . $this->_sUrlDoc . '">' . $this->_sUrlDoc . '</a> '; - } - if ($this->_sUrlHome) { - $sReturn.='<a href="' . $this->_sUrlHome . '">' . $this->_sUrlHome . '</a> '; + if ($this->_sUrlDoc) { + $sReturn.='<a href="' . $this->_sUrlDoc . '">' . $this->_sUrlDoc . '</a> '; + } + if ($this->_sUrlHome) { + $sReturn.='<a href="' . $this->_sUrlHome . '">' . $this->_sUrlHome . '</a> '; + } + $sReturn.='</p></div>'; + } else { + + $sReturn.= + '<div id="content" style="height: 1000px; overflow: hidden;">' + .$sError .''. $this->_sTitle + .'</div>' + ; } - $sReturn.='</p>' - . '</div></body></html>'; + $sReturn.='</body></html>'; return $sReturn; } diff --git a/public_html/webservice/sws-config.json b/public_html/webservice/sws-config.json index dfd5b7596faa92e85baa7d5f0609c1d621be570b..0048074041f605b3c320c8f40a4b0b5a27a5ccb3 100644 --- a/public_html/webservice/sws-config.json +++ b/public_html/webservice/sws-config.json @@ -1,4 +1,7 @@ { + "options": { + "enableGui": 0 + }, "classes": { "Actionlog": { "file": "actionlog.class.php",