[TYPO3-ect] Merging fhlibrary into tx_lib: pi_getSetupOrFFvalue
Elmar Hinz
elmar.DOT.hinz at team.MINUS.red.DOT.net
Tue Aug 29 13:59:40 CEST 2006
Hi,
Franz proposes to merge fh_library into tx_lib/tx_div. A good idea, but
lets look at some details first and give us your opinions:
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.
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?
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.
Questions: Is there a function to Merge Setup and Flexforms recursively?
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.
Regards
More information about the TYPO3-team-extension-coordination
mailing list