Commit d1f1fec3 authored by Carsten  Rose's avatar Carsten Rose
Browse files

AbstractBuildForm.php, BuildFormBootstrap.php, BuildFormTable.php,...

AbstractBuildForm.php, BuildFormBootstrap.php, BuildFormTable.php, Constants.php, QuickFormQuery.php, Save.php: Replace string 'tableName' through constant F_TABLE_NAME.
parent e942cb6a
......@@ -339,7 +339,7 @@ abstract class AbstractBuildForm {
// get current data record
if ($recordId > 0 && $this->store->getVar('id', STORE_RECORD) === false) {
$row = $this->db->sql("SELECT * FROM " . $this->formSpec['tableName'] . " WHERE id = ?", ROW_EXPECT_1, array($recordId));
$row = $this->db->sql("SELECT * FROM " . $this->formSpec[F_TABLE_NAME] . " WHERE id = ?", ROW_EXPECT_1, array($recordId));
$this->store->setVarArray($row, STORE_RECORD);
}
......@@ -994,7 +994,7 @@ abstract class AbstractBuildForm {
$fieldTypeDefinition = $this->store->getVar($column, STORE_TABLE_COLUMN_TYPES);
if ($fieldTypeDefinition === false) {
throw new UserFormException("Column '$column' unknown in table '" . $this->formSpec['tableName'] . "'", ERROR_DB_UNKNOWN_COLUMN);
throw new UserFormException("Column '$column' unknown in table '" . $this->formSpec[F_TABLE_NAME] . "'", ERROR_DB_UNKNOWN_COLUMN);
}
$length = strlen($fieldTypeDefinition);
......@@ -1551,9 +1551,9 @@ abstract class AbstractBuildForm {
* @throws DbException
*/
private function getFormTable($formName) {
$row = $this->db->sql("SELECT tableName FROM Form AS f WHERE f.name = ?", ROW_EXPECT_0_1, [$formName]);
if (isset($row['tableName'])) {
return $row['tableName'];
$row = $this->db->sql("SELECT " . F_TABLE_NAME . " FROM Form AS f WHERE f.name = ?", ROW_EXPECT_0_1, [$formName]);
if (isset($row[F_TABLE_NAME])) {
return $row[F_TABLE_NAME];
}
return '';
......
......@@ -145,7 +145,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip = 'Save';
if ($this->showDebugInfo) {
$toolTip .= PHP_EOL . "table = '" . $this->formSpec['tableName'] . "'" . PHP_EOL . "r = '" . $recordId . "'";
$toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$buttonSave = $this->buildButtonCode('save-button', $toolTip, 'glyphicon-ok');
......@@ -156,7 +156,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip = 'Close';
if ($this->showDebugInfo) {
$toolTip .= PHP_EOL . "table = '" . $this->formSpec['tableName'] . "'" . PHP_EOL . "r = '" . $recordId . "'";
$toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$buttonClose = $this->buildButtonCode('close-button', 'Close', 'glyphicon-remove');
......@@ -167,7 +167,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip = 'Delete';
if ($this->showDebugInfo && $recordId > 0) {
$toolTip .= PHP_EOL . "table = '" . $this->formSpec['tableName'] . "'" . PHP_EOL . "r = '" . $recordId . "'";
$toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$disabled = ($recordId > 0) ? '' : 'disabled';
......@@ -315,7 +315,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$tabId = $this->getTabId();
if (0 < ($recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP))) {
$deleteUrl = $this->createDeleteUrl($this->formSpec['tableName'], $recordId);
$deleteUrl = $this->createDeleteUrl($this->formSpec[F_TABLE_NAME], $recordId);
}
$actionUpload = FILE_ACTION . '=' . FILE_ACTION_UPLOAD;
......
......@@ -77,7 +77,7 @@ class BuildFormTable extends AbstractBuildForm {
$formEditUrl = $this->createFormEditUrl();
$html .= "<p><a " . Support::doAttribute('href', $formEditUrl) . ">Edit</a><small>[$sipParamString]</small></p>";
$deleteUrl = $this->createDeleteUrl($this->formSpec['tableName'], $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
$deleteUrl = $this->createDeleteUrl($this->formSpec[F_TABLE_NAME], $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
$html .= "<p><a " . Support::doAttribute('href', $deleteUrl) . ">Delete</a>";
$html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
......
......@@ -402,8 +402,10 @@ const GLYPH_ICON_TOOL = 'glyphicon-wrench';
const GLYPH_ICON_CHECK = 'glyphicon glyphicon-ok';
// FORM
const F_TABLE_NAME = 'tableName';
const F_REQUIRED_PARAMETER = 'requiredParameter';
// FORM_ELEMENT_STATI
const FE_MODE_SHOW = 'show';
const FE_MODE_READONLY = 'readonly';
......
......@@ -227,7 +227,7 @@ class QuickFormQuery {
$this->store->createSipAfterFormLoad($formName);
}
$this->store->fillStoreTableDefaultColumnType($this->formSpec['tableName']);
$this->store->fillStoreTableDefaultColumnType($this->formSpec[F_TABLE_NAME]);
switch ($this->formSpec['render']) {
case 'plain':
......@@ -252,13 +252,13 @@ class QuickFormQuery {
case FORM_SAVE:
// If an old record exist: load it. Necessary to delete uploaded files which should be overwritten.
$this->fillStoreRecord($this->formSpec['tableName'], $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
$this->fillStoreRecord($this->formSpec[F_TABLE_NAME], $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
$save = new Save($this->formSpec, $this->feSpecAction, $this->feSpecNative);
$rc = $save->process();
// Reload fresh saved record and fill STORE_RECORD with it
$this->fillStoreRecord($this->formSpec['tableName'], $rc);
$this->fillStoreRecord($this->formSpec[F_TABLE_NAME], $rc);
$htmlElementNameIdZero = false;
// Retrieve current STORE_SIP.
......
......@@ -105,9 +105,9 @@ class Save {
}
if ($recordId == 0) {
$rc = $this->insertRecord($this->formSpec['tableName'], $newValues);
$rc = $this->insertRecord($this->formSpec[F_TABLE_NAME], $newValues);
} else {
$this->updateRecord($this->formSpec['tableName'], $newValues, $recordId);
$this->updateRecord($this->formSpec[F_TABLE_NAME], $newValues, $recordId);
$rc = $recordId;
}
......
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