Commit 7a01f6c7 authored by Carsten  Rose's avatar Carsten Rose
Browse files

ErrorHandler: print CWD at end of error message.

Logger: print CWD at end of error message.
Support: new function to prepend file with the extenions path.
Store: if SQLLOG is relative, prepend extension path.
AbstractBuildForm: get the Typo3 page 'id' from Typo3 and not from the URL.
BuildFormBootstrap: implemented 'EditForm' Button. Implemented 'Delete' Button. Prepared 'Debug' Button
Constants: new TYPO3_PAGE_ID
parent ec7d7e86
......@@ -134,70 +134,66 @@ abstract class AbstractBuildForm {
}
/**
* If SHOW_DEBUG_INFO=yes: create a link (incl. SIP) to edit the current form. Show also the hidden content of the SIP.
* Builds the head area of the form.
*
* @return string String: <a href="?pageId&sip=....">Edit</a> <small>[sip:..., r:..., urlparam:..., ...]</small>
* @return string
*/
public function createFormEditUrl() {
public function head() {
$html = '';
if ($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) !== 'yes') {
return '';
}
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything
$queryStringArray = [
'id' => $this->store->getVar(CLIENT_PAGE_ID, STORE_CLIENT),
'form' => 'form',
'r' => $this->formSpec['id']
];
// Logged in BE User will see a FormEdit Link
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
$formEditUrl = $this->createFormEditUrl();
$queryString = Support::arrayToQueryString($queryStringArray);
$html .= "<p><a href='$formEditUrl'>Edit</a> <small>[$sipParamString]</small></p>";
$sip = $this->store->getSipInstance();
$url = $sip->queryStringToSip($queryString);
$html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
return $url;
$html .= $this->getFormTag();
return $html;
}
/**
* Create a link (incl. SIP) to delete the current record.
* Format's an attribute: $type=$value. If $flagOmitEmpty==true && $value=='': return ''.
*
* @return string String: "API_DIR/delete.php?sip=...."
* @param $type
* @param $value
* @param bool|false $flagOmitEmpty
* @return string
*/
public function createDeleteUrl($table, $recordId) {
$queryStringArray = [
SIP_TABLE => $table,
SIP_RECORD_ID => $recordId
];
$queryString = Support::arrayToQueryString($queryStringArray);
$sip = $this->store->getSipInstance();
public function getAttribute($type, $value, $flagOmitEmpty = true) {
if ($flagOmitEmpty && $value === "")
return '';
return $sip->queryStringToSip($queryString, RETURN_URL, API_DIR . '/delete.php');
return $type . '="' . trim($value) . '" ';
}
/**
* Builds the head area of the form.
* If SHOW_DEBUG_INFO=yes: create a link (incl. SIP) to edit the current form. Show also the hidden content of the SIP.
*
* @return string
* @return string String: <a href="?pageId&sip=....">Edit</a> <small>[sip:..., r:..., urlparam:..., ...]</small>
*/
public function head() {
$html = '';
public function createFormEditUrl() {
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything
if ($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) !== 'yes') {
return '';
}
// Logged in BE User will see a FormEdit Link
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
$formEditUrl = $this->createFormEditUrl();
$queryStringArray = [
'id' => $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3),
'form' => 'form',
'r' => $this->formSpec['id']
];
$html .= "<p><a href='$formEditUrl'>Edit</a> <small>[$sipParamString]</small></p>";
$html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
$queryString = Support::arrayToQueryString($queryStringArray);
$html .= $this->getFormTag();
$sip = $this->store->getSipInstance();
$url = $sip->queryStringToSip($queryString);
return $html;
return $url;
}
/**
......@@ -355,6 +351,25 @@ abstract class AbstractBuildForm {
abstract public function doSubrecords();
/**
* Create a link (incl. SIP) to delete the current record.
*
* @return string String: "API_DIR/delete.php?sip=...."
*/
public function createDeleteUrl($table, $recordId) {
$queryStringArray = [
SIP_TABLE => $table,
SIP_RECORD_ID => $recordId
];
$queryString = Support::arrayToQueryString($queryStringArray);
$sip = $this->store->getSipInstance();
return $sip->queryStringToSip($queryString, RETURN_URL, API_DIR . '/delete.php');
}
abstract public function buildRowNative($formElement, $elementHtml);
abstract public function buildRowPill($formElement, $elementHtml);
......@@ -438,21 +453,6 @@ abstract class AbstractBuildForm {
}
/**
* Format's an attribute: $type=$value. If $flagOmitEmpty==true && $value=='': return ''.
*
* @param $type
* @param $value
* @param bool|false $flagOmitEmpty
* @return string
*/
public function getAttribute($type, $value, $flagOmitEmpty = true) {
if ($flagOmitEmpty && $value === "")
return '';
return $type . '="' . trim($value) . '" ';
}
/**
* Get column spec from tabledefinition and parse size of it. If nothing defined, return false.
*
......
......@@ -90,13 +90,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @return string
*/
public function head() {
// Logged in BE User will see a FormEdit Link
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
$formEditUrl = $this->createFormEditUrl();
$html = "<p><a href='$formEditUrl'>Edit</a> <small>[$sipParamString]</small></p>";
$deleteUrl = $this->createDeleteUrl($this->formSpec['tableName'], $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
$html .= "<p><a href='$deleteUrl'>Delete</a>";
$html = '';
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
......@@ -188,9 +182,13 @@ class BuildFormBootstrap extends AbstractBuildForm {
*/
private function buildButtons() {
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
$formEditUrl = $this->createFormEditUrl();
$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>
<button id="debug-button" type="button" class="btn btn-default navbar-btn"><span class="glyphicon glyphicon-eye-open"></span></button>
<a href="$formEditUrl" id="form-edit-button" class="btn btn-default navbar-btn"><span class="glyphicon glyphicon-wrench"></span></a>
</div>
BUTTONS;
......@@ -248,6 +246,8 @@ BUTTONS;
$formId = $this->getFormId();
$tabId = $this->getTabId();
$deleteUrl = $this->createDeleteUrl($this->formSpec['tableName'], $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
$html .= '</form>'; // <form class="form-horizontal" ...
$html .= <<<EOF
<script type="text/javascript">
......@@ -260,7 +260,7 @@ BUTTONS;
tabsId: '$tabId',
formId: '$formId',
submitTo: 'typo3conf/ext/qfq/qfq/api/save.php',
deleteUrl: 'typo3conf/ext/qfq/qfq/api/delete.php'
deleteUrl: '$deleteUrl'
});
})
</script>
......
......@@ -197,6 +197,7 @@ const TYPO3_FE_USER = 'feUser';
const TYPO3_FE_USER_UID = 'feUserUid';
const TYPO3_FE_USER_GROUP = 'feUserGroup';
const TYPO3_TT_CONTENT_UID = 'ttcontentUid';
const TYPO3_PAGE_ID = 'typo3PageId';
// System
const SYSTEM_DBUSER = 'DBUSER';
......
......@@ -17,7 +17,7 @@ class ErrorHandler {
// This error code is not included in error_reporting
return false;
}
throw new CodeException("Catchable Error in '$file' on line $line: " . $message, $severity, NULL);
throw new CodeException(": Catchable Error in '$file' on line $line: " . $message . " CWD: " . getcwd(), $severity, NULL);
}
}
\ No newline at end of file
......@@ -23,11 +23,12 @@ class Logger {
public static function logMessage($msg, $filename) {
if (!$handle = fopen($filename, 'a')) {
throw new UserException("Error - cannot open. File: " . $filename, ERROR_IO_OPEN);
throw new UserException("Error - cannot open. File: " . $filename . " ( CWD: " . getcwd() . ")", ERROR_IO_OPEN);
}
if (fwrite($handle, $msg . PHP_EOL) === FALSE) {
throw new UserException("Error - cannot write. File: " . $filename, ERROR_IO_WRITE);
throw new UserException("Error - cannot write. File: " . $filename . " ( CWD: " . getcwd() . ")", ERROR_IO_WRITE);
}
fclose($handle);
......
......@@ -81,10 +81,20 @@ class Support {
*/
public static function appendTooltip($inner, $tooltipText) {
// $inner .= '<span class="tooltiptext">' . $tooltipText . '</span>';
// return self::wrapTag('<div class="tooltip">', $inner);
return $inner . "<img src='" . GFX_INFO . "' title='$tooltipText'>";
}
/**
* If the given $file does not start with a '/', it's relative and the Typo3 Extension path will be added.
* @param $file
* @return string
*/
public static function ifRelativePathPrependExtensionPath($file) {
if ($file[0] !== '/') {
if (isset($_SERVER['SCRIPT_FILENAME']))
$file = dirname($_SERVER['SCRIPT_FILENAME']) . '/typo3conf/ext/qfq/' . $file;
}
return $file;
}
}
\ No newline at end of file
......@@ -157,6 +157,9 @@ class Store {
//TODO: Vernuenftige Fehlermeldung falls nicht auf qfq.ini zugegriffen werden kann.
//TODO: sinnvollen Platz fuer qfq.ini bestimmen. In der Installationsdoku erwaehnen.
$config = parse_ini_file(__DIR__ . '/../../../' . CONFIG_INI, false);
$config['SQLLOG'] = Support::ifRelativePathPrependExtensionPath($config['SQLLOG']);
} catch (\Exception $e) {
throw new qfq\UserException ("Error read file " . CONFIG_INI . ": " . $e->getMessage(), ERROR_IO_READ_FILE);
}
......@@ -206,6 +209,9 @@ class Store {
if (isset($GLOBALS["TSFE"]->fe_user->user["usergroup"]))
$arr[TYPO3_FE_USER_GROUP] = $GLOBALS["TSFE"]->fe_user->user["usergroup"];
if (isset($GLOBALS["TSFE"]->id))
$arr[TYPO3_PAGE_ID] = $GLOBALS["TSFE"]->id;
self::setVarArray($arr, STORE_TYPO3, true);
}
......
Markdown is supported
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