-element) */ function dbFileCon($formObj = 'document.forms[0]') { // @TODO: Export this to an own file, it is more static than dynamic JavaScript -- olly $str = ' // *************** // Used to connect the db/file browser with this document and the formfields on it! // *************** var browserWin=""; function setFormValueOpenBrowser(mode,params) { // var url = "' . $this->backPath . 'browser.php?mode="+mode+"&bparams="+params; browserWin = window.open(url,"Typo3WinBrowser","height=650,width="+(mode=="db"?650:600)+",status=0,menubar=0,resizable=1,scrollbars=1"); browserWin.focus(); } function setFormValueFromBrowseWin(fName,value,label,title,exclusiveValues) { var formObj = setFormValue_getFObj(fName), fObj, isMultiple = false, isList = false, len; if (formObj && value !== "--div--") { // Check if the form object has a "_list" element or not // The "_list" element exists for multiple selection select types if (formObj[fName + "_list"]) { fObj = (formObj[fName + "_list"][0] && typeof formObj[fName + "_list"][0] == "object" && formObj[fName + "_list"][0].nodeName != "OPTION") ? formObj[fName + "_list"][0] : formObj[fName + "_list"]; isMultiple = fObj.multiple && fObj.getAttribute("size") != "1"; isList = true; } else { fObj = formObj[fName]; } // clear field before adding value, if configured so (maxitems==1) if (typeof TBE_EDITOR.clearBeforeSettingFormValueFromBrowseWin[fName] != "undefined") { clearSettings = TBE_EDITOR.clearBeforeSettingFormValueFromBrowseWin[fName]; setFormValueManipulate(fName, "Remove"); // Clear the upload field var filesContainer = document.getElementById(clearSettings.itemFormElID_file); if(filesContainer) { filesContainer.innerHTML = filesContainer.innerHTML; } // update len after removing value len = fObj.length; } if (isMultiple || isList) { if (!isMultiple) { // If multiple values are not allowed, clear anything that is in the control already fObj.options.length = 0; fObj.length = 0; // Note: this is dangerous! "length" on the object is a reserved JS attribute! } len = fObj.length; // Clear elements if exclusive values are found if (exclusiveValues) { var m = new RegExp("(^|,)" + value + "($|,)"); if (exclusiveValues.match(m)) { // the new value is exclusive for (a = len - 1; a >= 0; a--) { fObj[a] = null; // This is dangerous because it works on the object\'s numeric properties directly instead of using a custom attribute! } len = 0; } else if (len == 1) { m = new RegExp("(^|,)" + fObj.options[0].value + "($|,)"); if (exclusiveValues.match(m)) { // the old value is exclusive fObj[0] = null; len = 0; } } } // Inserting element var setOK = true; if (!formObj[fName + "_mul"] || formObj[fName + "_mul"].value == 0) { for (a = 0; a < len; a++) { if (fObj.options[a].value == value) { setOK = false; } } } if (setOK) { fObj.length++; fObj.options[len].value = value; fObj.options[len].text = unescape(label); fObj.options[len].title = title; // Traversing list and set the hidden-field setHiddenFromList(fObj,formObj[fName]); ' . $this->TBE_EDITOR_fieldChanged_func . ' } } else { // The incoming value consists of the table name, an underscore and the uid // For a single selection field we need only the uid, so we extract it var uidValue = value; var pattern = /_(\d+)$/; var result = value.match(pattern); if (result != null) { uidValue = result[1]; } // Change the selected value fObj.value = uidValue; } } } function setHiddenFromList(fObjSel,fObjHid) { // l=fObjSel.length; fObjHid.value=""; for (a=0;a 1) || type=="Top" || type=="Bottom") { if (type=="Top") { for (a=0;a 0) { for (aa=0;aa 0) { for (aa=0;aa=0;a--) { if (fObjSel.options[a].selected!=1) { // Add non-selected element: localArray_V[c]=fObjSel.options[a].value; localArray_L[c]=fObjSel.options[a].text; localArray_S[c]=0; localArray_T[c] = fObjSel.options[a].title; c--; // Transfer any accumulated and reset: if (tA.length > 0) { for (aa=0;aa 0) { for (aa=0;aaTBE_EDITOR_fieldChanged_func . ' } } function setFormValue_getFObj(fName) { // var formObj = ' . $formObj . '; var listobj = (formObj[fName + "_list"][0] && typeof formObj[fName + "_list"][0] == "object" && formObj[fName + "_list"][0].nodeName != "OPTION") ? formObj[fName + "_list"][0] : formObj[fName + "_list"]; if (formObj) { // Take the form object if it is either of type select-one or of type-multiple and it has a "_list" element if (formObj[fName] && ((formObj[fName].type == "select-one") || (listobj.type && listobj.type.match(/select-(one|multiple)/) ) )) { return formObj; } else { alert("Formfields missing:\n fName: " + formObj[fName] + "\n fName_list:" + listobj + "\n type:" + listobj.type + "\n fName:" + fName); } } return ""; } // END: dbFileCon parts. '; return $str; } } ?>