Commit 266aafb0 authored by Carsten  Rose's avatar Carsten Rose
Browse files

config.qfq.ini: new syntax for SHOW_DEBUG_INFO - [yes,no,auto][,download]

Manual.rst, AbstractException.php, SessionCookie.php, Downoad.php, Error.php, Link.php, Report.php, Store.php, AbstractBuildForm.php, BuildFormBootstrap.php, config.qfq.example.ini: replace all access to SHOW_DEBUG_INFO with respect to multiple values.
parent 7f946457
......@@ -446,7 +446,7 @@ QFQ Keywords (Bodytext)
+-------------------+---------------------------------------------------------------------------------+
| <level>.althead | If <level>.sql is empty, these token will be rendered |
+-------------------+---------------------------------------------------------------------------------+
| debugShowBodyText | If ='1' and config.qfq.ini:*showDebugInfo=yes* - shows a tooltip with bodytext |
| debugShowBodyText | If='1' and config.qfq.ini:*SHOW_DEBUG_INFO =yes*, shows a tooltip with bodytext |
+-------------------+---------------------------------------------------------------------------------+
.. _debug:
......@@ -3375,14 +3375,14 @@ Syntax
Debug the bodytext
------------------
The parsed bodytext could be displayed by activating 'showDebugInfo' (:ref:`debug`) and specifying
The parsed bodytext could be displayed by activating 'SHOW_DEBUG_INFO ' (:ref:`debug`) and specifying
::
debugShowBodyText = 1
A small symbol with a tooltip will be shown, where the content record will be displayed on the webpage.
Note: :ref:`debug` information will only be shown with *showDebugInfo=yes* in config.ini .
Note: :ref:`debug` information will only be shown with *SHOW_DEBUG_INFO = yes* in config.ini .
Structure
---------
......
......@@ -15,7 +15,7 @@ SQL_LOG = sql.log
; all, modify
SQL_LOG_MODE = modify
; auto|yes|no|download. 'auto': if BE User is logged in the value will be 'yes', else 'no'
; [auto|yes|no][,download]. 'auto': if BE User is logged in the value will be replaced by 'yes', else 'no'. Additional choose 'download'.
SHOW_DEBUG_INFO = auto
; REDIRECT_ALL_MAIL_TO = john.doe@example.com
......
......@@ -37,7 +37,7 @@ abstract class AbstractBuildForm {
protected $pattern = array();
protected $wrap = array();
protected $symbol = array();
protected $showDebugInfo = false;
protected $showDebugInfoFlag = false;
protected $inputCheckPattern = array();
// protected $feDivClass = array(); // Wrap FormElements in <div class="$feDivClass[type]">
......@@ -73,7 +73,7 @@ abstract class AbstractBuildForm {
$this->store = Store::getInstance();
$this->db = new Database();
$this->evaluate = new Evaluate($this->store, $this->db);
$this->showDebugInfo = ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === SYSTEM_SHOW_DEBUG_INFO_YES);
$this->showDebugInfoFlag = Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM));
$this->sip = $this->store->getSipInstance();
......@@ -228,7 +228,7 @@ abstract class AbstractBuildForm {
*/
public function createFormEditorUrl($form, $recordId, array $param = array()) {
if (!$this->showDebugInfo) {
if (!$this->showDebugInfoFlag) {
return '';
}
......@@ -508,7 +508,7 @@ abstract class AbstractBuildForm {
if ($flagOutput) {
// debugStack as Tooltip
if ($this->showDebugInfo) {
if ($this->showDebugInfoFlag) {
if (count($debugStack) > 0) {
$elementHtml .= Support::doTooltip($formElement[FE_HTML_ID] . HTML_ID_EXTENSION_TOOLTIP, implode("\n", $debugStack));
}
......@@ -806,7 +806,7 @@ abstract class AbstractBuildForm {
$url = $sip->queryStringToSip(OnArray::toString($urlParam));
if ($this->showDebugInfo) {
if ($this->showDebugInfoFlag) {
//TODO: missing decoding of SIP
$toolTipNew .= PHP_EOL . PHP_EOL . OnArray::toString($urlParam, ' = ', PHP_EOL, "'");
}
......@@ -2140,7 +2140,7 @@ abstract class AbstractBuildForm {
if ($flagDelete) {
$toolTip = 'Delete';
if ($this->showDebugInfo) {
if ($this->showDebugInfoFlag) {
$toolTip .= PHP_EOL . "form = '" . $formElement[F_FINAL_DELETE_FORM] . "'" . PHP_EOL . "r = '" . $row[$nameColumnId] . "'";
}
......@@ -2260,7 +2260,7 @@ abstract class AbstractBuildForm {
}
}
if ($this->showDebugInfo)
if ($this->showDebugInfoFlag)
$toolTip .= PHP_EOL . OnArray::toString($queryStringArray, ' = ', PHP_EOL, "'");
Support::appendTypo3ParameterToArray($queryStringArray);
......
......@@ -204,7 +204,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
// Button: FormEdit
if ($this->showDebugInfo) {
if ($this->showDebugInfoFlag) {
$toolTip = "Edit form" . PHP_EOL . PHP_EOL . OnArray::toString($this->store->getStore(STORE_SIP), ' = ', PHP_EOL, "'");
$url = $this->createFormEditorUrl(FORM_NAME_FORM, $this->formSpec[F_ID]);
......@@ -217,7 +217,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
if (Support::findInSet(FORM_BUTTON_SAVE, $this->formSpec[F_SHOW_BUTTON]) && $this->formSpec[F_SUBMIT_BUTTON_TEXT] === '') {
$toolTip = 'Save';
if ($this->showDebugInfo) {
if ($this->showDebugInfoFlag) {
$toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
......@@ -235,7 +235,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
if (Support::findInSet(FORM_BUTTON_DELETE, $this->formSpec[F_SHOW_BUTTON])) {
$toolTip = 'Delete';
if ($this->showDebugInfo && $recordId > 0) {
if ($this->showDebugInfoFlag && $recordId > 0) {
$toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_FINAL_DELETE_FORM] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$disabled = ($recordId > 0) ? '' : 'disabled';
......
......@@ -82,7 +82,7 @@ class AbstractException extends \Exception {
$html = "<h2>Error</h2>" . Support::wrapTag('<p>', $html);
$html = Support::wrapTag("<div class='warning'>", $html);
if ($store !== null && $store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === SYSTEM_SHOW_DEBUG_INFO_YES) {
if ($store !== null && Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM))) {
$this->messageArray['current sip'] = $store->getStore(STORE_SIP);
......
......@@ -31,7 +31,7 @@ class SessionCookie {
public function __construct(array $config) {
$lines = '';
$this->cleanTempFiles = ($config[SYSTEM_SHOW_DEBUG_INFO] !== SYSTEM_SHOW_DEBUG_INFO_DOWNLOAD);
$this->cleanTempFiles = !Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_DOWNLOAD, $config[SYSTEM_SHOW_DEBUG_INFO]);
$urlParts = parse_url($config[SYSTEM_BASE_URL_PRINT]);
$domain = $urlParts['host'];
......
......@@ -72,7 +72,7 @@ class Download {
$this->db = new Database();
$this->html2pdf = new Html2Pdf($this->store->getStore(STORE_SYSTEM), $phpUnit);
if ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === SYSTEM_SHOW_DEBUG_INFO_DOWNLOAD) {
if (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_DOWNLOAD, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM))) {
$this->downloadDebugLog = $this->store->getVar(SYSTEM_SQL_LOG, STORE_SYSTEM);
}
}
......
......@@ -68,7 +68,7 @@ class SyntaxReportException extends \Exception {
$this->customMessage = [$this->customMessage];
//error message
if ($store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === SYSTEM_SHOW_DEBUG_INFO_YES) {
if (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM))) {
$errorMsg = nl2br("<hr />Error: <strong>" . htmlentities($this->getMessage()) . "</strong><br />");
$errorMsg .= "Formreport statement: <strong>" . htmlentities($this->fr_error["row"]) . "</strong><br />";
......@@ -78,6 +78,7 @@ class SyntaxReportException extends \Exception {
$tmparr = explode(":", $value, 2);
$errorMsg .= $tmparr[0] . ":<strong>" . htmlentities($tmparr[1]) . "</strong><br />";
}
$errorMsg .= "T3 Page pid: <strong>" . $this->fr_error["pid"] . "</strong><br />";
$errorMsg .= "ttcontent record uid: <strong>" . $this->fr_error["uid"] . "</strong><br />";
$errorMsg .= "File: <strong>" . $this->file . "</strong><br />Line: <strong>" . $this->line . "</strong><br />MSG: <strong>" . $this->code . "</strong><br />";
......@@ -85,7 +86,9 @@ class SyntaxReportException extends \Exception {
} else {
$errorMsg = "<hr />Error: <strong>" . htmlentities($this->getMessage()) . "</strong><hr />";
}
return $errorMsg;
} // errorMessage()
} // class syntaxException
......
......@@ -737,7 +737,7 @@ class Link {
$paramArray = $this->sip->queryStringToSip($urlNParam, RETURN_ARRAY);
$urlNParam = $paramArray['_url'];
if ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === SYSTEM_SHOW_DEBUG_INFO_YES) {
if (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM))) {
$vars[NAME_TOOL_TIP] .= PHP_EOL . PHP_EOL . $this->sip->debugSip($paramArray);
}
}
......
......@@ -79,7 +79,7 @@ class Report {
private $phpUnit = false;
private $showDebugInfo = false;
private $showDebugInfoFlag = false;
/**
* Report constructor.
......@@ -105,7 +105,7 @@ class Report {
$this->store = Store::getInstance();
$this->showDebugInfo = ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === SYSTEM_SHOW_DEBUG_INFO_YES);
$this->showDebugInfoFlag = (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM)));
$this->pageDefaults[DEFAULT_QUESTION]["pagec"] = "Please confirm!:info";
$this->pageDefaults[DEFAULT_QUESTION]["paged"] = "Do you really want to delete the record?:warning";
......
......@@ -236,13 +236,8 @@ class Store {
* @return array
*/
private static function adjustConfig(array $config) {
// Adjust config
if ($config[SYSTEM_SHOW_DEBUG_INFO] === SYSTEM_SHOW_DEBUG_INFO_AUTO) {
$rc = self::beUserLoggdIn();
if ($rc !== false) {
$config[SYSTEM_SHOW_DEBUG_INFO] = $rc;
}
}
$config[SYSTEM_SHOW_DEBUG_INFO] = self::adjustConfigShowDebugInfo($config[SYSTEM_SHOW_DEBUG_INFO], self::beUserLoggdIn());
// make SQL PATH absolute. This is necessary to work in different directories correctly.
if (isset($config[SYSTEM_SQL_LOG]) && $config[SYSTEM_SQL_LOG][0] !== '/') {
......@@ -253,17 +248,29 @@ class Store {
}
/**
* @return bool|string
* @param string $value
* @return string
*/
private static function beUserLoggdIn() {
private static function adjustConfigShowDebugInfo($value, $flag) {
if (isset($GLOBALS["TSFE"])) {
$rc = (isset($GLOBALS["TSFE"]->beUserLogin) && $GLOBALS["TSFE"]->beUserLogin === true) ? 'yes' : 'no';
} else {
$rc = false;
// Check if SHOW_DEBUG_INFO contains 'auto'. Replace with appropriate.
if (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_AUTO, $value)) {
$replace = $flag ? SYSTEM_SHOW_DEBUG_INFO_YES : SYSTEM_SHOW_DEBUG_INFO_NO;
$value = str_replace(SYSTEM_SHOW_DEBUG_INFO_AUTO, $replace, $value);
}
return $rc;
return $value;
}
/**
* Check if there is a Typo3 beUser is logged in. This is only possible if QFQ is called via T3, not via API
*
* @return bool true: current Browser session is a logged in BE User.
*/
private static function beUserLoggdIn() {
return (!empty($GLOBALS["TSFE"]->beUserLogin) && $GLOBALS["TSFE"]->beUserLogin === true);
}
/**
......@@ -523,7 +530,7 @@ class Store {
// Disable TYPO3_DEBUG_SHOW_BODY_TEXT=1 if SYSTEM_SHOW_DEBUG_INFO!='yes'
if (self::getVar(TYPO3_DEBUG_SHOW_BODY_TEXT, STORE_TYPO3) === '1' &&
self::getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) !== SYSTEM_SHOW_DEBUG_INFO_YES
!Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, self::getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM))
) {
self::setVar(TYPO3_DEBUG_SHOW_BODY_TEXT, '0', STORE_TYPO3);
}
......@@ -587,7 +594,6 @@ class Store {
$store[$key] = $value;
Session::set(STORE_EXTRA, $store);
}
}
......@@ -776,11 +782,9 @@ class Store {
self::setStore($typo3VarsArray, STORE_TYPO3, true);
// If necessary, update SYSTEM_SHOW_DEBUG_INFO
if (self::getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) == SYSTEM_SHOW_DEBUG_INFO_AUTO) {
$val = ($typo3VarsArray[TYPO3_BE_USER_LOGGED_IN] == 'yes') ? 'yes' : 'no';
self::setVar(SYSTEM_SHOW_DEBUG_INFO, $val, STORE_SYSTEM);
}
$value = self::getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM);
$value = self::adjustConfigShowDebugInfo($value, ($typo3VarsArray[TYPO3_BE_USER_LOGGED_IN] == 'yes'));
self::setVar(SYSTEM_SHOW_DEBUG_INFO, $value, STORE_SYSTEM);
}
}
......
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