Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
b5b3f75f
Commit
b5b3f75f
authored
Sep 12, 2018
by
Elias Villiger
Browse files
Refactoring Store: add fillStoreWithRecord
parent
2ef0e16c
Changes
4
Hide whitespace changes
Inline
Side-by-side
extension/qfq/qfq/QuickFormQuery.php
View file @
b5b3f75f
...
...
@@ -381,7 +381,8 @@ class QuickFormQuery {
}
if
(
$this
->
store
->
getVar
(
'id'
,
STORE_BEFORE
)
===
false
)
{
$this
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
,
STORE_BEFORE
);
$this
->
store
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
,
$this
->
dbArray
[
$this
->
dbIndexData
],
STORE_BEFORE
);
}
// Check (and release) dirtyRecord.
...
...
@@ -466,7 +467,8 @@ class QuickFormQuery {
$formAction
->
elements
(
$recordId
,
$this
->
feSpecAction
,
FE_TYPE_BEFORE_INSERT
.
','
.
FE_TYPE_BEFORE_UPDATE
.
','
.
FE_TYPE_BEFORE_SAVE
);
// If an old record exist: load it. Necessary to delete uploaded files which should be overwritten.
$this
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
,
STORE_RECORD
);
$this
->
store
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
,
$this
->
dbArray
[
$this
->
dbIndexData
]);
// SAVE
$save
=
new
Save
(
$this
->
formSpec
,
$this
->
feSpecAction
,
$this
->
feSpecNative
,
$this
->
feSpecNativeRaw
);
...
...
@@ -477,7 +479,7 @@ class QuickFormQuery {
$rc
=
$save
->
process
();
// Reload fresh saved record and fill STORE_RECORD with it.
$this
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$rc
,
STORE_RECORD
);
$this
->
store
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$rc
,
$this
->
dbArray
[
$this
->
dbIndexData
]
);
$save
->
processAllUploads
(
$rc
);
...
...
@@ -485,7 +487,7 @@ class QuickFormQuery {
$status
=
$formAction
->
elements
(
$rc
,
$this
->
feSpecAction
,
FE_TYPE_AFTER_INSERT
.
','
.
FE_TYPE_AFTER_UPDATE
.
','
.
FE_TYPE_AFTER_SAVE
);
if
(
$status
!=
ACTION_ELEMENT_NO_CHANGE
)
{
// Reload fresh saved record and fill STORE_RECORD with it.
$this
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$rc
,
STORE_RECORD
);
$this
->
store
->
fillStoreWithRecord
(
$this
->
formSpec
[
F_TABLE_NAME
],
$rc
,
$this
->
dbArray
[
$this
->
dbIndexData
]
);
}
// Action: Paste
...
...
@@ -848,7 +850,7 @@ class QuickFormQuery {
// This is needed for filling templateGroup records with their default values
// and for evaluating variables in the Form title
$this
->
fillStoreWithRecord
(
$form
[
F_TABLE_NAME
],
$recordId
,
STORE_RECORD
);
$this
->
store
->
fillStoreWithRecord
(
$form
[
F_TABLE_NAME
],
$recordId
,
$this
->
dbArray
[
$this
->
dbIndexData
]
);
$formSpec
=
$this
->
eval
->
parseArray
(
$form
);
...
...
@@ -1303,24 +1305,6 @@ class QuickFormQuery {
return
$sipFound
;
}
/**
* Load record $id from $table and saves them in $store
*
* @param string $table tablename from where to load record wiht $recordId
* @param string $recordId record ID of current record
* @param string $store name of store where to save the record
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
private
function
fillStoreWithRecord
(
$table
,
$recordId
,
$store
=
STORE_RECORD
)
{
if
(
$recordId
!==
false
&&
$recordId
>
0
)
{
$record
=
$this
->
dbArray
[
$this
->
dbIndexData
]
->
sql
(
"SELECT * FROM
$table
WHERE id = ?"
,
ROW_EXPECT_1
,
[
$recordId
]);
$this
->
store
->
setStore
(
$record
,
$store
,
true
);
}
}
/**
* Searches the whole array $dataArray on the second level for API_ELEMENT_UPDATE.
* All found elements collect under $collect[API_ELEMENT_UPDATE]... . Leave the rest unchanged.
...
...
@@ -1422,7 +1406,7 @@ class QuickFormQuery {
// Subrecord DragAndDrop
$subrecord
=
$this
->
dbArray
[
$this
->
dbIndexQfq
]
->
sql
(
SQL_FORM_ELEMENT_BY_ID
,
ROW_REGULAR
,
[
$dndSubrecordId
]);
$recordId
=
$this
->
store
->
getVar
(
DND_SUBRECORD_FORM_ID
,
STORE_SIP
.
STORE_ZERO
);
$this
->
fillStoreWithRecord
(
'Form'
,
$recordId
);
$this
->
store
->
fillStoreWithRecord
(
'Form'
,
$recordId
,
$this
->
dbArray
[
$this
->
dbIndexQfq
]
);
$dndOrderSql
=
$this
->
eval
->
parse
(
$subrecord
[
0
][
FE_SQL1
]);
foreach
(
$dndOrderSql
as
$i
=>
$row
)
{
foreach
(
$row
as
$key
=>
$value
)
{
...
...
extension/qfq/qfq/form/FormAction.php
View file @
b5b3f75f
...
...
@@ -145,7 +145,7 @@ class FormAction {
break
;
default
:
// Always work on recent data: previous actions might have modified the data.
$this
->
fillStoreRecord
(
$this
->
primaryTableName
,
$recordId
);
$this
->
store
->
fillStore
With
Record
(
$this
->
primaryTableName
,
$recordId
,
$this
->
db
);
}
if
(
!
$this
->
checkRequiredList
(
$fe
))
{
...
...
@@ -192,28 +192,6 @@ class FormAction {
return
$rc
;
}
/**
* Copy the current primary record to STORE_RECORD
*
* @param $table
* @param $recordId
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
private
function
fillStoreRecord
(
$table
,
$recordId
)
{
if
(
!
is_string
(
$table
)
||
$table
===
''
)
{
throw
new
UserFormException
(
""
);
}
if
(
$recordId
!==
false
&&
$recordId
>
0
)
{
$record
=
$this
->
db
->
sql
(
"SELECT * FROM
$table
WHERE id = ?"
,
ROW_EXPECT_1
,
[
$recordId
]);
$this
->
store
->
setStore
(
$record
,
STORE_RECORD
,
true
);
}
}
/**
* Process all FormElements given in the `requiredList` identified by their name.
* If none is empty in STORE_FORM return true, else false.
...
...
extension/qfq/qfq/store/FillStoreForm.php
View file @
b5b3f75f
...
...
@@ -49,6 +49,7 @@ class FillStoreForm {
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public
function
__construct
()
{
...
...
@@ -71,8 +72,7 @@ class FillStoreForm {
$form
=
$this
->
feSpecNative
[
'form'
];
$table
=
$form
.
'magic'
;
$recordId
=
$this
->
feSpecNative
[
'r'
];
$record
=
$this
->
dbArray
[
$this
->
dbIndexData
]
->
sql
(
"SELECT * FROM Test WHERE id = 1"
,
ROW_EXPECT_1
);
Store
::
setStore
(
$record
,
STORE_RECORD
,
true
);
$this
->
store
->
fillStoreWithRecord
(
"Test"
,
1
,
$this
->
dbArray
[
$this
->
dbIndexData
]);
$this
->
evaluate
=
new
Evaluate
(
$this
->
store
,
$this
->
dbArray
[
$this
->
dbIndexData
]);
...
...
extension/qfq/qfq/store/Store.php
View file @
b5b3f75f
...
...
@@ -830,6 +830,7 @@ class Store {
* @param string $sipTypo3Vars
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
static
function
fillTypo3StoreFromSip
(
$sipTypo3Vars
)
{
$t3vars
=
self
::
getStore
(
STORE_TYPO3
);
...
...
@@ -849,6 +850,25 @@ class Store {
self
::
setVar
(
SYSTEM_SHOW_DEBUG_INFO
,
$value
,
STORE_SYSTEM
);
}
/**
* Load $recordId from $tableName using $db and saves it in $store.
*
* @param $tableName
* @param $recordId
* @param $db
* @param string $store
* @throws CodeException
* @throws UserFormException
*/
public
static
function
fillStoreWithRecord
(
$tableName
,
$recordId
,
$db
,
$store
=
STORE_RECORD
)
{
if
(
$recordId
!==
false
&&
$recordId
>
0
&&
is_string
(
$tableName
)
&&
$tableName
!==
''
)
{
$record
=
$db
->
sql
(
"SELECT * FROM
$tableName
WHERE id = ?"
,
ROW_EXPECT_1
,
[
$recordId
]);
self
::
setStore
(
$record
,
$store
,
true
);
}
}
/**
* Read SYSTEM_FILL_STORE_SYSTEM_BY_SQL_1|2|3 from SYSTEM_STORE and if set:
* a) fire the SQL
...
...
@@ -857,6 +877,7 @@ class Store {
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public
static
function
StoreSystemUpdate
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment