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

Form.php: added Evaluate()

parent ab7eb626
...@@ -23,6 +23,7 @@ require_once(__DIR__ . '/../qfq/exceptions/UserException.php'); ...@@ -23,6 +23,7 @@ require_once(__DIR__ . '/../qfq/exceptions/UserException.php');
require_once(__DIR__ . '/../qfq/exceptions/CodeException.php'); require_once(__DIR__ . '/../qfq/exceptions/CodeException.php');
require_once(__DIR__ . '/../qfq/exceptions/DbException.php'); require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
require_once(__DIR__ . '/../qfq/Database.php'); require_once(__DIR__ . '/../qfq/Database.php');
require_once(__DIR__ . '/../qfq/Evaluate.php');
require_once(__DIR__ . '/../qfq/FormBuildPlain.php'); require_once(__DIR__ . '/../qfq/FormBuildPlain.php');
/* /*
...@@ -78,6 +79,8 @@ class Form { ...@@ -78,6 +79,8 @@ class Form {
$build = null; $build = null;
$master = null; $master = null;
mb_internal_encoding("UTF-8");
// render: // render:
// plain // plain
// multimode: none // multimode: none
...@@ -88,9 +91,9 @@ class Form { ...@@ -88,9 +91,9 @@ class Form {
$formName = $this->loadFormDefinition(); $formName = $this->loadFormDefinition();
$sipFound = $this->checkFormLoad(); $sipFound = $this->validateForm();
if (!$sipFound) { if (!$sipFound) {
$this->store->createFakeSipAfterFormLoad($formName); $this->store->createSipAfterFormLoad($formName);
} }
// TODO: replace switch() by Marschaller // TODO: replace switch() by Marschaller
...@@ -160,12 +163,12 @@ class Form { ...@@ -160,12 +163,12 @@ class Form {
private function getFormName() { private function getFormName() {
$formName = $this->store->getVar(T3_BODYTEXT_FORM, STORE_T3_BODYTEXT . STORE_SIP . STORE_CLIENT); $formName = $this->store->getVar(TYPO3_FORM, STORE_TYPO3 . STORE_SIP . STORE_CLIENT);
if ($formName !== false) if ($formName !== false)
return $formName; return $formName;
// TODO: phpunit tests all - missing formname always fires this exception // TODO: phpunit tests all - missing formname always fires this exception
throw new CodeException("Missing form name. Not found in T3_BODYTEXT / SIP / GET", ERROR_MISSING_FORM_NAME); throw new UserException("Missing form name. Not found in T3_BODYTEXT / SIP / GET", ERROR_MISSING_FORM_NAME);
} }
/** /**
...@@ -173,7 +176,7 @@ class Form { ...@@ -173,7 +176,7 @@ class Form {
* @throws CodeException * @throws CodeException
* @throws UserException * @throws UserException
*/ */
private function checkFormLoad() { private function validateForm() {
// Retrieve record_id either from SIP (prefered) or via URL // Retrieve record_id either from SIP (prefered) or via URL
$r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_CLIENT); $r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_CLIENT);
...@@ -209,6 +212,11 @@ class Form { ...@@ -209,6 +212,11 @@ class Form {
throw new CodeException("Unknown permission mode: '" . $mode . "'", ERROR_FORM_UNKNOWN_PERMISSION_MODE); throw new CodeException("Unknown permission mode: '" . $mode . "'", ERROR_FORM_UNKNOWN_PERMISSION_MODE);
} }
// Form Definition valid?
if( $this->formDef['multiMode'] !=='none' && $this->formDef['multiSql']==='') {
throw new UserException("MultiMode selected, but MultiSQL missing", ERROR_MULTI_SQL_MISSING);
}
return $sipFound; return $sipFound;
} }
......
...@@ -20,6 +20,7 @@ class FormBuildPlain { ...@@ -20,6 +20,7 @@ class FormBuildPlain {
protected $feDefAction = array(); // copy of all formElement.class='action' 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 $feDefNative = array(); // copy of all formElement.class='native' of the loaded form
protected $store = null; protected $store = null;
protected $evaluate = null;
public function __construct(array $formDef, array $feDefAction, array $feDefNative) { public function __construct(array $formDef, array $feDefAction, array $feDefNative) {
$this->formDef = $formDef; $this->formDef = $formDef;
...@@ -27,10 +28,13 @@ class FormBuildPlain { ...@@ -27,10 +28,13 @@ class FormBuildPlain {
$this->feDefNative = $feDefNative; $this->feDefNative = $feDefNative;
$this->store = \qfq\store\Store::getInstance(); $this->store = \qfq\store\Store::getInstance();
$this->db = new Database(); $this->db = new Database();
$this->evaluate = new Evaluate($this->store, $this->db);
} }
public function head() { public function head() {
$html = '<h1>' . $this->formDef['title'] . '</h1><form action="?" method="post" target="_top" accept-charset="UTF-8">'; $html = '<h1>' . $this->formDef['title'] . '</h1><form action="?" method="post" target="_top" accept-charset="UTF-8">';
return $html; return $html;
...@@ -45,6 +49,10 @@ class FormBuildPlain { ...@@ -45,6 +49,10 @@ class FormBuildPlain {
public function elements() { public function elements() {
$html = ''; $html = '';
if ($this->formDef['multiMode'] !== 'none') {
$masterRecords = $this->db->sql($this->formDef['multiMode']);
}
foreach ($this->feDefNative as $fe) { foreach ($this->feDefNative as $fe) {
$html .= $fe['name'] . '<br>'; $html .= $fe['name'] . '<br>';
} }
......
...@@ -18,7 +18,7 @@ class FormTest extends PHPUnit_Framework_TestCase { ...@@ -18,7 +18,7 @@ class FormTest extends PHPUnit_Framework_TestCase {
public function testProcess() { public function testProcess() {
$form = new qfq\Form("\n; some comment\n".T3_BODYTEXT_FORM."=testformnameDoNotChange\n".T3_BODYTEXT_DEBUG_SAVE."=6\n".T3_BODYTEXT_DEBUG_LOAD."=7\n"); $form = new qfq\Form("\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n" . TYPO3_DEBUG_SAVE . "=6\n" . TYPO3_DEBUG_LOAD . "=7\n");
$this->assertEquals("", $form->process()); $this->assertEquals("", $form->process());
} }
......
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