Bug #21424 ยป wizard_add.diff
wizard_add.php 2009-11-02 06:24:59.000000000 +0200 | ||
---|---|---|
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
|
||
* (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
... | ... | |
/**
|
||
* Wizard to add new records to a group/select TCEform formfield
|
||
*
|
||
* $Id: wizard_add.php 3439 2008-03-16 19:16:51Z flyguide $
|
||
* $Id$
|
||
* Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
|
||
*
|
||
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
|
||
... | ... | |
/**
|
||
* Script Class for adding new items to a group/select field. Performs proper redirection as needed.
|
||
*
|
||
... | ... | |
$this->table = $this->P['params']['table'];
|
||
// Get TSconfig for it.
|
||
$TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->table,is_array($origRow)?$origRow:array('pid'=>$this->P['pid']));
|
||
$TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->P['table'],is_array($origRow)?$origRow:array('pid'=>$this->P['pid']));
|
||
// Set [params][pid]
|
||
if (substr($this->P['params']['pid'],0,3)=='###' && substr($this->P['params']['pid'],-3)=='###') {
|
||
... | ... | |
// ... and if everything seems OK we will register some classes for inclusion and instruct the object to perform processing later.
|
||
if ($this->P['params']['setValue'] && $cmd=='edit' && $this->id && $this->P['table'] && $this->P['field'] && $this->P['uid']) {
|
||
if ($LiveRec=t3lib_BEfunc::getLiveVersionOfRecord($this->table, $this->id, 'uid')) { $this->id=$LiveRec['uid'];}
|
||
$this->include_once[]=PATH_t3lib.'class.t3lib_loaddbgroup.php';
|
||
$this->include_once[]=PATH_t3lib.'class.t3lib_transferdata.php';
|
||
$this->include_once[]=PATH_t3lib.'class.t3lib_tcemain.php';
|
||
... | ... | |
if (is_array($current)) {
|
||
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
|
||
$tce->stripslashes_values=0;
|
||
$data=array();
|
||
$data = array();
|
||
$addEl = $this->table.'_'.$this->id;
|
||
switch((string)$this->P['params']['setValue']) {
|
||
case 'set':
|
||
$data[$this->P['table']][$this->P['uid']][$this->P['field']] = $addEl;
|
||
break;
|
||
case 'prepend':
|
||
$data[$this->P['table']][$this->P['uid']][$this->P['field']] = $current[$this->P['field']].','.$addEl;
|
||
break;
|
||
case 'append':
|
||
$data[$this->P['table']][$this->P['uid']][$this->P['field']] = $addEl.','.$current[$this->P['field']];
|
||
break;
|
||
}
|
||
// Setting the new field data:
|
||
$data[$this->P['table']][$this->P['uid']][$this->P['field']] = implode(',',t3lib_div::trimExplode(',',$data[$this->P['table']][$this->P['uid']][$this->P['field']],1));
|
||
if ($this->P['flexFormPath']) { // If the field is a flexform field, work with the XML structure instead:
|
||
$currentFlexFormData = t3lib_div::xml2array($current[$this->P['field']]); // Current value of flexform path:
|
||
$flexToolObj = t3lib_div::makeInstance('t3lib_flexformtools');
|
||
$curValueOfFlexform = $flexToolObj->getArrayValueByPath($this->P['flexFormPath'], $currentFlexFormData);
|
||
$insertValue = '';
|
||
switch((string)$this->P['params']['setValue']) {
|
||
case 'set':
|
||
$insertValue = $addEl;
|
||
break;
|
||
case 'prepend':
|
||
$insertValue = $curValueOfFlexform.','.$addEl;
|
||
break;
|
||
case 'append':
|
||
$insertValue = $addEl.','.$curValueOfFlexform;
|
||
break;
|
||
}
|
||
$insertValue = implode(',',t3lib_div::trimExplode(',',$insertValue,1));
|
||
$data[$this->P['table']][$this->P['uid']][$this->P['field']] = array();
|
||
$flexToolObj->setArrayValueByPath($this->P['flexFormPath'],$data[$this->P['table']][$this->P['uid']][$this->P['field']],$insertValue);
|
||
} else {
|
||
switch((string)$this->P['params']['setValue']) {
|
||
case 'set':
|
||
$data[$this->P['table']][$this->P['uid']][$this->P['field']] = $addEl;
|
||
break;
|
||
case 'prepend':
|
||
$data[$this->P['table']][$this->P['uid']][$this->P['field']] = $current[$this->P['field']].','.$addEl;
|
||
break;
|
||
case 'append':
|
||
$data[$this->P['table']][$this->P['uid']][$this->P['field']] = $addEl.','.$current[$this->P['field']];
|
||
break;
|
||
}
|
||
$data[$this->P['table']][$this->P['uid']][$this->P['field']] = implode(',',t3lib_div::trimExplode(',',$data[$this->P['table']][$this->P['uid']][$this->P['field']],1));
|
||
}
|
||
// Submit the data:
|
||
$tce->start($data,array());
|
||
... | ... | |
}
|
||
}
|
||
// Include extension?
|
||
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_add.php']) {
|
||
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_add.php']);
|
||
}
|
||
// Make instance:
|
||
$SOBE = t3lib_div::makeInstance('SC_wizard_add');
|
||
$SOBE->init();
|
||
... | ... | |
foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
|
||
$SOBE->main();
|
||
?>
|
||
?>
|