Skip to content
GitLab
Menu
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
f5f3f9af
Commit
f5f3f9af
authored
Jan 25, 2016
by
Carsten Rose
Browse files
BuildForm.php, Form.ph: Class 'BuildFormPlain' renamed to BuildElements
parent
aabfc75b
Changes
2
Hide whitespace changes
Inline
Side-by-side
qfq/
Form
Build
Plain
.php
→
qfq/Build
Form
.php
View file @
f5f3f9af
...
...
@@ -39,8 +39,10 @@ class FormBuildPlain {
$this
->
wrap
[
WRAP_SETUP_TITLE
][
WRAP_SETUP_START
]
=
'<h3>'
;
$this
->
wrap
[
WRAP_SETUP_TITLE
][
WRAP_SETUP_END
]
=
'</h3>'
;
$this
->
wrap
[
WRAP_SETUP_ELEMENT
][
WRAP_SETUP_START
]
=
'<p>'
;
$this
->
wrap
[
WRAP_SETUP_ELEMENT
][
WRAP_SETUP_END
]
=
'</p>'
;
$this
->
wrap
[
WRAP_SETUP_LABEL
][
WRAP_SETUP_START
]
=
''
;
$this
->
wrap
[
WRAP_SETUP_LABEL
][
WRAP_SETUP_END
]
=
''
;
$this
->
wrap
[
WRAP_SETUP_INPUT
][
WRAP_SETUP_START
]
=
''
;
...
...
@@ -50,8 +52,8 @@ class FormBuildPlain {
$this
->
buildElementFunctionName
=
[
'checkbox'
=>
'Checkbox'
,
'dateJQW'
=>
'
d
ateJQW'
,
'datetimeJQW'
=>
'
d
ateJQW'
,
'dateJQW'
=>
'
D
ateJQW'
,
'datetimeJQW'
=>
'
D
ateJQW'
,
'email'
=>
'Input'
,
'gridJQW'
=>
'GridJQW'
,
'hidden'
=>
'Hidden'
,
...
...
@@ -60,7 +62,7 @@ class FormBuildPlain {
'password'
=>
'Input'
,
'radio'
=>
'Radio'
,
'select'
=>
'Select'
,
'subrecord'
=>
'
s
ubrecord'
,
'subrecord'
=>
'
S
ubrecord'
,
'upload'
=>
'File'
,
'url'
=>
'Input'
];
...
...
@@ -131,8 +133,10 @@ class FormBuildPlain {
$html
=
''
;
// get current data record
$row
=
$this
->
db
->
sql
(
"SELECT * FROM `"
.
$this
->
formSpec
[
'tableName'
]
.
"` WHERE id = ?"
,
ROW_REGULAR
,
array
(
$recordId
));
$this
->
store
->
setVarArray
(
$row
,
STORE_RECORD
);
if
(
$recordId
>
0
)
{
$row
=
$this
->
db
->
sql
(
"SELECT * FROM `"
.
$this
->
formSpec
[
'tableName'
]
.
"` WHERE id = ?"
,
ROW_REGULAR
,
array
(
$recordId
));
$this
->
store
->
setVarArray
(
$row
[
0
],
STORE_RECORD
);
}
// Iterate over all FormElements
foreach
(
$this
->
feSpecNative
as
$fe
)
{
...
...
@@ -217,11 +221,10 @@ class FormBuildPlain {
$attribute
.
=
$this
->
getAttribute
(
'rows'
,
$colsRows
[
1
]);
}
else
{
$attribute
.
=
$this
->
getAttribute
(
'type'
,
$formElement
[
'type'
]);
$attribute
.
=
$this
->
getAttribute
(
'size'
,
$formElement
[
'size'
]);
$attribute
.
=
$this
->
getAttributeList
(
$formElement
,
[
'type'
,
'size'
,
'maxLength'
]);
}
// 'maxLength' needs an upper 'L': naming convention for DB tables!
$attribute
.
=
$this
->
getAttributeList
(
$formElement
,
[
'autocomplete'
,
'autofocus'
,
'maxLength'
,
'placeholder'
]);
$attribute
.
=
$this
->
getAttributeList
(
$formElement
,
[
'autocomplete'
,
'autofocus'
,
'placeholder'
]);
if
(
$formElement
[
'type'
]
===
'email'
&&
$formElement
[
'checkType'
]
===
''
)
$formElement
[
'checkType'
]
=
'email'
;
...
...
@@ -230,7 +233,7 @@ class FormBuildPlain {
$attribute
.
=
$this
->
getAttributeMode
(
$formElement
);
$attribute
.
=
$this
->
getAttribute
(
'value'
,
addslash
es
(
$value
),
false
);
$attribute
.
=
$this
->
getAttribute
(
'value'
,
htmlentiti
es
(
$value
),
false
);
return
"
$htmlTag
$attribute
>
$htmlTagClosing
"
;
}
...
...
@@ -399,9 +402,21 @@ class FormBuildPlain {
$itemValue
=
$this
->
getItemsForEnumOrSet
(
$formElement
[
'name'
],
$fieldType
);
if
(
is_array
(
$formElement
[
'sql1'
]))
{
$
itemValue
=
array_
column
(
$formElement
[
'sql1'
]
,
'label'
);
$
keys
=
array_
keys
(
$formElement
[
'sql1'
]
[
0
]
);
$itemKey
=
array_column
(
$formElement
[
'sql1'
],
'id'
);
// If there is no column 'id' and at least two columns in total
if
(
count
(
$itemKey
)
===
0
&&
count
(
$keys
)
>=
2
)
{
$itemKey
=
array_column
(
$formElement
[
'sql1'
],
$keys
[
0
]);
}
$itemValue
=
array_column
(
$formElement
[
'sql1'
],
'label'
);
// If there is no column 'label' (e.g.: SHOW tables)
if
(
count
(
$itemValue
)
===
0
)
{
$idx
=
count
(
$keys
)
==
1
?
0
:
1
;
$itemValue
=
array_column
(
$formElement
[
'sql1'
],
$keys
[
$idx
]);
}
}
elseif
(
isset
(
$formElement
[
'itemList'
]))
{
$arr
=
qfq\helper\KeyValueStringParser
::
parse
(
$formElement
[
'itemList'
],
':'
,
','
,
IF_VALUE_EMPTY_COPY_KEY
);
$itemValue
=
array_values
(
$arr
);
...
...
@@ -409,7 +424,7 @@ class FormBuildPlain {
}
elseif
(
$fieldType
===
'enum'
||
$fieldType
===
'set'
)
{
// already done at the beginning with '$this->getItemsForEnumOrSet($formElement['name'], $fieldType);'
}
else
{
throw
new
UserException
(
"Missing definition (nothing in 'sql1', 'parameter:itemValues, 'enum-' or 'set-definition'
)
"
,
ERROR_MISSING_ITEM_VALUES
);
throw
new
UserException
(
"Missing definition (
-
nothing
found
in 'sql1', 'parameter:itemValues
'
, 'enum-' or 'set-definition'"
,
ERROR_MISSING_ITEM_VALUES
);
}
if
(
count
(
$itemKey
)
===
0
)
{
...
...
@@ -525,7 +540,7 @@ class FormBuildPlain {
* @return string
*/
private
function
buildHidden
(
array
$formElement
,
$htmlFormElementId
,
$value
)
{
return
'<input type="hidden" name="'
.
$htmlFormElementId
.
'" value="'
.
addslash
es
(
$value
)
.
'">'
;
return
'<input type="hidden" name="'
.
$htmlFormElementId
.
'" value="'
.
htmlentiti
es
(
$value
)
.
'">'
;
}
/**
...
...
@@ -679,14 +694,16 @@ class FormBuildPlain {
* @throws UserException
*/
private
function
buildSubrecord
(
array
$formElement
,
$htmlFormElementId
,
$value
)
{
$html
=
''
;
if
(
!
is_array
(
$formElement
[
'sql1'
]))
{
throw
new
UserException
(
'Missing \'sql1\' Query'
,
ERROR_MISSING_SQL1
);
}
// construct column attributes
$control
=
$this
->
getSubrecordColumnControl
(
array_keys
(
$formElement
[
'sql1'
][
0
]));
$html
=
'<b>'
.
$formElement
[
'label'
]
.
'</b>'
;
$html
.
=
'<table>'
;
//
$html
.
= '<b>' . $formElement['label'] . '</b>';
$html
.
=
'<table
border="1"
>'
;
$html
.
=
'<tr><th>'
.
implode
(
'</th><th>'
,
$control
[
'title'
])
.
'</th></tr>'
;
foreach
(
$formElement
[
'sql1'
]
as
$row
)
{
$html
.
=
'<tr>'
;
...
...
@@ -703,7 +720,7 @@ class FormBuildPlain {
}
$html
.
=
'</table>'
;
return
"<p>
$html
</p>"
;
return
$html
;
}
/**
...
...
@@ -731,6 +748,8 @@ class FormBuildPlain {
}
$control
[
$attribute
][
$col
]
=
$value
;
}
// Limit title length
$control
[
'title'
][
$col
]
=
substr
(
$control
[
'title'
][
$col
],
0
,
$control
[
'width'
][
$col
]);
}
return
$control
;
}
...
...
qfq/Form.php
View file @
f5f3f9af
...
...
@@ -25,7 +25,7 @@ require_once(__DIR__ . '/../qfq/exceptions/CodeException.php');
require_once
(
__DIR__
.
'/../qfq/exceptions/DbException.php'
);
require_once
(
__DIR__
.
'/../qfq/Database.php'
);
require_once
(
__DIR__
.
'/../qfq/Evaluate.php'
);
require_once
(
__DIR__
.
'/../qfq/
Form
Build
Plain
.php'
);
require_once
(
__DIR__
.
'/../qfq/Build
Form
.php'
);
/*
* Form will be called
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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