Project

General

Profile

Feature #17542 » ConditionalRequiredFields_v4_(trunk).patch

Administrator Admin, 2007-10-24 17:55

View differences:

/t3lib/class.t3lib_tceforms.php (working copy)
var $hiddenFieldListArr = array(); // This array of fields will be set as hidden-fields instead of rendered normally! For instance palette fields edited in the top frame are set as hidden fields since the main form has to submit the values. The top frame actually just sets the value in the main form!
var $requiredFields=array(); // Used to register input-field names, which are required. (Done during rendering of the fields). This information is then used later when the JavaScript is made.
var $requiredElements=array(); // Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
var $requiredNested=array(); // Used to determine where $requiredFields or $requiredElements are nested (in Tabs or IRRE)
var $requiredConditions = array(); // Used to register the condition for required-field
var $requiredTriggers = array(); // Used to register trigger-fields, which checks a required field on a change
var $renderDepth=0; // Keeps track of the rendering depth of nested records.
var $savedSchemes=array(); // Color scheme buffer.
var $dynNestedStack = array(); // holds the path an element is nested in (e.g. required for RTEhtmlarea)
......
foreach ($evalList as $func) {
switch ($func) {
case 'required':
$this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
$this->registerRequiredProperty('field', $table.'_'.$row['uid'].'_'.$field, $PA['itemFormElName']);
foreach ($evalList AS $evalListItem) {
}
break;
default:
if (substr($func, 0, 3) == 'tx_') {
......
);
$PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
}
}else if (substr($func, 0, 9) == 'condition' && in_array('required',$evalList)) {
$this->registerRequiredCondition($table,$row['uid'],$field,substr($func,9));
}
break;
}
......
// Wrap a wizard around the item?
$item= $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'].'_hr',$specConf);
if (!empty($item)) {
$this->registerPossibleTrigger($PA['itemFormElName'],'input');
}
return $item;
}
......
$item = $this->renderWizards(array($item,$altItem),$config['wizards'],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,$RTEwouldHaveBeenLoaded);
}
}
if (!empty($item)) {
$this->registerPossibleTrigger($PA['itemFormElName'],'text');
}
// Return field HTML:
return $item;
}
......
if (!$disabled) {
$item.= '<input type="hidden" name="'.$PA['itemFormElName'].'" value="'.htmlspecialchars($thisValue).'" />';
}
$this->registerPossibleTrigger($PA['itemFormElName'],'check',count($selItems));
return $item;
}
......
<label for="'.$rID.'">'.htmlspecialchars($p[0]).'</label>
<br />';
}
$this->registerPossibleTrigger($PA['itemFormElName'],'radio',count($selItems));
return $item;
}
......
$minitems = t3lib_div::intInRange($config['minitems'],0);
// Register the required number of elements:
$this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
$this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field));
// Get "removeItems":
$removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
......
}
$item.= '<input type="hidden" name="'.$PA['itemFormElName'].'_mul" value="'.($config['multiple']?1:0).'"'.$disabled.' />';
$this->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
$this->registerRequiredProperty('range', $PA['itemFormElName'], array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field));
$info='';
// "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. See http://typo3.org/documentation/document-library/doc_core_api/Wizards_Configuratio/.
......
$jsFile = array();
$elements = array();
$this->validateConditions();
// required:
foreach ($this->requiredFields as $itemImgName => $itemName) {
$match = array();
......
$field = $match[2];
$elements[$record][$field]['required'] = 1;
$elements[$record][$field]['requiredImg'] = $itemImgName;
if (isset($this->requiredConditions[$itemName])) {
$elements[$record][$field]['requiredCond'] = $this->requiredConditions[$itemName];
}
}
}
// range:
......
$elements[$record][$field]['rangeImg'] = $range['imgName'];
}
}
// trigger:
foreach ($this->requiredTriggers AS $itemName => $parameter) {
if (count($parameter['fields']) > 0) {
if (preg_match('/^(.+)\[((\w|\d|_)+)\]$/', $itemName, $match)) {
$record = $match[1];
$field = $match[2];
$elements[$record][$field]['trigger'] = $parameter['fields'];
$elements[$record][$field]['triggerType'] = $parameter['type'];
}
}
}
$this->TBE_EDITOR_fieldChanged_func='TBE_EDITOR.fieldChanged_fName(fName,formObj[fName+"_list"]);';
......
inline.addToDataArray('.t3lib_div::array2json($this->inline->inlineData).');
';
}
// Registered nested elements for tabs or inline levels:
if (count($this->requiredNested)) {
$out .= '
TBE_EDITOR.addNested('.$this->inline->getJSON($this->requiredNested).');
';
}
// elements which are required or have a range definition:
if (count($elements)) {
$out .= '
......
TBE_EDITOR.initRequired()
';
}
// $this->additionalJS_post:
// $this->additionalJS_subit:
if ($this->additionalJS_submit) {
$additionalJS_submit = implode('', $this->additionalJS_submit);
$additionalJS_submit = str_replace("\r", '', $additionalJS_submit);
......
}
return ($json ? t3lib_div::array2json($result) : $result);
}
/**
* Takes care of registering properties in requiredFields and requiredElements.
* The current hierarchy of IRRE and/or Tabs is stored. Thus, it is possible to determine,
* which required field/element was filled incorrectly and show it, even if the Tab or IRRE
* level is hidden.
*
* @param string $type: Type of requirement ('field' or 'range')
* @param string $name: The name of the form field
* @param mixed $value: For type 'field' string, for type 'range' array
* @return void
*/
function registerRequiredProperty($type, $name, $value) {
if ($type == 'field' && is_string($value)) {
$this->requiredFields[$name] = $value;
// requiredFields have name/value swapped! For backward compatibility we keep this:
$itemName = $value;
} elseif ($type == 'range' && is_array($value)) {
$this->requiredElements[$name] = $value;
$itemName = $name;
}
// Set the situation of nesting for the current field:
$this->registerNestedElement($itemName);
}
/**
* Set the current situation of nested tabs and inline levels for a given element.
*
* @param string $itemName: The element the nesting should be stored for
* @param boolean $setLevel: Set the reverse level lookup - default: true
* @return void
*/
function registerNestedElement($itemName, $setLevel=true) {
$dynNestedStack = $this->getDynNestedStack();
if (count($dynNestedStack) && preg_match('/^(.+\])\[(\w+)\]$/', $itemName, $match)) {
array_shift($match);
$this->requiredNested[$itemName] = array(
'parts' => $match,
'level' => $dynNestedStack,
);
}
}
/**
* Takes care of registering properties in requiredConditions.
*
* @param string $table: The name of the form field
* @param string $uid: The name of the form field
* @param string $field: The name of the form field
* @param string $condition: Condition string
* @return void
*/
function registerRequiredCondition($table,$uid,$field, $condition) {
$name = $this->prependFormFieldNames.'['.$table.']['.$uid.']['.$field.']';
$this->requiredConditions[$name]['cond'] = $condition;
$this->requiredConditions[$name]['table'] = $table;
$this->requiredConditions[$name]['uid'] = $uid;
$this->requiredConditions[$name]['field'] = $field;
}
/**
* Takes care of registering properties in requiredConditions.
*
* @param string $name: The name of the form field
* @param string $type: field type (input,text,check,etc.)
* @return void
*/
function registerPossibleTrigger($name,$type,$count = null) {
$this->requiredTriggers[$name] = array(
'type' => $type,
'fields' => array(),
);
if ($count !== null) {
$this->requiredTriggers[$name]['count'] = $count;
}
}
/**
* Validates requiredConditions.
* Checking wether a field exists etc.
*
* @return void
*/
function validateConditions() {
foreach ($this->requiredConditions AS $field => $condition) {
$this->validateCondition($condition['table'],$condition['uid'],$condition['field'],$condition['cond']);
}
}
/**
* Takes care of registering properties in requiredTriggers and requiredCondition.
*
* @param string $table: Tablename of the form field
* @param string $uid: Uid of the form field
* @param string $name: The name of the form field
* @param string $condition: Condition string
* @return void
*/
function validateCondition($table,$uid,$field, $condition) {
$i = 0;
$condParts = array();
//Getting all Trigger-Fields
$replace = "([a-z\_\-\!]+[0-9a-zA-Z\_\-\;]*)";
while(preg_match($replace, $condition,$res)) {
// trigger element with value
$trigger = $res[0];
list($trigger_name,$item_value) = explode(";",$trigger);
// replacing this field
$condition = preg_replace($replace , "~$i~", $condition,1);
// storing this field
$condParts[$i]['part'] = $trigger_name;
$condParts[$i]['cond'] = false;
// is field negative?
$item_bool = 1;
if (substr($trigger_name,0,1) == '!') {
$trigger_name = substr($trigger_name,1);
$item_bool = 0;
}
// does trigger exists/is allowed
$triggerElementName = $this->prependFormFieldNames.'['.$table.']['.$uid.']['.$trigger_name.']';
if (!isset($this->requiredTriggers[$triggerElementName])) {
continue;
}
switch ($this->requiredTriggers[$triggerElementName]['type']) {
case 'radio':
if (!(is_numeric($item_value) && 0 <= $item_value && $this->requiredTriggers[$triggerElementName]['count'] > $item_value)) {
$item_value = null;
}
if ($item_value === null) {
$item_value = 0;
}
settype($item_value,'integer'); // Needed for JavaScript
break;
case 'check':
if (!(is_numeric($item_value) && 0 <= $item_value && $this->requiredTriggers[$triggerElementName]['count'] > $item_value)) {
$item_value = null;
}
if ($item_value === null) {
$item_value = 0;
}
settype($item_value,'integer'); // Needed for JavaScript
break;
case 'input':
if (empty($item_value)) {
$item_value = null;
}
break;
}
if (!in_array($field,$this->requiredTriggers[$triggerElementName]['fields'])) {
$this->requiredTriggers[$triggerElementName]['fields'][] = $field;
}
$condParts[$i]['cond'] = array(
'type' => 'field',
'parameter' => array(
'name' => $trigger_name,
'type' => $this->requiredTriggers[$triggerElementName]['type'],
'bool' => $item_bool,
'value' => $item_value,
)
);
$i++;
}
// Getting Subpattern with ORs and ANDs
$replace = "|\[([0-9\~\&\|\;]+)\]|";
while(preg_match($replace, $condition,$res)) {
$res = str_replace('[','',str_replace(']','',$res[0]));
$condParts[$i]['part'] = $res; //check output
$ors = explode("|",$res);
$condParts[$i]['cond'] = array('type' => 'or', 'parameter' => array());
foreach ($ors AS $or) {
$ands = explode("&",$or);
$or = array('type' => 'and', 'parameter' => array());
foreach($ands AS $and) {
$and = $condParts[str_replace('~','',$and)]['cond'];
if ($and !== false) {
$or['parameter'][] = $and;
}
}
if (count($or['parameter']) == 1) {
$or = $or['parameter'][0];
}
if (count($or['parameter']) > 0) {
$condParts[$i]['cond']['parameter'][] = $or;
}
}
if (count($condParts[$i]['cond']['parameter']) == 1) {
$condParts[$i]['cond'] = $condParts[$i]['cond']['parameter'][0];
}
if (count($condParts[$i]['cond']['parameter']) == 0) {
$condParts[$i]['cond'] = false;
}
$condition = preg_replace($replace , "~$i~", $condition,1);
$i++;
}
$condition = $condParts[str_replace('~','',$condition)]['cond'];
if ($condition === false) {
$condition = array('type' => 'ignore');
}
$this->requiredConditions[$this->prependFormFieldNames.'['.$table.']['.$uid.']['.$field.']'] = $condition;
}
}
/t3lib/jsfunc.inline.js (working copy)
// Remove from TBE_EDITOR (required fields, required range, etc.):
if (TBE_EDITOR && TBE_EDITOR.removeElement) {
var removeStack = [];
inlineRecords = document.getElementsByClassName('inlineRecord', objectId+'_div');
// Remove nested child records from TBE_EDITOR required/range checks:
for (i=inlineRecords.length-1; i>=0; i--) {
......
childObjectId = this.data.map[inlineRecords[i].name];
childTable = this.data.config[childObjectId].table;
for (j=records.length-1; j>=0; j--) {
TBE_EDITOR.removeElement(this.prependFormFieldNames+'['+childTable+']['+records[j]+']');
removeStack.push(this.prependFormFieldNames+'['+childTable+']['+records[j]+']');
}
}
}
TBE_EDITOR.removeElement(this.prependFormFieldNames+shortName);
removeStack.push(this.prependFormFieldNames+shortName);
TBE_EDITOR.removeElementArray(removeStack);
}
var recordCount = this.memorizeRemoveRecord(
/typo3/jsfunc.tbe_editor.js (working copy)
'requiredImg': ''
}
}
},
*/
elements: {},
nested: {'field':{}, 'level':{}},
ignoreElements: [],
recentUpdatedElements: {},
actionChecks: { submit: [] },
formname: '',
formnameUENC: '',
loadTime: 0,
......
prependFormFieldNames: 'data',
prependFormFieldNamesUENC: 'data',
prependFormFieldNamesCnt: 0,
isPalettedoc: null,
doSaveFieldName: 0,
labels: {},
images: {
req: new Image(),
......
TBE_EDITOR.recentUpdatedElements = elements;
TBE_EDITOR.elements = $H(TBE_EDITOR.elements).merge(elements);
},
addNested: function(elements) {
var name, nested, levelMax, i, currentLevel, subLevel;
// Merge data structures:
if (elements) {
for (name in elements) {
nested = elements[name];
if (nested.level && nested.level.length) {
// If the first level is of type 'inline', it could be created by a AJAX request to IRRE.
// So, try to get the upper levels this dynamic level is nested in:
if (nested.level[0][0]=='inline') {
nested.level = inline.findContinuedNestedLevel(nested.level, nested.level[0][1]);
}
levelMax = nested.level.length-1;
for (i=0; i<=levelMax; i++) {
currentLevel = TBE_EDITOR.getNestedLevelIdent(nested.level[i]);
if (typeof TBE_EDITOR.nested.level[currentLevel] == 'undefined') {
TBE_EDITOR.nested.level[currentLevel] = { 'clean': true, 'item': {}, 'sub': {} };
}
// Add next sub level to the current level:
if (i<levelMax) {
subLevel = TBE_EDITOR.getNestedLevelIdent(nested.level[i+1]);
TBE_EDITOR.nested.level[currentLevel].sub[subLevel] = true;
// Add the current item to the last level in nesting:
} else {
TBE_EDITOR.nested.level[currentLevel].item[name] = nested.parts;
}
}
}
}
// Merge the nested fields:
TBE_EDITOR.nested.field = $H(TBE_EDITOR.nested.field).merge(elements);
}
},
removeElement: function(record) {
if (TBE_EDITOR.elements && TBE_EDITOR.elements[record]) {
// Inform envolved levels the this record is removed and the missing requirements are resolved:
$H(TBE_EDITOR.elements[record]).each(
function(pair) {
TBE_EDITOR.notifyNested(record+'['+pair.key+']', true);
}
);
delete(TBE_EDITOR.elements[record]);
}
},
removeElementArray: function(removeStack) {
if (removeStack && removeStack.length) {
TBE_EDITOR.ignoreElements = removeStack;
for (var i=removeStack.length; i>=0; i--) {
TBE_EDITOR.removeElement(removeStack[i]);
}
TBE_EDITOR.ignoreElements = [];
}
},
getElement: function(record, field, type) {
var result = null;
var element;
if (TBE_EDITOR.elements && TBE_EDITOR.elements[record] && TBE_EDITOR.elements[record][field]) {
element = TBE_EDITOR.elements[record][field];
if (type) {
......
result = element;
}
}
return result;
},
checkElements: function(type, recentUpdated, record, field) {
var result = 1;
var elementName, elementData, elementRecord, elementField;
var source = recentUpdated ? TBE_EDITOR.recentUpdatedElements : TBE_EDITOR.elements;
var source = (recentUpdated ? TBE_EDITOR.recentUpdatedElements : TBE_EDITOR.elements);
if (TBE_EDITOR.ignoreElements.length && TBE_EDITOR.ignoreElements.indexOf(record)!=-1) {
return result;
}
if (type) {
if (record && field) {
elementName = record+'['+field+']';
elementData = TBE_EDITOR.getElement(record, field, type);
if (elementData) {
if (!TBE_EDITOR.checkElementByType(type, elementName, elementData)) result = 0;
if (!TBE_EDITOR.checkElementByType(type, elementName, elementData, recentUpdated)) {
result = 0;
}
}
} else {
var elementFieldList, elRecIndex, elRecCnt, elFldIndex, elFldCnt;
var elementRecordList = $H(source).keys();
......
elementData = TBE_EDITOR.getElement(elementRecord, elementField, type);
if (elementData) {
elementName = elementRecord+'['+elementField+']';
if (!TBE_EDITOR.checkElementByType(type, elementName, elementData)) result = 0;
if (!TBE_EDITOR.checkElementByType(type, elementName, elementData, recentUpdated)) {
result = 0;
}
}
}
}
}
}
return result;
},
checkElementByType: function(type, elementName, elementData) {
checkElementByType: function(type, elementName, elementData, autoNotify) {
var result = 1;
if (type) {
if (type == 'required') {
if (!document[TBE_EDITOR.formname][elementName].value) {
result = 0;
TBE_EDITOR.setImage('req_'+elementData.requiredImg, TBE_EDITOR.images.req);
if (!elementData.requiredCond) {
result = 0;
if (autoNotify) {
TBE_EDITOR.setImage('req_'+elementData.requiredImg, TBE_EDITOR.images.req);
TBE_EDITOR.notifyNested(elementName, false);
}
}else {
if (TBE_EDITOR.checkCondition(TBE_EDITOR.getTheRecord(elementName),elementData.requiredCond)) {
result = 0;
if (autoNotify) {
TBE_EDITOR.setImage('req_'+elementData.requiredImg, TBE_EDITOR.images.req);
TBE_EDITOR.notifyNested(elementName, false);
}
}
}
}
} else if (type == 'range' && elementData.range) {
var formObj = document[TBE_EDITOR.formname][elementName+'_list'];
......
}
if (!TBE_EDITOR.checkRange(formObj, elementData.range[0], elementData.range[1])) {
result = 0;
TBE_EDITOR.setImage('req_'+elementData.rangeImg, TBE_EDITOR.images.req);
if (autoNotify) {
TBE_EDITOR.setImage('req_'+elementData.rangeImg, TBE_EDITOR.images.req);
TBE_EDITOR.notifyNested(elementName, false);
}
}
}
}
return result;
},
// Get the Recordname of a elementName
getTheRecord: function(elementName) {
var idx = 2+TBE_EDITOR.prependFormFieldNamesCnt;
var table = TBE_EDITOR.split(elementName, "[", idx);
var uid = TBE_EDITOR.split(elementName, "[", idx+1);
table = table.substr(0,table.length-1);
uid = uid.substr(0,uid.length-1);
return TBE_EDITOR.prependFormFieldNames+'['+table+']['+uid+']';
},
// Checks if the checkBool is equal to a Check
compareCheck: function(checkBool,check) {
if ((checkBool && check) || (!checkBool && !check)) {
return 1;
}
return 0;
},
// Checks the Input-Conditions
checkFieldCondition: function(theRecord,parameter) {
var checkBool = parameter['bool'];
var elementType = TBE_EDITOR.getElement(theRecord,parameter['name'],'trigger');
elementType = elementType['triggerType'];
var elementNameCond = theRecord+'['+parameter['name']+']';
if (elementType == 'check') {
// spliting the hidden field is slower
elementNameCond+= '_'+parameter['value'];
}
var element = document[TBE_EDITOR.formname][elementNameCond];
switch (elementType) {
// input
case 'input':
if (parameter['value']) {
return TBE_EDITOR.compareCheck(checkBool,(element.value == parameter['value']));
}
return TBE_EDITOR.compareCheck(checkBool,(element.value));
// radio
case 'radio':
if (element.length > 1) {
element = element[parameter['value']];
}
return TBE_EDITOR.compareCheck(checkBool,element.checked);
// checkbox
case 'check':
return TBE_EDITOR.compareCheck(checkBool,element.checked);
default:
return 0;
}
},
// Checks the Or-Condition
checkOrCondition: function(theRecord,conditions) {
for (var i = 0; i < conditions.size(); i++) {
if (TBE_EDITOR.checkCondition(theRecord,conditions[i])) {
return 1;
}
}
return 0;
},
// Checks the And-Condition
checkAndCondition: function(theRecord,conditions) {
for (var i = 0; i < conditions.size(); i++) {
if (!TBE_EDITOR.checkCondition(theRecord,conditions[i])) {
return 0;
}
}
return 1;
},
// Switch for the condition type: field,and,or
checkCondition: function(theRecord,condition) {
switch (condition['type']) {
// Checking a single Field
case 'field':
return TBE_EDITOR.checkFieldCondition(theRecord,condition['parameter']);
// Checking a and-Array
case 'and':
return TBE_EDITOR.checkAndCondition(theRecord,condition['parameter']);
// Checking a or-Array
case 'or':
return TBE_EDITOR.checkOrCondition(theRecord,condition['parameter']);
default:
return 0;
}
},
// Notify tabs and inline levels with nested requiredFields/requiredElements:
notifyNested: function(elementName, resolved) {
if (TBE_EDITOR.nested.field[elementName]) {
var i, nested, element, fieldLevels, fieldLevelIdent, nestedLevelType, nestedLevelName;
fieldLevels = TBE_EDITOR.nested.field[elementName].level;
TBE_EDITOR.nestedCache = {};
for (i=fieldLevels.length-1; i>=0; i--) {
nestedLevelType = fieldLevels[i][0];
nestedLevelName = fieldLevels[i][1];
fieldLevelIdent = TBE_EDITOR.getNestedLevelIdent(fieldLevels[i]);
// Construct the CSS id strings of the image/icon tags showing the notification:
if (nestedLevelType == 'tab') {
element = nestedLevelName+'-REQ';
} else if (nestedLevelType == 'inline') {
element = nestedLevelName+'_req';
} else {
continue;
}
// Set the icons:
if (resolved) {
if (TBE_EDITOR.checkNested(fieldLevelIdent)) {
TBE_EDITOR.setImage(element, TBE_EDITOR.images.clear);
} else {
break;
}
} else {
if (TBE_EDITOR.nested.level && TBE_EDITOR.nested.level[fieldLevelIdent]) {
TBE_EDITOR.nested.level[fieldLevelIdent].clean = false;
}
TBE_EDITOR.setImage(element, TBE_EDITOR.images.req);
}
}
}
},
// Check all the input fields on a given level of nesting - if only on is unfilled, the whole level is marked as required:
checkNested: function(nestedLevelIdent) {
var nestedLevel, isClean;
if (nestedLevelIdent && TBE_EDITOR.nested.level && TBE_EDITOR.nested.level[nestedLevelIdent]) {
nestedLevel = TBE_EDITOR.nested.level[nestedLevelIdent];
if (!nestedLevel.clean) {
if (typeof nestedLevel.item == 'object') {
$H(nestedLevel.item).each(
function(pair) {
if (isClean || typeof isClean == 'undefined') {
isClean = (
TBE_EDITOR.checkElements('required', false, pair.value[0], pair.value[1]) &&
TBE_EDITOR.checkElements('range', false, pair.value[0], pair.value[1])
);
}
}
);
if (typeof isClean != 'undefined' && !isClean) {
return false;
}
}
if (typeof nestedLevel.sub == 'object') {
$H(nestedLevel.sub).each(
function(pair) {
if (isClean || typeof isClean == 'undefined') {
isClean = TBE_EDITOR.checkNested(pair.key);
}
}
);
if (typeof isClean != 'undefined' && !isClean) {
return false;
}
}
// Store the result, that this level (the fields on this and the sub levels) are clean:
nestedLevel.clean = true;
}
}
return true;
},
getNestedLevelIdent: function(level) {
return level.join('::');
},
addActionChecks: function(type, checks) {
TBE_EDITOR.actionChecks[type].push(checks);
},
// Regular TCEforms JSbottom scripts:
loginRefreshed: function() {
var date = new Date();
......
fieldChanged: function(table,uid,field,el) {
var theField = TBE_EDITOR.prependFormFieldNames+'['+table+']['+uid+']['+field+']';
var theRecord = TBE_EDITOR.prependFormFieldNames+'['+table+']['+uid+']';
TBE_EDITOR.isChanged = 1;
if (el != '') {
TBE_EDITOR.isChanged = 1;
// Set change image:
var imgObjName = "cm_"+table+"_"+uid+"_"+field;
TBE_EDITOR.setImage(imgObjName,TBE_EDITOR.images.cm);
// Set change image:
var imgObjName = "cm_"+table+"_"+uid+"_"+field;
TBE_EDITOR.setImage(imgObjName,TBE_EDITOR.images.cm);
// Set change image
if (document[TBE_EDITOR.formname][theField] && document[TBE_EDITOR.formname][theField].type=="select-one" && document[TBE_EDITOR.formname][theField+"_selIconVal"]) {
var imgObjName = "selIcon_"+table+"_"+uid+"_"+field+"_";
TBE_EDITOR.setImage(imgObjName+document[TBE_EDITOR.formname][theField+"_selIconVal"].value,TBE_EDITOR.images.clear);
document[TBE_EDITOR.formname][theField+"_selIconVal"].value = document[TBE_EDITOR.formname][theField].selectedIndex;
TBE_EDITOR.setImage(imgObjName+document[TBE_EDITOR.formname][theField+"_selIconVal"].value,TBE_EDITOR.images.sel);
// Set change image
if (document[TBE_EDITOR.formname][theField] && document[TBE_EDITOR.formname][theField].type=="select-one" && document[TBE_EDITOR.formname][theField+"_selIconVal"]) {
var imgObjName = "selIcon_"+table+"_"+uid+"_"+field+"_";
TBE_EDITOR.setImage(imgObjName+document[TBE_EDITOR.formname][theField+"_selIconVal"].value,TBE_EDITOR.images.clear);
document[TBE_EDITOR.formname][theField+"_selIconVal"].value = document[TBE_EDITOR.formname][theField].selectedIndex;
TBE_EDITOR.setImage(imgObjName+document[TBE_EDITOR.formname][theField+"_selIconVal"].value,TBE_EDITOR.images.sel);
}
}
// Set required flag:
......
if (TBE_EDITOR.getElement(theRecord,field,'required') && document[TBE_EDITOR.formname][theField]) {
if (TBE_EDITOR.checkElements('required', false, theRecord, field)) {
TBE_EDITOR.setImage(imgReqObjName,TBE_EDITOR.images.clear);
TBE_EDITOR.notifyNested(theField, true);
} else {
TBE_EDITOR.setImage(imgReqObjName,TBE_EDITOR.images.req);
TBE_EDITOR.notifyNested(theField, false);
}
}
if (TBE_EDITOR.getElement(theRecord,field,'range') && document[TBE_EDITOR.formname][theField]) {
if (TBE_EDITOR.checkElements('range', false, theRecord, field)) {
TBE_EDITOR.setImage(imgReqObjName,TBE_EDITOR.images.clear);
TBE_EDITOR.notifyNested(theField, true);
} else {
TBE_EDITOR.setImage(imgReqObjName,TBE_EDITOR.images.req);
TBE_EDITOR.notifyNested(theField, false);
}
}
// Activate trigger
if (TBE_EDITOR.getElement(theRecord,field,'trigger') && document[TBE_EDITOR.formname][theField]) {
var condElement = TBE_EDITOR.getElement(theRecord,field,'trigger');
for (var i = 0; i < condElement['trigger'].size(); i++) {
// el part must be empty, otherwise the change-image is set
TBE_EDITOR.fieldChanged(table,uid,condElement['trigger'][i],'');
}
}
if (TBE_EDITOR.isPalettedoc) { TBE_EDITOR.setOriginalFormFieldValue(theField) };
},
setOriginalFormFieldValue: function(theField) {
......
if (!TBE_EDITOR.checkElements('required', false)) { OK = 0; }
// $reqRangeCheck
if (!TBE_EDITOR.checkElements('range', false)) { OK = 0; }
if (OK || sendAlert==-1) {
return true;
} else {
......
TBE_EDITOR.checkElements('range', true);
},
setImage: function(name,image) {
var object;
if (document[name]) {
object = document[name];
} else if (document.getElementById(name)) {
object = document.getElementById(name);
}
if (object) {
if (typeof image == 'object') {
document[name].src = image.src;
} else {
/typo3/template.php (working copy)
if ($isActive) {
$mouseOverOut = ' onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
$requiredIcon = '<img id="'.$id.'-'.$index.'-REQ" src="clear.gif" width="10" height="10" hspace="4" alt="" />';
if (!$foldout) {
// Create TAB cell:
$options[$tabRows][] = '
<td class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
$requiredIcon.
$def['icon'].
($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
$this->icons($def['stateIcon'],'margin-left: 10px;').
......
$divs[] = '
<div class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
$requiredIcon.
$def['icon'].
($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
($isActive ? '</a>' : '').
(3-3/5)