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
35a053b4
Commit
35a053b4
authored
Aug 08, 2017
by
Carsten Rose
Browse files
AbstractBuildForm.php, BuildFormBootstrap.php: split buildRecordHashMd5 in two functions.
parent
360de0a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
extension/qfq/qfq/AbstractBuildForm.php
View file @
35a053b4
...
...
@@ -181,11 +181,18 @@ abstract class AbstractBuildForm {
$htmlElements
=
$this
->
elements
(
$recordId
,
$filter
,
0
,
$json
,
$modeCollectFe
,
$htmlElementNameIdZero
,
$storeUse
,
$mode
);
if
(
$mode
===
FORM_SAVE
&&
$recordId
!=
0
)
{
$record
=
$this
->
db
->
sql
(
"SELECT * FROM "
.
$this
->
formSpec
[
F_TABLE_NAME
]
.
" WHERE id=?"
,
ROW_EXPECT_1
,
[
$recordId
],
"Record to load not found."
);
$newMd5
=
OnArray
::
getMd5
(
$record
);
$json
[]
=
[
API_ELEMENT_UPDATE
=>
[
DIRTY_RECORD_HASH_MD5
=>
[
API_ELEMENT_ATTRIBUTE
=>
[
'value'
=>
$newMd5
]]]];
// $json[] = [API_ELEMENT_UPDATE => [DIRTY_RECORD_HASH_MD5 => [API_ELEMENT_ATTRIBUTE => ['value' => $newMd5]]]];
// $json[] = [API_ELEMENT_UPDATE => [DIRTY_RECORD_HASH_MD5 => ['value' => $newMd5]]];
// $json[DIRTY_RECORD_HASH_MD5][API_ELEMENT_UPDATE][DIRTY_RECORD_HASH_MD5][API_ELEMENT_ATTRIBUTE]['value'] = $newMd5;
// element-update: with 'content'
// $inputMd5 = $this->buildInputRecordHashMd5(false);
// $json[][API_ELEMENT_UPDATE][DIRTY_RECORD_HASH_MD5_SPAN][API_ELEMENT_CONTENT] = $inputMd5;
// element-update: with 'value'
$recordId
=
$this
->
store
->
getVar
(
SIP_RECORD_ID
,
STORE_SIP
.
STORE_ZERO
);
$md5
=
$this
->
buildRecordHashMd5
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
);
$json
[][
API_ELEMENT_UPDATE
][
DIRTY_RECORD_HASH_MD5
][
API_ELEMENT_ATTRIBUTE
][
'value'
]
=
$md5
;
}
}
...
...
@@ -284,23 +291,47 @@ abstract class AbstractBuildForm {
$honeypot
=
$this
->
getHoneypotVars
();
$md5
=
$this
->
buildRecordHashMd5
();
$md5
=
$this
->
build
Input
RecordHashMd5
();
return
'<form '
.
OnArray
::
toString
(
$attribute
,
'='
,
' '
,
"'"
)
.
'>'
.
$honeypot
.
$md5
;
}
/**
* Build MD5 from the current record. Return HTML Input element.
* @param bool $flagWithSpan
* @return string
* @throws \qfq\CodeException
* @throws \qfq\DbException
*/
public
function
buildRecordHashMd5
()
{
$record
=
array
();
public
function
build
Input
RecordHashMd5
(
$flagWithSpan
=
true
)
{
$recordId
=
$this
->
store
->
getVar
(
SIP_RECORD_ID
,
STORE_SIP
.
STORE_ZERO
);
$md5
=
$this
->
buildRecordHashMd5
(
$this
->
formSpec
[
F_TABLE_NAME
],
$recordId
);
$data
=
"<input id='"
.
DIRTY_RECORD_HASH_MD5
.
"' name='"
.
DIRTY_RECORD_HASH_MD5
.
"' type='hidden' value='
$md5
'>"
;
if
(
$flagWithSpan
)
{
$data
=
Support
::
wrapTag
(
'<span id="'
.
DIRTY_RECORD_HASH_MD5_SPAN
.
'">'
,
$data
);
}
return
$data
;
}
/**
* @param $tableName
* @param $recordId
* @return string
* @throws \qfq\CodeException
* @throws \qfq\DbException
*/
public
function
buildRecordHashMd5
(
$tableName
,
$recordId
){
$record
=
array
();
if
(
$recordId
!=
0
)
{
$record
=
$this
->
db
->
sql
(
"SELECT * FROM
"
.
$this
->
formSpec
[
F_TABLE_NAME
]
.
"
WHERE id=?"
,
ROW_EXPECT_1
,
[
$recordId
],
"Record to load not found."
);
$record
=
$this
->
db
->
sql
(
"SELECT * FROM
$tableName
WHERE id=?"
,
ROW_EXPECT_1
,
[
$recordId
],
"Record to load not found."
);
}
return
"<input id='"
.
DIRTY_RECORD_HASH_MD5
.
"' name='"
.
DIRTY_RECORD_HASH_MD5
.
"' type='hidden' value='"
.
OnArray
::
getMd5
(
$record
)
.
"'>"
;
return
OnArray
::
getMd5
(
$record
);
}
/**
...
...
extension/qfq/qfq/BuildFormBootstrap.php
View file @
35a053b4
...
...
@@ -445,7 +445,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
}
$honeypot
=
$this
->
getHoneypotVars
();
$md5
=
$this
->
buildRecordHashMd5
();
$md5
=
$this
->
build
Input
RecordHashMd5
();
return
'<form '
.
OnArray
::
toString
(
$attribute
,
'='
,
' '
,
"'"
)
.
'>'
.
$honeypot
.
$md5
;
}
...
...
extension/qfq/qfq/Constants.php
View file @
35a053b4
...
...
@@ -1122,6 +1122,7 @@ const DIRTY_EXPIRE = 'expire';
const
DIRTY_TABLE_NAME
=
'tableName'
;
const
DIRTY_RECORD_ID
=
'recordId'
;
const
DIRTY_RECORD_HASH_MD5
=
'recordHashMd5'
;
const
DIRTY_RECORD_HASH_MD5_SPAN
=
'recordHashMd5Span'
;
const
DIRTY_REMOTE_ADDRESS
=
'remoteAddress'
;
const
DIRTY_API_ACTION
=
'action'
;
// Name of parameter in API call of dirty.php?action=...&s=...
const
DIRTY_API_ACTION_LOCK
=
'lock'
;
...
...
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