作者:RocKordie
项目:rn_bas
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;
}
作者:rickymathe
项目:TYPO3.CM
/**
* Type fetching method, based on the type that softRefParserObj returns
*
* @param array $value Reference properties
* @param string $type Current type
* @param string $key Validator hook name
* @return string fetched type
*/
public function fetchType($value, $type, $key)
{
if (StringUtility::beginswith(strtolower($value['tokenValue']), 'file:')) {
$type = 'file';
}
return $type;
}
作者:Gregp
项目:TYPO3.CM
/**
* 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;
}
作者:rickymathe
项目:TYPO3.CM
/**
* Unset all additional properties of test classes to help PHP
* garbage collection. This reduces memory footprint with lots
* of tests.
*
* If owerwriting tearDown() in test classes, please call
* parent::tearDown() at the end. Unsetting of own properties
* is not needed this way.
*
* @throws \RuntimeException
* @return void
*/
protected function tearDown()
{
// Unset properties of test classes to safe memory
$reflection = new \ReflectionObject($this);
foreach ($reflection->getProperties() as $property) {
$declaringClass = $property->getDeclaringClass()->getName();
if (!$property->isStatic() && $declaringClass !== \TYPO3\CMS\Core\Tests\UnitTestCase::class && $declaringClass !== \TYPO3\CMS\Core\Tests\BaseTestCase::class && strpos($property->getDeclaringClass()->getName(), 'PHPUnit_') !== 0) {
$propertyName = $property->getName();
unset($this->{$propertyName});
}
}
unset($reflection);
// Delete registered test files and directories
foreach ($this->testFilesToDelete as $absoluteFileName) {
$absoluteFileName = GeneralUtility::fixWindowsFilePath(PathUtility::getCanonicalPath($absoluteFileName));
if (!GeneralUtility::validPathStr($absoluteFileName)) {
throw new \RuntimeException('tearDown() cleanup: Filename contains illegal characters', 1410633087);
}
if (!StringUtility::beginsWith($absoluteFileName, PATH_site . 'typo3temp/')) {
throw new \RuntimeException('tearDown() cleanup: Files to delete must be within typo3temp/', 1410633412);
}
// file_exists returns false for links pointing to not existing targets, so handle links before next check.
if (@is_link($absoluteFileName) || @is_file($absoluteFileName)) {
unlink($absoluteFileName);
} elseif (@is_dir($absoluteFileName)) {
GeneralUtility::rmdir($absoluteFileName, true);
} else {
throw new \RuntimeException('tearDown() cleanup: File, link or directory does not exist', 1410633510);
}
}
$this->testFilesToDelete = array();
}
作者:smichaelse
项目:t3gravata
/**
* @param array|NULL $backendUser
* @param int $size
* @param bool $showIcon
* @return string
*/
public function render(array $backendUser = NULL, $size = 32, $showIcon = FALSE)
{
$size = (int) $size;
if (!is_array($backendUser)) {
$backendUser = $this->getBackendUser()->user;
}
$image = parent::render($backendUser, $size, $showIcon);
if (!StringUtility::beginsWith($image, '<span class="avatar"><span class="avatar-image"></span>') || empty($backendUser['email'])) {
return $image;
}
$cachedFilePath = PATH_site . 'typo3temp/t3gravatar/';
$cachedFileName = sha1($backendUser['email'] . $size) . '.jpg';
if (!file_exists($cachedFilePath . $cachedFileName)) {
$gravatar = 'https://www.gravatar.com/avatar/' . md5(strtolower($backendUser['email'])) . '?s=' . $size . '&d=404';
$gravatarImage = GeneralUtility::getUrl($gravatar);
if (empty($gravatarImage)) {
return $image;
}
GeneralUtility::writeFileToTypo3tempDir($cachedFileName, $gravatarImage);
}
// Icon
$icon = '';
if ($showIcon) {
$icon = '<span class="avatar-icon">' . IconUtility::getSpriteIconForRecord('be_users', $backendUser) . '</span>';
}
$relativeFilePath = PathUtility::getRelativePath(PATH_typo3, $cachedFilePath);
return '<span class="avatar"><span class="avatar-image">' . '<img src="' . $relativeFilePath . $cachedFileName . '" width="' . $size . '" height="' . $size . '" /></span>' . $icon . '</span>';
}
作者:Audibene-GMB
项目:TYPO3.CM
/**
* Resolve placeholders for input/text fields. Placeholders that are simple
* strings will be returned unmodified. Placeholders beginning with __row are
* being resolved, possibly traversing multiple tables.
*
* @param array $result
* @return array
*/
public function addData(array $result)
{
foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
// Placeholders are only valid for input and text type fields
if ($fieldConfig['config']['type'] !== 'input' && $fieldConfig['config']['type'] !== 'text' || !isset($fieldConfig['config']['placeholder'])) {
continue;
}
// Resolve __row|field type placeholders
if (StringUtility::beginsWith($fieldConfig['config']['placeholder'], '__row|')) {
// split field names into array and remove the __row indicator
$fieldNameArray = array_slice(GeneralUtility::trimExplode('|', $fieldConfig['config']['placeholder'], true), 1);
$result['processedTca']['columns'][$fieldName]['config']['placeholder'] = $this->getPlaceholderValue($fieldNameArray, $result);
}
// Resolve placeholders from language files
if (StringUtility::beginsWith($fieldConfig['config']['placeholder'], 'LLL:')) {
$result['processedTca']['columns'][$fieldName]['config']['placeholder'] = $this->getLanguageService()->sl($fieldConfig['config']['placeholder']);
}
// Remove empty placeholders
if (empty($fieldConfig['config']['placeholder'])) {
unset($result['processedTca']['columns'][$fieldName]['config']['placeholder']);
continue;
}
}
return $result;
}
作者:wmdbsystem
项目:mediac
/**
* 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;
}
作者:hlo
项目:TYPO3.CM
/**
* @param Icon $icon
* @param array $options
* @return string
* @throws \InvalidArgumentException
*/
protected function generateInlineMarkup(Icon $icon, array $options)
{
if (empty($options['source'])) {
throw new \InvalidArgumentException('The option "source" is required and must not be empty', 1440754980);
}
$source = $options['source'];
if (StringUtility::beginsWith($source, 'EXT:') || !StringUtility::beginsWith($source, '/')) {
$source = GeneralUtility::getFileAbsFileName($source);
}
return $this->getInlineSvg($source);
}
作者:rickymathe
项目:TYPO3.CM
/**
* @param Icon $icon
* @param array $options
* @return string
* @throws \InvalidArgumentException
*/
protected function generateMarkup(Icon $icon, array $options)
{
if (empty($options['source'])) {
throw new \InvalidArgumentException('[' . $icon->getIdentifier() . '] The option "source" is required and must not be empty', 1440754980);
}
$source = $options['source'];
if (StringUtility::beginsWith($source, 'EXT:') || !StringUtility::beginsWith($source, '/')) {
$source = GeneralUtility::getFileAbsFileName($source);
}
$source = PathUtility::getAbsoluteWebPath($source);
return '<img src="' . htmlspecialchars($source) . '" width="' . $icon->getDimension()->getWidth() . '" height="' . $icon->getDimension()->getHeight() . '" />';
}
作者:rickymathe
项目:TYPO3.CM
/**
* 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;
}
作者:c2p
项目:autoloade
/**
* Add the given icon to the TCA table type
*
* @param string $table
* @param string $type
* @param string $icon
*/
public static function addTcaTypeIcon($table, $type, $icon)
{
if (GeneralUtility::compat_version('7.0')) {
$fullIconPath = substr(PathUtility::getAbsoluteWebPath($icon), 1);
if (StringUtility::endsWith(strtolower($fullIconPath), 'svg')) {
$iconProviderClass = 'TYPO3\\CMS\\Core\\Imaging\\IconProvider\\SvgIconProvider';
} else {
$iconProviderClass = 'TYPO3\\CMS\\Core\\Imaging\\IconProvider\\BitmapIconProvider';
}
/** @var IconRegistry $iconRegistry */
$iconRegistry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\IconRegistry');
$iconIdentifier = 'tcarecords-' . $table . '-' . $type;
$iconRegistry->registerIcon($iconIdentifier, $iconProviderClass, ['source' => $fullIconPath]);
$GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes'][$type] = $iconIdentifier;
} else {
$fullIconPath = str_replace('../typo3/', '', $icon);
SpriteManager::addTcaTypeIcon('tt_content', $type, $fullIconPath);
}
}
作者:rickymathe
项目:TYPO3.CM
/**
* Return the default value of a field formatted to match the native MySQL SQL dialect
*
* @param array $fieldDefinition
* @return mixed
*/
protected function getNativeDefaultValue($fieldDefinition)
{
if (!$fieldDefinition['has_default']) {
$returnValue = null;
} elseif ($fieldDefinition['type'] === 'SERIAL' && substr($fieldDefinition['default_value'], 0, 7) === 'nextval') {
$returnValue = null;
} elseif ($fieldDefinition['type'] === 'varchar') {
// Strip character class and unquote string
if (StringUtility::beginsWith($fieldDefinition['default_value'], 'NULL::')) {
$returnValue = null;
} else {
$returnValue = str_replace("\\'", "'", preg_replace('/\'(.*)\'(::(?:character\\svarying|varchar|character|char|text)(?:\\(\\d+\\))?)?\\z/', '\\1', $fieldDefinition['default_value']));
}
} elseif (substr($fieldDefinition['type'], 0, 3) === 'int') {
$returnValue = (int) preg_replace('/^\\(?(\\-?\\d+)\\)?$/', '\\1', $fieldDefinition['default_value']);
} else {
$returnValue = $fieldDefinition['default_value'];
}
return $returnValue;
}
作者:rickymathe
项目:TYPO3.CM
/**
* @param array $data
* @return array
*/
protected function decryptDataArray(array $data)
{
foreach ($data as $key => $value) {
if (empty($value)) {
continue;
}
if (is_array($value)) {
$data[$key] = $this->decryptDataArray($value);
continue;
}
if (!StringUtility::beginsWith($value, 'rsa:')) {
continue;
}
$decryptedValue = $this->getBackend()->decrypt($this->getKey(), substr($value, 4));
if ($decryptedValue !== null) {
$data[$key] = $decryptedValue;
}
}
return $data;
}
作者:rickymathe
项目:TYPO3.CM
/**
* Determine which fields are required to render the placeholders and
* add those to the list of columns that must be processed by the next
* data providers.
*
* @param array $result
* @return array
*/
public function addData(array $result)
{
foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
// Placeholders are only valid for input and text type fields
if ($fieldConfig['config']['type'] !== 'input' && $fieldConfig['config']['type'] !== 'text' || !isset($fieldConfig['config']['placeholder'])) {
continue;
}
// Process __row|field type placeholders
if (StringUtility::beginsWith($fieldConfig['config']['placeholder'], '__row|')) {
// split field names into array and remove the __row indicator
$fieldNameArray = array_slice(GeneralUtility::trimExplode('|', $fieldConfig['config']['placeholder'], true), 1);
// only the first field is required to be processed as it's the one referring to
// the current record. All other columns will be resolved in a later pass through
// the related records.
if (!empty($fieldNameArray[0])) {
$result['columnsToProcess'][] = $fieldNameArray[0];
}
}
}
return $result;
}
作者:hlo
项目:TYPO3.CM
/**
* Generates the JumpURL for the given parameters.
*
* @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::processUrlModifiers()
* @param string $context The context in which the URL is generated (e.g. "typolink").
* @param string $url The URL that should be processed.
* @param array $configuration The link configuration.
* @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer The calling content object renderer.
* @param bool $keepProcessing If this is set to FALSE no further hooks will be processed after the current one.
* @return string
*/
public function process($context, $url, array $configuration, ContentObjectRenderer $contentObjectRenderer, &$keepProcessing)
{
if (!$this->isEnabled($context, $configuration)) {
return $url;
}
$this->contentObjectRenderer = $contentObjectRenderer;
// Strip the absRefPrefix from the URLs.
$urlPrefix = (string) $this->getTypoScriptFrontendController()->absRefPrefix;
if ($urlPrefix !== '' && StringUtility::beginsWith($url, $urlPrefix)) {
$url = substr($url, strlen($urlPrefix));
}
// Make sure the slashes in the file URL are not encoded.
if ($context === UrlProcessorInterface::CONTEXT_FILE) {
$url = str_replace('%2F', '/', rawurlencode(rawurldecode($url)));
}
$url = $this->build($url, isset($configuration['jumpurl.']) ? $configuration['jumpurl.'] : array());
// Now add the prefix again if it was not added by a typolink call already.
if ($urlPrefix !== '' && !StringUtility::beginsWith($url, $urlPrefix)) {
$url = $urlPrefix . $url;
}
return $url;
}
作者:rickymathe
项目:TYPO3.CM
/**
* @param string $status
* @param string $table
* @param int $id
* @param array $fieldArray
* @param DataHandler $parentObject
*/
public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $parentObject)
{
if ($table !== 'be_groups' || $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'] !== 'explicitAllow') {
return;
}
$backendUserGroup = BackendUtility::getRecord($table, $id, 'explicit_allowdeny');
$explicitAllowDenyFields = GeneralUtility::trimExplode(',', $backendUserGroup['explicit_allowdeny']);
foreach ($explicitAllowDenyFields as $value) {
if (StringUtility::beginsWith($value, 'tt_content:list_type:')) {
if (!in_array('tt_content:CType:list:ALLOW', $explicitAllowDenyFields, true)) {
/** @var $flashMessage FlashMessage */
$flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->sl('LLL:EXT:lang/locallang_core.xlf:error.backendUserGroupListTypeError.message'), $this->getLanguageService()->sl('LLL:EXT:lang/locallang_core.xlf:error.backendUserGroupListTypeError.header'), FlashMessage::WARNING, true);
/** @var $flashMessageService FlashMessageService */
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
/** @var $defaultFlashMessageQueue FlashMessageQueue */
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$defaultFlashMessageQueue->enqueue($flashMessage);
}
return;
}
}
}
作者:dachcom-digita
项目:TYPO3.CM
/**
* Checks if this is the handler for the given link
*
* The handler may store this information locally for later usage.
*
* @param array $linkParts Link parts as returned from TypoLinkCodecService
*
* @return bool
*/
public function canHandleLink(array $linkParts)
{
if (!$linkParts['url']) {
return false;
}
$url = rawurldecode($linkParts['url']);
if (StringUtility::beginsWith($url, 'file:') && !StringUtility::beginsWith($url, 'file://')) {
$rel = substr($url, 5);
try {
// resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
$fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
if (is_a($fileOrFolderObject, $this->expectedClass)) {
$this->linkParts = $linkParts;
$this->linkParts['url'] = $rel;
$this->linkParts['name'] = $fileOrFolderObject->getName();
return true;
}
} catch (FileDoesNotExistException $e) {
}
}
return false;
}
作者:franzhol
项目:TYPO3.CM
/**
* 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)) {
//.........这里部分代码省略.........
作者:grauru
项目:testgit_t3
/**
* Check if an update is possible at all
*
* @param string $version The target version number
* @return bool TRUE on success
* @throws \TYPO3\CMS\Install\Status\Exception
*/
public function checkPreConditions($version)
{
$success = true;
$messages = array();
/** @var StatusUtility $statusUtility */
$statusUtility = $this->objectManager->get(StatusUtility::class);
// Folder structure test: Update can be done only if folder structure returns no errors
/** @var $folderStructureFacade \TYPO3\CMS\Install\FolderStructure\StructureFacade */
$folderStructureFacade = $this->objectManager->get(DefaultFactory::class)->getStructure();
$folderStructureErrors = $statusUtility->filterBySeverity($folderStructureFacade->getStatus(), 'error');
$folderStructureWarnings = $statusUtility->filterBySeverity($folderStructureFacade->getStatus(), 'warning');
if (!empty($folderStructureErrors) || !empty($folderStructureWarnings)) {
$success = false;
/** @var $message StatusInterface */
$message = $this->objectManager->get(ErrorStatus::class);
$message->setTitle('Automatic TYPO3 CMS core update not possible: Folder structure has errors or warnings');
$message->setMessage('To perform an update, the folder structure of this TYPO3 CMS instance must' . ' stick to the conventions, or the update process could lead to unexpected' . ' results and may be hazardous to your system');
$messages[] = $message;
}
// No core update on windows
if (TYPO3_OS === 'WIN') {
$success = false;
/** @var $message StatusInterface */
$message = $this->objectManager->get(ErrorStatus::class);
$message->setTitle('Automatic TYPO3 CMS core update not possible: Update not supported on Windows OS');
$messages[] = $message;
}
if ($success) {
// Explicit write check to document root
$file = PATH_site . StringUtility::getUniqueId('install-core-update-test-');
$result = @touch($file);
if (!$result) {
$success = false;
/** @var $message StatusInterface */
$message = $this->objectManager->get(ErrorStatus::class);
$message->setTitle('Automatic TYPO3 CMS core update not possible: No write access to document root');
$message->setMessage('Could not write a file in path "' . PATH_site . '"!');
$messages[] = $message;
} else {
unlink($file);
}
if (!$this->checkCoreFilesAvailable($version)) {
// Explicit write check to upper directory of current core location
$coreLocation = @realPath($this->symlinkToCoreFiles . '/../');
$file = $coreLocation . '/' . StringUtility::getUniqueId('install-core-update-test-');
$result = @touch($file);
if (!$result) {
$success = false;
/** @var $message StatusInterface */
$message = $this->objectManager->get(ErrorStatus::class);
$message->setTitle('Automatic TYPO3 CMS core update not possible: No write access to TYPO3 CMS core location');
$message->setMessage('New TYPO3 CMS core should be installed in "' . $coreLocation . '", but this directory is not writable!');
$messages[] = $message;
} else {
unlink($file);
}
}
}
if ($success && !$this->coreVersionService->isInstalledVersionAReleasedVersion()) {
$success = false;
/** @var $message StatusInterface */
$message = $this->objectManager->get(ErrorStatus::class);
$message->setTitle('Automatic TYPO3 CMS core update not possible: You are running a development version of TYPO3');
$message->setMessage('Your current version is specified as ' . $this->coreVersionService->getInstalledVersion() . '.' . ' This is a development version and can not be updated automatically. If this is a "git"' . ' checkout, please update using git directly.');
$messages[] = $message;
}
$this->messages = $messages;
return $success;
}
作者:Audibene-GMB
项目:TYPO3.CM
/**
* Renders Content Elements from the tt_content table from page id
*
* @param int $id Page id
* @return string HTML for the listing
*/
public function getTable_tt_content($id)
{
$backendUser = $this->getBackendUser();
$this->pageinfo = BackendUtility::readPageAccess($this->id, $backendUser->getPagePermsClause($this->ext_CALC_PERMS));
$this->initializeLanguages();
$this->initializeClipboard();
$pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility::getRecordTitle('pages', BackendUtility::getRecordWSOL('pages', $id), true));
/** @var $pageRenderer PageRenderer */
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/DragDrop');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
$userCanEditPage = $this->ext_CALC_PERMS & Permission::PAGE_EDIT && !empty($this->id) && ($backendUser->isAdmin() || (int) $this->pageinfo['editlock'] === 0);
if ($this->tt_contentConfig['languageColsPointer'] > 0) {
$userCanEditPage = $this->getBackendUser()->check('tables_modify', 'pages_language_overlay');
}
if ($userCanEditPage) {
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', 'function(PageActions) {
PageActions.setPageId(' . (int) $this->id . ');
PageActions.setLanguageOverlayId(' . $this->tt_contentConfig['languageColsPointer'] . ');
PageActions.initializePageTitleRenaming();
}');
}
// Get labels for CTypes and tt_content element fields in general:
$this->CType_labels = array();
foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
$this->CType_labels[$val[1]] = $this->getLanguageService()->sL($val[0]);
}
$this->itemLabels = array();
foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
$this->itemLabels[$name] = $this->getLanguageService()->sL($val['label']);
}
$languageColumn = array();
$out = '';
// Setting language list:
$langList = $this->tt_contentConfig['sys_language_uid'];
if ($this->tt_contentConfig['languageMode']) {
if ($this->tt_contentConfig['languageColsPointer']) {
$langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
} else {
$langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
}
$languageColumn = array();
}
$langListArr = GeneralUtility::intExplode(',', $langList);
$defLanguageCount = array();
$defLangBinding = array();
// For each languages... :
// If not languageMode, then we'll only be through this once.
foreach ($langListArr as $lP) {
$lP = (int) $lP;
if (!isset($this->contentElementCache[$lP])) {
$this->contentElementCache[$lP] = array();
}
if (count($langListArr) === 1 || $lP === 0) {
$showLanguage = ' AND sys_language_uid IN (' . $lP . ',-1)';
} else {
$showLanguage = ' AND sys_language_uid=' . $lP;
}
$cList = explode(',', $this->tt_contentConfig['cols']);
$content = array();
$head = array();
// Select content records per column
$contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, array_values($cList), $showLanguage);
// For each column, render the content into a variable:
foreach ($cList as $key) {
if (!isset($this->contentElementCache[$lP][$key])) {
$this->contentElementCache[$lP][$key] = array();
}
if (!$lP) {
$defLanguageCount[$key] = array();
}
// Start wrapping div
$content[$key] .= '<div data-colpos="' . $key . '" data-language-uid="' . $lP . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $lP . ' t3-page-ce-wrapper';
if (empty($contentRecordsPerColumn[$key])) {
$content[$key] .= ' t3-page-ce-empty';
}
$content[$key] .= '">';
// Add new content at the top most position
$link = '';
if ($this->getPageLayoutController()->pageIsNotLockedForEditors() && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
$link = '<a href="#" onclick="' . htmlspecialchars($this->newContentElementOnClick($id, $key, $lP)) . '" title="' . $this->getLanguageService()->getLL('newContentElement', true) . '" class="btn btn-default btn-sm">' . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render() . ' ' . $this->getLanguageService()->getLL('content', true) . '</a>';
}
$content[$key] .= '
<div class="t3-page-ce t3js-page-ce" data-page="' . (int) $id . '" id="' . StringUtility::getUniqueId() . '">
<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id . '-' . StringUtility::getUniqueId() . '">' . $link . '</div>
<div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
</div>
';
$editUidList = '';
$rowArr = $contentRecordsPerColumn[$key];
$this->generateTtContentDataArray($rowArr);
foreach ((array) $rowArr as $rKey => $row) {
$this->contentElementCache[$lP][$key][$row['uid']] = $row;
if ($this->tt_contentConfig['languageMode']) {
//.........这里部分代码省略.........