diff --git a/qfq/AbstractBuildForm.php b/qfq/AbstractBuildForm.php index 27ddf58058b5353a17d7fd5f6b3becc8fbb1f3f4..46f14ced43bee07cf73c44e547f49db06dbaac18 100644 --- a/qfq/AbstractBuildForm.php +++ b/qfq/AbstractBuildForm.php @@ -126,7 +126,85 @@ abstract class AbstractBuildForm { return $html; } - abstract public function head(); + public function head() { + $html = ''; + + $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true); + $html .= $this->getFormTag(); + + return $html; + } + + /** + * @param $item + * @param $value + * @param bool|false $flagOmitEmpty + * @return string + */ + public function wrapItem($item, $value, $flagOmitEmpty = false) { + if ($flagOmitEmpty && $value === "") + return ''; + return $this->wrap[$item][WRAP_SETUP_START] . $value . $this->wrap[$item][WRAP_SETUP_END]; + } + + /** + * Rreturns complete '<form ...>' + * + * @return string + */ + public function getFormTag() { + + $attribute = $this->getFormTagAtrributes(); + + return '<form ' . OnArray::toString($attribute, '=', ' ', "'") . '>'; + } + + /** + * Build an assoc array with standard form attributes. + * + * @return mixed + */ + public function getFormTagAtrributes() { + + $attribute['method'] = 'post'; + $attribute['action'] = $this->getActionUrl(); + $attribute['target'] = '_top'; + $attribute['accept-charset'] = 'UTF-8'; + $attribute['autocomplete'] = 'on'; + $attribute['enctype'] = $this->getEncType(); + + return $attribute; + } + + /** + * Builds the HTML 'form'-tag inlcuding all attributes and target. + * + * @return string + * @throws DbException + */ + public function getActionUrl() { + + $queryStringArray['s'] = $this->store->getVar(SIP_SIP, STORE_SIP); + + Support::appendTypo3ParameterToArray($queryStringArray); + + return basename($_SERVER['SCRIPT_NAME']) . "?" . Support::arrayToQueryString($queryStringArray); + } + + /** + * Determines the enctype. + * + * See: https://www.w3.org/wiki/HTML/Elements/form#HTML_Attributes + * + * @return string + * @throws DbException + */ + public function getEncType() { + + $result = $this->db->sql("SELECT id FROM FormElement AS fe WHERE fe.formId=? AND fe.type='upload' LIMIT 1", ROW_EMPTY_IS_OK, [$this->formSpec['id']], 'Look for Formelement.type="upload"'); + return (count($result) === 1) ? 'multipart/form-data' : 'application/x-www-form-urlencoded'; + + } abstract public function getProcessFilter(); @@ -197,18 +275,6 @@ abstract class AbstractBuildForm { abstract public function buildRowSubrecord($formElement, $elementHtml); - /** - * @param $item - * @param $value - * @param bool|false $flagOmitEmpty - * @return string - */ - public function wrapItem($item, $value, $flagOmitEmpty = false) { - if ($flagOmitEmpty && $value === "") - return ''; - return $this->wrap[$item][WRAP_SETUP_START] . $value . $this->wrap[$item][WRAP_SETUP_END]; - } - /** * @param $tag * @param $value @@ -1001,64 +1067,5 @@ abstract class AbstractBuildForm { return $html; } - /** - * Rreturns complete '<form ...>' - * - * @return string - */ - private function getFormTag() { - - $attribute = $this->getFormTagAtrributes(); - - return '<form ' . OnArray::toString($attribute, '=', ' ', "'") . '>'; - } - - /** - * Build an assoc array with standard form attributes. - * - * @return mixed - */ - public function getFormTagAtrributes() { - - $attribute['method'] = 'post'; - $attribute['action'] = $this->getActionUrl(); - $attribute['target'] = '_top'; - $attribute['accept-charset'] = 'UTF-8'; - $attribute['autocomplete'] = 'on'; - $attribute['enctype'] = $this->getEncType(); - - return $attribute; - } - - /** - * Builds the HTML 'form'-tag inlcuding all attributes and target. - * - * @return string - * @throws DbException - */ - public function getActionUrl() { - - $queryStringArray['s'] = $this->store->getVar(SIP_SIP, STORE_SIP); - - Support::appendTypo3ParameterToArray($queryStringArray); - - return basename($_SERVER['SCRIPT_NAME']) . "?" . Support::arrayToQueryString($queryStringArray); - } - - /** - * Determines the enctype. - * - * See: https://www.w3.org/wiki/HTML/Elements/form#HTML_Attributes - * - * @return string - * @throws DbException - */ - public function getEncType() { - - $result = $this->db->sql("SELECT id FROM FormElement AS fe WHERE fe.formId=? AND fe.type='upload' LIMIT 1", ROW_EMPTY_IS_OK, [$this->formSpec['id']], 'Look for Formelement.type="upload"'); - return (count($result) === 1) ? 'multipart/form-data' : 'application/x-www-form-urlencoded'; - - } - } \ No newline at end of file diff --git a/qfq/BuildFormBootstrap.php b/qfq/BuildFormBootstrap.php index a04d5f6ea41bf0a5d0bf3c196bb86b2d8465c7d3..75d5d76c463f6f13a1304c47660d0cbe7c19207c 100644 --- a/qfq/BuildFormBootstrap.php +++ b/qfq/BuildFormBootstrap.php @@ -186,7 +186,7 @@ BUTTONS; * * @return string */ - private function getFormTag() { + public function getFormTag() { $attribute = $this->getFormTagAtrributes(); diff --git a/qfq/BuildFormPlain.php b/qfq/BuildFormPlain.php index 8b114382fd307e6a89c23c4ec03159ea76d55b70..7538baedd3be5bb25d496c9e569c952b9fa23118 100644 --- a/qfq/BuildFormPlain.php +++ b/qfq/BuildFormPlain.php @@ -55,18 +55,6 @@ class BuildFormPlain extends AbstractBuildForm { return $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_SUBRECORD); } - /** - * @return string - */ - public function head() { - $html = ''; - - $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true); - $html .= '<form action="?" method="post" target="_top" accept-charset="UTF-8">'; - - return $html; - } - /** * @param $htmlFormElementId * @param $formElement diff --git a/qfq/BuildFormTable.php b/qfq/BuildFormTable.php index 8ec84dcd583e4e0252f90cb5f32b009f5708dc94..d4f1edd1a62777bd8033358e5e211384a424dc6d 100644 --- a/qfq/BuildFormTable.php +++ b/qfq/BuildFormTable.php @@ -64,7 +64,7 @@ class BuildFormTable extends AbstractBuildForm { $html = ''; $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true); - $html .= '<form action="?" method="post" target="_top" accept-charset="UTF-8">'; + $html .= $this->getFormTag(); $html .= '<table>'; return $html;