00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00090 class t3lib_TCEforms_inline {
00091 var $fObj;
00092 var $backPath;
00093
00094 var $inlineStructure = array();
00095 var $inlineFirstPid;
00096 var $inlineNames = array();
00097 var $inlineData = array();
00098 var $inlineView = array();
00099 var $inlineCount = 0;
00100 var $inlineStyles = array();
00101
00102 var $prependNaming = 'data';
00103 var $prependFormFieldNames;
00104 var $prependCmdFieldNames;
00105
00106
00113 function init(&$tceForms) {
00114 $this->fObj =& $tceForms;
00115 $this->backPath =& $tceForms->backPath;
00116 $this->prependFormFieldNames =& $this->fObj->prependFormFieldNames;
00117 $this->prependCmdFieldNames =& $this->fObj->prependCmdFieldNames;
00118 $this->inlineStyles['margin-right'] = '5';
00119 }
00120
00121
00132 function getSingleField_typeInline($table,$field,$row,&$PA) {
00133
00134 if ($this->checkConfiguration($PA['fieldConf']['config']) === false) return false;
00135
00136
00137 $this->inlineCount++;
00138
00139
00140 $config = $PA['fieldConf']['config'];
00141 $foreign_table = $config['foreign_table'];
00142 t3lib_div::loadTCA($foreign_table);
00143
00144 $minitems = t3lib_div::intInRange($config['minitems'],0);
00145 $maxitems = t3lib_div::intInRange($config['maxitems'],0);
00146 if (!$maxitems) $maxitems=100000;
00147
00148
00149 $this->fObj->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
00150
00151
00152
00153 if (!isset($this->inlineFirstPid)) {
00154
00155
00156 if (t3lib_div::testInt($row['uid'])) {
00157 $inlineView = unserialize($GLOBALS['BE_USER']->uc['inlineView']);
00158 $this->inlineView = $inlineView[$table][$row['uid']];
00159 }
00160
00161 if ($row['pid'] < 0) {
00162 $prevRec = t3lib_BEfunc::getRecord($table, abs($row['pid']));
00163 $this->inlineFirstPid = $prevRec['pid'];
00164
00165 } else {
00166 $this->inlineFirstPid = $row['pid'];
00167 }
00168 }
00169
00170 $this->pushStructure($table, $row['uid'], $field, $config);
00171
00172 $nameForm = $this->inlineNames['form'];
00173
00174 $nameObject = $this->inlineNames['object'];
00175
00176 $recordList = $this->getRelatedRecords($table,$field,$row,$PA,$config);
00177
00178 $config['inline']['first'] = $recordList[0]['uid'];
00179 $config['inline']['last'] = $recordList[count($recordList)-1]['uid'];
00180
00181
00182 $top = $this->getStructureLevel(0);
00183 $this->inlineData['config'][$nameObject] = array('table' => $foreign_table);
00184 $this->inlineData['config'][$nameObject.'['.$foreign_table.']'] = array(
00185 'min' => $minitems,
00186 'max' => $maxitems,
00187 'sortable' => $config['appearance']['useSortable'],
00188 'top' => array(
00189 'table' => $top['table'],
00190 'uid' => $top['uid'],
00191 ),
00192 );
00193
00194
00195 if ($config['foreign_unique']) {
00196
00197 $selConfig = $this->getPossibleRecordsSelectorConfig($config, $config['foreign_unique']);
00198
00199 $uniqueIds = $this->getUniqueIds($recordList, $config, $selConfig['type']=='groupdb');
00200 $possibleRecords = $this->getPossibleRecords($table,$field,$row,$config,'foreign_unique');
00201 $uniqueMax = $config['appearance']['useCombination'] || $possibleRecords === false ? -1 : count($possibleRecords);
00202 $this->inlineData['unique'][$nameObject.'['.$foreign_table.']'] = array(
00203 'max' => $uniqueMax,
00204 'used' => $uniqueIds,
00205 'type' => $selConfig['type'],
00206 'table' => $config['foreign_table'],
00207 'elTable' => $selConfig['table'],
00208 'field' => $config['foreign_unique'],
00209 'selector' => $selConfig['selector'],
00210 'possible' => $this->getPossibleRecordsFlat($possibleRecords),
00211 );
00212 }
00213
00214
00215 if ($config['foreign_selector']) {
00216
00217 if (!$config['foreign_unique']) {
00218 $possibleRecords = $this->getPossibleRecords($table,$field,$row,$config);
00219 $uniqueIds = array();
00220 }
00221 $selectorBox = $this->renderPossibleRecordsSelector($possibleRecords,$config,$uniqueIds);
00222 $item .= $selectorBox;
00223 }
00224
00225
00226 $item .= '<div id="'.$nameObject.'">';
00227
00228
00229 if (count($recordList) >= $maxitems || ($uniqueMax > 0 && count($recordList) >= $uniqueMax)) {
00230 $config['inline']['inlineNewButtonStyle'] = 'display: none;';
00231 }
00232
00233 if (in_array($config['appearance']['newRecordLinkPosition'], array('both', 'top'))) {
00234 $item .= $this->getNewRecordLink($nameObject.'['.$foreign_table.']', $config);
00235 }
00236
00237 $item .= '<div id="'.$nameObject.'_records">';
00238 $relationList = array();
00239 if (count($recordList)) {
00240 foreach ($recordList as $rec) {
00241 $item .= $this->renderForeignRecord($row['uid'],$rec,$config);
00242 $relationList[] = $rec['uid'];
00243 }
00244 }
00245 $item .= '</div>';
00246
00247
00248 if (in_array($config['appearance']['newRecordLinkPosition'], array('both', 'bottom'))) {
00249 $item .= $this->getNewRecordLink($nameObject.'['.$foreign_table.']', $config);
00250 }
00251
00252
00253 if (count($relationList) > 1 && $config['appearance']['useSortable'])
00254 $this->addJavaScriptSortable($nameObject.'_records');
00255
00256 $item .= '<input type="hidden" name="'.$nameForm.'" value="'.implode(',', $relationList).'" class="inlineRecord" />';
00257
00258 $item .= '</div>';
00259
00260
00261 $this->popStructure();
00262
00263
00264 if (!$this->getStructureDepth()) {
00265 unset($this->inlineFirstPid);
00266 }
00267
00268 return $item;
00269 }
00270
00271
00272
00273
00274
00275
00276
00277
00278
00287 function renderForeignRecord($parentUid, $rec, $config = array()) {
00288 $foreign_table = $config['foreign_table'];
00289 $foreign_field = $config['foreign_field'];
00290 $foreign_selector = $config['foreign_selector'];
00291
00292
00293
00294 $this->inlineData['map'][$this->inlineNames['form']] = $this->inlineNames['object'];
00295
00296
00297 $isNewRecord = t3lib_div::testInt($rec['uid']) ? false : true;
00298
00299 if ($foreign_selector) {
00300 $rec[$foreign_selector] = $this->normalizeUid($rec[$foreign_selector]);
00301 }
00302
00303 $hasAccess = $this->checkAccess($isNewRecord?'new':'edit', $foreign_table, $rec['uid']);
00304
00305 if(!$hasAccess) return false;
00306
00307
00308 $nameObject = $this->inlineNames['object'];
00309 $appendFormFieldNames = '['.$foreign_table.']['.$rec['uid'].']';
00310 $formFieldNames = $nameObject.$appendFormFieldNames;
00311
00312 $header = $this->renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config);
00313 $combination = $this->renderCombinationTable($rec, $appendFormFieldNames, $config);
00314 $fields = $this->fObj->getMainFields($foreign_table,$rec);
00315 $fields = $this->wrapFormsSection($fields);
00316
00317 if ($isNewRecord) {
00318
00319 $isExpanded = is_array($config['appearance']) && $config['appearance']['collapseAll'] ? 1 : 0;
00320
00321 $top = $this->getStructureLevel(0);
00322 $ucFieldName = 'uc['.$top['table'].']['.$top['uid'].']'.$appendFormFieldNames;
00323
00324 $fields .= '<input type="hidden" name="'.$this->prependFormFieldNames.$appendFormFieldNames.'[pid]" value="'.$rec['pid'].'"/>';
00325 $fields .= '<input type="hidden" name="'.$ucFieldName.'" value="'.$isExpanded.'" />';
00326
00327 } else {
00328
00329 $isExpanded = $this->getExpandedCollapsedState($foreign_table, $rec['uid']);
00330
00331 $fields .= '<input type="hidden" name="'.$this->prependCmdFieldNames.$appendFormFieldNames.'[delete]" value="1" disabled="disabled" />';
00332 }
00333
00334
00335 if (!$isExpanded) $appearanceStyleFields = ' style="display: none;"';
00336
00337
00338 $out = '<div id="'.$formFieldNames.'_header">'.$header.'</div>';
00339 $out .= '<div id="'.$formFieldNames.'_fields"'.$appearanceStyleFields.'>'.$fields.$combination.'</div>';
00340
00341 $out = '<div id="'.$formFieldNames.'_div"'.($isNewRecord ? ' class="inlineIsNewRecord"' : '').'>' . $out . '</div>';
00342
00343 return $out;
00344 }
00345
00346
00357 function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config = array()) {
00358
00359 $formFieldNames = $this->inlineNames['object'].'['.$foreign_table.']['.$rec['uid'].']';
00360 $expandSingle = $config['appearance']['expandSingle'] ? 1 : 0;
00361 $onClick = "return inline.expandCollapseRecord('".htmlspecialchars($formFieldNames)."', $expandSingle)";
00362
00363
00364 $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
00365 $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? true : false;
00366 $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? true : false;
00367
00368
00369 if ($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc']) {
00370 $params = array(
00371 'table' => $foreign_table,
00372 'row' => $rec,
00373 'title' => '',
00374 'isOnSymmetricSide' => $isOnSymmetricSide
00375 );
00376 $null = null;
00377 t3lib_div::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
00378 $recTitle = $params['title'];
00379
00380 } elseif ($hasForeignLabel || $hasSymmetricLabel) {
00381 $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
00382 $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
00383
00384 if ($foreignConfig['type'] != 'groupdb') {
00385 $recTitle = t3lib_BEfunc::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, false);
00386
00387 } else {
00388
00389 $valueParts = t3lib_div::trimExplode('|', $rec[$titleCol]);
00390 $itemParts = t3lib_div::revExplode('_', $valueParts[0], 2);
00391 $recTemp = t3lib_befunc::getRecordWSOL($itemParts[0], $itemParts[1]);
00392 $recTitle = t3lib_BEfunc::getRecordTitle($itemParts[0], $recTemp, true);
00393 }
00394 $recTitle = t3lib_BEfunc::getRecordTitlePrep($recTitle);
00395 if (!strcmp(trim($recTitle),'')) {
00396 $recTitle = t3lib_BEfunc::getNoRecordTitle(true);
00397 }
00398
00399 } else {
00400 $recTitle = t3lib_BEfunc::getRecordTitle($foreign_table, $rec, true);
00401 }
00402
00403 $altText = t3lib_BEfunc::getRecordIconAltText($rec, $foreign_table);
00404 $iconImg =
00405 '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.t3lib_iconWorks::getIconImage(
00406 $foreign_table, $rec, $this->backPath,
00407 'title="'.htmlspecialchars($altText).'" class="absmiddle"'
00408 ).'</a>';
00409
00410 $label =
00411 '<a href="#" onclick="'.htmlspecialchars($onClick).'" style="display: block;">'.
00412 '<span id="'.$formFieldNames.'_label">'.$recTitle.'</span>'.
00413 '</a>';
00414
00415 $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config);
00416
00417
00418 $header =
00419 '<table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-right: '.$this->inlineStyles['margin-right'].'px;"'.
00420 ($this->fObj->borderStyle[2] ? ' background="'.htmlspecialchars($this->backPath.$this->fObj->borderStyle[2]).'"':'').
00421 ($this->fObj->borderStyle[3] ? ' class="'.htmlspecialchars($this->fObj->borderStyle[3]).'"':'').'>' .
00422 '<tr class="class-main12"><td width="18">'.$iconImg.'</td><td align="left"><b>'.$label.'</b></td><td align="right">'.$ctrl.'</td></tr></table>';
00423
00424 return $header;
00425 }
00426
00427
00438 function renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config = array()) {
00439
00440 $cells=array();
00441 $isNewItem = substr($rec['uid'], 0, 3) == 'NEW';
00442
00443 $tcaTableCtrl =& $GLOBALS['TCA'][$foreign_table]['ctrl'];
00444 $tcaTableCols =& $GLOBALS['TCA'][$foreign_table]['columns'];
00445
00446 $isPagesTable = $foreign_table == 'pages' ? true : false;
00447 $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
00448 $enableManualSorting = $tcaTableCtrl['sortby'] || $config['MM'] || (!$isOnSymmetricSide && $config['foreign_sortby']) || ($isOnSymmetricSide && $config['symmetric_sortby']) ? true : false;
00449
00450 $nameObjectFt = $this->inlineNames['object'].'['.$foreign_table.']';
00451 $nameObjectFtId = $nameObjectFt.'['.$rec['uid'].']';
00452
00453 $calcPerms = $GLOBALS['BE_USER']->calcPerms(
00454 t3lib_BEfunc::readPageAccess($rec['pid'], $GLOBALS['BE_USER']->getPagePermsClause(1))
00455 );
00456
00457
00458 if ($isPagesTable) {
00459 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$rec['uid']));
00460 }
00461
00462
00463 $permsEdit = ($isPagesTable && ($localCalcPerms&2)) || (!$isPagesTable && ($calcPerms&16));
00464
00465
00466 if (!$isNewItem)
00467 $cells[]='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$foreign_table.'\', \''.$rec['uid'].'\'); return false;').'">'.
00468 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:showInfo',1).'" alt="" />'.
00469 '</a>';
00470
00471
00472 if (!$tcaTableCtrl['readOnly']) {
00473
00474
00475 if ($enableManualSorting || $tcaTableCtrl['useColumnsForDefaultValues']) {
00476 if (
00477 (!$isPagesTable && ($calcPerms&16)) ||
00478 ($isPagesTable && ($calcPerms&8))
00479 ) {
00480 $onClick = "return inline.createNewRecord('".$nameObjectFt."','".$rec['uid']."')";
00481 if ($config['inline']['inlineNewButtonStyle']) {
00482 $style = ' style="'.$config['inline']['inlineNewButtonStyle'].'"';
00483 }
00484 $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'" class="inlineNewButton"'.$style.'>'.
00485 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($isPagesTable?'page':'el').'.gif','width="'.($isPagesTable?13:11).'" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:new'.($isPagesTable?'Page':'Record'),1).'" alt="" />'.
00486 '</a>';
00487 }
00488 }
00489
00490
00491 if ($permsEdit && $enableManualSorting && $config['appearance']['useSortable']) {
00492 $cells[] = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move.gif','width="16" height="16" hspace="2"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.move',1).'" alt="" style="cursor: move;" class="sortableHandle" />';
00493 }
00494
00495
00496 if ($permsEdit && $enableManualSorting) {
00497 $onClick = "return inline.changeSorting('".$nameObjectFtId."', '1')";
00498 $style = $config['inline']['first'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
00499 $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'" class="sortingUp" '.$style.'>'.
00500 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:moveUp',1).'" alt="" />'.
00501 '</a>';
00502
00503 $onClick = "return inline.changeSorting('".$nameObjectFtId."', '-1')";
00504 $style = $config['inline']['last'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
00505 $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'" class="sortingDown" '.$style.'>'.
00506 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:moveDown',1).'" alt="" />'.
00507 '</a>';
00508 }
00509
00510
00511 $hiddenField = $tcaTableCtrl['enablecolumns']['disabled'];
00512 if ($permsEdit && $hiddenField && $tcaTableCols[$hiddenField] && (!$tcaTableCols[$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$foreign_table.':'.$hiddenField))) {
00513 $onClick = "return inline.enableDisableRecord('".$nameObjectFtId."')";
00514 if ($rec[$hiddenField]) {
00515 $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
00516 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:unHide'.($isPagesTable?'Page':''),1).'" alt="" id="'.$nameObjectFtId.'_disabled" />'.
00517 '</a>';
00518 } else {
00519 $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
00520 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:hide'.($isPagesTable?'Page':''),1).'" alt="" id="'.$nameObjectFtId.'_disabled" />'.
00521 '</a>';
00522 }
00523 }
00524
00525
00526 if (
00527 ($isPagesTable && ($localCalcPerms&4)) || (!$isPagesTable && ($calcPerms&16))
00528 ) {
00529 $onClick = "inline.deleteRecord('".$nameObjectFtId."');";
00530 $cells[]='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')).')) { '.$onClick.' } return false;').'">'.
00531 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:delete',1).'" alt="" />'.
00532 '</a>';
00533 }
00534 }
00535
00536
00537 if ($lockInfo=t3lib_BEfunc::isRecordLocked($foreign_table,$rec['uid'])) {
00538 $cells[]='<a href="#" onclick="'.htmlspecialchars('alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;').'">'.
00539 '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
00540 '</a>';
00541 }
00542
00543
00544 return '
00545 <!-- CONTROL PANEL: '.$foreign_table.':'.$rec['uid'].' -->
00546 <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
00547 }
00548
00549
00560 function renderCombinationTable(&$rec, $appendFormFieldNames, $config = array()) {
00561 $foreign_table = $config['foreign_table'];
00562 $foreign_selector = $config['foreign_selector'];
00563
00564 if ($foreign_selector && $config['appearance']['useCombination']) {
00565 $comboConfig = $GLOBALS['TCA'][$foreign_table]['columns'][$foreign_selector]['config'];
00566 $comboRecord = array();
00567
00568
00569 if (t3lib_div::testInt($rec[$foreign_selector])) {
00570 $comboRecord = $this->getRecord(
00571 $this->inlineFirstPid,
00572 $comboConfig['foreign_table'],
00573 $rec[$foreign_selector]
00574 );
00575 $isNewRecord = false;
00576
00577 } else {
00578 $comboRecord = $this->getNewRecord(
00579 $this->inlineFirstPid,
00580 $comboConfig['foreign_table']
00581 );
00582 $isNewRecord = true;
00583 }
00584
00585
00586 $out = $this->fObj->getMainFields($comboConfig['foreign_table'], $comboRecord);
00587 $out = $this->wrapFormsSection($out, array(), array('class' => 'wrapperAttention'));
00588
00589
00590 if ($isNewRecord) {
00591 $comboFormFieldName = $this->prependFormFieldNames.'['.$comboConfig['foreign_table'].']['.$comboRecord['uid'].'][pid]';
00592 $out .= '<input type="hidden" name="'.$comboFormFieldName.'" value="'.$this->inlineFirstPid.'"/>';
00593 }
00594
00595
00596 if ($isNewRecord || $config['foreign_unique'] == $foreign_selector) {
00597 $parentFormFieldName = $this->prependFormFieldNames.$appendFormFieldNames.'['.$foreign_selector.']';
00598 $out .= '<input type="hidden" name="'.$parentFormFieldName.'" value="'.$comboRecord['uid'].'" />';
00599 }
00600 }
00601
00602 return $out;
00603 }
00604
00605
00615 function renderPossibleRecordsSelector($selItems, $conf, $uniqueIds=array()) {
00616 $foreign_table = $conf['foreign_table'];
00617 $foreign_selector = $conf['foreign_selector'];
00618
00619 $selConfig = $this->getPossibleRecordsSelectorConfig($conf, $foreign_selector);
00620 $config = $selConfig['PA']['fieldConf']['config'];
00621
00622 if ($selConfig['type'] == 'select') {
00623 $item = $this->renderPossibleRecordsSelectorTypeSelect($selItems, $conf, $selConfig['PA'], $uniqueIds);
00624 } elseif ($selConfig['type'] == 'groupdb') {
00625 $item = $this->renderPossibleRecordsSelectorTypeGroupDB($conf, $selConfig['PA']);
00626 }
00627
00628 return $item;
00629 }
00630
00631
00642 function renderPossibleRecordsSelectorTypeSelect($selItems, $conf, &$PA, $uniqueIds=array()) {
00643 $foreign_table = $conf['foreign_table'];
00644 $foreign_selector = $conf['foreign_selector'];
00645
00646 $PA = array();
00647 $PA['fieldConf'] = $GLOBALS['TCA'][$foreign_table]['columns'][$foreign_selector];
00648 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
00649 $PA['fieldTSConfig'] = $this->fObj->setTSconfig($foreign_table,array(),$foreign_selector);
00650 $config = $PA['fieldConf']['config'];
00651
00652 if(!$disabled) {
00653
00654 $opt = array();
00655 $styleAttrValue = '';
00656 foreach($selItems as $p) {
00657 if ($config['iconsInOptionTags']) {
00658 $styleAttrValue = $this->fObj->optionTagStyle($p[2]);
00659 }
00660 if (!in_array($p[1], $uniqueIds)) {
00661 $opt[]= '<option value="'.htmlspecialchars($p[1]).'"'.
00662 ' style="'.(in_array($p[1], $uniqueIds) ? '' : '').
00663 ($styleAttrValue ? ' style="'.htmlspecialchars($styleAttrValue) : '').'">'.
00664 htmlspecialchars($p[0]).'</option>';
00665 }
00666 }
00667
00668 // Put together the selector box:
00669 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="'.htmlspecialchars($config['itemListStyle']).'"' : ' style="'.$this->fObj->defaultMultipleSelectorStyle.'"';
00670 $size = intval($conf['size']);
00671 $size = $conf['autoSizeMax'] ? t3lib_div::intInRange(count($itemArray)+1,t3lib_div::intInRange($size,1),$conf['autoSizeMax']) : $size;
00672 $onChange = "return inline.importNewRecord('".$this->inlineNames['object']."[".$conf['foreign_table']."]')";
00673 $item = '
00674 <select id="'.$this->inlineNames['object'].'['.$conf['foreign_table'].']_selector"'.
00675 $this->fObj->insertDefStyle('select').
00676 ($size ? ' size="'.$size.'"' : '').
00677 ' onchange="'.htmlspecialchars($onChange).'"'.
00678 $PA['onFocus'].
00679 $selector_itemListStyle.
00680 ($conf['foreign_unique'] ? ' isunique="isunique"' : '').'>
00681 '.implode('
00682 ',$opt).'
00683 </select>';
00684
00685
00686
00687
00688
00689 $createNewRelationText = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createNewRelation',1);
00690 $item .=
00691 '<a href="#" onclick="'.htmlspecialchars($onChange).'" align="abstop">'.
00692 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' align="absmiddle" '.t3lib_BEfunc::titleAltAttrib($createNewRelationText).' /> '.$createNewRelationText.
00693 '</a>';
00694
00695 $item = '<div style="margin-bottom: 20px;">'.$item.'</div>';
00696 }
00697
00698 return $item;
00699 }
00700
00701
00710 function renderPossibleRecordsSelectorTypeGroupDB($conf, &$PA) {
00711 $foreign_table = $conf['foreign_table'];
00712
00713 $config = $PA['fieldConf']['config'];
00714 $allowed = $config['allowed'];
00715 $objectPrefix = $this->inlineNames['object'].'['.$foreign_table.']';
00716
00717 $createNewRelationText = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createNewRelation',1);
00718 $onClick = "setFormValueOpenBrowser('db','".('|||'.$allowed.'|'.$objectPrefix.'|inline.checkUniqueElement||inline.importElement')."'); return false;";
00719 $item =
00720 '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
00721 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert3.gif','width="14" height="14"').' align="absmiddle" '.t3lib_BEfunc::titleAltAttrib($createNewRelationText).' /> '.$createNewRelationText.
00722 '</a>';
00723
00724 return $item;
00725 }
00726
00727
00735 function getNewRecordLink($objectPrefix, $conf = array()) {
00736 if ($conf['inline']['inlineNewButtonStyle']) $style = ' style="'.$conf['inline']['inlineNewButtonStyle'].'"';
00737
00738 $onClick = "return inline.createNewRecord('$objectPrefix')";
00739 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createnew',1);
00740
00741 if ($conf['appearance']['newRecordLinkAddTitle'])
00742 $tableTitle .= ' '.$GLOBALS['LANG']->sL($GLOBALS['TCA'][$conf['foreign_table']]['ctrl']['title'],1);
00743
00744 $out = '
00745 <div class="typo3-newRecordLink">
00746 <a href="#" onClick="'.$onClick.'" class="inlineNewButton"'.$style.' title="'.$title.$tableTitle.'">'.
00747 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_el.gif','width="11" height="12"').' alt="'.$title.$tableTitle.'" />'.
00748 $title.t3lib_div::fixed_lgd_cs($tableTitle, $this->fObj->titleLen).
00749 '</a>
00750 </div>';
00751 return $out;
00752 }
00753
00754
00761 function addJavaScriptSortable($objectId) {
00762 $this->fObj->additionalJS_post[] = '
00763 inline.createDragAndDropSorting("'.$objectId.'");
00764 ';
00765 }
00766
00767
00768
00769
00770
00771
00772
00773
00774
00783 function createNewRecord($domObjectId, $foreignUid = 0) {
00784
00785 $this->parseStructureString($domObjectId, true);
00786
00787 $current = $this->inlineStructure['unstable'];
00788
00789 $parent = $this->getStructureLevel(-1);
00790
00791 $config = $parent['config'];
00792
00793
00794 if (!$foreignUid || !t3lib_div::testInt($foreignUid) || $config['foreign_selector']) {
00795 $record = $this->getNewRecord($this->inlineFirstPid, $current['table']);
00796
00797
00798 } else {
00799 $record = $this->getRecord($this->inlineFirstPid, $current['table'], $foreignUid);
00800 }
00801
00802
00803
00804
00805 if ($config['foreign_selector'] && $foreignUid) {
00806 $selConfig = $this->getPossibleRecordsSelectorConfig($config, $config['foreign_selector']);
00807
00808 $record[$config['foreign_selector']] = $selConfig['type'] != 'groupdb' ? '' : $selConfig['table'].'_';
00809 $record[$config['foreign_selector']] .= $foreignUid;
00810 }
00811
00812
00813 $objectPrefix = $this->inlineNames['object'].'['.$current['table'].']';
00814 $objectId = $objectPrefix.'['.$record['uid'].']';
00815
00816
00817 $item = $this->renderForeignRecord($parent['uid'], $record, $config);
00818 if($item === false) {
00819 $jsonArray = array(
00820 'data' => 'Access denied',
00821 'scriptCall' => array(
00822 "alert('Access denied');",
00823 )
00824 );
00825 return $this->getJSON($jsonArray);
00826 }
00827
00828
00829 $item = $GLOBALS['LANG']->csConvObj->utf8_encode($item, $GLOBALS['LANG']->charSet);
00830
00831 if (!$current['uid']) {
00832 $jsonArray = array(
00833 'data' => $item,
00834 'scriptCall' => array(
00835 "inline.domAddNewRecord('bottom','".$this->inlineNames['object']."_records','$objectPrefix',json.data);",
00836 "inline.memorizeAddRecord('$objectPrefix','".$record['uid']."',null,'$foreignUid');"
00837 )
00838 );
00839
00840
00841 } else {
00842 $jsonArray = array(
00843 'data' => $item,
00844 'scriptCall' => array(
00845 "inline.domAddNewRecord('after','".$domObjectId.'_div'."','$objectPrefix',json.data);",
00846 "inline.memorizeAddRecord('$objectPrefix','".$record['uid']."','".$current['uid']."','$foreignUid');"
00847 )
00848 );
00849 }
00850
00851
00852 $jsonArray['scriptCall'][] = $this->fObj->JSbottom($this->fObj->formName, true);
00853
00854 if ($config['appearance']['useSortable'])
00855 $jsonArray['scriptCall'][] = "inline.createDragAndDropSorting('".$this->inlineNames['object']."_records');";
00856
00857 if ($this->fObj->extJSCODE)
00858 $jsonArray['scriptCall'][] = $this->fObj->extJSCODE;
00859
00860 $jsonArray['scriptCall'][] = "Element.scrollTo('".$objectId."_div');";
00861
00862 $jsonArray['scriptCall'][] = "inline.fadeOutFadeIn('".$objectId."_div');";
00863
00864
00865 return $this->getJSON($jsonArray);
00866 }
00867
00868
00877 function setExpandedCollapsedState($domObjectId, $expand, $collapse) {
00878
00879 $this->parseStructureString($domObjectId, false);
00880
00881 $current = $this->inlineStructure['unstable'];
00882
00883 $top = $this->getStructureLevel(0);
00884
00885
00886 if (t3lib_div::testInt($top['uid'])) {
00887 $inlineView = unserialize($GLOBALS['BE_USER']->uc['inlineView']);
00888 $inlineViewCurrent =& $inlineView[$top['table']][$top['uid']];
00889
00890 $expandUids = t3lib_div::trimExplode(',', $expand);
00891 $collapseUids = t3lib_div::trimExplode(',', $collapse);
00892
00893
00894 foreach ($expandUids as $uid) {
00895 $inlineViewCurrent[$current['table']][] = $uid;
00896 }
00897
00898 foreach ($collapseUids as $uid) {
00899 $inlineViewCurrent[$current['table']] = $this->removeFromArray($uid, $inlineViewCurrent[$current['table']]);
00900 }
00901
00902
00903 if (is_array($inlineViewCurrent[$current['table']])) {
00904 $GLOBALS['BE_USER']->uc['inlineView'] = serialize($inlineView);
00905 $GLOBALS['BE_USER']->writeUC();
00906 }
00907 }
00908 }
00909
00910
00911
00912
00913
00914
00915
00916
00917
00928 function getRelatedRecords($table,$field,$row,&$PA,$config) {
00929 $records = array();
00930
00931
00932 $nMV_label = isset($PA['fieldTSConfig']['noMatchingValue_label']) ? $this->fObj->sL($PA['fieldTSConfig']['noMatchingValue_label']) : '[ '.$this->fObj->getLL('l_noMatchingValue').' ]';
00933
00934
00935 # $this->fObj->requiredElements[$PA['itemFormElName']] = array($minitems,$maxitems,'imgName'=>$table.'_'.$row['uid'].'_'.$field);
00936
00937
00938 $itemArray = t3lib_div::trimExplode(',',$PA['itemFormElValue'],1);
00939 foreach($itemArray as $tk => $tv) {
00940 $tvP = explode('|',$tv,2);
00941
00942 $records[] = $this->getRecord($row['pid'], $config['foreign_table'], $tvP[0]);
00943 }
00944
00945 return $records;
00946 }
00947
00948
00960 function getPossibleRecords($table,$field,$row,$conf,$checkForConfField='foreign_selector') {
00961
00962 $tcaTableCtrl = $GLOBALS['TCA'][$table]['ctrl'];
00963
00964 $foreign_table = $conf['foreign_table'];
00965 $foreign_check = $conf[$checkForConfField];
00966
00967 $foreignConfig = $this->getPossibleRecordsSelectorConfig($conf, $foreign_check);
00968 $PA = $foreignConfig['PA'];
00969 $config = $PA['fieldConf']['config'];
00970
00971 if ($foreignConfig['type'] == 'select') {
00972
00973 $selItems = $this->fObj->addSelectOptionsToItemArray($this->fObj->initItemArray($PA['fieldConf']),$PA['fieldConf'],$this->fObj->setTSconfig($table,$row),$field);
00974 if ($config['itemsProcFunc']) $selItems = $this->fObj->procItems($selItems,$PA['fieldTSConfig']['itemsProcFunc.'],$config,$table,$row,$field);
00975
00976
00977 $removeItems = t3lib_div::trimExplode(',',$PA['fieldTSConfig']['removeItems'],1);
00978 foreach($selItems as $tk => $p) {
00979
00980
00981 $languageDeny = $tcaTableCtrl['languageField'] && !strcmp($tcaTableCtrl['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
00982 $authModeDeny = $config['form_type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table,$field,$p[1],$config['authMode']);
00983 if (in_array($p[1],$removeItems) || $languageDeny || $authModeDeny) {
00984 unset($selItems[$tk]);
00985 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
00986 $selItems[$tk][0]=$this->fObj->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
00987 }
00988
00989
00990 if ($table.'.'.$field == 'pages.doktype') {
00991 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'],$p[1]))) {
00992 unset($selItems[$tk]);
00993 }
00994 }
00995 }
00996 } else {
00997 $selItems = false;
00998 }
00999
01000 return $selItems;
01001 }
01002
01011 function getUniqueIds($records, $conf=array(), $splitValue=false) {
01012 $uniqueIds = array();
01013
01014 if ($conf['foreign_unique'] && count($records)) {
01015 foreach ($records as $rec) {
01016 $value = $rec[$conf['foreign_unique']];
01017
01018 if ($splitValue) {
01019 $valueParts = t3lib_div::trimExplode('|', $value);
01020 $itemParts = explode('_', $valueParts[0]);
01021 $value = array(
01022 'uid' => array_pop($itemParts),
01023 'table' => implode('_', $itemParts)
01024 );
01025 }
01026 $uniqueIds[$rec['uid']] = $value;
01027 }
01028 }
01029
01030 return $uniqueIds;
01031 }
01032
01033
01044 function getRecord($pid, $table, $uid, $cmd='') {
01045 $trData = t3lib_div::makeInstance('t3lib_transferData');
01046 $trData->addRawData = TRUE;
01047 # $trData->defVals = $this->defVals;
01048 $trData->lockRecords=1;
01049 $trData->disableRTE = $GLOBALS['SOBE']->MOD_SETTINGS['disableRTE'];
01050
01051 $trData->fetchRecord($table, $uid, ($cmd === 'new' ? 'new' : ''));
01052 reset($trData->regTableItems_data);
01053 $rec = current($trData->regTableItems_data);
01054 $rec['uid'] = $cmd == 'new' ? uniqid('NEW') : $uid;
01055 if ($cmd=='new') $rec['pid'] = $pid;
01056
01057 return $rec;
01058 }
01059
01060
01068 function getNewRecord($pid, $table) {
01069 return $this->getRecord($pid, $table, '', 'new');
01070 }
01071
01072
01073
01074
01075
01076
01077
01078
01079
01090 function pushStructure($table, $uid, $field = '', $config = array()) {
01091 $this->inlineStructure['stable'][] = array(
01092 'table' => $table,
01093 'uid' => $uid,
01094 'field' => $field,
01095 'config' => $config,
01096 );
01097 $this->updateStructureNames();
01098 }
01099
01100
01106 function popStructure() {
01107 if (count($this->inlineStructure['stable'])) {
01108 $popItem = array_pop($this->inlineStructure['stable']);
01109 $this->updateStructureNames();
01110 }
01111 return $popItem;
01112 }
01113
01114
01123 function updateStructureNames() {
01124 $current = $this->getStructureLevel(-1);
01125
01126 if ($current !== false) {
01127 $lastItemName = $this->getStructureItemName($current);
01128 $this->inlineNames = array(
01129 'form' => $this->prependFormFieldNames.$lastItemName,
01130 'object' => $this->prependNaming.'['.$this->inlineFirstPid.']'.$this->getStructurePath(),
01131 );
01132
01133 } else {
01134 $this->inlineNames = array();
01135 }
01136 }
01137
01138
01145 function getStructureItemName($levelData) {
01146 if (is_array($levelData)) {
01147 $name = '['.$levelData['table'].']' .
01148 '['.$levelData['uid'].']' .
01149 (isset($levelData['field']) ? '['.$levelData['field'].']' : '');
01150 }
01151 return $name;
01152 }
01153
01154
01163 function getStructureLevel($level) {
01164 $inlineStructureCount = count($this->inlineStructure['stable']);
01165 if ($level < 0) $level = $inlineStructureCount+$level;
01166 if ($level >= 0 && $level < $inlineStructureCount)
01167 return $this->inlineStructure['stable'][$level];
01168 else
01169 return false;
01170 }
01171
01172
01180 function getStructurePath($structureDepth = -1) {
01181 $structureCount = count($this->inlineStructure['stable']);
01182 if ($structureDepth < 0 || $structureDepth > $structureCount) $structureDepth = $structureCount;
01183
01184 for ($i = 1; $i <= $structureDepth; $i++) {
01185 $current = $this->getStructureLevel(-$i);
01186 $string = $this->getStructureItemName($current).$string;
01187 }
01188
01189 return $string;
01190 }
01191
01192
01205 function parseStructureString($string, $loadConfig = false) {
01206 $unstable = array();
01207 $vector = array('table', 'uid', 'field');
01208 $pattern = '/^'.$this->prependNaming.'\[(.+?)\]\[(.+)\]$/';
01209 if (preg_match($pattern, $string, $match)) {
01210 $this->inlineFirstPid = $match[1];
01211 $parts = explode('][', $match[2]);
01212 $partsCnt = count($parts);
01213 for ($i = 0; $i < $partsCnt; $i++) {
01214 if ($i > 0 && $i % 3 == 0) {
01215
01216 if ($loadConfig) {
01217 t3lib_div::loadTCA($unstable['table']);
01218 $unstable['config'] = $GLOBALS['TCA'][$unstable['table']]['columns'][$unstable['field']]['config'];
01219
01220 $TSconfig = $this->fObj->setTSconfig(
01221 $unstable['table'],
01222 array('uid' => $unstable['uid'], 'pid' => $this->inlineFirstPid),
01223 $unstable['field']
01224 );
01225
01226 if (!$TSconfig['disabled']) {
01227 $unstable['config'] = $this->fObj->overrideFieldConf($unstable['config'], $TSconfig);
01228 }
01229 }
01230 $this->inlineStructure['stable'][] = $unstable;
01231 $unstable = array();
01232 }
01233 $unstable[$vector[$i % 3]] = $parts[$i];
01234 }
01235 $this->updateStructureNames();
01236 if (count($unstable)) $this->inlineStructure['unstable'] = $unstable;
01237 }
01238 }
01239
01240
01241
01242
01243
01244
01245
01246
01247
01254 function checkConfiguration(&$config) {
01255 $foreign_table = $config['foreign_table'];
01256
01257
01258 if (!$foreign_table || !is_array($GLOBALS['TCA'][$foreign_table])) {
01259 return false;
01260 }
01261
01262 if (!is_array($config['appearance'])) {
01263 $config['appearance'] = array();
01264 }
01265
01266 if ($config['foreign_selector'] && !$config['appearance']['useCombination']) {
01267 $config['appearance']['newRecordLinkPosition'] = 'none';
01268 } elseif (!in_array($config['appearance']['newRecordLinkPosition'], array('top', 'bottom', 'both', 'none'))) {
01269 $config['appearance']['newRecordLinkPosition'] = 'top';
01270 }
01271
01272 return true;
01273 }
01274
01275
01285 function checkAccess($cmd, $table, $theUid) {
01286
01287
01288 $hasAccess = 0;
01289 $deniedAccessReason = '';
01290
01291
01292 if ($cmd=='new') {
01293 $calcPRec = t3lib_BEfunc::getRecord('pages',$this->inlineFirstPid);
01294 if(!is_array($calcPRec)) {
01295 return false;
01296 }
01297 $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);
01298 if ($table=='pages') {
01299 $hasAccess = $CALC_PERMS&8 ? 1 : 0;
01300 } else {
01301 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
01302 }
01303 } else {
01304 $calcPRec = t3lib_BEfunc::getRecord($table,$theUid);
01305 t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
01306 if (is_array($calcPRec)) {
01307 if ($table=='pages') {
01308 $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);
01309 $hasAccess = $CALC_PERMS&2 ? 1 : 0;
01310 } else {
01311 $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));
01312 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
01313 }
01314
01315
01316 if ($hasAccess) {
01317 $hasAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($table, $calcPRec);
01318 }
01319 }
01320 }
01321
01322 if(!$GLOBALS['BE_USER']->check('tables_modify', $table)) {
01323 $hasAccess = 0;
01324 }
01325
01326 if(!$hasAccess) {
01327 $deniedAccessReason = $GLOBALS['BE_USER']->errorMsg;
01328 if($deniedAccessReason) {
01329 debug($deniedAccessReason);
01330 }
01331 }
01332
01333 return $hasAccess ? true : false;
01334 }
01335
01336
01345 function compareStructureConfiguration($compare) {
01346 $level = $this->getStructureLevel(-1);
01347 $result = $this->arrayCompareComplex($level, $compare);
01348
01349 return $result;
01350 }
01351
01352
01359 function normalizeUid($string) {
01360 $parts = explode('|', $string);
01361 return $parts[0];
01362 }
01363
01364
01373 function wrapFormsSection($section, $styleAttrs = array(), $tableAttrs = array()) {
01374 if (!$styleAttrs['margin-right']) $styleAttrs['margin-right'] = $this->inlineStyles['margin-right'].'px';
01375
01376 foreach ($styleAttrs as $key => $value) $style .= ($style?' ':'').$key.': '.htmlspecialchars($value).'; ';
01377 if ($style) $style = ' style="'.$style.'"';
01378
01379 if (!$tableAttrs['background'] && $this->fObj->borderStyle[2]) $tableAttrs['background'] = $this->backPath.$this->borderStyle[2];
01380 if (!$tableAttrs['cellspacing']) $tableAttrs['cellspacing'] = '0';
01381 if (!$tableAttrs['cellpadding']) $tableAttrs['cellpadding'] = '0';
01382 if (!$tableAttrs['border']) $tableAttrs['border'] = '0';
01383 if (!$tableAttrs['width']) $tableAttrs['width'] = '100%';
01384 if (!$tableAttrs['class'] && $this->borderStyle[3]) $tableAttrs['class'] = $this->borderStyle[3];
01385
01386 foreach ($tableAttrs as $key => $value) $table .= ($table?' ':'').$key.'="'.htmlspecialchars($value).'"';
01387
01388 $out = '<table '.$table.$style.'>'.$section.'</table>';
01389 return $out;
01390 }
01391
01392
01402 function isInlineChildAndLabelField($table, $field) {
01403 $level = $this->getStructureLevel(-1);
01404 if ($level['config']['foreign_label'])
01405 $label = $level['config']['foreign_label'];
01406 else
01407 $label = $GLOBALS['TCA'][$table]['ctrl']['label'];
01408 return $level['config']['foreign_table'] === $table && $label == $field ? true : false;
01409 }
01410
01411
01418 function getStructureDepth() {
01419 return count($this->inlineStructure['stable']);
01420 }
01421
01422
01455 function arrayCompareComplex($subjectArray, $searchArray, $type = '') {
01456 $localMatches = 0;
01457 $localEntries = 0;
01458
01459 if (is_array($searchArray) && count($searchArray)) {
01460
01461 if (!$type) {
01462 reset($searchArray);
01463 $type = key($searchArray);
01464 $searchArray = current($searchArray);
01465 }
01466
01467
01468 $type = strtoupper($type);
01469
01470
01471 foreach ($searchArray as $key => $value) {
01472 $localEntries++;
01473
01474
01475 if ($key == '%OR') {
01476 $localMatches += $this->arrayCompareComplex($subjectArray, $value, '%OR') ? 1 : 0;
01477
01478 } elseif ($key == '%AND') {
01479 $localMatches += $this->arrayCompareComplex($subjectArray, $value, '%AND') ? 1 : 0;
01480
01481 } elseif (is_array($value) && $this->isAssociativeArray($searchArray)) {
01482 $localMatches += $this->arrayCompareComplex($subjectArray[$key], $value, $type) ? 1 : 0;
01483
01484 } elseif (is_array($value)) {
01485 $localMatches += $this->arrayCompareComplex($subjectArray, $value, $type) ? 1 : 0;
01486
01487 } else {
01488 $localMatches += isset($subjectArray[$key]) && isset($value) && $subjectArray[$key] === $value ? 1 : 0;
01489 }
01490
01491
01492 if ($type == '%OR' && $localMatches > 0) return true;
01493
01494 if ($type == '%AND' && $localMatches == 0) return false;
01495 }
01496 }
01497
01498
01499 return $localEntries == $localMatches ? true : false;
01500 }
01501
01502
01509 function isAssociativeArray($object) {
01510 return is_array($object) && count($object) && (array_keys($object) !== range(0, sizeof($object) - 1))
01511 ? true
01512 : false;
01513 }
01514
01515
01524 function removeFromArray($needle, $haystack, $strict=null) {
01525 $pos = array_search($needle, $haystack, $strict);
01526 if ($pos !== false) unset($haystack[$pos]);
01527 return $haystack;
01528 }
01529
01530
01539 function getPossibleRecordsFlat($possibleRecords) {
01540 $flat = false;
01541 if (is_array($possibleRecords)) {
01542 $flat = array();
01543 foreach ($possibleRecords as $record) $flat[$record[1]] = $record[0];
01544 }
01545 return $flat;
01546 }
01547
01548
01555 function getPossibleRecordsSelectorConfig($conf, $field = '') {
01556 $foreign_table = $conf['foreign_table'];
01557 $foreign_selector = $conf['foreign_selector'];
01558
01559 $PA = false;
01560 $type = false;
01561 $table = false;
01562 $selector = false;
01563
01564 if ($field) {
01565 $PA = array();
01566 $PA['fieldConf'] = $GLOBALS['TCA'][$foreign_table]['columns'][$field];
01567 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
01568 $PA['fieldTSConfig'] = $this->fObj->setTSconfig($foreign_table,array(),$field);
01569 $config = $PA['fieldConf']['config'];
01570
01571 $type = $this->getPossibleRecordsSelectorType($config);
01572
01573 $table = $type == 'select' ? $config['foreign_table'] : $config['allowed'];
01574
01575 if ($foreign_selector && $foreign_selector == $field && $type) {
01576 $selector = $type;
01577 }
01578 }
01579
01580 return array(
01581 'PA' => $PA,
01582 'type' => $type,
01583 'table' => $table,
01584 'selector' => $selector,
01585 );
01586 }
01587
01588
01595 function getPossibleRecordsSelectorType($config) {
01596 $type = false;
01597 if ($config['type'] == 'select') {
01598 $type = 'select';
01599 } elseif ($config['type'] == 'group' && $config['internal_type'] == 'db') {
01600 $type = 'groupdb';
01601 }
01602 return $type;
01603 }
01604
01605
01616 function skipField($table, $field, $row, $config) {
01617 $skipThisField = false;
01618
01619 if ($this->getStructureDepth()) {
01620 $searchArray = array(
01621 '%OR' => array(
01622 'config' => array(
01623 0 => array(
01624 '%AND' => array(
01625 'foreign_table' => $table,
01626 '%OR' => array(
01627 '%AND' => array(
01628 'appearance' => array('useCombination' => 1),
01629 'foreign_selector' => $field,
01630 ),
01631 'MM' => $config['MM']
01632 ),
01633 ),
01634 ),
01635 1 => array(
01636 '%AND' => array(
01637 'foreign_table' => $config['foreign_table'],
01638 'foreign_selector' => $config['foreign_field'],
01639 ),
01640 ),
01641 ),
01642 ),
01643 );
01644
01645
01646 $level = $this->getStructureLevel(-1);
01647
01648
01649 if (t3lib_loadDBGroup::isOnSymmetricSide($level['uid'], $level['config'], $row)) {
01650 $searchArray['%OR']['config'][0]['%AND']['%OR']['symmetric_field'] = $field;
01651 $searchArray['%OR']['config'][0]['%AND']['%OR']['symmetric_sortby'] = $field;
01652
01653 } else {
01654 $searchArray['%OR']['config'][0]['%AND']['%OR']['foreign_field'] = $field;
01655 $searchArray['%OR']['config'][0]['%AND']['%OR']['foreign_sortby'] = $field;
01656 }
01657
01658 $skipThisField = $this->compareStructureConfiguration($searchArray, true);
01659 }
01660
01661 return $skipThisField;
01662 }
01663
01664
01672 function getJSON($jsonArray) {
01673 if (!$GLOBALS['JSON']) {
01674 require_once(PATH_typo3.'contrib/json.php');
01675 $GLOBALS['JSON'] = t3lib_div::makeInstance('Services_JSON');
01676 }
01677 return $GLOBALS['JSON']->encode($jsonArray);
01678 }
01679
01680
01688 function getExpandedCollapsedState($table, $uid) {
01689 if (is_array($this->inlineView) && is_array($this->inlineView[$table])) {
01690 if (in_array($uid, $this->inlineView[$table]) !== false) return true;
01691 }
01692 return false;
01693 }
01694
01695
01703 function updateInlineView(&$uc, &$tce) {
01704 if (is_array($uc) && $uc['inlineView']) {
01705 $inlineView = unserialize($GLOBALS['BE_USER']->uc['inlineView']);
01706
01707 foreach ($uc['inlineView'] as $topTable => $topRecords) {
01708 foreach ($topRecords as $topUid => $childElements) {
01709 foreach ($childElements as $childTable => $childRecords) {
01710 $uids = array_keys($tce->substNEWwithIDs_table, $childTable);
01711 if (count($uids)) {
01712 foreach ($childRecords as $childUid => $state) {
01713 if ($state && in_array($childUid, $uids)) {
01714 $newChildUid = $tce->substNEWwithIDs[$childUid];
01715 $inlineView[$topTable][$topUid][$childTable][$newChildUid] = 1;
01716 }
01717 }
01718 }
01719 }
01720 }
01721 }
01722
01723 $GLOBALS['BE_USER']->uc['inlineView'] = serialize($inlineView);
01724 $GLOBALS['BE_USER']->writeUC();
01725 }
01726 }
01727
01728
01734 function getLevelMargin() {
01735 $margin = $this->inlineStyles['margin-right'];
01736 return $margin;
01737 }
01738 }
01739 ?>