Commit 654a8011 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Constants: added error codes. Added FORM_FOWARD_MODE

QuickFormQuery: added saveForm() as new entrypoint. Will be directly called from save.php. Rearranged process().
parent 04d3eafe
......@@ -18,6 +18,10 @@ const FORM_PERMISSION_LOGGED_OUT = 'logged_out';
const FORM_PERMISSION_ALWAYS = 'always';
const FORM_PERMISSION_NEVER = 'never';
const FORM_FORWARD_MODE_NO = 'no';
const FORM_FORWARD_MODE_AUTO = 'auto';
const FORM_FORWARD_MODE_PAGE = 'page';
const SESSION_FE_USER_UID = 'fe_user_uid';
const RETURN_URL = 'return_url';
......@@ -98,7 +102,7 @@ const ERROR_UNKNOWN_MODE = 1032;
const ERROR_NOT_IMPLEMENTED = 1033;
const ERROR_RESERVED_KEY_NAME = 1034;
const ERROR_VALUE_HAS_NO_KEY = 1035;
const ERROR_UNKNOWN_FORWARD_MODE = 1036;
const ERROR_COLUMN_NOT_FOUND_IN_TABLE = 1037;
const ERROR_MISSING_HIDDEN_FIELD_IN_SIP = 1038;
const ERROR_KEY_EXIST_IN_STORE = 1039;
......@@ -183,6 +187,7 @@ const TYPO3_FE_USER = 'feUser';
const TYPO3_FE_USER_UID = 'feUserUid';
const TYPO3_FE_USER_GROUP = 'feUserGroup';
const TYPO3_TT_CONTENT_UID = 'ttcontentUid';
// System
const SYSTEM_DBUSER = 'DBUSER';
const SYSTEM_DBSERVER = 'DBSERVER';
......@@ -198,6 +203,7 @@ const SYSTEM_SQL_PARAM_ARRAY = 'sqlParamArray'; // Type: SANATIZE_ALL / Paramet
const SYSTEM_FORM = CLIENT_FORM; // '<formName> / <formId>'
const SYSTEM_FORM_ELEMENT = 'formElement'; // '<formElementName> / <formElementeId>'
const SYSTEM_FORM_ELEMENT_COLUMN = 'formElementColumn'; // '<columnname of current processed formElement>'
const SYSTEM_FORM_ELEMENT_MESSAGE = 'formElementMessage'; // '<columnname of current processed formElement>'
// die folgenden Elemente sind vermutlich nicht noetig, wenn Store Klassen gloable Vars benutzt.
//const SYSTEM_FORM_DEF = 'formDefinition'; // Type: SANATIZE_ALNUMX / AssocArray. Final form to process. Useful for error reporting.
......
......@@ -96,31 +96,43 @@ class QuickFormQuery {
*
* @param string $bodytext
*/
public function __construct($t3data = array(), $phpUnit = false) {
$this->t3data = $t3data;
public function __construct(array $t3data = array(), $phpUnit = false) {
mb_internal_encoding("UTF-8");
set_error_handler("\\qfq\\ErrorHandler::exception_error_handler");
if (!isset($t3data['bodytext']))
$t3data['bodytext'] = '';
if (!isset($t3data['uid']))
$t3data['uid'] = 0;
$this->t3data = $t3data;
$bodytext = $this->t3data['bodytext'];
$this->store = Store::getInstance($bodytext, $phpUnit);
$this->store->setVar(TYPO3_TT_CONTENT_UID, (isset($t3data['uid'])) ? $t3data['uid'] : 0, STORE_TYPO3);
$this->store->setVar(TYPO3_TT_CONTENT_UID, $t3data['uid'], STORE_TYPO3);
$this->db = new Database();
$this->eval = new Evaluate($this->store, $this->db);
}
/**
* @param $forwardPage
* @return mixed
*/
public function getForwardMode(&$forwardPage) {
$forwardPage = $this->formSpec['forwardPage'];
return $this->formSpec['forwardMode'];
}
/**
* @return string
*/
public function process() {
$html = '';
$build = null;
$master = null;
mb_internal_encoding("UTF-8");
$html .= $this->doForm();
$html = $this->doForm();
$html .= $this->doReport();
return $html;
......@@ -148,23 +160,22 @@ class QuickFormQuery {
}
$this->store->fillStoreTableDefaultColumnType($this->formSpec['tableName']);
switch ($this->formSpec['render']) {
case 'plain':
$build = new BuildFormPlain($this->formSpec, $this->feSpecAction, $this->feSpecNative);
break;
case 'table':
$build = new BuildFormTable($this->formSpec, $this->feSpecAction, $this->feSpecNative);
break;
case 'bootstrap':
$build = new BuildFormBootstrap($this->formSpec, $this->feSpecAction, $this->feSpecNative);
break;
default:
throw new CodeException("This statement should never be reached", ERROR_CODE_SHOULD_NOT_HAPPEN);
}
switch ($mode) {
case FORM_LOAD:
$html .= $build->process();
switch ($this->formSpec['render']) {
case 'plain':
$build = new BuildFormPlain($this->formSpec, $this->feSpecAction, $this->feSpecNative);
break;
case 'table':
$build = new BuildFormTable($this->formSpec, $this->feSpecAction, $this->feSpecNative);
break;
case 'bootstrap':
$build = new BuildFormBootstrap($this->formSpec, $this->feSpecAction, $this->feSpecNative);
break;
default:
throw new CodeException("This statement should never be reached", ERROR_CODE_SHOULD_NOT_HAPPEN);
}
$html = $build->process();
break;
case FORM_SAVE:
$save = new Save($this->formSpec, $this->feSpecAction, $this->feSpecNative);
......@@ -301,4 +312,14 @@ class QuickFormQuery {
}
/**
* @return string
*/
public function saveForm() {
$html = $this->doForm();
return $html;
}
}
\ No newline at end of file
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