Commit 564a5e60 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Form: getFormName() improved

parent d7c87bbb
......@@ -32,7 +32,7 @@
<?php
include("t3/form.php");
qfq\renderForm("\n# some notes\ndebug = 5\n form = mytestform");
qfq\renderForm("\n# some notes\ndebugLoad = 5\n debugSave = 0\n form = mytestform");
?>
......
......@@ -18,6 +18,7 @@ const ERROR_STORE_NOT_IMPLEMENTED = 1002;
const ERROR_UNKNOWN_STORE = 1003;
const ERROR_VALUES_ALREADY_CODPIED = 1004;
const ERROR_SETVARARRAY_NOT_IMPLEMENTED = 1005;
const ERROR_MISSING_FORM_NAME = 1006;
// Store Identifier
const STORE_FORM = "F"; // form, still not saved in database
......@@ -31,7 +32,7 @@ const STORE_ZERO = "0"; // value: 0, might helpfull if variable is empty but use
const USE_STORE_DEFAULT = "FSRD";
// Well known URL variables
// URL variables
const CLIENT_FORM = 'form';
const CLIENT_SIP = 's';
const CLIENT_RECORD_ID = 'r ';
......@@ -40,3 +41,8 @@ const CLIENT_KEY_SEM_ID_USER = 'keySemIdUser';
const CLIENT_PAGE_ID = 'pageId';
const CLIENT_PAGE_TYPE = 'pageType';
const CLIENT_PAGE_LANGUAGE = 'pageLanguage';
// T3 Bodytext Keywords
const T3_BODYTEXT_FORM = CLIENT_FORM;
const T3_BODYTEXT_DEBUG_LOAD = 'debugLoad';
const T3_BODYTEXT_DEBUG_SAVE = 'debugSave';
\ No newline at end of file
......@@ -10,11 +10,12 @@
namespace qfq;
use qfq;
use qfq\exceptions\UserException;
require_once(__DIR__ . '/../qfq/Store.php');
require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/helper/KeyValueStringParser.php');
require_once(__DIR__ . '/../qfq/exceptions/UserException.php');
class Form {
......@@ -45,21 +46,21 @@ class Form {
}
/*
*
*/
public function process($bodytext) {
$this->parseBodyText($bodytext);
$this->loadFormDefinition();
//
return "Hello World from class Form";
}
/*
*
*/
private function parseBodyText($bodytext) {
$keyValue = new KeyValueStringParser("=", "\n");
......@@ -71,21 +72,33 @@ class Form {
$formName = $this->getFormName();
echo "--$formName--";
echo "Formname: $formName";
}
/*
*
/**
* @return string
* @throws UserException
* @throws exceptions\CodeException
*/
private function getFormName() {
// by bodytext
// by session
// by GET['formular']
// Store: T3 Bodytext
$formName = $this->store->getVar(T3_BODYTEXT_FORM, STORE_T3_BODYTEXT);
if ($formName !== false)
return $formName;
// Store: SIP
// $fomName = $this->store->getVar(????_FORM, STORE_SIP);
// if($formName !== false)
// return $formName;
// Store: CLIENT
$formName = $this->store->getVar(CLIENT_FORM, STORE_CLIENT);
return $formName;
if ($formName !== false)
return $formName;
throw new UserException("Missing form name. Not found in T3_BODYTEXT / SIP / GET", ERROR_MISSING_FORM_NAME);
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ class FormTest extends PHPUnit_Framework_TestCase {
public function testProcess() {
$form = new qfq\Form();
$this->assertEquals("Hello World from class Form", $form->process(''));
$this->assertEquals("Hello World from class Form", $form->process('form=fakeformname'));
}
}
Markdown is supported
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