Bug #17119 » 0005556_v5.patch
t3lib/jsfunc.inline.js (Arbeitskopie) | ||
---|---|---|
/*<![CDATA[*/
|
||
/***************************************************************
|
||
* Inline-Relational-Record Editing
|
||
* Inline-Relational-Record Editing
|
||
*
|
||
* $Id$
|
||
*
|
||
* Copyright notice
|
||
*
|
||
* (c) 2006-2007 Oliver Hader <oh@inpublica.de>
|
||
* All rights reserved
|
||
*
|
||
* Copyright notice
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* (c) 2006-2007 Oliver Hader <oh@inpublica.de>
|
||
* All rights reserved
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
var inline = {
|
||
prependFormFieldNames: 'data',
|
||
noTitleString: '[No title]',
|
||
lockedAjaxMethod: {},
|
||
data: {},
|
||
addToDataArray: function(object) { for (var i in object) { this.data[i] = $H(this.data[i]).merge(object[i]); } },
|
||
... | ... | |
},
|
||
createNewRecord: function(objectId,prevRecordUid) {
|
||
if (this.isBelowMax(objectId)) this.makeAjaxCall('createNewRecord', objectId+(prevRecordUid ? '['+prevRecordUid+']' : ''));
|
||
else alert('There are no more relations possible at this moment!');
|
||
if (this.isBelowMax(objectId)) {
|
||
if (prevRecordUid) {
|
||
objectId += '['+prevRecordUid+']';
|
||
}
|
||
this.makeAjaxCall('createNewRecord', [this.getNumberOfRTE(), objectId], true);
|
||
} else {
|
||
alert('There are no more relations possible at this moment!');
|
||
}
|
||
return false;
|
||
},
|
||
setExpandedCollapsedState: function(objectId, expand, collapse) {
|
||
this.makeAjaxCall('setExpandedCollapsedState', objectId, expand, collapse);
|
||
this.makeAjaxCall('setExpandedCollapsedState', [objectId, expand, collapse]);
|
||
},
|
||
makeAjaxCall: function() {
|
||
if (arguments.length > 1) {
|
||
var params = '';
|
||
for (var i=0; i<arguments.length; i++) params += '&ajax['+i+']='+arguments[i];
|
||
var url = 'alt_doc_ajax.php';
|
||
var options = {
|
||
makeAjaxCall: function(method, params, lock) {
|
||
var max, url='', urlParams='', options={};
|
||
if (method && params && params.length && this.lockAjaxMethod(method, lock)) {
|
||
url = 'alt_doc_ajax.php';
|
||
urlParams += '&ajax[0]='+method;
|
||
for (var i=0, max=params.length; i<max; i++) {
|
||
urlParams += '&ajax['+(i+1)+']='+params[i];
|
||
}
|
||
options = {
|
||
method: 'post',
|
||
parameters: params,
|
||
onSuccess: inline.processAjaxResponse,
|
||
onFailure: inline.showAjaxFailure
|
||
parameters: urlParams,
|
||
onSuccess: function(xhr) { inline.processAjaxResponse(method, xhr); },
|
||
onFailure: function(xhr) { inline.showAjaxFailure(method, xhr); }
|
||
};
|
||
new Ajax.Request(url, options);
|
||
}
|
||
},
|
||
processAjaxResponse: function(xhr) {
|
||
lockAjaxMethod: function(method, lock) {
|
||
if (!lock || !inline.lockedAjaxMethod[method]) {
|
||
inline.lockedAjaxMethod[method] = true;
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
},
|
||
unlockAjaxMethod: function(method) {
|
||
inline.lockedAjaxMethod[method] = false;
|
||
},
|
||
processAjaxResponse: function(method, xhr) {
|
||
inline.unlockAjaxMethod(method);
|
||
var json = eval('('+xhr.responseText+')');
|
||
for (var i in json.scriptCall) eval(json.scriptCall[i]);
|
||
},
|
||
showAjaxFailure: function(xhr) {
|
||
showAjaxFailure: function(method, xhr) {
|
||
inline.unlockAjaxMethod(method);
|
||
alert('Error: '+xhr.status+"\n"+xhr.statusText);
|
||
},
|
||
... | ... | |
if (!this.data.unique || !this.data.unique[objectId]) {
|
||
selector.options[selector.selectedIndex].selected = false;
|
||
}
|
||
this.makeAjaxCall('createNewRecord', objectId, selectedValue);
|
||
this.makeAjaxCall('createNewRecord', [this.getNumberOfRTE(), objectId, selectedValue], true);
|
||
}
|
||
return false;
|
||
},
|
||
... | ... | |
importElement: function(objectId, table, uid, type) {
|
||
window.setTimeout(
|
||
function() {
|
||
inline.makeAjaxCall('createNewRecord', objectId, uid);
|
||
inline.makeAjaxCall('createNewRecord', [this.getNumberOfRTE(), objectId, uid], true);
|
||
},
|
||
10
|
||
);
|
||
... | ... | |
// for select: only the uid is stored
|
||
if (unique['type'] == 'select') {
|
||
if (values.indexOf(uid) != -1) return true;
|
||
|
||
// for group/db: table and uid is stored in a assoc array
|
||
} else if (unique.type == 'groupdb') {
|
||
for (var i=values.length-1; i>=0; i--) {
|
||
... | ... | |
var checked = new Array();
|
||
var order = Sortable.sequence(element);
|
||
var records = formObj[0].value.split(',');
|
||
|
||
// check if ordered uid is really part of the records
|
||
// virtually deleted items might still be there but ordering shouldn't saved at all on them
|
||
for (var i=0; i<order.length; i++) {
|
||
... | ... | |
if (unique.type == 'select') {
|
||
if (fieldObj && fieldObj.length) {
|
||
delete(this.data.unique[objectPrefix].used[recordUid])
|
||
|
||
if (unique.selector == 'select') {
|
||
if (!isNaN(fieldObj[0].value)) {
|
||
var selector = $(objectPrefix+'_selector');
|
||
... | ... | |
return $(objectId+'_div') && $(objectId+'_div').hasClassName('inlineIsNewRecord')
|
||
? true
|
||
: false;
|
||
},
|
||
getNumberOfRTE: function() {
|
||
var number = 0;
|
||
if (typeof RTEarea != 'undefined' && RTEarea.length > 0) {
|
||
number = RTEarea.length-1;
|
||
}
|
||
return number;
|
||
}
|
||
}
|
||
t3lib/class.t3lib_tceforms_inline.php (Arbeitskopie) | ||
---|---|---|
/**
|
||
* Initialize environment for AJAX calls
|
||
*
|
||
* @param string $method: Name of the method to be called
|
||
* @param array $arguments: Arguments to be delivered to the method
|
||
* @return void
|
||
*/
|
||
function initForAJAX($method, &$arguments) {
|
||
// Set t3lib_TCEforms::$RTEcounter to the given value:
|
||
if ($method == 'createNewRecord') {
|
||
$this->fObj->RTEcounter = intval(array_shift($arguments));
|
||
}
|
||
}
|
||
/**
|
||
* Handle AJAX calls to show a new inline-record of the given table.
|
||
* Normally this method is never called from inside TYPO3. Always from outside by AJAX.
|
||
*
|
typo3/alt_doc_ajax.php (Arbeitskopie) | ||
---|---|---|
$method = array_shift($this->ajax);
|
||
// Security check
|
||
if(!in_array($method, array('createNewRecord', 'setExpandedCollapsedState'))) return false;
|
||
if (!in_array($method, array('createNewRecord', 'setExpandedCollapsedState'))) {
|
||
return false;
|
||
}
|
||
// Perform the requested action:
|
||
$this->tceforms->inline->initForAJAX($method, $this->ajax);
|
||
$this->content = call_user_func_array(
|
||
array(&$this->tceforms->inline, $method),
|
||
$this->ajax
|