[TYPO3-ect] Merging fhlibrary into tx_lib: pi_getSetupOrFFvalue
Franz Holzinger
franz at fholzinger.com
Tue Aug 29 22:54:04 CEST 2006
Hello Elmar,
> function getSetupOrFFvalue(&$pibase, $code, $codeExt, $defaultCode,
> $T3FlexForm_array, $fieldName='display_mode', $useFlexforms=1,
> $sheet='sDEF',$lang='lDEF',$value='vDEF') {
> $rc = '';
> if (empty($code)) {
> if ($useFlexforms) {
> // Converting flexform data into array:
> $rc = $pibase->pi_getFFvalue($T3FlexForm_array,
> $fieldName, $sheet, $lang, $value);
> } else {
> $rc = strtoupper(trim($pibase->cObj->stdWrap($code,
> $codeExt)));
> }
> if (empty($rc)) {
> $rc = strtoupper($defaultCode);
> }
> } else {
> $rc = $code;
> }
> return $rc;
> }
>
>
> My first idea is, that this function should be splitted, cause it
> servers different tasks.
The task of this function is to support a flexform as well as the CODE.
By this the admin can use the plugin with a flexform and use the CODE in
TypoScript Setup. Or he can choose in the Extension Manager that he
wants to stay only with CODE fields.
The result of this function is the list of codes separated by comma. And
it considers a default code if nothing has been chosen.
So this functions should not be splitted.
It gets called like this:
$this->pi_initPIflexForm();
$config['code'] =
$this->pi_getSetupOrFFvalue(
$this->conf['code'],
$this->conf['code.'],
$this->conf['defaultCode'],
$this->cObj->data['pi_flexform'],
'display_mode',
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][TT_PRODUCTS_EXTkey]['useFlexforms']
);
$this->codeArray=t3lib_div::trimExplode(',', $config['code'],1);
>
> A) With strtoupper (for CODE):
>
> t3lib_div::evalCodeFromSetup($defaultValue, $setupValue, $setupWrapper);
>
> Questions: What is the use of $setupWrapper for CODE? Where does the
> value from the tt_content CODE field go? Is it the $defaultValue?
>
The code is stored in the select_key field of tt_content.
The defaultValue comes from TypoScript settings of the extension. It
would be nice to have the same setup for each extension.
$this->conf['code.'] is needed when someone sets e.g.
code = TEXT
code.value = LIST
But shall this be supported?
>
> B) Merge Setup with Flexforms:
>
> t3lib_div::mergeSetupAndFlexForm(
> $defaultValue,
> $setupValue, $setupWrapper,
> $flexformArray, $fieldName,
> $sheetName='sDEF', $languageName='lDEF', $valueName='vDEF'
> );
>
> Remark: Don't put strtoupper into the function. For CODE use strtoupper
> in a second step upon the result.
The problem is that this code will be the same for each extension.
I want to put all the same necessary code into a function to have less
code in the extensions.
> Remark: From my philosophy a script should never hardcode default
> values. Instead it should deliver an understandable error message if the
> user has forgotten to set a value. Default values belong into typoscript
> or other configuration files not into the programm code.
The default CODE can be used to set the HELP code. This shall be used to
display a help page for the extension. The default code is read from
TypoScript, but if unset it shall always default to HELP for each extension.
- Franz
More information about the TYPO3-team-extension-coordination
mailing list