Commit 9029bcbb authored by Carsten  Rose's avatar Carsten Rose
Browse files

Store: determine 'SHOW_DEBUG_INFO' and set it to 'yes' or 'no'.

AbstractBuildForm: Show 'formEditLink' incl. SIP Parameter.
BuildFormBootstrap: Added Icon in buildButton to edit form.
Evaluate: reformat Debug info.
formEditor.sql: showDebugInfo removed from table - now implemented by checking if BE User is logged in.
parent be3a94b4
......@@ -6,4 +6,7 @@ DB = <DB>
TESTDB = <TESTDB>
SESSIONNAME = qfq
\ No newline at end of file
SESSIONNAME = qfq
; auto|yes|no. 'auto': if BE User is loggend in 'true', else 'false'
SHOW_DEBUG_INFO = auto
\ No newline at end of file
......@@ -127,6 +127,30 @@ abstract class AbstractBuildForm {
return $html;
}
/**
* @return string
*/
public function formEditLink() {
if($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) !== 'yes') {
return '';
}
$queryStringArray = [
'form' => 'form',
'r' => $this->formSpec['id']
];
$queryString = Support::arrayToQueryString($queryStringArray);
$sip = $this->store->getSipInstance();
$url = $sip->queryStringToSip($queryString);
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP),':', ', ',"'");
return "<p></p><a href='$url'>Edit</a> <small>[$sipParamString]</small></p>";
}
/**
* Builds the head area of the form.
*
......@@ -137,6 +161,10 @@ abstract class AbstractBuildForm {
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything
// Logged in BE User will see a FormEdit Link
$html .= $this->formEditLink();
// $html .= $this->showSipParam();
$html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
$html .= $this->getFormTag();
......@@ -282,8 +310,7 @@ abstract class AbstractBuildForm {
$elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $debugStack);
// debugStack as Tooltip
if( $this->formSpec['showDebugInfo'] === 'yes' && count($debugStack)>0) {
// $elementHtml = Support::wrapWithTooltip($elementHtml, addslashes(implode("\n", Support::htmlentitiesOnArray($debugStack))));
if( $this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) === 'yes' && count($debugStack)>0) {
$elementHtml = Support::appendTooltip($elementHtml, implode("\n", OnArray::htmlentitiesOnArray($debugStack)));
}
......@@ -1030,7 +1057,7 @@ abstract class AbstractBuildForm {
/**
* Renders an Link with a symbol (edit) and register a new SIP to grant permission to the link..
*
* Returns <a href="<Link>"><span ...></span></a>
* Returns <a href="<Link>">[icon]</a>
*
* Link: <page>?s=<SIP>&<standard typo3 params>
* SIP: form = $formElement['form'] (provided via formElement['parameter'])
......
......@@ -90,7 +90,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @return string
*/
public function head() {
$html = '';
$html = $this->formEditLink();
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
......@@ -180,9 +180,21 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @return string
*/
private function buildButtons() {
$tmp = <<<BUTTONS
<div class="btn-group" role="group">
<button id="form-edit-button" type="button" class="btn btn-default navbar-btn"><span class="glyphicon glyphicon-wrench"></span></button>
</div>
BUTTONS;
if($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) === 'yes'){
$formEditButton = $tmp;
}
$html = <<<BUTTONS
<div class="col-md-3 ">
<div class="btn-toolbar pull-right" role="toolbar">
$formEditButton
<div class="btn-group" role="group">
<button id="save-button" type="button" class="btn btn-default navbar-btn"><span class="glyphicon glyphicon-ok"></span></button>
<button id="close-button" type="button" class="btn btn-default navbar-btn"><span class="glyphicon glyphicon-remove"></span></button>
......
......@@ -97,14 +97,16 @@ class Evaluate {
$evaluated = $this->substitute($match);
$debugLocal[] = $debugIndent . "#Replace: '$match'";
$debugLocal[] = $debugIndent . "#By: '$evaluated'";
// If an array is returned, break everything and return this assoc array.
if (is_array($evaluated)) {
$result = $evaluated;
$debugLocal[] = $debugIndent . "#By: 'array(" . count($result) . ")'";
break;
}
$debugLocal[] = $debugIndent . "#By: '$evaluated'";
// More to substitute in the new evaluated result? Start recursion just with the new result..
if (strpos($evaluated, $this->endDelimiter) !== false) {
$evaluated = $this->parse($evaluated, $recursion + 1, $debugLocal);
......
......@@ -160,6 +160,11 @@ class Store {
} catch (\Exception $e) {
throw new qfq\UserException ("Error read file " . CONFIG_INI . ": " . $e->getMessage(), ERROR_IO_READ_FILE);
}
if(!isset($config['SHOW_DEBUG_INFO']) || $config['SHOW_DEBUG_INFO'] === 'auto') {
$config['SHOW_DEBUG_INFO'] = (isset($GLOBALS["TSFE"]->beUserLogin) && $GLOBALS["TSFE"]->beUserLogin === true) ? 'yes' : 'no';
}
self::setVarArray($config, STORE_SYSTEM, true);
}
......
......@@ -24,7 +24,6 @@ CREATE TABLE IF NOT EXISTS `Form` (
`bsNoteColumns` VARCHAR(255) NOT NULL DEFAULT '',
`parameter` TEXT NOT NULL,
`showDebugInfo` ENUM('yes', 'no') NOT NULL DEFAULT 'no',
`deleted` ENUM('yes', 'no') NOT NULL DEFAULT 'no',
`modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
......@@ -151,7 +150,6 @@ VALUES
(1, 'bsInputColumns', 'BS Input Columns', 'show', 'text', 'native', 290, 40, 250, '', '', '', '', '', '', 3),
(1, 'bsNoteColumns', 'BS Note Columns', 'show', 'text', 'native', 300, 40, 250, '', '', '', '', '', '', 3),
(1, 'showDebugInfo', 'Show debug info', 'show', 'checkbox', 'native', 400, 0, 0, '', '', '', '', '', '', 3),
(1, 'deleted', 'Deleted', 'show', 'checkbox', 'native', 405, 0, 0, '', '', '', '', '', '', 3),
(1, 'modified', 'Modified', 'readonly', 'text', 'native', 410, 40, 20, '', '', '', '', '', '', 3),
(1, 'created', 'Created', 'readonly', 'text', 'native', 420, 40, 20, '', '', '', '', '', '', 3),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment