Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qfq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
typo3
qfq
Commits
54e8e69d
Commit
54e8e69d
authored
9 years ago
by
Carsten Rose
Browse files
Options
Downloads
Patches
Plain Diff
Form.php: started to implement FormPlain
FormBuildPlan.php: created
parent
124d7232
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
qfq/Form.php
+70
-6
70 additions, 6 deletions
qfq/Form.php
qfq/FormBuildPlain.php
+54
-0
54 additions, 0 deletions
qfq/FormBuildPlain.php
qfq/store/Store.php
+2
-1
2 additions, 1 deletion
qfq/store/Store.php
with
126 additions
and
7 deletions
qfq/Form.php
+
70
−
6
View file @
54e8e69d
...
...
@@ -11,6 +11,8 @@ namespace qfq;
use
qfq
;
use
qfq\exceptions\UserException
;
use
qfq\exceptions\CodeException
;
use
qfq\exceptions\DbException
;
use
qfq\helper
;
use
qfq\store
;
...
...
@@ -18,12 +20,22 @@ require_once(__DIR__ . '/../qfq/store/Store.php');
require_once
(
__DIR__
.
'/../qfq/Constants.php'
);
require_once
(
__DIR__
.
'/../qfq/helper/KeyValueStringParser.php'
);
require_once
(
__DIR__
.
'/../qfq/exceptions/UserException.php'
);
require_once
(
__DIR__
.
'/../qfq/exceptions/CodeException.php'
);
require_once
(
__DIR__
.
'/../qfq/exceptions/DbException.php'
);
require_once
(
__DIR__
.
'/../qfq/Database.php'
);
require_once
(
__DIR__
.
'/../qfq/FormBuildPlain.php'
);
class
Form
{
protected
$config
=
null
;
protected
$store
=
null
;
protected
$db
=
null
;
protected
$formDef
=
array
();
// copy of the loaded form
protected
$feDefAction
=
array
();
// copy of all formElement.class='action' of the loaded form
protected
$feDefNative
=
array
();
// copy of all formElement.class='native' of the loaded form
protected
$fe
=
array
();
// current processed formElement
// protected $formElements = null;
// protected $userLog = null;
...
...
@@ -45,27 +57,79 @@ class Form {
*/
$this
->
store
=
\qfq\store\Store
::
getInstance
(
$bodytext
);
$this
->
db
=
new
Database
();
}
/*
*
*/
public
function
process
()
{
$html
=
''
;
$build
=
null
;
// render:
// plain
// multimode: none
try
{
// Form action: load or save?
$mode
=
(
$this
->
store
->
getVar
(
CLIENT_POST_SIP
,
STORE_CLIENT
)
===
false
)
?
FORM_LOAD
:
FORM_SAVE
;
$this
->
loadFormDefinition
();
// TODO: replace switch() by Marschaller
// render: FormPlain | FormBootstrap
switch
(
$this
->
formDef
[
'render'
])
{
case
'Plain'
:
$build
=
new
FormBuildPlain
(
$this
->
formDef
,
$this
->
feDefAction
,
$this
->
feDefNative
);
break
;
case
'Bootstrap'
:
//TODO: implement bootstrap rendering: FormBuildBootstrap
break
;
default
:
throw
new
CodeException
(
"this statement should never be reached"
,
ERROR_CODE_SHOULD_NOT_HAPPEN
);
}
switch
(
$mode
)
{
case
FORM_LOAD
:
// $this->formActionBefore();
$html
.
=
$build
->
head
();
$html
.
=
$build
->
elements
();
$html
.
=
$build
->
tail
();
// $this->formActionAfter();
break
;
case
FORM_SAVE
:
break
;
default
:
throw
new
CodeException
(
"this statement should never be reached"
,
ERROR_CODE_SHOULD_NOT_HAPPEN
);
}
return
$html
;
}
catch
(
UserException
$e
)
{
echo
$e
->
formatMessage
();
}
catch
(
CodeException
$e
)
{
echo
$e
->
formatMessage
();
}
catch
(
DbException
$e
)
{
echo
$e
->
formatMessage
();
}
catch
(
\Exception
$e
)
{
echo
"Generic Exception: "
.
$e
->
getMessage
();
}
$this
->
loadFormDefinition
();
return
"Hello World from class Form"
;
}
/**
* @throws DbException
*/
private
function
loadFormDefinition
()
{
$formName
=
$this
->
getFormName
();
$this
->
formDef
=
$this
->
db
->
sql
(
"SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'"
,
ROW_EXACT_1
,
[
$formName
]);
echo
"Formname:
$formName
"
;
$sql
=
"SELECT * FROM FormElement AS fe WHERE fe.formId = ? AND fe.deleted='no' AND fe.class = ? AND fe.enabled='yes' ORDER BY fe.order, fe.id"
;
$this
->
feDefAction
=
$this
->
db
->
sql
(
$sql
,
ROW_REGULAR
,
[
$this
->
formDef
[
"id"
],
'action'
]);
$this
->
feDefNative
=
$this
->
db
->
sql
(
$sql
,
ROW_REGULAR
,
[
$this
->
formDef
[
"id"
],
'native'
]);
}
/**
...
...
This diff is collapsed.
Click to expand it.
qfq/FormBuildPlain.php
0 → 100644
+
54
−
0
View file @
54e8e69d
<?php
namespace
qfq
;
use
qfq
;
require_once
(
__DIR__
.
'/../qfq/store/Store.php'
);
require_once
(
__DIR__
.
'/../qfq/Constants.php'
);
require_once
(
__DIR__
.
'/../qfq/exceptions/DbException.php'
);
require_once
(
__DIR__
.
'/../qfq/Database.php'
);
/**
* Created by PhpStorm.
* User: crose
* Date: 1/6/16
* Time: 8:02 PM
*/
class
FormBuildPlain
{
protected
$formDef
=
array
();
// copy of the loaded form
protected
$feDefAction
=
array
();
// copy of all formElement.class='action' of the loaded form
protected
$feDefNative
=
array
();
// copy of all formElement.class='native' of the loaded form
protected
$store
=
null
;
public
function
__construct
(
array
$formDef
,
array
$feDefAction
,
array
$feDefNative
)
{
$this
->
formDef
=
$formDef
;
$this
->
feDefAction
=
$feDefAction
;
$this
->
feDefNative
=
$feDefNative
;
$this
->
store
=
\qfq\store\Store
::
getInstance
();
$this
->
db
=
new
Database
();
}
public
function
head
()
{
$html
=
'<h1>'
.
$this
->
formDef
[
'title'
]
.
'</h1><form action="?" method="post" target="_top" accept-charset="UTF-8">'
;
return
$html
;
}
public
function
tail
()
{
$html
=
'<input type="submit" value="Submit"></form>'
;
return
$html
;
}
public
function
elements
()
{
$html
=
''
;
foreach
(
$this
->
feDefNative
as
$fe
)
{
$html
.
=
$fe
[
'name'
]
.
'<br>'
;
}
return
$html
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
qfq/store/Store.php
+
2
−
1
View file @
54e8e69d
...
...
@@ -67,7 +67,8 @@ class Store {
// SYSTEM_FORM_ELEMENT_FIELD => SANATIZE_ALL,
SYSTEM_SQL_RAW
=>
SANATIZE_ALL
,
SYSTEM_SQL_FINAL
=>
SANATIZE_ALL
,
SYSTEM_SQL_COUNT
=>
SANATIZE_DIGIT
SYSTEM_SQL_COUNT
=>
SANATIZE_DIGIT
,
SYSTEM_SQL_PARAM_ARRAY
=>
SANATIZE_ALL
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment