本文整理汇总了PHP中TYPO3\CMS\Core\Utility\StringUtility::getUniqueId方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtility::getUniqueId方法的具体用法?PHP StringUtility::getUniqueId怎么用?PHP StringUtility::getUniqueId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\StringUtility
的用法示例。
在下文中一共展示了StringUtility::getUniqueId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Handler for unknown types.
*
* @return array As defined in initializeResultArray() of AbstractNode
*/
public function render()
{
$resultArray = $this->initializeResultArray();
$languageService = $this->getLanguageService();
$row = $this->data['databaseRow'];
$parameterArray = $this->data['parameterArray'];
// If ratios are set do not add default options
if (isset($parameterArray['fieldConf']['config']['ratios'])) {
unset($this->defaultConfig['ratios']);
}
$config = ArrayUtility::arrayMergeRecursiveOverrule($this->defaultConfig, $parameterArray['fieldConf']['config']);
// By default we allow all image extensions that can be handled by the GFX functionality
if ($config['allowedExtensions'] === null) {
$config['allowedExtensions'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
}
if ($config['readOnly']) {
$options = array();
$options['parameterArray'] = array('fieldConf' => array('config' => $config), 'itemFormElValue' => $parameterArray['itemFormElValue']);
$options['renderType'] = 'none';
return $this->nodeFactory->create($options)->render();
}
$file = $this->getFile($row, $config['file_field']);
if (!$file) {
return $resultArray;
}
$content = '';
$preview = '';
if (GeneralUtility::inList(mb_strtolower($config['allowedExtensions']), mb_strtolower($file->getExtension()))) {
// Get preview
$preview = $this->getPreview($file, $parameterArray['itemFormElValue']);
// Check if ratio labels hold translation strings
foreach ((array) $config['ratios'] as $ratio => $label) {
$config['ratios'][$ratio] = $languageService->sL($label, true);
}
$formFieldId = StringUtility::getUniqueId('formengine-image-manipulation-');
$wizardData = array('zoom' => $config['enableZoom'] ? '1' : '0', 'ratios' => json_encode($config['ratios']), 'file' => $file->getUid());
$wizardData['token'] = GeneralUtility::hmac(implode('|', $wizardData), 'ImageManipulationWizard');
$buttonAttributes = array('data-url' => BackendUtility::getAjaxUrl('wizard_image_manipulation', $wizardData), 'data-severity' => 'notice', 'data-image-name' => $file->getNameWithoutExtension(), 'data-image-uid' => $file->getUid(), 'data-file-field' => $config['file_field'], 'data-field' => $formFieldId);
$button = '<button class="btn btn-default t3js-image-manipulation-trigger"';
foreach ($buttonAttributes as $key => $value) {
$button .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
}
$button .= '><span class="t3-icon fa fa-crop"></span>';
$button .= $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.open-editor', true);
$button .= '</button>';
$inputField = '<input type="hidden" ' . 'id="' . $formFieldId . '" ' . 'name="' . $parameterArray['itemFormElName'] . '" ' . 'value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
$content .= $inputField . $button;
$content .= $this->getImageManipulationInfoTable($parameterArray['itemFormElValue']);
$resultArray['requireJsModules'][] = array('TYPO3/CMS/Backend/ImageManipulation' => 'function(ImageManipulation){ImageManipulation.initializeTrigger()}');
}
$content .= '<p class="text-muted"><em>' . $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.supported-types-message', true) . '<br />';
$content .= mb_strtoupper(implode(', ', GeneralUtility::trimExplode(',', $config['allowedExtensions'])));
$content .= '</em></p>';
$item = '<div class="media">';
$item .= $preview;
$item .= '<div class="media-body">' . $content . '</div>';
$item .= '</div>';
$resultArray['html'] = $item;
return $resultArray;
}
示例2: renderHtml
public function renderHtml($name, $value, $options)
{
$width = $options['width'];
// TODO: das Feld beachten!
$maxlength = $options['maxlength'];
$attributes = array();
// for data-formengine-input-params
$paramsList = array('field' => $name, 'evalList' => 'int', 'is_in' => '');
$attributes['id'] = StringUtility::getUniqueId('formengine-input-');
$attributes['value'] = '';
$attributes['data-formengine-validation-rules'] = json_encode(array('type' => 'int'));
$attributes['data-formengine-input-params'] = json_encode($paramsList);
$attributes['data-formengine-input-name'] = htmlspecialchars($name);
$attributeString = '';
foreach ($attributes as $attributeName => $attributeValue) {
$attributeString .= ' ' . $attributeName . '="' . htmlspecialchars($attributeValue) . '"';
}
//$width = (int)$this->formMaxWidth($size);
$width = $GLOBALS['TBE_TEMPLATE']->formWidth($width);
$html = '
<input type="text"' . $attributeString . $width . ' />';
// This is the ACTUAL form field - values from the EDITABLE field must be transferred to this field which is the one that is written to the database.
$html .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
// Den Wrap lassen wir weg, weil es zu einem Zeilenumbruch kommt
// $html = '<div class="form-control-wrap"' . $width . '>' . $html . '</div>';
return $html;
}
示例3: render
/**
* Rendering the cObject, QTOBJECT
*
* @param array $conf Array of TypoScript properties
* @return string Output
*/
public function render($conf = array())
{
$params = $prefix = '';
if ($GLOBALS['TSFE']->baseUrl) {
$prefix = $GLOBALS['TSFE']->baseUrl;
}
if ($GLOBALS['TSFE']->absRefPrefix) {
$prefix = $GLOBALS['TSFE']->absRefPrefix;
}
$type = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
// If file is audio and an explicit path has not been set,
// take path from audio fallback property
if ($type == 'audio' && empty($conf['file'])) {
$conf['file'] = $conf['audioFallback'];
}
$filename = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
$typeConf = $conf[$type . '.'];
// Add QTobject js-file
$this->getPageRenderer()->addJsFile($this->getPathToLibrary('flashmedia/qtobject/qtobject.js'));
$replaceElementIdString = StringUtility::getUniqueId('mmqt');
$GLOBALS['TSFE']->register['MMQTID'] = $replaceElementIdString;
$qtObject = 'QTObject' . $replaceElementIdString;
// Merge with default parameters
$conf['params.'] = array_merge((array) $typeConf['default.']['params.'], (array) $conf['params.']);
if (is_array($conf['params.']) && is_array($typeConf['mapping.']['params.'])) {
ArrayUtility::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
foreach ($conf['params.'] as $key => $value) {
$params .= $qtObject . '.addParam("' . $key . '", "' . $value . '");' . LF;
}
}
$params = ($params ? substr($params, 0, -2) : '') . LF . $qtObject . '.write("' . $replaceElementIdString . '");';
$alternativeContent = isset($conf['alternativeContent.']) ? $this->cObj->stdWrap($conf['alternativeContent'], $conf['alternativeContent.']) : $conf['alternativeContent'];
$layout = str_replace(array('###ID###', '###QTOBJECT###'), array($replaceElementIdString, '<div id="' . $replaceElementIdString . '">' . $alternativeContent . '</div>'), isset($conf['layout.']) ? $this->cObj->stdWrap($conf['layout'], $conf['layout.']) : $conf['layout']);
$width = isset($conf['width.']) ? $this->cObj->stdWrap($conf['width'], $conf['width.']) : $conf['width'];
if (!$width) {
$width = $conf[$type . '.']['defaultWidth'];
}
$height = isset($conf['height.']) ? $this->cObj->stdWrap($conf['height'], $conf['height.']) : $conf['height'];
if (!$height) {
$height = $conf[$type . '.']['defaultHeight'];
}
$fullFilename = $filename;
// If the file name doesn't contain a scheme, prefix with appropriate data
if (strpos($filename, '://') === false && !empty($prefix)) {
$fullFilename = $prefix . $filename;
}
$embed = 'var ' . $qtObject . ' = new QTObject("' . $fullFilename . '", "' . $replaceElementIdString . '", "' . $width . '", "' . $height . '");';
$content = $layout . '
<script type="text/javascript">
' . $embed . '
' . $params . '
</script>';
if (isset($conf['stdWrap.'])) {
$content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
}
return $content;
}
示例4: addData
/**
* Initialize new row with unique uid
*
* @param array $result
* @return array
* @throws \InvalidArgumentException
*/
public function addData(array $result)
{
if ($result['command'] !== 'new') {
return $result;
}
// Throw exception if uid is already set
if (isset($result['databaseRow']['uid'])) {
throw new \InvalidArgumentException('uid is already set to ' . $result['databaseRow']['uid'], 1437991120);
}
$result['databaseRow']['uid'] = StringUtility::getUniqueId('NEW');
return $result;
}
示例5: setRelations
/**
* At the end of the import process all file and DB relations should be set properly (that is relations
* to imported records are all re-created so imported records are correctly related again)
* Relations in flexform fields are processed in setFlexFormRelations() after this function
*
* @return void
* @see setFlexFormRelations()
*/
public function setRelations()
{
$updateData = array();
// import_newId contains a register of all records that was in the import memorys "records" key
foreach ($this->import_newId as $nId => $dat) {
$table = $dat['table'];
$uid = $dat['uid'];
// original UID - NOT the new one!
// If the record has been written and received a new id, then proceed:
if (is_array($this->import_mapId[$table]) && isset($this->import_mapId[$table][$uid])) {
$thisNewUid = BackendUtility::wsMapId($table, $this->import_mapId[$table][$uid]);
if (is_array($this->dat['records'][$table . ':' . $uid]['rels'])) {
$thisNewPageUid = 0;
if ($this->legacyImport) {
if ($table != 'pages') {
$oldPid = $this->dat['records'][$table . ':' . $uid]['data']['pid'];
$thisNewPageUid = BackendUtility::wsMapId($table, $this->import_mapId['pages'][$oldPid]);
} else {
$thisNewPageUid = $thisNewUid;
}
}
// Traverse relation fields of each record
foreach ($this->dat['records'][$table . ':' . $uid]['rels'] as $field => $config) {
// uid_local of sys_file_reference needs no update because the correct reference uid was already written
// @see ImportExport::fixUidLocalInSysFileReferenceRecords()
if ($table === 'sys_file_reference' && $field === 'uid_local') {
continue;
}
switch ((string) $config['type']) {
case 'db':
if (is_array($config['itemArray']) && !empty($config['itemArray'])) {
$itemConfig = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
$valArray = $this->setRelations_db($config['itemArray'], $itemConfig);
$updateData[$table][$thisNewUid][$field] = implode(',', $valArray);
}
break;
case 'file':
if (is_array($config['newValueFiles']) && !empty($config['newValueFiles'])) {
$valArr = array();
foreach ($config['newValueFiles'] as $fI) {
$valArr[] = $this->import_addFileNameToBeCopied($fI);
}
if ($this->legacyImport && $this->legacyImportFolder === null && isset($this->legacyImportMigrationTables[$table][$field])) {
// Do nothing - the legacy import folder is missing
} elseif ($this->legacyImport && $this->legacyImportFolder !== null && isset($this->legacyImportMigrationTables[$table][$field])) {
$refIds = array();
foreach ($valArr as $tempFile) {
$fileName = $this->alternativeFileName[$tempFile];
$fileObject = null;
try {
// check, if there is alreay the same file in the folder
if ($this->legacyImportFolder->hasFile($fileName)) {
$fileStorage = $this->legacyImportFolder->getStorage();
$file = $fileStorage->getFile($this->legacyImportFolder->getIdentifier() . $fileName);
if ($file->getSha1() === sha1_file($tempFile)) {
$fileObject = $file;
}
}
} catch (Exception $e) {
}
if ($fileObject === null) {
try {
$fileObject = $this->legacyImportFolder->addFile($tempFile, $fileName, DuplicationBehavior::RENAME);
} catch (Exception $e) {
$this->error('Error: no file could be added to the storage for file name' . $this->alternativeFileName[$tempFile]);
}
}
if ($fileObject !== null) {
$refId = StringUtility::getUniqueId('NEW');
$refIds[] = $refId;
$updateData['sys_file_reference'][$refId] = array('uid_local' => $fileObject->getUid(), 'uid_foreign' => $thisNewUid, 'tablenames' => $table, 'fieldname' => $field, 'pid' => $thisNewPageUid, 'table_local' => 'sys_file');
}
}
$updateData[$table][$thisNewUid][$field] = implode(',', $refIds);
if (!empty($this->legacyImportMigrationTables[$table][$field])) {
$this->legacyImportMigrationRecords[$table][$thisNewUid][$field] = $refIds;
}
} else {
$updateData[$table][$thisNewUid][$field] = implode(',', $valArr);
}
}
break;
}
}
} else {
$this->error('Error: no record was found in data array!');
}
} else {
$this->error('Error: this records is NOT created it seems! (' . $table . ':' . $uid . ')');
}
}
if (!empty($updateData)) {
//.........这里部分代码省略.........
示例6: render
//.........这里部分代码省略.........
$dateFormat = $dateFormats['time'];
$isDateField = true;
$classes[] = 't3js-datetimepicker';
$attributes['data-date-type'] = 'time';
} elseif (in_array('timesec', $evalList)) {
$dateFormat = $dateFormats['timesec'];
$isDateField = true;
$classes[] = 't3js-datetimepicker';
$attributes['data-date-type'] = 'timesec';
} else {
if ($checkboxIsset === false) {
$config['checkbox'] = '';
}
}
// @todo: The whole eval handling is a mess and needs refactoring
foreach ($evalList as $func) {
switch ($func) {
case 'required':
$attributes['data-formengine-validation-rules'] = $this->getValidationDataAsJsonString(array('required' => true));
break;
default:
// @todo: This is ugly: The code should find out on it's own whether a eval definition is a
// @todo: keyword like "date", or a class reference. The global registration could be dropped then
// Pair hook to the one in \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval()
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func])) {
if (class_exists($func)) {
$evalObj = GeneralUtility::makeInstance($func);
if (method_exists($evalObj, 'deevaluateFieldValue')) {
$_params = array('value' => $parameterArray['itemFormElValue']);
$parameterArray['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
}
}
}
}
}
$paramsList = array('field' => $parameterArray['itemFormElName'], 'evalList' => implode(',', $evalList), 'is_in' => trim($config['is_in']), 'checkbox' => $config['checkbox'] ? 1 : 0, 'checkboxValue' => $config['checkbox']);
// set classes
$classes[] = 'form-control';
$classes[] = 't3js-clearable';
$classes[] = 'hasDefaultValue';
// calculate attributes
$attributes['data-formengine-validation-rules'] = $this->getValidationDataAsJsonString($config);
$attributes['data-formengine-input-params'] = json_encode($paramsList);
$attributes['data-formengine-input-name'] = htmlspecialchars($parameterArray['itemFormElName']);
$attributes['id'] = StringUtility::getUniqueId('formengine-input-');
$attributes['value'] = '';
if (isset($config['max']) && (int) $config['max'] > 0) {
$attributes['maxlength'] = (int) $config['max'];
}
if (!empty($classes)) {
$attributes['class'] = implode(' ', $classes);
}
// This is the EDITABLE form field.
if (!empty($config['placeholder'])) {
$attributes['placeholder'] = trim($config['placeholder']);
}
if (isset($config['autocomplete'])) {
$attributes['autocomplete'] = empty($config['autocomplete']) ? 'off' : 'on';
}
// Build the attribute string
$attributeString = '';
foreach ($attributes as $attributeName => $attributeValue) {
$attributeString .= ' ' . $attributeName . '="' . htmlspecialchars($attributeValue) . '"';
}
$html = '
<input type="text"' . $attributeString . $parameterArray['onFocus'] . ' />';
// This is the ACTUAL form field - values from the EDITABLE field must be transferred to this field which is the one that is written to the database.
$html .= '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
// Going through all custom evaluations configured for this field
// @todo: Similar to above code!
foreach ($evalList as $evalData) {
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData])) {
if (class_exists($evalData)) {
$evalObj = GeneralUtility::makeInstance($evalData);
if (method_exists($evalObj, 'returnFieldJS')) {
$resultArray['extJSCODE'] .= LF . 'TBE_EDITOR.customEvalFunctions[' . GeneralUtility::quoteJSvalue($evalData) . '] = function(value) {' . $evalObj->returnFieldJS() . '}';
}
}
}
}
// add HTML wrapper
if ($isDateField) {
$html = '
<div class="input-group">
' . $html . '
<span class="input-group-btn">
<label class="btn btn-default" for="' . $attributes['id'] . '">
' . $iconFactory->getIcon('actions-edit-pick-date', Icon::SIZE_SMALL)->render() . '
</label>
</span>
</div>';
}
// Wrap a wizard around the item?
$html = $this->renderWizards(array($html), $config['wizards'], $table, $row, $fieldName, $parameterArray, $parameterArray['itemFormElName'], $specConf);
// Add a wrapper to remain maximum width
$width = (int) $this->formMaxWidth($size);
$html = '<div class="form-control-wrap"' . ($width ? ' style="max-width: ' . $width . 'px"' : '') . '>' . $html . '</div>';
$resultArray['html'] = $html;
return $resultArray;
}
示例7: render
/**
* This will render a <textarea>
*
* @return array As defined in initializeResultArray() of AbstractNode
*/
public function render()
{
$languageService = $this->getLanguageService();
$table = $this->data['tableName'];
$fieldName = $this->data['fieldName'];
$row = $this->data['databaseRow'];
$parameterArray = $this->data['parameterArray'];
$resultArray = $this->initializeResultArray();
$backendUser = $this->getBackendUserAuthentication();
$config = $parameterArray['fieldConf']['config'];
// Setting columns number
$cols = MathUtility::forceIntegerInRange($config['cols'] ?: $this->defaultInputWidth, $this->minimumInputWidth, $this->maxInputWidth);
// Setting number of rows
$rows = MathUtility::forceIntegerInRange($config['rows'] ?: 5, 1, 20);
$originalRows = $rows;
$itemFormElementValueLength = strlen($parameterArray['itemFormElValue']);
if ($itemFormElementValueLength > $this->charactersPerRow * 2) {
$cols = $this->maxInputWidth;
$rows = MathUtility::forceIntegerInRange(round($itemFormElementValueLength / $this->charactersPerRow), count(explode(LF, $parameterArray['itemFormElValue'])), 20);
if ($rows < $originalRows) {
$rows = $originalRows;
}
}
// must be called after the cols and rows calculation, so the parameters are applied
// to read-only fields as well.
// @todo: Same as in InputTextElement ...
if ($config['readOnly']) {
$config['cols'] = $cols;
$config['rows'] = $rows;
$options = $this->data;
$options['parameterArray'] = array('fieldConf' => array('config' => $config), 'itemFormElValue' => $parameterArray['itemFormElValue']);
$options['renderType'] = 'none';
return $this->nodeFactory->create($options)->render();
}
$evalList = GeneralUtility::trimExplode(',', $config['eval'], true);
// "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
$specialConfiguration = BackendUtility::getSpecConfParts($parameterArray['fieldConf']['defaultExtras']);
$html = '';
// Show message, if no RTE (field can only be edited with RTE!)
if ($specialConfiguration['rte_only']) {
$html = '<p><em>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noRTEfound')) . '</em></p>';
} else {
$attributes = array();
// validation
foreach ($evalList as $func) {
if ($func === 'required') {
$attributes['data-formengine-validation-rules'] = $this->getValidationDataAsJsonString(array('required' => true));
} else {
// @todo: This is ugly: The code should find out on it's own whether a eval definition is a
// @todo: keyword like "date", or a class reference. The global registration could be dropped then
// Pair hook to the one in \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval()
// There is a similar hook for "evaluateFieldValue" in DataHandler and InputTextElement
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func])) {
if (class_exists($func)) {
$evalObj = GeneralUtility::makeInstance($func);
if (method_exists($evalObj, 'deevaluateFieldValue')) {
$_params = array('value' => $parameterArray['itemFormElValue']);
$parameterArray['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
}
}
}
}
}
// calculate classes
$classes = array();
$classes[] = 'form-control';
$classes[] = 't3js-formengine-textarea';
$classes[] = 'formengine-textarea';
if ($specialConfiguration['fixed-font']) {
$classes[] = 'text-monospace';
}
if ($specialConfiguration['enable-tab']) {
$classes[] = 't3js-enable-tab';
}
// calculate styles
$styles = array();
// add the max-height from the users' preference to it
$maximumHeight = (int) $backendUser->uc['resizeTextareas_MaxHeight'];
if ($maximumHeight > 0) {
$styles[] = 'max-height: ' . $maximumHeight . 'px';
}
// calculate attributes
$attributes['id'] = StringUtility::getUniqueId('formengine-textarea-');
$attributes['name'] = htmlspecialchars($parameterArray['itemFormElName']);
$attributes['data-formengine-input-name'] = htmlspecialchars($parameterArray['itemFormElName']);
if (!empty($styles)) {
$attributes['style'] = implode(' ', $styles);
}
if (!empty($classes)) {
$attributes['class'] = implode(' ', $classes);
}
$attributes['rows'] = $rows;
$attributes['wrap'] = $specialConfiguration['nowrap'] ? 'off' : ($config['wrap'] ?: 'virtual');
$attributes['onChange'] = implode('', $parameterArray['fieldChangeFunc']);
if (isset($config['max']) && (int) $config['max'] > 0) {
//.........这里部分代码省略.........
示例8: getSelectMmQueryParts
/**
* Creates SELECT query components for selecting fields ($select) from two/three tables joined
* Use $mm_table together with $local_table or $foreign_table to select over two tables. Or use all three tables to select the full MM-relation.
* The JOIN is done with [$local_table].uid <--> [$mm_table].uid_local / [$mm_table].uid_foreign <--> [$foreign_table].uid
* The function is very useful for selecting MM-relations between tables adhering to the MM-format used by TCE (TYPO3 Core Engine). See the section on $GLOBALS['TCA'] in Inside TYPO3 for more details.
*
* @param string $select See exec_SELECT_mm_query()
* @param string $local_table See exec_SELECT_mm_query()
* @param string $mm_table See exec_SELECT_mm_query()
* @param string $foreign_table See exec_SELECT_mm_query()
* @param string $whereClause See exec_SELECT_mm_query()
* @param string $groupBy See exec_SELECT_mm_query()
* @param string $orderBy See exec_SELECT_mm_query()
* @param string $limit See exec_SELECT_mm_query()
* @return array SQL query components
*/
protected function getSelectMmQueryParts($select, $local_table, $mm_table, $foreign_table, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '')
{
$foreign_table_as = $foreign_table == $local_table ? $foreign_table . StringUtility::getUniqueId('_join') : '';
$mmWhere = $local_table ? $local_table . '.uid=' . $mm_table . '.uid_local' : '';
$mmWhere .= ($local_table and $foreign_table) ? ' AND ' : '';
$tables = ($local_table ? $local_table . ',' : '') . $mm_table;
if ($foreign_table) {
$mmWhere .= ($foreign_table_as ?: $foreign_table) . '.uid=' . $mm_table . '.uid_foreign';
$tables .= ',' . $foreign_table . ($foreign_table_as ? ' AS ' . $foreign_table_as : '');
}
return array('SELECT' => $select, 'FROM' => $tables, 'WHERE' => $mmWhere . ' ' . $whereClause, 'GROUPBY' => $groupBy, 'ORDERBY' => $orderBy, 'LIMIT' => $limit);
}
示例9: modifyRecords
/**
* @param int $pageId
* @param array $tableRecordData
*/
public function modifyRecords($pageId, array $tableRecordData)
{
$dataMap = array();
$currentUid = null;
$previousTableName = null;
$previousUid = null;
foreach ($tableRecordData as $tableName => $recordData) {
if (empty($recordData['uid'])) {
continue;
}
$recordData = $this->resolvePreviousUid($recordData, $currentUid);
$currentUid = $recordData['uid'];
if ($recordData['uid'] === '__NEW') {
$recordData['pid'] = $pageId;
$currentUid = StringUtility::getUniqueId('NEW');
}
unset($recordData['uid']);
$dataMap[$tableName][$currentUid] = $recordData;
if ($previousTableName !== null && $previousUid !== null) {
$dataMap[$previousTableName][$previousUid] = $this->resolveNextUid($dataMap[$previousTableName][$previousUid], $currentUid);
}
$previousTableName = $tableName;
$previousUid = $currentUid;
}
$this->createDataHandler();
$this->dataHandler->start($dataMap, array());
$this->dataHandler->process_datamap();
}
示例10: getUniqueIdReturnsIdWithoutDot
/**
* @test
*/
public function getUniqueIdReturnsIdWithoutDot()
{
$this->assertNotContains('.', StringUtility::getUniqueId());
}
示例11: render
/**
* Entry method
*
* @return array As defined in initializeResultArray() of AbstractNode
*/
public function render()
{
/** @var IconFactory $iconFactory */
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$languageService = $this->getLanguageService();
$flexFormFieldsArray = $this->data['flexFormDataStructureArray'];
$flexFormRowData = $this->data['flexFormRowData'];
$flexFormFieldIdentifierPrefix = $this->data['flexFormFieldIdentifierPrefix'];
$flexFormSectionType = $this->data['flexFormSectionType'];
$flexFormSectionTitle = $this->data['flexFormSectionTitle'];
$userHasAccessToDefaultLanguage = $this->getBackendUserAuthentication()->checkLanguageAccess(0);
$resultArray = $this->initializeResultArray();
// Creating IDs for form fields:
// It's important that the IDs "cascade" - otherwise we can't dynamically expand the flex form
// because this relies on simple string substitution of the first parts of the id values.
$flexFormFieldIdentifierPrefix = $flexFormFieldIdentifierPrefix . '-' . GeneralUtility::shortMd5(uniqid('id', true));
// Render each existing container
foreach ($flexFormRowData as $flexFormContainerCounter => $existingSectionContainerData) {
// @todo: This relies on the fact that "_TOGGLE" is *below* the real data in the saved xml structure
if (is_array($existingSectionContainerData)) {
$existingSectionContainerDataStructureType = key($existingSectionContainerData);
$existingSectionContainerData = $existingSectionContainerData[$existingSectionContainerDataStructureType];
$containerDataStructure = $flexFormFieldsArray[$existingSectionContainerDataStructureType];
// There may be cases where a field is still in DB but does not exist in definition
if (is_array($containerDataStructure)) {
$sectionTitle = '';
if (!empty($containerDataStructure['title'])) {
$sectionTitle = $languageService->sL($containerDataStructure['title']);
}
$options = $this->data;
$options['flexFormRowData'] = $existingSectionContainerData['el'];
$options['flexFormDataStructureArray'] = $containerDataStructure['el'];
$options['flexFormFieldIdentifierPrefix'] = $flexFormFieldIdentifierPrefix;
$options['flexFormFormPrefix'] = $this->data['flexFormFormPrefix'] . '[' . $flexFormSectionType . ']' . '[el]';
$options['flexFormContainerName'] = $existingSectionContainerDataStructureType;
$options['flexFormContainerCounter'] = $flexFormContainerCounter;
$options['flexFormContainerTitle'] = $sectionTitle;
$options['flexFormContainerElementCollapsed'] = (bool) $existingSectionContainerData['el']['_TOGGLE'];
$options['renderType'] = 'flexFormContainerContainer';
$flexFormContainerContainerResult = $this->nodeFactory->create($options)->render();
$resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $flexFormContainerContainerResult);
}
}
}
// "New container" handling: Creates a "template" of each possible container and stuffs it
// somewhere into DOM to be handled with JS magic.
// Fun part: Handle the fact that such things may be set for children
$containerTemplatesHtml = array();
foreach ($flexFormFieldsArray as $flexFormContainerName => $flexFormFieldDefinition) {
$containerTemplateHtml = array();
$sectionTitle = '';
if (!empty($flexFormFieldDefinition['title'])) {
$sectionTitle = $languageService->sL($flexFormFieldDefinition['title']);
}
$options = $this->data;
// @todo: this should use the prepared templateRow parallel to the single elements to have support of default values!
$options['flexFormRowData'] = array();
$options['flexFormDataStructureArray'] = $flexFormFieldDefinition['el'];
$options['flexFormFieldIdentifierPrefix'] = $flexFormFieldIdentifierPrefix;
$options['flexFormFormPrefix'] = $this->data['flexFormFormPrefix'] . '[' . $flexFormSectionType . ']' . '[el]';
$options['flexFormContainerName'] = $flexFormContainerName;
$options['flexFormContainerCounter'] = $flexFormFieldIdentifierPrefix . '-form';
$options['flexFormContainerTitle'] = $sectionTitle;
$options['flexFormContainerElementCollapsed'] = false;
$options['renderType'] = 'flexFormContainerContainer';
$flexFormContainerContainerTemplateResult = $this->nodeFactory->create($options)->render();
$uniqueId = StringUtility::getUniqueId('idvar');
$identifierPrefixJs = 'replace(/' . $flexFormFieldIdentifierPrefix . '-/g,"' . $flexFormFieldIdentifierPrefix . '-"+' . $uniqueId . '+"-")';
$identifierPrefixJs .= '.replace(/(tceforms-(datetime|date)field-)/g,"$1" + (new Date()).getTime())';
$onClickInsert = array();
$onClickInsert[] = 'var ' . $uniqueId . ' = "' . 'idx"+(new Date()).getTime();';
$onClickInsert[] = 'TYPO3.jQuery("#' . $flexFormFieldIdentifierPrefix . '").append(TYPO3.jQuery(' . json_encode($flexFormContainerContainerTemplateResult['html']) . '.' . $identifierPrefixJs . '));';
$onClickInsert[] = 'TYPO3.jQuery("#' . $flexFormFieldIdentifierPrefix . '").t3FormEngineFlexFormElement();';
$onClickInsert[] = 'eval(unescape("' . rawurlencode(implode(';', $flexFormContainerContainerTemplateResult['additionalJavaScriptPost'])) . '").' . $identifierPrefixJs . ');';
$onClickInsert[] = 'TBE_EDITOR.addActionChecks("submit", unescape("' . rawurlencode(implode(';', $flexFormContainerContainerTemplateResult['additionalJavaScriptSubmit'])) . '").' . $identifierPrefixJs . ');';
$onClickInsert[] = 'TYPO3.FormEngine.reinitialize();';
$onClickInsert[] = 'return false;';
$containerTemplateHtml[] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars(implode(LF, $onClickInsert)) . '">';
$containerTemplateHtml[] = $iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render();
$containerTemplateHtml[] = htmlspecialchars(GeneralUtility::fixed_lgd_cs($sectionTitle, 30));
$containerTemplateHtml[] = '</a>';
$containerTemplatesHtml[] = implode(LF, $containerTemplateHtml);
$flexFormContainerContainerTemplateResult['html'] = '';
$flexFormContainerContainerTemplateResult['additionalJavaScriptPost'] = array();
$flexFormContainerContainerTemplateResult['additionalJavaScriptSubmit'] = array();
$resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $flexFormContainerContainerTemplateResult);
}
// Create new elements links
$createElementsHtml = array();
if ($userHasAccessToDefaultLanguage) {
$createElementsHtml[] = '<div class="t3-form-field-add-flexsection">';
$createElementsHtml[] = '<div class="btn-group">';
$createElementsHtml[] = implode('|', $containerTemplatesHtml);
$createElementsHtml[] = '</div>';
$createElementsHtml[] = '</div>';
//.........这里部分代码省略.........
示例12: renderSelectElement
/**
* Renders a <select> element
*
* @param array $optionElements List of rendered <option> elements
* @param array $parameterArray
* @param array $config Field configuration
* @return string
*/
protected function renderSelectElement(array $optionElements, array $parameterArray, array $config)
{
$selectItems = $parameterArray['fieldConf']['config']['items'];
$size = (int) $config['size'];
$cssPrefix = $size === 1 ? 'tceforms-select' : 'tceforms-multiselect';
if ($config['autoSizeMax']) {
$size = MathUtility::forceIntegerInRange(count($selectItems) + 1, MathUtility::forceIntegerInRange($size, 1), $config['autoSizeMax']);
}
$attributes = ['name' => $parameterArray['itemFormElName'] . '[]', 'multiple' => 'multiple', 'onchange' => implode('', $parameterArray['fieldChangeFunc']), 'id' => StringUtility::getUniqueId($cssPrefix), 'class' => 'form-control ' . $cssPrefix];
if ($size) {
$attributes['size'] = $size;
}
if ($config['readOnly']) {
$attributes['disabled'] = 'disabled';
}
if (isset($config['itemListStyle'])) {
$attributes['style'] = $config['itemListStyle'];
}
$html = ['<select ' . $this->implodeAttributes($attributes) . ' ' . $parameterArray['onFocus'] . ' ' . $this->getValidationDataAsDataAttribute($config) . '>', implode(LF, $optionElements), '</select>'];
return implode(LF, $html);
}
示例13: render
/**
* Render side by side element.
*
* @return array As defined in initializeResultArray() of AbstractNode
*/
public function render()
{
$table = $this->data['tableName'];
$field = $this->data['fieldName'];
$parameterArray = $this->data['parameterArray'];
// Field configuration from TCA:
$config = $parameterArray['fieldConf']['config'];
// Creating the label for the "No Matching Value" entry.
$noMatchingLabel = isset($parameterArray['fieldTSConfig']['noMatchingValue_label']) ? $this->getLanguageService()->sL($parameterArray['fieldTSConfig']['noMatchingValue_label']) : '[ ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue') . ' ]';
$selItems = $config['items'];
$html = '';
$disabled = '';
if ($config['readOnly']) {
$disabled = ' disabled="disabled"';
}
// Setting this hidden field (as a flag that JavaScript can read out)
if (!$disabled) {
$html .= '<input type="hidden" data-formengine-input-name="' . htmlspecialchars($parameterArray['itemFormElName']) . '" value="' . ($config['multiple'] ? 1 : 0) . '" />';
}
// Set max and min items:
$maxitems = MathUtility::forceIntegerInRange($config['maxitems'], 0);
if (!$maxitems) {
$maxitems = 100000;
}
// Get "removeItems":
$removeItems = GeneralUtility::trimExplode(',', $parameterArray['fieldTSConfig']['removeItems'], true);
// Get the array with selected items:
$itemsArray = $parameterArray['itemFormElValue'] ?: [];
// Perform modification of the selected items array:
// @todo: this part should probably be moved to TcaSelectItems provider?!
foreach ($itemsArray as $itemNumber => $itemValue) {
$itemArray = array(0 => $itemValue, 1 => '');
$itemIcon = null;
$isRemoved = in_array($itemValue, $removeItems) || $config['type'] == 'select' && $config['authMode'] && !$this->getBackendUserAuthentication()->checkAuthMode($table, $field, $itemValue, $config['authMode']);
if ($isRemoved && !$parameterArray['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
$itemArray[1] = rawurlencode(@sprintf($noMatchingLabel, $itemValue));
} else {
if (isset($parameterArray['fieldTSConfig']['altLabels.'][$itemValue])) {
$itemArray[1] = rawurlencode($this->getLanguageService()->sL($parameterArray['fieldTSConfig']['altLabels.'][$itemValue]));
}
if (isset($parameterArray['fieldTSConfig']['altIcons.'][$itemValue])) {
$itemArray[2] = $parameterArray['fieldTSConfig']['altIcons.'][$itemValue];
}
}
if ($itemArray[1] === '') {
foreach ($selItems as $selItem) {
if ($selItem[1] == $itemValue) {
$itemArray[1] = $selItem[0];
break;
}
}
}
$itemsArray[$itemNumber] = implode('|', $itemArray);
}
// size must be at least two, as there are always maxitems > 1 (see parent function)
if (isset($config['size'])) {
$size = (int) $config['size'];
} else {
$size = 2;
}
$size = $config['autoSizeMax'] ? MathUtility::forceIntegerInRange(count($itemsArray) + 1, MathUtility::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
$itemsToSelect = [];
$filterTextfield = [];
$filterSelectbox = '';
if (!$disabled) {
// Create option tags:
$opt = array();
foreach ($selItems as $p) {
$opt[] = '<option value="' . htmlspecialchars($p[1]) . '" title="' . $p[0] . '">' . $p[0] . '</option>';
}
// Put together the selector box:
$selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : '';
$sOnChange = implode('', $parameterArray['fieldChangeFunc']);
$multiSelectId = StringUtility::getUniqueId('tceforms-multiselect-');
$itemsToSelect[] = '<select data-relatedfieldname="' . htmlspecialchars($parameterArray['itemFormElName']) . '" ' . 'data-exclusivevalues="' . htmlspecialchars($config['exclusiveKeys']) . '" ' . 'id="' . $multiSelectId . '" ' . 'data-formengine-input-name="' . htmlspecialchars($parameterArray['itemFormElName']) . '" ' . 'class="form-control t3js-formengine-select-itemstoselect" ' . ($size ? ' size="' . $size . '" ' : '') . 'onchange="' . htmlspecialchars($sOnChange) . '" ' . $parameterArray['onFocus'] . $this->getValidationDataAsDataAttribute($config) . $selector_itemListStyle . '>';
$itemsToSelect[] = implode(LF, $opt);
$itemsToSelect[] = '</select>';
// enable filter functionality via a text field
if ($config['enableMultiSelectFilterTextfield']) {
$filterTextfield[] = '<span class="input-group input-group-sm">';
$filterTextfield[] = '<span class="input-group-addon">';
$filterTextfield[] = '<span class="fa fa-filter"></span>';
$filterTextfield[] = '</span>';
$filterTextfield[] = '<input class="t3js-formengine-multiselect-filter-textfield form-control" value="">';
$filterTextfield[] = '</span>';
}
// enable filter functionality via a select
if (isset($config['multiSelectFilterItems']) && is_array($config['multiSelectFilterItems']) && count($config['multiSelectFilterItems']) > 1) {
$filterDropDownOptions = array();
foreach ($config['multiSelectFilterItems'] as $optionElement) {
$optionValue = $this->getLanguageService()->sL(isset($optionElement[1]) && $optionElement[1] != '' ? $optionElement[1] : $optionElement[0]);
$filterDropDownOptions[] = '<option value="' . htmlspecialchars($this->getLanguageService()->sL($optionElement[0])) . '">' . htmlspecialchars($optionValue) . '</option>';
}
$filterSelectbox = '<select class="form-control input-sm t3js-formengine-multiselect-filter-dropdown">' . implode(LF, $filterDropDownOptions) . '</select>';
}
//.........这里部分代码省略.........
示例14: getSingleField_typeSelect_single
/**
* Creates a single-selector box
*
* @param string $table See getSingleField_typeSelect()
* @param string $field See getSingleField_typeSelect()
* @param array $row See getSingleField_typeSelect()
* @param array $parameterArray See getSingleField_typeSelect()
* @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
* @param array $selectItems Items available for selection
* @param string $noMatchingLabel Label for no-matching-value
* @return string The HTML code for the item
*/
protected function getSingleField_typeSelect_single($table, $field, $row, $parameterArray, $config, $selectItems, $noMatchingLabel)
{
// Initialization:
$selectId = StringUtility::getUniqueId('tceforms-select-');
$selectedIndex = 0;
$selectedIcon = '';
$selectedValueFound = FALSE;
$onlySelectedIconShown = FALSE;
$size = (int) $config['size'];
// Style set on <select/>
$out = '';
$options = '';
$disabled = FALSE;
if ($config['readOnly']) {
$disabled = TRUE;
$onlySelectedIconShown = TRUE;
}
// Icon configuration:
if ($config['suppress_icons'] === 'IF_VALUE_FALSE') {
$suppressIcons = empty($parameterArray['itemFormElValue']);
} elseif ($config['suppress_icons'] === 'ONLY_SELECTED') {
$suppressIcons = FALSE;
$onlySelectedIconShown = TRUE;
} elseif ($config['suppress_icons']) {
$suppressIcons = TRUE;
} else {
$suppressIcons = FALSE;
}
// Prepare groups
$selectItemCounter = 0;
$selectItemGroupCount = 0;
$selectItemGroups = array();
$selectIcons = array();
$selectedValue = '';
if (!empty($parameterArray['itemFormElValue'])) {
$selectedValue = (string) $parameterArray['itemFormElValue'];
}
foreach ($selectItems as $item) {
if ($item[1] === '--div--') {
// IS OPTGROUP
if ($selectItemCounter !== 0) {
$selectItemGroupCount++;
}
$selectItemGroups[$selectItemGroupCount]['header'] = array('title' => $item[0], 'icon' => !empty($item[2]) ? FormEngineUtility::getIconHtml($item[2]) : '');
} else {
// IS ITEM
$title = htmlspecialchars($item['0'], ENT_COMPAT, 'UTF-8', FALSE);
$selected = $selectedValue === (string) $item[1];
if ($selected) {
$selectedIndex = $selectItemCounter;
$selectedIcon = $icon;
$selectedValueFound = TRUE;
}
$icon = !empty($item[2]) ? $this->getIconHtml($item[2], $selected) : '';
$selectItemGroups[$selectItemGroupCount]['items'][] = array('title' => $title, 'value' => $item[1], 'icon' => $icon, 'selected' => $selected, 'index' => $selectItemCounter);
// ICON
if ($icon && !$suppressIcons && (!$onlySelectedIconShown || $selected)) {
$onClick = 'document.editform[' . GeneralUtility::quoteJSvalue($parameterArray['itemFormElName']) . '].selectedIndex=' . $selectItemCounter . ';';
$onClick .= implode('', $parameterArray['fieldChangeFunc']);
$onClick .= 'this.blur();return false;';
$selectIcons[] = array('title' => $title, 'icon' => $icon, 'index' => $selectItemCounter, 'onClick' => $onClick);
}
$selectItemCounter++;
}
}
// No-matching-value:
if ($selectedValue && !$selectedValueFound && !$parameterArray['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
$noMatchingLabel = @sprintf($noMatchingLabel, $selectedValue);
$options = '<option value="' . htmlspecialchars($selectedValue) . '" selected="selected">' . htmlspecialchars($noMatchingLabel) . '</option>';
} elseif (!$selectedIcon && $selectItemGroups[0]['items'][0]['icon']) {
$selectedIcon = $selectItemGroups[0]['items'][0]['icon'];
}
// Process groups
foreach ($selectItemGroups as $selectItemGroup) {
// suppress groups without items
if (empty($selectItemGroup['items'])) {
continue;
}
$optionGroup = is_array($selectItemGroup['header']);
$options .= $optionGroup ? '<optgroup label="' . htmlspecialchars($selectItemGroup['header']['title'], ENT_COMPAT, 'UTF-8', FALSE) . '">' : '';
if (is_array($selectItemGroup['items'])) {
foreach ($selectItemGroup['items'] as $item) {
$options .= '<option value="' . htmlspecialchars($item['value']) . '" data-icon="' . htmlspecialchars($item['icon']) . '"' . ($item['selected'] ? ' selected="selected"' : '') . '>' . $item['title'] . '</option>';
}
}
$options .= $optionGroup ? '</optgroup>' : '';
}
// Create item form fields:
//.........这里部分代码省略.........
示例15: insertNewCopyVersion
/**
* Inserts a record in the database, passing TCA configuration values through checkValue() but otherwise does NOTHING and checks nothing regarding permissions.
* Passes the "version" parameter to insertDB() so the copy will look like a new version in the log - should probably be changed or modified a bit for more broad usage...
*
* @param string $table Table name
* @param array $fieldArray Field array to insert as a record
* @param int $realPid The value of PID field. -1 is indication that we are creating a new version!
* @return int Returns the new ID of the record (if applicable)
*/
public function insertNewCopyVersion($table, $fieldArray, $realPid)
{
$id = StringUtility::getUniqueId('NEW');
// $fieldArray is set as current record.
// The point is that when new records are created as copies with flex type fields there might be a field containing information about which DataStructure to use and without that information the flexforms cannot be correctly processed.... This should be OK since the $checkValueRecord is used by the flexform evaluation only anyways...
$this->checkValue_currentRecord = $fieldArray;
// Makes sure that transformations aren't processed on the copy.
$backupDontProcessTransformations = $this->dontProcessTransformations;
$this->dontProcessTransformations = true;
// Traverse record and input-process each value:
foreach ($fieldArray as $field => $fieldValue) {
if (isset($GLOBALS['TCA'][$table]['columns'][$field])) {
// Evaluating the value.
$res = $this->checkValue($table, $field, $fieldValue, $id, 'new', $realPid, 0);
if (isset($res['value'])) {
$fieldArray[$field] = $res['value'];
}
}
}
// System fields being set:
if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {
$fieldArray[$GLOBALS['TCA'][$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
}
if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {
$fieldArray[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']] = $this->userid;
}
if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {
$fieldArray[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
}
// Finally, insert record:
$this->insertDB($table, $id, $fieldArray, true);
// Resets dontProcessTransformations to the previous state.
$this->dontProcessTransformations = $backupDontProcessTransformations;
// Return new id:
return $this->substNEWwithIDs[$id];
}