Commit 70a4f34d authored by Carsten  Rose's avatar Carsten Rose
Browse files

Preparation 'DynamicUpdate' fuer beliebige Felder.

FillStoreForm.php, HelperFormElement.php, BuildFormBootstap.php, BuildFormPlain.php, BuildFormTable.php, QuickFormQuery.php: Rename buildFormElementId() to buildFormElementname(). New Function buildFormElementId(). Rename variable $htmlFormElementId to $htmlFormElementName.
Support.php: tooltips now contain an html id.
Constants.php: Preparation for API 'element-update'.
parent 81e5a8dc
This diff is collapsed.
......@@ -384,11 +384,11 @@ EOF;
/**
* @param array $formElement
* @param $htmlFormElementId
* @param $htmlFormElementName
* @param $value
* @return mixed
*/
public function buildPill(array $formElement, $htmlFormElementId, $value, array &$json) {
public function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) {
$html = '';
// save parent processed FE's
$tmpStore = $this->feSpecNative;
......@@ -408,16 +408,16 @@ EOF;
/**
* @param array $formElement Complete FormElement, especially some FE_WRAP
* @param string $htmlElement Content to wrap.
* @param $htmlFormElementId
* @param $htmlFormElementName
* @return string Wrapped $htmlElement
* @throws \qfq\UserFormException
*/
public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementId) {
public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementName) {
$html = '';
$htmlLabel = '';
if ($formElement[FE_BS_LABEL_COLUMNS] > 0) {
$htmlLabel = $this->buildLabel($htmlFormElementId, $formElement[FE_LABEL]);
$htmlLabel = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL]);
}
$html .= $this->customWrap($formElement, $htmlLabel, FE_WRAP_LABEL, $formElement[FE_BS_LABEL_COLUMNS],
......
......@@ -65,12 +65,12 @@ class BuildFormPlain extends AbstractBuildForm {
}
/**
* @param $htmlFormElementId
* @param $htmlFormElementName
* @param $formElement
* @param $value
* @return string
*/
public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementId) {
public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementName) {
$html = '';
// Construct Marshaller Name
......
......@@ -90,12 +90,12 @@ class BuildFormTable extends AbstractBuildForm {
}
/**
* @param $htmlFormElementId
* @param $htmlFormElementName
* @param $formElement
* @param $value
* @return string
*/
public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementId) {
public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementName) {
$html = '';
// Construct Marshaller Name
......
......@@ -417,6 +417,7 @@ const API_REDIRECT_URL = 'redirect-url';
const API_FIELD_NAME = 'field-name';
const API_FIELD_MESSAGE = 'field-message';
const API_FORM_UPDATE = 'form-update';
const API_ELEMENT_UPDATE = 'element-update';
const API_JSON_HIDDEN = 'hidden';
const API_JSON_DISABLED = 'disabled';
......@@ -469,6 +470,7 @@ const GLYPH_ICON_CHECK = 'glyphicon-ok';
const GLYPH_ICON_CLOSE = 'glyphicon-remove';
// FORM
const F_ID = 'id';
const F_NAME = 'name';
const F_TITLE = 'title';
const F_TABLE_NAME = 'tableName';
......@@ -570,6 +572,8 @@ const FE_TEMPLATE_GROUP_NAME_PATTERN = '%d';
const FE_BUTTON_CLASS = 'buttonClass';
const RETYPE_FE_NAME_EXTENSION = 'RETYPE';
const FE_HTML_ID = 'htmlId'; // Will be dynamically computed during runtime.
// FormElement Types
const FE_TYPE_UPLOAD = 'upload';
const FE_TYPE_EXTRA = 'extra';
......
......@@ -185,8 +185,10 @@ class QuickFormQuery {
public function process() {
$html = '';
if ($this->store->getVar(TYPO3_DEBUG_SHOW_BODY_TEXT, STORE_TYPO3) === '1') {
$html .= Support::appendTooltip('', $this->t3data['bodytext']);
if ($this->store->getVar(TYPO3_DEBUG_SHOW_BODY_TEXT, STORE_TYPO3) === 'yes') {
// TODO: hier den Tootltip mit eienr ID versehen
// $htmlId = HelperFormElement::buildFormElementId($this->)
$html .= Support::doTooltip('', $this->t3data['bodytext']);
}
$html .= $this->doForm(FORM_LOAD);
......
......@@ -64,7 +64,7 @@ class HelperFormElement
}
/**
* Build the FE name: <field>:<record index)
* Build the FE name: <field>-<record index)
*
* @param string $field
* @param string $id
......@@ -72,7 +72,20 @@ class HelperFormElement
*/
public static function buildFormElementName($field, $id)
{
return ($field . ':' . $id);
return "$field-$id";
}
/**
* Build the FE id: <$formId>-<$formElementId>-<$formElementCopy>
*
* @param $formId
* @param $formElementId
* @param $recordId
* @param $formElementCopy
* @return string
*/
public static function buildFormElementId($formId, $formElementId, $recordId, $formElementCopy) {
return "$formId-$formElementId-$recordId-$formElementCopy";
}
/**
......@@ -82,8 +95,8 @@ class HelperFormElement
* @param string $index
* @return string
*/
public static function prependFormElementIdCheckBoxMulti($field, $index) {
return ('_' . $index . '_' . $field);
public static function prependFormElementNameCheckBoxMulti($field, $index) {
return '_' . $index . '_' . $field;
}
/**
......
......@@ -84,6 +84,20 @@ class Support {
return $tag . $value . $closing;
}
/**
* Wraps some $inner fragment with a CSS styled $tooltipText . CSS is configured in 'Resources/Public/qfq-jqw.css'.
*
* Based on: http://www.w3schools.com/howto/howto_css_tooltip.asp
*
* @param string $before
* @param string $tooltipText
* @return string
*/
public static function doTooltip($htmlId, $tooltipText) {
return "<img " . self::doAttribute('id', $htmlId) . " src='" . GFX_INFO . "' title=\"" . htmlentities($tooltipText) . "\">";
}
/**
* Format's an attribute: $type=$value. If $flagOmitEmpty==true && $value=='': return ''.
*
......@@ -161,23 +175,6 @@ class Support {
return $newStr;
}
/**
* Wraps some $inner fragment with a CSS styled $tooltipText . CSS is configured in 'Resources/Public/qfq-jqw.css'.
*
* Based on: http://www.w3schools.com/howto/howto_css_tooltip.asp
*
* @param string $before
* @param string $tooltipText
* @return string
*/
public static function appendTooltip($before, $tooltipText) {
// addslashes, htmlentities & htmlspecialchars
// str_replace('"', '&quot;', $tooltipText)
return $before . "<img src='" . GFX_INFO . "' title=\"" . htmlentities($tooltipText) . "\">";
}
/**
* Search for the parameter $needle in $haystack. The arguments has to be seperated by ','.
*
......
......@@ -246,7 +246,7 @@ class FillStoreForm {
*/
private function collectMultiValues($clientFieldName, array $clientValues) {
$checkboxKey = HelperFormElement::prependFormElementIdCheckBoxMulti($clientFieldName, 'h');
$checkboxKey = HelperFormElement::prependFormElementNameCheckBoxMulti($clientFieldName, 'h');
// For templateGroups: all expanded FormElements will be tried to collect - this fails for not submitted fields.
// Therefore skip not existing clientvalues.
......@@ -258,7 +258,7 @@ class FillStoreForm {
if (isset($clientValues[$checkboxKey])) {
$checkboxValue = $clientValues[$checkboxKey];
$pattern = '/' . HelperFormElement::prependFormElementIdCheckBoxMulti($clientFieldName, '\d+') . '/';
$pattern = '/' . HelperFormElement::prependFormElementNameCheckBoxMulti($clientFieldName, '\d+') . '/';
foreach ($clientValues as $key => $value) {
if (1 === preg_match($pattern, $key)) {
$checkboxValue .= ',' . $value;
......
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