/** * Get a selector as used for the select type, to select from all available * records and to create a relation to the embedding record (e.g. like MM). * * @param array $selItems: Array of all possible records * @param array $conf: TCA configuration of the parent(!) field * @param array $PA: An array with additional configuration options * @param array $uniqueIds: The uids that have already been used and should be unique * @return string A HTML <select> box with all possible records */ function renderPossibleRecordsSelectorTypeSelect($selItems, $conf, &$PA, $uniqueIds = array()) { $foreign_table = $conf['foreign_table']; $foreign_selector = $conf['foreign_selector']; $PA = array(); $PA['fieldConf'] = $GLOBALS['TCA'][$foreign_table]['columns'][$foreign_selector]; $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type']; // Using "form_type" locally in this script $PA['fieldTSConfig'] = $this->fObj->setTSconfig($foreign_table, array(), $foreign_selector); $config = $PA['fieldConf']['config']; if (!$disabled) { // Create option tags: $opt = array(); $styleAttrValue = ''; foreach ($selItems as $p) { if ($config['iconsInOptionTags']) { $styleAttrValue = $this->fObj->optionTagStyle($p[2]); } if (!in_array($p[1], $uniqueIds)) { $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . ' style="' . (in_array($p[1], $uniqueIds) ? '' : '') . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) : '') . '">' . htmlspecialchars($p[0]) . '</option>'; } } // Put together the selector box: $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->fObj->defaultMultipleSelectorStyle . '"'; $size = intval($conf['size']); $size = $conf['autoSizeMax'] ? t3lib_div::intInRange(count($itemArray) + 1, t3lib_div::intInRange($size, 1), $conf['autoSizeMax']) : $size; $onChange = "return inline.importNewRecord('" . $this->inlineNames['object'] . self::Structure_Separator . $conf['foreign_table'] . "')"; $item = ' <select id="' . $this->inlineNames['object'] . self::Structure_Separator . $conf['foreign_table'] . '_selector"' . $this->fObj->insertDefStyle('select') . ($size ? ' size="' . $size . '"' : '') . ' onchange="' . htmlspecialchars($onChange) . '"' . $PA['onFocus'] . $selector_itemListStyle . ($conf['foreign_unique'] ? ' isunique="isunique"' : '') . '> ' . implode(' ', $opt) . ' </select>'; // add a "Create new relation" link for adding new relations // this is neccessary, if the size of the selector is "1" or if // there is only one record item in the select-box, that is selected by default // the selector-box creates a new relation on using a onChange event (see some line above) $createNewRelationText = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createNewRelation', 1); $item .= '<a href="#" onclick="' . htmlspecialchars($onChange) . '" align="abstop">' . t3lib_iconWorks::getSpriteIcon('actions-document-new', array('title' => $createNewRelationText)) . $createNewRelationText . '</a>'; // wrap the selector and add a spacer to the bottom $item = '<div style="margin-bottom: 20px;">' . $item . '</div>'; } return $item; }