@@ -19,47 +19,47 @@ |
||
| 19 | 19 | class DeleteButton extends AbstractComponentView |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Renders a "delete" button to be placed in the grid. |
|
| 24 | - * |
|
| 25 | - * @param Content $object |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public function render(Content $object = null) |
|
| 29 | - { |
|
| 30 | - $labelField = Tca::table($object->getDataType())->getLabelField(); |
|
| 31 | - $label = $object[$labelField] ? $object[$labelField] : $object->getUid(); |
|
| 22 | + /** |
|
| 23 | + * Renders a "delete" button to be placed in the grid. |
|
| 24 | + * |
|
| 25 | + * @param Content $object |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public function render(Content $object = null) |
|
| 29 | + { |
|
| 30 | + $labelField = Tca::table($object->getDataType())->getLabelField(); |
|
| 31 | + $label = $object[$labelField] ? $object[$labelField] : $object->getUid(); |
|
| 32 | 32 | |
| 33 | - return $this->makeLinkButton() |
|
| 34 | - ->setHref($this->getDeleteUri($object)) |
|
| 35 | - ->setDataAttributes([ |
|
| 36 | - 'uid' => $object->getUid(), |
|
| 37 | - 'toggle' => 'tooltip', |
|
| 38 | - 'label' => $label, |
|
| 39 | - ]) |
|
| 40 | - ->setClasses('btn-delete') |
|
| 41 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:delete')) |
|
| 42 | - ->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)) |
|
| 43 | - ->render(); |
|
| 44 | - } |
|
| 33 | + return $this->makeLinkButton() |
|
| 34 | + ->setHref($this->getDeleteUri($object)) |
|
| 35 | + ->setDataAttributes([ |
|
| 36 | + 'uid' => $object->getUid(), |
|
| 37 | + 'toggle' => 'tooltip', |
|
| 38 | + 'label' => $label, |
|
| 39 | + ]) |
|
| 40 | + ->setClasses('btn-delete') |
|
| 41 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:delete')) |
|
| 42 | + ->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)) |
|
| 43 | + ->render(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @param Content $object |
|
| 48 | - * @return string |
|
| 49 | - */ |
|
| 50 | - protected function getDeleteUri(Content $object) |
|
| 51 | - { |
|
| 52 | - $additionalParameters = array( |
|
| 53 | - $this->getModuleLoader()->getParameterPrefix() => array( |
|
| 54 | - 'controller' => 'Content', |
|
| 55 | - 'action' => 'delete', |
|
| 56 | - 'format' => 'json', |
|
| 57 | - 'matches' => array( |
|
| 58 | - 'uid' => $object->getUid(), |
|
| 59 | - ), |
|
| 60 | - ), |
|
| 61 | - ); |
|
| 62 | - return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
| 63 | - } |
|
| 46 | + /** |
|
| 47 | + * @param Content $object |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | + protected function getDeleteUri(Content $object) |
|
| 51 | + { |
|
| 52 | + $additionalParameters = array( |
|
| 53 | + $this->getModuleLoader()->getParameterPrefix() => array( |
|
| 54 | + 'controller' => 'Content', |
|
| 55 | + 'action' => 'delete', |
|
| 56 | + 'format' => 'json', |
|
| 57 | + 'matches' => array( |
|
| 58 | + 'uid' => $object->getUid(), |
|
| 59 | + ), |
|
| 60 | + ), |
|
| 61 | + ); |
|
| 62 | + return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | } |
@@ -22,109 +22,109 @@ |
||
| 22 | 22 | class NewButton extends AbstractComponentView |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Renders a "new" button to be placed in the doc header. |
|
| 27 | - * |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - public function render(): string |
|
| 31 | - { |
|
| 32 | - $output = ''; |
|
| 25 | + /** |
|
| 26 | + * Renders a "new" button to be placed in the doc header. |
|
| 27 | + * |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + public function render(): string |
|
| 31 | + { |
|
| 32 | + $output = ''; |
|
| 33 | 33 | |
| 34 | - // New button only for the current data type. |
|
| 35 | - if ($this->getModulePidService()->isConfiguredPidValid()) { |
|
| 36 | - $output = $this->makeLinkButton()->setHref($this->getNewUri()) |
|
| 37 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:newRecordGeneral')) |
|
| 38 | - ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
| 39 | - ->render(); |
|
| 40 | - } |
|
| 41 | - return $output; |
|
| 42 | - } |
|
| 34 | + // New button only for the current data type. |
|
| 35 | + if ($this->getModulePidService()->isConfiguredPidValid()) { |
|
| 36 | + $output = $this->makeLinkButton()->setHref($this->getNewUri()) |
|
| 37 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:newRecordGeneral')) |
|
| 38 | + ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
| 39 | + ->render(); |
|
| 40 | + } |
|
| 41 | + return $output; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Render a create URI given a data type. |
|
| 46 | - * |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 49 | - protected function getUriWizardNew(): string |
|
| 50 | - { |
|
| 51 | - // Return URL in any case. |
|
| 52 | - $arguments['returnUrl'] = $this->getModuleLoader()->getModuleUrl(); |
|
| 44 | + /** |
|
| 45 | + * Render a create URI given a data type. |
|
| 46 | + * |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | + protected function getUriWizardNew(): string |
|
| 50 | + { |
|
| 51 | + // Return URL in any case. |
|
| 52 | + $arguments['returnUrl'] = $this->getModuleLoader()->getModuleUrl(); |
|
| 53 | 53 | |
| 54 | - // Add possible id parameter |
|
| 55 | - if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 56 | - $arguments['id'] = GeneralUtility::_GP(Parameter::PID); |
|
| 57 | - } |
|
| 54 | + // Add possible id parameter |
|
| 55 | + if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 56 | + $arguments['id'] = GeneralUtility::_GP(Parameter::PID); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $uri = BackendUtility::getModuleUrl( |
|
| 60 | - 'db_new', |
|
| 61 | - $arguments |
|
| 62 | - ); |
|
| 59 | + $uri = BackendUtility::getModuleUrl( |
|
| 60 | + 'db_new', |
|
| 61 | + $arguments |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - return $uri; |
|
| 65 | - } |
|
| 64 | + return $uri; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Render a create URI given a data type. |
|
| 69 | - * |
|
| 70 | - * @return string |
|
| 71 | - */ |
|
| 72 | - protected function getNewUri(): string |
|
| 73 | - { |
|
| 74 | - $uri = BackendUtility::getModuleUrl( |
|
| 75 | - 'record_edit', |
|
| 76 | - array( |
|
| 77 | - $this->getNewParameterName() => 'new', |
|
| 78 | - 'returnUrl' => $this->getModuleLoader()->getModuleUrl() |
|
| 79 | - ) |
|
| 80 | - ); |
|
| 81 | - return $uri; |
|
| 82 | - } |
|
| 67 | + /** |
|
| 68 | + * Render a create URI given a data type. |
|
| 69 | + * |
|
| 70 | + * @return string |
|
| 71 | + */ |
|
| 72 | + protected function getNewUri(): string |
|
| 73 | + { |
|
| 74 | + $uri = BackendUtility::getModuleUrl( |
|
| 75 | + 'record_edit', |
|
| 76 | + array( |
|
| 77 | + $this->getNewParameterName() => 'new', |
|
| 78 | + 'returnUrl' => $this->getModuleLoader()->getModuleUrl() |
|
| 79 | + ) |
|
| 80 | + ); |
|
| 81 | + return $uri; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @return string |
|
| 86 | - */ |
|
| 87 | - protected function getNewParameterName(): string |
|
| 88 | - { |
|
| 89 | - return sprintf( |
|
| 90 | - 'edit[%s][%s]', |
|
| 91 | - $this->getModuleLoader()->getDataType(), |
|
| 92 | - $this->getStoragePid() |
|
| 93 | - ); |
|
| 94 | - } |
|
| 84 | + /** |
|
| 85 | + * @return string |
|
| 86 | + */ |
|
| 87 | + protected function getNewParameterName(): string |
|
| 88 | + { |
|
| 89 | + return sprintf( |
|
| 90 | + 'edit[%s][%s]', |
|
| 91 | + $this->getModuleLoader()->getDataType(), |
|
| 92 | + $this->getStoragePid() |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Return the default configured pid. |
|
| 98 | - * |
|
| 99 | - * @return int |
|
| 100 | - */ |
|
| 101 | - protected function getStoragePid(): int |
|
| 102 | - { |
|
| 103 | - if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 104 | - $pid = GeneralUtility::_GP(Parameter::PID); |
|
| 105 | - } elseif ((int)Tca::table()->get('rootLevel') === 1) { |
|
| 106 | - $pid = 0; |
|
| 107 | - } else { |
|
| 108 | - // Get configuration from User TSConfig if any |
|
| 109 | - $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->getModuleLoader()->getDataType()); |
|
| 110 | - $tsConfig = $this->getBackendUser()->getTSConfig($tsConfigPath); |
|
| 111 | - $pid = $tsConfig['value']; |
|
| 96 | + /** |
|
| 97 | + * Return the default configured pid. |
|
| 98 | + * |
|
| 99 | + * @return int |
|
| 100 | + */ |
|
| 101 | + protected function getStoragePid(): int |
|
| 102 | + { |
|
| 103 | + if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 104 | + $pid = GeneralUtility::_GP(Parameter::PID); |
|
| 105 | + } elseif ((int)Tca::table()->get('rootLevel') === 1) { |
|
| 106 | + $pid = 0; |
|
| 107 | + } else { |
|
| 108 | + // Get configuration from User TSConfig if any |
|
| 109 | + $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->getModuleLoader()->getDataType()); |
|
| 110 | + $tsConfig = $this->getBackendUser()->getTSConfig($tsConfigPath); |
|
| 111 | + $pid = $tsConfig['value']; |
|
| 112 | 112 | |
| 113 | - // Get pid from Module Loader |
|
| 114 | - if (null === $pid) { |
|
| 115 | - $pid = $this->getModuleLoader()->getDefaultPid(); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - return (int)$pid; |
|
| 119 | - } |
|
| 113 | + // Get pid from Module Loader |
|
| 114 | + if (null === $pid) { |
|
| 115 | + $pid = $this->getModuleLoader()->getDefaultPid(); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + return (int)$pid; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * @return ModulePidService|object |
|
| 123 | - */ |
|
| 124 | - public function getModulePidService() |
|
| 125 | - { |
|
| 126 | - /** @var ModulePidService $modulePidService */ |
|
| 127 | - return GeneralUtility::makeInstance(ModulePidService::class); |
|
| 128 | - } |
|
| 121 | + /** |
|
| 122 | + * @return ModulePidService|object |
|
| 123 | + */ |
|
| 124 | + public function getModulePidService() |
|
| 125 | + { |
|
| 126 | + /** @var ModulePidService $modulePidService */ |
|
| 127 | + return GeneralUtility::makeInstance(ModulePidService::class); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | } |
@@ -20,35 +20,35 @@ |
||
| 20 | 20 | class EditButton extends AbstractComponentView |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Renders a "edit" button to be placed in the grid. |
|
| 25 | - * |
|
| 26 | - * @param Content $object |
|
| 27 | - * @return string |
|
| 28 | - */ |
|
| 29 | - public function render(Content $object = null) |
|
| 30 | - { |
|
| 31 | - $editUri = $this->getUriRenderer()->render($object); |
|
| 23 | + /** |
|
| 24 | + * Renders a "edit" button to be placed in the grid. |
|
| 25 | + * |
|
| 26 | + * @param Content $object |
|
| 27 | + * @return string |
|
| 28 | + */ |
|
| 29 | + public function render(Content $object = null) |
|
| 30 | + { |
|
| 31 | + $editUri = $this->getUriRenderer()->render($object); |
|
| 32 | 32 | |
| 33 | - return $this->makeLinkButton() |
|
| 34 | - ->setHref($editUri) |
|
| 35 | - ->setDataAttributes([ |
|
| 36 | - 'uid' => $object->getUid(), |
|
| 37 | - 'toggle' => 'tooltip', |
|
| 38 | - ]) |
|
| 39 | - ->setClasses('btn-edit') |
|
| 40 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit')) |
|
| 41 | - ->setIcon($this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL)) |
|
| 42 | - ->render(); |
|
| 43 | - } |
|
| 33 | + return $this->makeLinkButton() |
|
| 34 | + ->setHref($editUri) |
|
| 35 | + ->setDataAttributes([ |
|
| 36 | + 'uid' => $object->getUid(), |
|
| 37 | + 'toggle' => 'tooltip', |
|
| 38 | + ]) |
|
| 39 | + ->setClasses('btn-edit') |
|
| 40 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit')) |
|
| 41 | + ->setIcon($this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL)) |
|
| 42 | + ->render(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @return EditUri |
|
| 47 | - * @throws \InvalidArgumentException |
|
| 48 | - */ |
|
| 49 | - protected function getUriRenderer() |
|
| 50 | - { |
|
| 51 | - return GeneralUtility::makeInstance(EditUri::class); |
|
| 52 | - } |
|
| 45 | + /** |
|
| 46 | + * @return EditUri |
|
| 47 | + * @throws \InvalidArgumentException |
|
| 48 | + */ |
|
| 49 | + protected function getUriRenderer() |
|
| 50 | + { |
|
| 51 | + return GeneralUtility::makeInstance(EditUri::class); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | } |
@@ -26,628 +26,628 @@ |
||
| 26 | 26 | class Row extends AbstractComponentView |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - protected $columns = []; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Registry for storing variable values and speed up the processing. |
|
| 36 | - * |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 39 | - protected $variables = []; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param array $columns |
|
| 43 | - */ |
|
| 44 | - public function __construct(array $columns = []) |
|
| 45 | - { |
|
| 46 | - $this->columns = $columns; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Render a row to be displayed in the Grid given an Content Object. |
|
| 51 | - * |
|
| 52 | - * @param Content $object |
|
| 53 | - * @param int $rowIndex |
|
| 54 | - * @return array |
|
| 55 | - * @throws \Exception |
|
| 56 | - */ |
|
| 57 | - public function render(Content $object = null, $rowIndex = 0) |
|
| 58 | - { |
|
| 59 | - |
|
| 60 | - // Initialize returned array |
|
| 61 | - $output = []; |
|
| 62 | - |
|
| 63 | - foreach (Tca::grid()->getFields() as $fieldNameAndPath => $configuration) { |
|
| 64 | - |
|
| 65 | - $value = ''; // default is empty at first. |
|
| 66 | - |
|
| 67 | - $this->computeVariables($object, $fieldNameAndPath); |
|
| 68 | - |
|
| 69 | - // Only compute the value if it is going to be shown in the Grid. Lost of time otherwise! |
|
| 70 | - if (in_array($fieldNameAndPath, $this->columns)) { |
|
| 71 | - |
|
| 72 | - // Fetch value |
|
| 73 | - if (Tca::grid()->hasRenderers($fieldNameAndPath)) { |
|
| 74 | - |
|
| 75 | - $value = ''; |
|
| 76 | - $renderers = Tca::grid()->getRenderers($fieldNameAndPath); |
|
| 77 | - |
|
| 78 | - // if is relation has one |
|
| 79 | - foreach ($renderers as $rendererClassName => $rendererConfiguration) { |
|
| 80 | - |
|
| 81 | - /** @var $rendererObject \Fab\Vidi\Grid\ColumnRendererInterface */ |
|
| 82 | - $rendererObject = GeneralUtility::makeInstance($rendererClassName); |
|
| 83 | - $value .= $rendererObject |
|
| 84 | - ->setObject($object) |
|
| 85 | - ->setFieldName($fieldNameAndPath) |
|
| 86 | - ->setRowIndex($rowIndex) |
|
| 87 | - ->setFieldConfiguration($configuration) |
|
| 88 | - ->setGridRendererConfiguration($rendererConfiguration) |
|
| 89 | - ->render(); |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - $value = $this->resolveValue($object, $fieldNameAndPath); |
|
| 93 | - $value = $this->processValue($value, $object, $fieldNameAndPath); // post resolve processing. |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // Possible formatting given by configuration. @see TCA['grid'] |
|
| 97 | - $value = $this->formatValue($value, $configuration); |
|
| 98 | - |
|
| 99 | - // Here, there is the chance to further "decorate" the value for inline editing, localization, ... |
|
| 100 | - if ($this->willBeEnriched()) { |
|
| 101 | - |
|
| 102 | - $localizedStructure = $this->initializeLocalizedStructure($value); |
|
| 103 | - |
|
| 104 | - if ($this->isEditable()) { |
|
| 105 | - $localizedStructure = $this->addEditableMarkup($localizedStructure); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - if ($this->isLocalized()) { |
|
| 109 | - $localizedStructure = $this->addLocalizationMarkup($localizedStructure); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - if ($this->hasIcon()) { |
|
| 113 | - $localizedStructure = $this->addSpriteIconMarkup($localizedStructure); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $value = $this->flattenStructure($localizedStructure); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // Final wrap given by configuration. @see TCA['grid'] |
|
| 120 | - $value = $this->wrapValue($value, $configuration); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $output[$this->getFieldName()] = $value; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $output['DT_RowId'] = 'row-' . $object->getUid(); |
|
| 127 | - $output['DT_RowClass'] = sprintf('%s_%s', $object->getDataType(), $object->getUid()); |
|
| 128 | - |
|
| 129 | - return $output; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Flatten the localized structure to render the final value |
|
| 134 | - * |
|
| 135 | - * @param array $localizedStructure |
|
| 136 | - * @return string |
|
| 137 | - */ |
|
| 138 | - protected function flattenStructure(array $localizedStructure) |
|
| 139 | - { |
|
| 140 | - |
|
| 141 | - // Flatten the structure. |
|
| 142 | - $value = ''; |
|
| 143 | - foreach ($localizedStructure as $structure) { |
|
| 144 | - $value .= sprintf('<div class="%s">%s</div>', |
|
| 145 | - $structure['status'] !== LocalizationStatus::LOCALIZED ? 'invisible' : '', |
|
| 146 | - $structure['value'] |
|
| 147 | - ); |
|
| 148 | - } |
|
| 149 | - return $value; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Store some often used variable values and speed up the processing. |
|
| 154 | - * |
|
| 155 | - * @param Content $object |
|
| 156 | - * @param string $fieldNameAndPath |
|
| 157 | - * @return void |
|
| 158 | - */ |
|
| 159 | - protected function computeVariables(Content $object, $fieldNameAndPath) |
|
| 160 | - { |
|
| 161 | - $this->variables = []; |
|
| 162 | - $this->variables['dataType'] = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
| 163 | - $this->variables['fieldName'] = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 164 | - $this->variables['fieldNameAndPath'] = $fieldNameAndPath; |
|
| 165 | - $this->variables['object'] = $object; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Tell whether the object will be decorated / wrapped such as |
|
| 170 | - * |
|
| 171 | - * @param string $value |
|
| 172 | - * @return array |
|
| 173 | - */ |
|
| 174 | - protected function initializeLocalizedStructure($value) |
|
| 175 | - { |
|
| 176 | - |
|
| 177 | - $localizedStructure[] = [ |
|
| 178 | - 'value' => empty($value) && $this->isEditable() ? $this->getEmptyValuePlaceholder() : $value, |
|
| 179 | - 'status' => empty($value) ? LocalizationStatus::EMPTY_VALUE : LocalizationStatus::LOCALIZED, |
|
| 180 | - 'language' => 0, |
|
| 181 | - 'languageFlag' => $defaultLanguage = $this->getLanguageService()->getDefaultFlag(), |
|
| 182 | - ]; |
|
| 183 | - |
|
| 184 | - if ($this->isLocalized()) { |
|
| 185 | - |
|
| 186 | - foreach ($this->getLanguageService()->getLanguages() as $language) { |
|
| 187 | - |
|
| 188 | - // Make sure the language is allowed for the current Backend User. |
|
| 189 | - if ($this->isLanguageAllowedForBackendUser($language)) { |
|
| 190 | - |
|
| 191 | - $resolvedObject = $this->getResolvedObject(); |
|
| 192 | - $fieldName = $this->getFieldName(); |
|
| 193 | - |
|
| 194 | - if ($this->getLanguageService()->hasLocalization($resolvedObject, $language['uid'])) { |
|
| 195 | - $localizedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedObject, $language['uid'], $fieldName); |
|
| 196 | - $status = LocalizationStatus::LOCALIZED; |
|
| 197 | - |
|
| 198 | - // Replace blank value by something more meaningful for the End User. |
|
| 199 | - if (empty($localizedValue)) { |
|
| 200 | - $status = LocalizationStatus::EMPTY_VALUE; |
|
| 201 | - $localizedValue = $this->isEditable() ? $this->getEmptyValuePlaceholder() : ''; |
|
| 202 | - } |
|
| 203 | - } else { |
|
| 204 | - $localizedValue = sprintf('<a href="%s" style="color: black">%s</a>', |
|
| 205 | - $this->getLocalizedUri($language['uid']), |
|
| 206 | - $this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:create_translation') |
|
| 207 | - ); |
|
| 208 | - $status = LocalizationStatus::NOT_YET_LOCALIZED; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - // Feed structure. |
|
| 212 | - $localizedStructure[] = [ |
|
| 213 | - 'value' => $localizedValue, |
|
| 214 | - 'status' => $status, |
|
| 215 | - 'language' => (int)$language['uid'], |
|
| 216 | - 'languageFlag' => $language['flag'], |
|
| 217 | - ]; |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - return $localizedStructure; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * @param array $language |
|
| 227 | - * @return bool |
|
| 228 | - */ |
|
| 229 | - protected function isLanguageAllowedForBackendUser(array $language) |
|
| 230 | - { |
|
| 231 | - return $this->getBackendUser()->checkLanguageAccess($language['uid']); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * Returns a placeholder when the value is empty. |
|
| 236 | - * |
|
| 237 | - * @return string |
|
| 238 | - */ |
|
| 239 | - protected function getEmptyValuePlaceholder() |
|
| 240 | - { |
|
| 241 | - return sprintf('<i>%s</i>', |
|
| 242 | - $this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:start_editing') |
|
| 243 | - ); |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * Tell whether the object will be decorated (or wrapped) for inline editing, localization purpose. |
|
| 248 | - * |
|
| 249 | - * @return bool |
|
| 250 | - */ |
|
| 251 | - protected function willBeEnriched() |
|
| 252 | - { |
|
| 253 | - |
|
| 254 | - $willBeEnriched = false; |
|
| 255 | - |
|
| 256 | - if ($this->fieldExists()) { |
|
| 257 | - $willBeEnriched = $this->isEditable() || $this->hasIcon() || $this->isLocalized(); |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - return $willBeEnriched; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * Tell whether the field in the context will be prepended by an icon. |
|
| 265 | - * |
|
| 266 | - * @return bool |
|
| 267 | - */ |
|
| 268 | - protected function hasIcon() |
|
| 269 | - { |
|
| 270 | - $dataType = $this->getDataType(); |
|
| 271 | - return Tca::table($dataType)->getLabelField() === $this->getFieldName(); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Tell whether the field in the context will be prepended by an icon. |
|
| 276 | - * |
|
| 277 | - * @return bool |
|
| 278 | - */ |
|
| 279 | - protected function isLocalized() |
|
| 280 | - { |
|
| 281 | - $object = $this->getObject(); |
|
| 282 | - $fieldName = $this->getFieldName(); |
|
| 283 | - $dataType = $this->getDataType(); |
|
| 284 | - $fieldNameAndPath = $this->getFieldNameAndPath(); |
|
| 285 | - |
|
| 286 | - return $this->getLanguageService()->hasLanguages() |
|
| 287 | - && Tca::grid($object)->isLocalized($fieldNameAndPath) |
|
| 288 | - && Tca::table($dataType)->field($fieldName)->isLocalized(); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Add some markup to have the content editable in the Grid. |
|
| 293 | - * |
|
| 294 | - * @param array $localizedStructure |
|
| 295 | - * @return array |
|
| 296 | - */ |
|
| 297 | - protected function addEditableMarkup(array $localizedStructure) |
|
| 298 | - { |
|
| 299 | - |
|
| 300 | - $dataType = $this->getDataType(); |
|
| 301 | - $fieldName = $this->getFieldName(); |
|
| 302 | - |
|
| 303 | - foreach ($localizedStructure as $index => $structure) { |
|
| 304 | - if ($structure['status'] !== LocalizationStatus::NOT_YET_LOCALIZED) { |
|
| 305 | - $localizedStructure[$index]['value'] = sprintf('<span class="%s" data-language="%s">%s</span>', |
|
| 306 | - Tca::table($dataType)->field($fieldName)->isTextArea() ? 'editable-textarea' : 'editable-textfield', |
|
| 307 | - $structure['language'], |
|
| 308 | - $structure['value'] |
|
| 309 | - ); |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - return $localizedStructure; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * Add some markup related to the localization. |
|
| 317 | - * |
|
| 318 | - * @param array $localizedStructure |
|
| 319 | - * @return array |
|
| 320 | - */ |
|
| 321 | - protected function addLocalizationMarkup(array $localizedStructure) |
|
| 322 | - { |
|
| 323 | - |
|
| 324 | - foreach ($localizedStructure as $index => $structure) { |
|
| 325 | - |
|
| 326 | - $localizedStructure[$index]['value'] = sprintf('<span>%s %s</span>', |
|
| 327 | - empty($structure['languageFlag']) ? '' : $this->getIconFactory()->getIcon('flags-' . $structure['languageFlag'], Icon::SIZE_SMALL), |
|
| 328 | - $structure['value'] |
|
| 329 | - ); |
|
| 330 | - } |
|
| 331 | - return $localizedStructure; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - /** |
|
| 335 | - * Add some markup related to the prepended icon. |
|
| 336 | - * |
|
| 337 | - * @param array $localizedStructure |
|
| 338 | - * @return array |
|
| 339 | - */ |
|
| 340 | - protected function addSpriteIconMarkup(array $localizedStructure) |
|
| 341 | - { |
|
| 342 | - |
|
| 343 | - $object = $this->getObject(); |
|
| 344 | - |
|
| 345 | - foreach ($localizedStructure as $index => $structure) { |
|
| 346 | - |
|
| 347 | - $recordData = []; |
|
| 348 | - |
|
| 349 | - $enablesMethods = array('Hidden', 'Deleted', 'StartTime', 'EndTime'); |
|
| 350 | - foreach ($enablesMethods as $enableMethod) { |
|
| 351 | - |
|
| 352 | - $methodName = 'get' . $enableMethod . 'Field'; |
|
| 353 | - |
|
| 354 | - // Fetch possible hidden filed. |
|
| 355 | - $enableField = Tca::table($object)->$methodName(); |
|
| 356 | - if ($enableField) { |
|
| 357 | - $recordData[$enableField] = $object[$enableField]; |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - // Get Enable Fields of the object to render the sprite with overlays. |
|
| 362 | - $localizedStructure[$index]['value'] = sprintf('%s %s', |
|
| 363 | - $this->getIconFactory()->getIconForRecord($object->getDataType(), $recordData, Icon::SIZE_SMALL), |
|
| 364 | - $structure['value'] |
|
| 365 | - ); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - return $localizedStructure; |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * Return whether the field given by the context is editable. |
|
| 373 | - * |
|
| 374 | - * @return boolean |
|
| 375 | - */ |
|
| 376 | - protected function isEditable() |
|
| 377 | - { |
|
| 378 | - $fieldNameAndPath = $this->getFieldNameAndPath(); |
|
| 379 | - $dataType = $this->getDataType(); |
|
| 380 | - $fieldName = $this->getFieldName(); |
|
| 381 | - |
|
| 382 | - return Tca::grid()->isEditable($fieldNameAndPath) |
|
| 383 | - && Tca::table($dataType)->hasField($fieldName) |
|
| 384 | - && Tca::table($dataType)->field($fieldName)->hasNoRelation(); // relation are editable through Renderers only. |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * Return the appropriate URI to create the translation. |
|
| 389 | - * |
|
| 390 | - * @param int $language |
|
| 391 | - * @return string |
|
| 392 | - */ |
|
| 393 | - protected function getLocalizedUri($language) |
|
| 394 | - { |
|
| 395 | - |
|
| 396 | - // Transmit recursive selection parameter. |
|
| 397 | - $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
| 398 | - $parameters = GeneralUtility::_GP($parameterPrefix); |
|
| 399 | - |
|
| 400 | - $additionalParameters = array( |
|
| 401 | - $this->getModuleLoader()->getParameterPrefix() => array( |
|
| 402 | - 'controller' => 'Content', |
|
| 403 | - 'action' => 'localize', |
|
| 404 | - 'format' => 'json', |
|
| 405 | - 'hasRecursiveSelection' => isset($parameters['hasRecursiveSelection']) ? (int)$parameters['hasRecursiveSelection'] : 0, |
|
| 406 | - 'fieldNameAndPath' => $this->getFieldNameAndPath(), |
|
| 407 | - 'language' => $language, |
|
| 408 | - 'matches' => array( |
|
| 409 | - 'uid' => $this->getObject()->getUid(), |
|
| 410 | - ), |
|
| 411 | - ), |
|
| 412 | - ); |
|
| 413 | - |
|
| 414 | - return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * Compute the value for the Content object according to a field name. |
|
| 419 | - * |
|
| 420 | - * @param Content $object |
|
| 421 | - * @param string $fieldNameAndPath |
|
| 422 | - * @return string |
|
| 423 | - */ |
|
| 424 | - protected function resolveValue(Content $object, $fieldNameAndPath) |
|
| 425 | - { |
|
| 426 | - |
|
| 427 | - // Get the first part of the field name and |
|
| 428 | - $fieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); |
|
| 429 | - |
|
| 430 | - $value = $object[$fieldName]; |
|
| 431 | - |
|
| 432 | - // Relation but contains no data. |
|
| 433 | - if (is_array($value) && empty($value)) { |
|
| 434 | - $value = ''; |
|
| 435 | - } elseif ($value instanceof Content) { |
|
| 436 | - |
|
| 437 | - $fieldNameOfForeignTable = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 438 | - |
|
| 439 | - // true means the field name does not contains a path. "title" vs "metadata.title" |
|
| 440 | - // Fetch the default label |
|
| 441 | - if ($fieldNameOfForeignTable === $fieldName) { |
|
| 442 | - $foreignTable = Tca::table($object->getDataType())->field($fieldName)->getForeignTable(); |
|
| 443 | - $fieldNameOfForeignTable = Tca::table($foreignTable)->getLabelField(); |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - $value = $object[$fieldName][$fieldNameOfForeignTable]; |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - return $value; |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * Check whether a string contains HTML tags. |
|
| 454 | - * |
|
| 455 | - * @param string $string the content to be analyzed |
|
| 456 | - * @return boolean |
|
| 457 | - */ |
|
| 458 | - protected function hasHtml($string) |
|
| 459 | - { |
|
| 460 | - $result = false; |
|
| 461 | - |
|
| 462 | - // We compare the length of the string with html tags and without html tags. |
|
| 463 | - if (strlen($string) !== strlen(strip_tags($string))) { |
|
| 464 | - $result = true; |
|
| 465 | - } |
|
| 466 | - return $result; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - /** |
|
| 470 | - * Check whether a string contains potential XSS. |
|
| 471 | - * |
|
| 472 | - * @param string $string the content to be analyzed |
|
| 473 | - * @return boolean |
|
| 474 | - */ |
|
| 475 | - protected function isClean($string) |
|
| 476 | - { |
|
| 477 | - |
|
| 478 | - // @todo implement me! |
|
| 479 | - $result = true; |
|
| 480 | - return $result; |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * Process the value |
|
| 485 | - * |
|
| 486 | - * @todo implement me as a processor chain to be cleaner implementation wise. Look out at the performance however! |
|
| 487 | - * e.g DefaultValueGridProcessor, TextAreaGridProcessor, ... |
|
| 488 | - * |
|
| 489 | - * @param string $value |
|
| 490 | - * @param Content $object |
|
| 491 | - * @param string $fieldNameAndPath |
|
| 492 | - * @return string |
|
| 493 | - * @throws InvalidKeyInArrayException |
|
| 494 | - */ |
|
| 495 | - protected function processValue($value, Content $object, $fieldNameAndPath) |
|
| 496 | - { |
|
| 497 | - |
|
| 498 | - // Set default value if $field name correspond to the label of the table |
|
| 499 | - $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 500 | - if (Tca::table($object->getDataType())->getLabelField() === $fieldName && empty($value)) { |
|
| 501 | - $value = sprintf('[%s]', $this->getLabelService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title')); |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - // Sanitize the value in case of "select" or "radio button". |
|
| 505 | - if (is_scalar($value)) { |
|
| 506 | - $fieldType = Tca::table($object->getDataType())->field($fieldNameAndPath)->getType(); |
|
| 507 | - if ($fieldType !== FieldType::TEXTAREA) { |
|
| 508 | - $value = htmlspecialchars($value); |
|
| 509 | - } elseif ($fieldType === FieldType::TEXTAREA && !$this->isClean($value)) { |
|
| 510 | - $value = htmlspecialchars($value); // Avoid bad surprise, converts characters to HTML. |
|
| 511 | - } elseif ($fieldType === FieldType::TEXTAREA && !$this->hasHtml($value)) { |
|
| 512 | - $value = nl2br($value); |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - return $value; |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - /** |
|
| 520 | - * Possible value formatting. |
|
| 521 | - * |
|
| 522 | - * @param string $value |
|
| 523 | - * @param array $configuration |
|
| 524 | - * @return string |
|
| 525 | - * @throws \InvalidArgumentException |
|
| 526 | - */ |
|
| 527 | - protected function formatValue($value, array $configuration) |
|
| 528 | - { |
|
| 529 | - if (empty($configuration['format'])) { |
|
| 530 | - return $value; |
|
| 531 | - } |
|
| 532 | - $className = $configuration['format']; |
|
| 533 | - |
|
| 534 | - /** @var FormatterInterface $formatter */ |
|
| 535 | - $formatter = GeneralUtility::makeInstance($className); |
|
| 536 | - $value = $formatter->format($value); |
|
| 537 | - |
|
| 538 | - return $value; |
|
| 539 | - } |
|
| 540 | - |
|
| 541 | - /** |
|
| 542 | - * Possible value wrapping. |
|
| 543 | - * |
|
| 544 | - * @param string $value |
|
| 545 | - * @param array $configuration |
|
| 546 | - * @return string |
|
| 547 | - */ |
|
| 548 | - protected function wrapValue($value, array $configuration) |
|
| 549 | - { |
|
| 550 | - if (!empty($configuration['wrap'])) { |
|
| 551 | - $parts = explode('|', $configuration['wrap']); |
|
| 552 | - $value = implode($value, $parts); |
|
| 553 | - } |
|
| 554 | - return $value; |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - /** |
|
| 558 | - * Tell whether the field in the context really exists. |
|
| 559 | - * |
|
| 560 | - * @return bool |
|
| 561 | - */ |
|
| 562 | - protected function fieldExists() |
|
| 563 | - { |
|
| 564 | - if ($this->variables['hasField'] === null) { |
|
| 565 | - $dataType = $this->getDataType(); |
|
| 566 | - $fieldName = $this->getFieldName(); |
|
| 567 | - $this->variables['hasField'] = Tca::table($dataType)->hasField($fieldName); |
|
| 568 | - } |
|
| 569 | - return $this->variables['hasField']; |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - /** |
|
| 573 | - * @return string |
|
| 574 | - */ |
|
| 575 | - protected function getDataType() |
|
| 576 | - { |
|
| 577 | - return $this->variables['dataType']; |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - /** |
|
| 581 | - * @return string |
|
| 582 | - */ |
|
| 583 | - protected function getFieldName() |
|
| 584 | - { |
|
| 585 | - return $this->variables['fieldName']; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * @return string |
|
| 590 | - */ |
|
| 591 | - protected function getFieldNameAndPath() |
|
| 592 | - { |
|
| 593 | - return $this->variables['fieldNameAndPath']; |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - /** |
|
| 597 | - * @return Content |
|
| 598 | - */ |
|
| 599 | - protected function getObject() |
|
| 600 | - { |
|
| 601 | - return $this->variables['object']; |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - /** |
|
| 605 | - * @return Content |
|
| 606 | - * @throws \InvalidArgumentException |
|
| 607 | - */ |
|
| 608 | - protected function getResolvedObject() |
|
| 609 | - { |
|
| 610 | - if (empty($this->variables['resolvedObject'])) { |
|
| 611 | - $object = $this->getObject(); |
|
| 612 | - $fieldNameAndPath = $this->getFieldNameAndPath(); |
|
| 613 | - $this->variables['resolvedObject'] = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath); |
|
| 614 | - } |
|
| 615 | - return $this->variables['resolvedObject']; |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - /** |
|
| 619 | - * @return FieldPathResolver|object |
|
| 620 | - * @throws \InvalidArgumentException |
|
| 621 | - */ |
|
| 622 | - protected function getFieldPathResolver() |
|
| 623 | - { |
|
| 624 | - return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - /** |
|
| 628 | - * @return ContentObjectResolver|object |
|
| 629 | - * @throws \InvalidArgumentException |
|
| 630 | - */ |
|
| 631 | - protected function getContentObjectResolver() |
|
| 632 | - { |
|
| 633 | - return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - /** |
|
| 637 | - * @return \TYPO3\CMS\Core\Localization\LanguageService |
|
| 638 | - */ |
|
| 639 | - protected function getLabelService() |
|
| 640 | - { |
|
| 641 | - return $GLOBALS['LANG']; |
|
| 642 | - } |
|
| 643 | - |
|
| 644 | - /** |
|
| 645 | - * @return LanguageService|object |
|
| 646 | - * @throws \InvalidArgumentException |
|
| 647 | - */ |
|
| 648 | - protected function getLanguageService() |
|
| 649 | - { |
|
| 650 | - return GeneralUtility::makeInstance(LanguageService::class); |
|
| 651 | - } |
|
| 29 | + /** |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + protected $columns = []; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Registry for storing variable values and speed up the processing. |
|
| 36 | + * |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | + protected $variables = []; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param array $columns |
|
| 43 | + */ |
|
| 44 | + public function __construct(array $columns = []) |
|
| 45 | + { |
|
| 46 | + $this->columns = $columns; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Render a row to be displayed in the Grid given an Content Object. |
|
| 51 | + * |
|
| 52 | + * @param Content $object |
|
| 53 | + * @param int $rowIndex |
|
| 54 | + * @return array |
|
| 55 | + * @throws \Exception |
|
| 56 | + */ |
|
| 57 | + public function render(Content $object = null, $rowIndex = 0) |
|
| 58 | + { |
|
| 59 | + |
|
| 60 | + // Initialize returned array |
|
| 61 | + $output = []; |
|
| 62 | + |
|
| 63 | + foreach (Tca::grid()->getFields() as $fieldNameAndPath => $configuration) { |
|
| 64 | + |
|
| 65 | + $value = ''; // default is empty at first. |
|
| 66 | + |
|
| 67 | + $this->computeVariables($object, $fieldNameAndPath); |
|
| 68 | + |
|
| 69 | + // Only compute the value if it is going to be shown in the Grid. Lost of time otherwise! |
|
| 70 | + if (in_array($fieldNameAndPath, $this->columns)) { |
|
| 71 | + |
|
| 72 | + // Fetch value |
|
| 73 | + if (Tca::grid()->hasRenderers($fieldNameAndPath)) { |
|
| 74 | + |
|
| 75 | + $value = ''; |
|
| 76 | + $renderers = Tca::grid()->getRenderers($fieldNameAndPath); |
|
| 77 | + |
|
| 78 | + // if is relation has one |
|
| 79 | + foreach ($renderers as $rendererClassName => $rendererConfiguration) { |
|
| 80 | + |
|
| 81 | + /** @var $rendererObject \Fab\Vidi\Grid\ColumnRendererInterface */ |
|
| 82 | + $rendererObject = GeneralUtility::makeInstance($rendererClassName); |
|
| 83 | + $value .= $rendererObject |
|
| 84 | + ->setObject($object) |
|
| 85 | + ->setFieldName($fieldNameAndPath) |
|
| 86 | + ->setRowIndex($rowIndex) |
|
| 87 | + ->setFieldConfiguration($configuration) |
|
| 88 | + ->setGridRendererConfiguration($rendererConfiguration) |
|
| 89 | + ->render(); |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + $value = $this->resolveValue($object, $fieldNameAndPath); |
|
| 93 | + $value = $this->processValue($value, $object, $fieldNameAndPath); // post resolve processing. |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // Possible formatting given by configuration. @see TCA['grid'] |
|
| 97 | + $value = $this->formatValue($value, $configuration); |
|
| 98 | + |
|
| 99 | + // Here, there is the chance to further "decorate" the value for inline editing, localization, ... |
|
| 100 | + if ($this->willBeEnriched()) { |
|
| 101 | + |
|
| 102 | + $localizedStructure = $this->initializeLocalizedStructure($value); |
|
| 103 | + |
|
| 104 | + if ($this->isEditable()) { |
|
| 105 | + $localizedStructure = $this->addEditableMarkup($localizedStructure); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + if ($this->isLocalized()) { |
|
| 109 | + $localizedStructure = $this->addLocalizationMarkup($localizedStructure); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + if ($this->hasIcon()) { |
|
| 113 | + $localizedStructure = $this->addSpriteIconMarkup($localizedStructure); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $value = $this->flattenStructure($localizedStructure); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // Final wrap given by configuration. @see TCA['grid'] |
|
| 120 | + $value = $this->wrapValue($value, $configuration); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $output[$this->getFieldName()] = $value; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $output['DT_RowId'] = 'row-' . $object->getUid(); |
|
| 127 | + $output['DT_RowClass'] = sprintf('%s_%s', $object->getDataType(), $object->getUid()); |
|
| 128 | + |
|
| 129 | + return $output; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Flatten the localized structure to render the final value |
|
| 134 | + * |
|
| 135 | + * @param array $localizedStructure |
|
| 136 | + * @return string |
|
| 137 | + */ |
|
| 138 | + protected function flattenStructure(array $localizedStructure) |
|
| 139 | + { |
|
| 140 | + |
|
| 141 | + // Flatten the structure. |
|
| 142 | + $value = ''; |
|
| 143 | + foreach ($localizedStructure as $structure) { |
|
| 144 | + $value .= sprintf('<div class="%s">%s</div>', |
|
| 145 | + $structure['status'] !== LocalizationStatus::LOCALIZED ? 'invisible' : '', |
|
| 146 | + $structure['value'] |
|
| 147 | + ); |
|
| 148 | + } |
|
| 149 | + return $value; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Store some often used variable values and speed up the processing. |
|
| 154 | + * |
|
| 155 | + * @param Content $object |
|
| 156 | + * @param string $fieldNameAndPath |
|
| 157 | + * @return void |
|
| 158 | + */ |
|
| 159 | + protected function computeVariables(Content $object, $fieldNameAndPath) |
|
| 160 | + { |
|
| 161 | + $this->variables = []; |
|
| 162 | + $this->variables['dataType'] = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
| 163 | + $this->variables['fieldName'] = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 164 | + $this->variables['fieldNameAndPath'] = $fieldNameAndPath; |
|
| 165 | + $this->variables['object'] = $object; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Tell whether the object will be decorated / wrapped such as |
|
| 170 | + * |
|
| 171 | + * @param string $value |
|
| 172 | + * @return array |
|
| 173 | + */ |
|
| 174 | + protected function initializeLocalizedStructure($value) |
|
| 175 | + { |
|
| 176 | + |
|
| 177 | + $localizedStructure[] = [ |
|
| 178 | + 'value' => empty($value) && $this->isEditable() ? $this->getEmptyValuePlaceholder() : $value, |
|
| 179 | + 'status' => empty($value) ? LocalizationStatus::EMPTY_VALUE : LocalizationStatus::LOCALIZED, |
|
| 180 | + 'language' => 0, |
|
| 181 | + 'languageFlag' => $defaultLanguage = $this->getLanguageService()->getDefaultFlag(), |
|
| 182 | + ]; |
|
| 183 | + |
|
| 184 | + if ($this->isLocalized()) { |
|
| 185 | + |
|
| 186 | + foreach ($this->getLanguageService()->getLanguages() as $language) { |
|
| 187 | + |
|
| 188 | + // Make sure the language is allowed for the current Backend User. |
|
| 189 | + if ($this->isLanguageAllowedForBackendUser($language)) { |
|
| 190 | + |
|
| 191 | + $resolvedObject = $this->getResolvedObject(); |
|
| 192 | + $fieldName = $this->getFieldName(); |
|
| 193 | + |
|
| 194 | + if ($this->getLanguageService()->hasLocalization($resolvedObject, $language['uid'])) { |
|
| 195 | + $localizedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedObject, $language['uid'], $fieldName); |
|
| 196 | + $status = LocalizationStatus::LOCALIZED; |
|
| 197 | + |
|
| 198 | + // Replace blank value by something more meaningful for the End User. |
|
| 199 | + if (empty($localizedValue)) { |
|
| 200 | + $status = LocalizationStatus::EMPTY_VALUE; |
|
| 201 | + $localizedValue = $this->isEditable() ? $this->getEmptyValuePlaceholder() : ''; |
|
| 202 | + } |
|
| 203 | + } else { |
|
| 204 | + $localizedValue = sprintf('<a href="%s" style="color: black">%s</a>', |
|
| 205 | + $this->getLocalizedUri($language['uid']), |
|
| 206 | + $this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:create_translation') |
|
| 207 | + ); |
|
| 208 | + $status = LocalizationStatus::NOT_YET_LOCALIZED; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + // Feed structure. |
|
| 212 | + $localizedStructure[] = [ |
|
| 213 | + 'value' => $localizedValue, |
|
| 214 | + 'status' => $status, |
|
| 215 | + 'language' => (int)$language['uid'], |
|
| 216 | + 'languageFlag' => $language['flag'], |
|
| 217 | + ]; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + return $localizedStructure; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * @param array $language |
|
| 227 | + * @return bool |
|
| 228 | + */ |
|
| 229 | + protected function isLanguageAllowedForBackendUser(array $language) |
|
| 230 | + { |
|
| 231 | + return $this->getBackendUser()->checkLanguageAccess($language['uid']); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * Returns a placeholder when the value is empty. |
|
| 236 | + * |
|
| 237 | + * @return string |
|
| 238 | + */ |
|
| 239 | + protected function getEmptyValuePlaceholder() |
|
| 240 | + { |
|
| 241 | + return sprintf('<i>%s</i>', |
|
| 242 | + $this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:start_editing') |
|
| 243 | + ); |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * Tell whether the object will be decorated (or wrapped) for inline editing, localization purpose. |
|
| 248 | + * |
|
| 249 | + * @return bool |
|
| 250 | + */ |
|
| 251 | + protected function willBeEnriched() |
|
| 252 | + { |
|
| 253 | + |
|
| 254 | + $willBeEnriched = false; |
|
| 255 | + |
|
| 256 | + if ($this->fieldExists()) { |
|
| 257 | + $willBeEnriched = $this->isEditable() || $this->hasIcon() || $this->isLocalized(); |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + return $willBeEnriched; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * Tell whether the field in the context will be prepended by an icon. |
|
| 265 | + * |
|
| 266 | + * @return bool |
|
| 267 | + */ |
|
| 268 | + protected function hasIcon() |
|
| 269 | + { |
|
| 270 | + $dataType = $this->getDataType(); |
|
| 271 | + return Tca::table($dataType)->getLabelField() === $this->getFieldName(); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Tell whether the field in the context will be prepended by an icon. |
|
| 276 | + * |
|
| 277 | + * @return bool |
|
| 278 | + */ |
|
| 279 | + protected function isLocalized() |
|
| 280 | + { |
|
| 281 | + $object = $this->getObject(); |
|
| 282 | + $fieldName = $this->getFieldName(); |
|
| 283 | + $dataType = $this->getDataType(); |
|
| 284 | + $fieldNameAndPath = $this->getFieldNameAndPath(); |
|
| 285 | + |
|
| 286 | + return $this->getLanguageService()->hasLanguages() |
|
| 287 | + && Tca::grid($object)->isLocalized($fieldNameAndPath) |
|
| 288 | + && Tca::table($dataType)->field($fieldName)->isLocalized(); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Add some markup to have the content editable in the Grid. |
|
| 293 | + * |
|
| 294 | + * @param array $localizedStructure |
|
| 295 | + * @return array |
|
| 296 | + */ |
|
| 297 | + protected function addEditableMarkup(array $localizedStructure) |
|
| 298 | + { |
|
| 299 | + |
|
| 300 | + $dataType = $this->getDataType(); |
|
| 301 | + $fieldName = $this->getFieldName(); |
|
| 302 | + |
|
| 303 | + foreach ($localizedStructure as $index => $structure) { |
|
| 304 | + if ($structure['status'] !== LocalizationStatus::NOT_YET_LOCALIZED) { |
|
| 305 | + $localizedStructure[$index]['value'] = sprintf('<span class="%s" data-language="%s">%s</span>', |
|
| 306 | + Tca::table($dataType)->field($fieldName)->isTextArea() ? 'editable-textarea' : 'editable-textfield', |
|
| 307 | + $structure['language'], |
|
| 308 | + $structure['value'] |
|
| 309 | + ); |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + return $localizedStructure; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * Add some markup related to the localization. |
|
| 317 | + * |
|
| 318 | + * @param array $localizedStructure |
|
| 319 | + * @return array |
|
| 320 | + */ |
|
| 321 | + protected function addLocalizationMarkup(array $localizedStructure) |
|
| 322 | + { |
|
| 323 | + |
|
| 324 | + foreach ($localizedStructure as $index => $structure) { |
|
| 325 | + |
|
| 326 | + $localizedStructure[$index]['value'] = sprintf('<span>%s %s</span>', |
|
| 327 | + empty($structure['languageFlag']) ? '' : $this->getIconFactory()->getIcon('flags-' . $structure['languageFlag'], Icon::SIZE_SMALL), |
|
| 328 | + $structure['value'] |
|
| 329 | + ); |
|
| 330 | + } |
|
| 331 | + return $localizedStructure; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + /** |
|
| 335 | + * Add some markup related to the prepended icon. |
|
| 336 | + * |
|
| 337 | + * @param array $localizedStructure |
|
| 338 | + * @return array |
|
| 339 | + */ |
|
| 340 | + protected function addSpriteIconMarkup(array $localizedStructure) |
|
| 341 | + { |
|
| 342 | + |
|
| 343 | + $object = $this->getObject(); |
|
| 344 | + |
|
| 345 | + foreach ($localizedStructure as $index => $structure) { |
|
| 346 | + |
|
| 347 | + $recordData = []; |
|
| 348 | + |
|
| 349 | + $enablesMethods = array('Hidden', 'Deleted', 'StartTime', 'EndTime'); |
|
| 350 | + foreach ($enablesMethods as $enableMethod) { |
|
| 351 | + |
|
| 352 | + $methodName = 'get' . $enableMethod . 'Field'; |
|
| 353 | + |
|
| 354 | + // Fetch possible hidden filed. |
|
| 355 | + $enableField = Tca::table($object)->$methodName(); |
|
| 356 | + if ($enableField) { |
|
| 357 | + $recordData[$enableField] = $object[$enableField]; |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + // Get Enable Fields of the object to render the sprite with overlays. |
|
| 362 | + $localizedStructure[$index]['value'] = sprintf('%s %s', |
|
| 363 | + $this->getIconFactory()->getIconForRecord($object->getDataType(), $recordData, Icon::SIZE_SMALL), |
|
| 364 | + $structure['value'] |
|
| 365 | + ); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + return $localizedStructure; |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * Return whether the field given by the context is editable. |
|
| 373 | + * |
|
| 374 | + * @return boolean |
|
| 375 | + */ |
|
| 376 | + protected function isEditable() |
|
| 377 | + { |
|
| 378 | + $fieldNameAndPath = $this->getFieldNameAndPath(); |
|
| 379 | + $dataType = $this->getDataType(); |
|
| 380 | + $fieldName = $this->getFieldName(); |
|
| 381 | + |
|
| 382 | + return Tca::grid()->isEditable($fieldNameAndPath) |
|
| 383 | + && Tca::table($dataType)->hasField($fieldName) |
|
| 384 | + && Tca::table($dataType)->field($fieldName)->hasNoRelation(); // relation are editable through Renderers only. |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * Return the appropriate URI to create the translation. |
|
| 389 | + * |
|
| 390 | + * @param int $language |
|
| 391 | + * @return string |
|
| 392 | + */ |
|
| 393 | + protected function getLocalizedUri($language) |
|
| 394 | + { |
|
| 395 | + |
|
| 396 | + // Transmit recursive selection parameter. |
|
| 397 | + $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
| 398 | + $parameters = GeneralUtility::_GP($parameterPrefix); |
|
| 399 | + |
|
| 400 | + $additionalParameters = array( |
|
| 401 | + $this->getModuleLoader()->getParameterPrefix() => array( |
|
| 402 | + 'controller' => 'Content', |
|
| 403 | + 'action' => 'localize', |
|
| 404 | + 'format' => 'json', |
|
| 405 | + 'hasRecursiveSelection' => isset($parameters['hasRecursiveSelection']) ? (int)$parameters['hasRecursiveSelection'] : 0, |
|
| 406 | + 'fieldNameAndPath' => $this->getFieldNameAndPath(), |
|
| 407 | + 'language' => $language, |
|
| 408 | + 'matches' => array( |
|
| 409 | + 'uid' => $this->getObject()->getUid(), |
|
| 410 | + ), |
|
| 411 | + ), |
|
| 412 | + ); |
|
| 413 | + |
|
| 414 | + return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * Compute the value for the Content object according to a field name. |
|
| 419 | + * |
|
| 420 | + * @param Content $object |
|
| 421 | + * @param string $fieldNameAndPath |
|
| 422 | + * @return string |
|
| 423 | + */ |
|
| 424 | + protected function resolveValue(Content $object, $fieldNameAndPath) |
|
| 425 | + { |
|
| 426 | + |
|
| 427 | + // Get the first part of the field name and |
|
| 428 | + $fieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); |
|
| 429 | + |
|
| 430 | + $value = $object[$fieldName]; |
|
| 431 | + |
|
| 432 | + // Relation but contains no data. |
|
| 433 | + if (is_array($value) && empty($value)) { |
|
| 434 | + $value = ''; |
|
| 435 | + } elseif ($value instanceof Content) { |
|
| 436 | + |
|
| 437 | + $fieldNameOfForeignTable = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 438 | + |
|
| 439 | + // true means the field name does not contains a path. "title" vs "metadata.title" |
|
| 440 | + // Fetch the default label |
|
| 441 | + if ($fieldNameOfForeignTable === $fieldName) { |
|
| 442 | + $foreignTable = Tca::table($object->getDataType())->field($fieldName)->getForeignTable(); |
|
| 443 | + $fieldNameOfForeignTable = Tca::table($foreignTable)->getLabelField(); |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + $value = $object[$fieldName][$fieldNameOfForeignTable]; |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + return $value; |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * Check whether a string contains HTML tags. |
|
| 454 | + * |
|
| 455 | + * @param string $string the content to be analyzed |
|
| 456 | + * @return boolean |
|
| 457 | + */ |
|
| 458 | + protected function hasHtml($string) |
|
| 459 | + { |
|
| 460 | + $result = false; |
|
| 461 | + |
|
| 462 | + // We compare the length of the string with html tags and without html tags. |
|
| 463 | + if (strlen($string) !== strlen(strip_tags($string))) { |
|
| 464 | + $result = true; |
|
| 465 | + } |
|
| 466 | + return $result; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + /** |
|
| 470 | + * Check whether a string contains potential XSS. |
|
| 471 | + * |
|
| 472 | + * @param string $string the content to be analyzed |
|
| 473 | + * @return boolean |
|
| 474 | + */ |
|
| 475 | + protected function isClean($string) |
|
| 476 | + { |
|
| 477 | + |
|
| 478 | + // @todo implement me! |
|
| 479 | + $result = true; |
|
| 480 | + return $result; |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * Process the value |
|
| 485 | + * |
|
| 486 | + * @todo implement me as a processor chain to be cleaner implementation wise. Look out at the performance however! |
|
| 487 | + * e.g DefaultValueGridProcessor, TextAreaGridProcessor, ... |
|
| 488 | + * |
|
| 489 | + * @param string $value |
|
| 490 | + * @param Content $object |
|
| 491 | + * @param string $fieldNameAndPath |
|
| 492 | + * @return string |
|
| 493 | + * @throws InvalidKeyInArrayException |
|
| 494 | + */ |
|
| 495 | + protected function processValue($value, Content $object, $fieldNameAndPath) |
|
| 496 | + { |
|
| 497 | + |
|
| 498 | + // Set default value if $field name correspond to the label of the table |
|
| 499 | + $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 500 | + if (Tca::table($object->getDataType())->getLabelField() === $fieldName && empty($value)) { |
|
| 501 | + $value = sprintf('[%s]', $this->getLabelService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title')); |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + // Sanitize the value in case of "select" or "radio button". |
|
| 505 | + if (is_scalar($value)) { |
|
| 506 | + $fieldType = Tca::table($object->getDataType())->field($fieldNameAndPath)->getType(); |
|
| 507 | + if ($fieldType !== FieldType::TEXTAREA) { |
|
| 508 | + $value = htmlspecialchars($value); |
|
| 509 | + } elseif ($fieldType === FieldType::TEXTAREA && !$this->isClean($value)) { |
|
| 510 | + $value = htmlspecialchars($value); // Avoid bad surprise, converts characters to HTML. |
|
| 511 | + } elseif ($fieldType === FieldType::TEXTAREA && !$this->hasHtml($value)) { |
|
| 512 | + $value = nl2br($value); |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + return $value; |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + /** |
|
| 520 | + * Possible value formatting. |
|
| 521 | + * |
|
| 522 | + * @param string $value |
|
| 523 | + * @param array $configuration |
|
| 524 | + * @return string |
|
| 525 | + * @throws \InvalidArgumentException |
|
| 526 | + */ |
|
| 527 | + protected function formatValue($value, array $configuration) |
|
| 528 | + { |
|
| 529 | + if (empty($configuration['format'])) { |
|
| 530 | + return $value; |
|
| 531 | + } |
|
| 532 | + $className = $configuration['format']; |
|
| 533 | + |
|
| 534 | + /** @var FormatterInterface $formatter */ |
|
| 535 | + $formatter = GeneralUtility::makeInstance($className); |
|
| 536 | + $value = $formatter->format($value); |
|
| 537 | + |
|
| 538 | + return $value; |
|
| 539 | + } |
|
| 540 | + |
|
| 541 | + /** |
|
| 542 | + * Possible value wrapping. |
|
| 543 | + * |
|
| 544 | + * @param string $value |
|
| 545 | + * @param array $configuration |
|
| 546 | + * @return string |
|
| 547 | + */ |
|
| 548 | + protected function wrapValue($value, array $configuration) |
|
| 549 | + { |
|
| 550 | + if (!empty($configuration['wrap'])) { |
|
| 551 | + $parts = explode('|', $configuration['wrap']); |
|
| 552 | + $value = implode($value, $parts); |
|
| 553 | + } |
|
| 554 | + return $value; |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + /** |
|
| 558 | + * Tell whether the field in the context really exists. |
|
| 559 | + * |
|
| 560 | + * @return bool |
|
| 561 | + */ |
|
| 562 | + protected function fieldExists() |
|
| 563 | + { |
|
| 564 | + if ($this->variables['hasField'] === null) { |
|
| 565 | + $dataType = $this->getDataType(); |
|
| 566 | + $fieldName = $this->getFieldName(); |
|
| 567 | + $this->variables['hasField'] = Tca::table($dataType)->hasField($fieldName); |
|
| 568 | + } |
|
| 569 | + return $this->variables['hasField']; |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + /** |
|
| 573 | + * @return string |
|
| 574 | + */ |
|
| 575 | + protected function getDataType() |
|
| 576 | + { |
|
| 577 | + return $this->variables['dataType']; |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + /** |
|
| 581 | + * @return string |
|
| 582 | + */ |
|
| 583 | + protected function getFieldName() |
|
| 584 | + { |
|
| 585 | + return $this->variables['fieldName']; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * @return string |
|
| 590 | + */ |
|
| 591 | + protected function getFieldNameAndPath() |
|
| 592 | + { |
|
| 593 | + return $this->variables['fieldNameAndPath']; |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + /** |
|
| 597 | + * @return Content |
|
| 598 | + */ |
|
| 599 | + protected function getObject() |
|
| 600 | + { |
|
| 601 | + return $this->variables['object']; |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + /** |
|
| 605 | + * @return Content |
|
| 606 | + * @throws \InvalidArgumentException |
|
| 607 | + */ |
|
| 608 | + protected function getResolvedObject() |
|
| 609 | + { |
|
| 610 | + if (empty($this->variables['resolvedObject'])) { |
|
| 611 | + $object = $this->getObject(); |
|
| 612 | + $fieldNameAndPath = $this->getFieldNameAndPath(); |
|
| 613 | + $this->variables['resolvedObject'] = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath); |
|
| 614 | + } |
|
| 615 | + return $this->variables['resolvedObject']; |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + /** |
|
| 619 | + * @return FieldPathResolver|object |
|
| 620 | + * @throws \InvalidArgumentException |
|
| 621 | + */ |
|
| 622 | + protected function getFieldPathResolver() |
|
| 623 | + { |
|
| 624 | + return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + /** |
|
| 628 | + * @return ContentObjectResolver|object |
|
| 629 | + * @throws \InvalidArgumentException |
|
| 630 | + */ |
|
| 631 | + protected function getContentObjectResolver() |
|
| 632 | + { |
|
| 633 | + return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + /** |
|
| 637 | + * @return \TYPO3\CMS\Core\Localization\LanguageService |
|
| 638 | + */ |
|
| 639 | + protected function getLabelService() |
|
| 640 | + { |
|
| 641 | + return $GLOBALS['LANG']; |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + /** |
|
| 645 | + * @return LanguageService|object |
|
| 646 | + * @throws \InvalidArgumentException |
|
| 647 | + */ |
|
| 648 | + protected function getLanguageService() |
|
| 649 | + { |
|
| 650 | + return GeneralUtility::makeInstance(LanguageService::class); |
|
| 651 | + } |
|
| 652 | 652 | |
| 653 | 653 | } |
@@ -17,17 +17,17 @@ |
||
| 17 | 17 | class MassEditMenuItem extends AbstractComponentView |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Renders a "mass edit" menu item to be placed in the grid menu. |
|
| 22 | - * |
|
| 23 | - * @return string |
|
| 24 | - * @throws \InvalidArgumentException |
|
| 25 | - */ |
|
| 26 | - public function render() |
|
| 27 | - { |
|
| 28 | - return sprintf('<li><a href="#" class="dropdown-item mass-edit">%s %s (not implemented)</a></li>', |
|
| 29 | - $this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL), |
|
| 30 | - $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit') |
|
| 31 | - ); |
|
| 32 | - } |
|
| 20 | + /** |
|
| 21 | + * Renders a "mass edit" menu item to be placed in the grid menu. |
|
| 22 | + * |
|
| 23 | + * @return string |
|
| 24 | + * @throws \InvalidArgumentException |
|
| 25 | + */ |
|
| 26 | + public function render() |
|
| 27 | + { |
|
| 28 | + return sprintf('<li><a href="#" class="dropdown-item mass-edit">%s %s (not implemented)</a></li>', |
|
| 29 | + $this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL), |
|
| 30 | + $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit') |
|
| 31 | + ); |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -19,115 +19,115 @@ |
||
| 19 | 19 | class BackendUtility |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /******************************************* |
|
| 22 | + /******************************************* |
|
| 23 | 23 | * |
| 24 | 24 | * SQL-related, selecting records, searching |
| 25 | 25 | * |
| 26 | 26 | *******************************************/ |
| 27 | - /** |
|
| 28 | - * Returns the WHERE clause " AND NOT [tablename].[deleted-field]" if a deleted-field |
|
| 29 | - * is configured in $GLOBALS['TCA'] for the tablename, $table |
|
| 30 | - * This function should ALWAYS be called in the backend for selection on tables which |
|
| 31 | - * are configured in $GLOBALS['TCA'] since it will ensure consistent selection of records, |
|
| 32 | - * even if they are marked deleted (in which case the system must always treat them as non-existent!) |
|
| 33 | - * In the frontend a function, ->enableFields(), is known to filter hidden-field, start- and endtime |
|
| 34 | - * and fe_groups as well. But that is a job of the frontend, not the backend. If you need filtering |
|
| 35 | - * on those fields as well in the backend you can use ->BEenableFields() though. |
|
| 36 | - * |
|
| 37 | - * @param string $table Table name present in $GLOBALS['TCA'] |
|
| 38 | - * @param string $withLogicalSeparator Table alias if any |
|
| 39 | - * @return string WHERE clause for filtering out deleted records, eg " AND tablename.deleted=0 |
|
| 40 | - */ |
|
| 41 | - public static function deleteClause($table, $withLogicalSeparator = ' AND') |
|
| 42 | - { |
|
| 43 | - if (empty($GLOBALS['TCA'][$table]['ctrl']['delete'])) { |
|
| 44 | - return ''; |
|
| 45 | - } |
|
| 46 | - $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
| 47 | - ->getQueryBuilderForTable($table) |
|
| 48 | - ->expr(); |
|
| 49 | - return $withLogicalSeparator . ' ' . $expressionBuilder->eq( |
|
| 50 | - $table . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'], |
|
| 51 | - 0 |
|
| 52 | - ); |
|
| 53 | - } |
|
| 54 | - /** |
|
| 55 | - * Backend implementation of enableFields() |
|
| 56 | - * Notice that "fe_groups" is not selected for - only disabled, starttime and endtime. |
|
| 57 | - * Notice that deleted-fields are NOT filtered - you must ALSO call deleteClause in addition. |
|
| 58 | - * $GLOBALS["SIM_ACCESS_TIME"] is used for date. |
|
| 59 | - * |
|
| 60 | - * @param string $table The table from which to return enableFields WHERE clause. Table name must have a 'ctrl' section in $GLOBALS['TCA']. |
|
| 61 | - * @param bool $inv Means that the query will select all records NOT VISIBLE records (inverted selection) |
|
| 62 | - * @return string WHERE clause part |
|
| 63 | - */ |
|
| 64 | - public static function BEenableFields($table, $inv = false) |
|
| 65 | - { |
|
| 66 | - $ctrl = $GLOBALS['TCA'][$table]['ctrl']; |
|
| 67 | - $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
| 68 | - ->getConnectionForTable($table) |
|
| 69 | - ->getExpressionBuilder(); |
|
| 70 | - $query = $expressionBuilder->andX(); |
|
| 71 | - $invQuery = $expressionBuilder->orX(); |
|
| 27 | + /** |
|
| 28 | + * Returns the WHERE clause " AND NOT [tablename].[deleted-field]" if a deleted-field |
|
| 29 | + * is configured in $GLOBALS['TCA'] for the tablename, $table |
|
| 30 | + * This function should ALWAYS be called in the backend for selection on tables which |
|
| 31 | + * are configured in $GLOBALS['TCA'] since it will ensure consistent selection of records, |
|
| 32 | + * even if they are marked deleted (in which case the system must always treat them as non-existent!) |
|
| 33 | + * In the frontend a function, ->enableFields(), is known to filter hidden-field, start- and endtime |
|
| 34 | + * and fe_groups as well. But that is a job of the frontend, not the backend. If you need filtering |
|
| 35 | + * on those fields as well in the backend you can use ->BEenableFields() though. |
|
| 36 | + * |
|
| 37 | + * @param string $table Table name present in $GLOBALS['TCA'] |
|
| 38 | + * @param string $withLogicalSeparator Table alias if any |
|
| 39 | + * @return string WHERE clause for filtering out deleted records, eg " AND tablename.deleted=0 |
|
| 40 | + */ |
|
| 41 | + public static function deleteClause($table, $withLogicalSeparator = ' AND') |
|
| 42 | + { |
|
| 43 | + if (empty($GLOBALS['TCA'][$table]['ctrl']['delete'])) { |
|
| 44 | + return ''; |
|
| 45 | + } |
|
| 46 | + $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
| 47 | + ->getQueryBuilderForTable($table) |
|
| 48 | + ->expr(); |
|
| 49 | + return $withLogicalSeparator . ' ' . $expressionBuilder->eq( |
|
| 50 | + $table . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'], |
|
| 51 | + 0 |
|
| 52 | + ); |
|
| 53 | + } |
|
| 54 | + /** |
|
| 55 | + * Backend implementation of enableFields() |
|
| 56 | + * Notice that "fe_groups" is not selected for - only disabled, starttime and endtime. |
|
| 57 | + * Notice that deleted-fields are NOT filtered - you must ALSO call deleteClause in addition. |
|
| 58 | + * $GLOBALS["SIM_ACCESS_TIME"] is used for date. |
|
| 59 | + * |
|
| 60 | + * @param string $table The table from which to return enableFields WHERE clause. Table name must have a 'ctrl' section in $GLOBALS['TCA']. |
|
| 61 | + * @param bool $inv Means that the query will select all records NOT VISIBLE records (inverted selection) |
|
| 62 | + * @return string WHERE clause part |
|
| 63 | + */ |
|
| 64 | + public static function BEenableFields($table, $inv = false) |
|
| 65 | + { |
|
| 66 | + $ctrl = $GLOBALS['TCA'][$table]['ctrl']; |
|
| 67 | + $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
| 68 | + ->getConnectionForTable($table) |
|
| 69 | + ->getExpressionBuilder(); |
|
| 70 | + $query = $expressionBuilder->andX(); |
|
| 71 | + $invQuery = $expressionBuilder->orX(); |
|
| 72 | 72 | |
| 73 | - if (is_array($ctrl)) { |
|
| 74 | - if (is_array($ctrl['enablecolumns'])) { |
|
| 75 | - if ($ctrl['enablecolumns']['disabled'] ?? false) { |
|
| 76 | - $field = $table . '.' . $ctrl['enablecolumns']['disabled']; |
|
| 77 | - $query->add($expressionBuilder->eq($field, 0)); |
|
| 78 | - $invQuery->add($expressionBuilder->neq($field, 0)); |
|
| 79 | - } |
|
| 80 | - if ($ctrl['enablecolumns']['starttime'] ?? false) { |
|
| 81 | - $field = $table . '.' . $ctrl['enablecolumns']['starttime']; |
|
| 82 | - $query->add($expressionBuilder->lte($field, (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'))); |
|
| 83 | - $invQuery->add( |
|
| 84 | - $expressionBuilder->andX( |
|
| 85 | - $expressionBuilder->neq($field, 0), |
|
| 86 | - $expressionBuilder->gt($field, (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp')) |
|
| 87 | - ) |
|
| 88 | - ); |
|
| 89 | - } |
|
| 90 | - if ($ctrl['enablecolumns']['endtime'] ?? false) { |
|
| 91 | - $field = $table . '.' . $ctrl['enablecolumns']['endtime']; |
|
| 92 | - $query->add( |
|
| 93 | - $expressionBuilder->orX( |
|
| 94 | - $expressionBuilder->eq($field, 0), |
|
| 95 | - $expressionBuilder->gt($field, (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp')) |
|
| 96 | - ) |
|
| 97 | - ); |
|
| 98 | - $invQuery->add( |
|
| 99 | - $expressionBuilder->andX( |
|
| 100 | - $expressionBuilder->neq($field, 0), |
|
| 101 | - $expressionBuilder->lte($field, (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp')) |
|
| 102 | - ) |
|
| 103 | - ); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - } |
|
| 73 | + if (is_array($ctrl)) { |
|
| 74 | + if (is_array($ctrl['enablecolumns'])) { |
|
| 75 | + if ($ctrl['enablecolumns']['disabled'] ?? false) { |
|
| 76 | + $field = $table . '.' . $ctrl['enablecolumns']['disabled']; |
|
| 77 | + $query->add($expressionBuilder->eq($field, 0)); |
|
| 78 | + $invQuery->add($expressionBuilder->neq($field, 0)); |
|
| 79 | + } |
|
| 80 | + if ($ctrl['enablecolumns']['starttime'] ?? false) { |
|
| 81 | + $field = $table . '.' . $ctrl['enablecolumns']['starttime']; |
|
| 82 | + $query->add($expressionBuilder->lte($field, (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'))); |
|
| 83 | + $invQuery->add( |
|
| 84 | + $expressionBuilder->andX( |
|
| 85 | + $expressionBuilder->neq($field, 0), |
|
| 86 | + $expressionBuilder->gt($field, (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp')) |
|
| 87 | + ) |
|
| 88 | + ); |
|
| 89 | + } |
|
| 90 | + if ($ctrl['enablecolumns']['endtime'] ?? false) { |
|
| 91 | + $field = $table . '.' . $ctrl['enablecolumns']['endtime']; |
|
| 92 | + $query->add( |
|
| 93 | + $expressionBuilder->orX( |
|
| 94 | + $expressionBuilder->eq($field, 0), |
|
| 95 | + $expressionBuilder->gt($field, (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp')) |
|
| 96 | + ) |
|
| 97 | + ); |
|
| 98 | + $invQuery->add( |
|
| 99 | + $expressionBuilder->andX( |
|
| 100 | + $expressionBuilder->neq($field, 0), |
|
| 101 | + $expressionBuilder->lte($field, (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp')) |
|
| 102 | + ) |
|
| 103 | + ); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - if ($query->count() === 0) { |
|
| 109 | - return ''; |
|
| 110 | - } |
|
| 108 | + if ($query->count() === 0) { |
|
| 109 | + return ''; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - return ' AND ' . ($inv ? $invQuery : $query); |
|
| 113 | - } |
|
| 112 | + return ' AND ' . ($inv ? $invQuery : $query); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Returns the URL to a given module |
|
| 117 | - * |
|
| 118 | - * @param string $moduleName Name of the module |
|
| 119 | - * @param array $urlParameters URL parameters that should be added as key value pairs |
|
| 120 | - * @return string Calculated URL |
|
| 121 | - */ |
|
| 122 | - public static function getModuleUrl($moduleName, $urlParameters = []) |
|
| 123 | - { |
|
| 124 | - $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); |
|
| 125 | - try { |
|
| 126 | - $uri = $uriBuilder->buildUriFromRoute($moduleName, $urlParameters); |
|
| 127 | - } catch (RouteNotFoundException $e) { |
|
| 128 | - $uri = $uriBuilder->buildUriFromRoutePath($moduleName, $urlParameters); |
|
| 129 | - } |
|
| 130 | - return (string)$uri; |
|
| 131 | - } |
|
| 115 | + /** |
|
| 116 | + * Returns the URL to a given module |
|
| 117 | + * |
|
| 118 | + * @param string $moduleName Name of the module |
|
| 119 | + * @param array $urlParameters URL parameters that should be added as key value pairs |
|
| 120 | + * @return string Calculated URL |
|
| 121 | + */ |
|
| 122 | + public static function getModuleUrl($moduleName, $urlParameters = []) |
|
| 123 | + { |
|
| 124 | + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); |
|
| 125 | + try { |
|
| 126 | + $uri = $uriBuilder->buildUriFromRoute($moduleName, $urlParameters); |
|
| 127 | + } catch (RouteNotFoundException $e) { |
|
| 128 | + $uri = $uriBuilder->buildUriFromRoutePath($moduleName, $urlParameters); |
|
| 129 | + } |
|
| 130 | + return (string)$uri; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | } |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 47 | 47 | ->getQueryBuilderForTable($table) |
| 48 | 48 | ->expr(); |
| 49 | - return $withLogicalSeparator . ' ' . $expressionBuilder->eq( |
|
| 50 | - $table . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'], |
|
| 49 | + return $withLogicalSeparator.' '.$expressionBuilder->eq( |
|
| 50 | + $table.'.'.$GLOBALS['TCA'][$table]['ctrl']['delete'], |
|
| 51 | 51 | 0 |
| 52 | 52 | ); |
| 53 | 53 | } |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | if (is_array($ctrl)) { |
| 74 | 74 | if (is_array($ctrl['enablecolumns'])) { |
| 75 | 75 | if ($ctrl['enablecolumns']['disabled'] ?? false) { |
| 76 | - $field = $table . '.' . $ctrl['enablecolumns']['disabled']; |
|
| 76 | + $field = $table.'.'.$ctrl['enablecolumns']['disabled']; |
|
| 77 | 77 | $query->add($expressionBuilder->eq($field, 0)); |
| 78 | 78 | $invQuery->add($expressionBuilder->neq($field, 0)); |
| 79 | 79 | } |
| 80 | 80 | if ($ctrl['enablecolumns']['starttime'] ?? false) { |
| 81 | - $field = $table . '.' . $ctrl['enablecolumns']['starttime']; |
|
| 81 | + $field = $table.'.'.$ctrl['enablecolumns']['starttime']; |
|
| 82 | 82 | $query->add($expressionBuilder->lte($field, (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'))); |
| 83 | 83 | $invQuery->add( |
| 84 | 84 | $expressionBuilder->andX( |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | ); |
| 89 | 89 | } |
| 90 | 90 | if ($ctrl['enablecolumns']['endtime'] ?? false) { |
| 91 | - $field = $table . '.' . $ctrl['enablecolumns']['endtime']; |
|
| 91 | + $field = $table.'.'.$ctrl['enablecolumns']['endtime']; |
|
| 92 | 92 | $query->add( |
| 93 | 93 | $expressionBuilder->orX( |
| 94 | 94 | $expressionBuilder->eq($field, 0), |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | return ''; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - return ' AND ' . ($inv ? $invQuery : $query); |
|
| 112 | + return ' AND '.($inv ? $invQuery : $query); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -7,33 +7,33 @@ |
||
| 7 | 7 | |
| 8 | 8 | call_user_func(function () { |
| 9 | 9 | |
| 10 | - $configuration = GeneralUtility::makeInstance( |
|
| 11 | - ExtensionConfiguration::class |
|
| 12 | - )->get('vidi'); |
|
| 13 | - |
|
| 14 | - if (false === isset($configuration['autoload_typoscript']) || true === (bool)$configuration['autoload_typoscript']) { |
|
| 15 | - |
|
| 16 | - ExtensionManagementUtility::addTypoScript( |
|
| 17 | - 'vidi', |
|
| 18 | - 'constants', |
|
| 19 | - '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:vidi/Configuration/TypoScript/constants.txt">' |
|
| 20 | - ); |
|
| 21 | - |
|
| 22 | - ExtensionManagementUtility::addTypoScript( |
|
| 23 | - 'vidi', |
|
| 24 | - 'setup', |
|
| 25 | - '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:vidi/Configuration/TypoScript/setup.txt">' |
|
| 26 | - ); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - // Initialize generic Vidi modules after the TCA is loaded. |
|
| 30 | - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'][] = 'Fab\Vidi\Configuration\VidiModulesAspect'; |
|
| 31 | - |
|
| 32 | - // Initialize generic grid TCA for all data types |
|
| 33 | - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'][] = 'Fab\Vidi\Configuration\TcaGridAspect'; |
|
| 34 | - |
|
| 35 | - // cache configuration, see https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/CachingFramework/Configuration/Index.html#cache-configurations |
|
| 36 | - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['vidi']['frontend'] = VariableFrontend::class; |
|
| 37 | - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['vidi']['groups'] = array('all', 'vidi'); |
|
| 38 | - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['vidi']['options']['defaultLifetime'] = 2592000; |
|
| 10 | + $configuration = GeneralUtility::makeInstance( |
|
| 11 | + ExtensionConfiguration::class |
|
| 12 | + )->get('vidi'); |
|
| 13 | + |
|
| 14 | + if (false === isset($configuration['autoload_typoscript']) || true === (bool)$configuration['autoload_typoscript']) { |
|
| 15 | + |
|
| 16 | + ExtensionManagementUtility::addTypoScript( |
|
| 17 | + 'vidi', |
|
| 18 | + 'constants', |
|
| 19 | + '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:vidi/Configuration/TypoScript/constants.txt">' |
|
| 20 | + ); |
|
| 21 | + |
|
| 22 | + ExtensionManagementUtility::addTypoScript( |
|
| 23 | + 'vidi', |
|
| 24 | + 'setup', |
|
| 25 | + '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:vidi/Configuration/TypoScript/setup.txt">' |
|
| 26 | + ); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + // Initialize generic Vidi modules after the TCA is loaded. |
|
| 30 | + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'][] = 'Fab\Vidi\Configuration\VidiModulesAspect'; |
|
| 31 | + |
|
| 32 | + // Initialize generic grid TCA for all data types |
|
| 33 | + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'][] = 'Fab\Vidi\Configuration\TcaGridAspect'; |
|
| 34 | + |
|
| 35 | + // cache configuration, see https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/CachingFramework/Configuration/Index.html#cache-configurations |
|
| 36 | + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['vidi']['frontend'] = VariableFrontend::class; |
|
| 37 | + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['vidi']['groups'] = array('all', 'vidi'); |
|
| 38 | + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['vidi']['options']['defaultLifetime'] = 2592000; |
|
| 39 | 39 | }); |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend; |
| 6 | 6 | defined('TYPO3') or die(); |
| 7 | 7 | |
| 8 | -call_user_func(function () { |
|
| 8 | +call_user_func(function() { |
|
| 9 | 9 | |
| 10 | 10 | $configuration = GeneralUtility::makeInstance( |
| 11 | 11 | ExtensionConfiguration::class |
@@ -2,88 +2,88 @@ |
||
| 2 | 2 | if (!defined('TYPO3')) die ('Access denied.'); |
| 3 | 3 | |
| 4 | 4 | return [ |
| 5 | - 'ctrl' => [ |
|
| 6 | - 'title' => 'LLL:EXT:phpdisplay/Resources/Private/Language/locallang_db.xml:tx_phpdisplay_displays', |
|
| 7 | - 'label' => 'name', |
|
| 8 | - 'tstamp' => 'tstamp', |
|
| 9 | - 'crdate' => 'crdate', |
|
| 10 | - 'cruser_id' => 'cruser_id', |
|
| 11 | - 'hideTable' => true, |
|
| 12 | - 'delete' => 'deleted', |
|
| 13 | - 'enablecolumns' => [ |
|
| 14 | - 'disabled' => 'hidden', |
|
| 15 | - ], |
|
| 16 | - 'searchFields' => 'type,name,data_type', |
|
| 17 | - 'typeicon_classes' => [ |
|
| 18 | - 'default' => 'extensions-vidi-selection', |
|
| 19 | - ], |
|
| 20 | - ], |
|
| 21 | - 'types' => [ |
|
| 22 | - '1' => ['showitem' => 'hidden,--palette--;;1,type,name,data_type,query'], |
|
| 23 | - ], |
|
| 24 | - 'palettes' => [ |
|
| 25 | - '1' => ['showitem' => ''], |
|
| 26 | - ], |
|
| 27 | - 'columns' => [ |
|
| 5 | + 'ctrl' => [ |
|
| 6 | + 'title' => 'LLL:EXT:phpdisplay/Resources/Private/Language/locallang_db.xml:tx_phpdisplay_displays', |
|
| 7 | + 'label' => 'name', |
|
| 8 | + 'tstamp' => 'tstamp', |
|
| 9 | + 'crdate' => 'crdate', |
|
| 10 | + 'cruser_id' => 'cruser_id', |
|
| 11 | + 'hideTable' => true, |
|
| 12 | + 'delete' => 'deleted', |
|
| 13 | + 'enablecolumns' => [ |
|
| 14 | + 'disabled' => 'hidden', |
|
| 15 | + ], |
|
| 16 | + 'searchFields' => 'type,name,data_type', |
|
| 17 | + 'typeicon_classes' => [ |
|
| 18 | + 'default' => 'extensions-vidi-selection', |
|
| 19 | + ], |
|
| 20 | + ], |
|
| 21 | + 'types' => [ |
|
| 22 | + '1' => ['showitem' => 'hidden,--palette--;;1,type,name,data_type,query'], |
|
| 23 | + ], |
|
| 24 | + 'palettes' => [ |
|
| 25 | + '1' => ['showitem' => ''], |
|
| 26 | + ], |
|
| 27 | + 'columns' => [ |
|
| 28 | 28 | |
| 29 | - 'hidden' => [ |
|
| 30 | - 'exclude' => 1, |
|
| 31 | - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden', |
|
| 32 | - 'config' => [ |
|
| 33 | - 'type' => 'check', |
|
| 34 | - ], |
|
| 35 | - ], |
|
| 36 | - 'visibility' => [ |
|
| 37 | - 'exclude' => 0, |
|
| 38 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility', |
|
| 39 | - 'config' => [ |
|
| 40 | - 'type' => 'select', |
|
| 41 | - 'renderType' => 'selectSingle', |
|
| 42 | - 'items' => [ |
|
| 43 | - ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.everyone', 0], |
|
| 44 | - ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.private', 1], |
|
| 45 | - ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.admin_only', 2], |
|
| 46 | - ], |
|
| 47 | - 'size' => 1, |
|
| 48 | - 'maxitems' => 1, |
|
| 49 | - 'minitems' => 1, |
|
| 50 | - ], |
|
| 51 | - ], |
|
| 52 | - 'name' => [ |
|
| 53 | - 'exclude' => 0, |
|
| 54 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:name', |
|
| 55 | - 'config' => [ |
|
| 56 | - 'type' => 'input', |
|
| 57 | - 'size' => 30, |
|
| 58 | - 'eval' => 'trim,required' |
|
| 59 | - ], |
|
| 60 | - ], |
|
| 61 | - 'data_type' => [ |
|
| 62 | - 'exclude' => 0, |
|
| 63 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:data_type', |
|
| 64 | - 'config' => [ |
|
| 65 | - 'type' => 'input', |
|
| 66 | - 'size' => 30, |
|
| 67 | - 'eval' => 'trim,required' |
|
| 68 | - ], |
|
| 69 | - ], |
|
| 70 | - 'query' => [ |
|
| 71 | - 'exclude' => 0, |
|
| 72 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:query', |
|
| 73 | - 'config' => [ |
|
| 74 | - 'type' => 'text', |
|
| 75 | - 'rows' => 5, |
|
| 76 | - 'cols' => 5, |
|
| 77 | - ], |
|
| 78 | - ], |
|
| 79 | - 'speaking_query' => [ |
|
| 80 | - 'exclude' => 0, |
|
| 81 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:speaking_query', |
|
| 82 | - 'config' => [ |
|
| 83 | - 'type' => 'text', |
|
| 84 | - 'rows' => 5, |
|
| 85 | - 'cols' => 5, |
|
| 86 | - ], |
|
| 87 | - ], |
|
| 88 | - ], |
|
| 29 | + 'hidden' => [ |
|
| 30 | + 'exclude' => 1, |
|
| 31 | + 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden', |
|
| 32 | + 'config' => [ |
|
| 33 | + 'type' => 'check', |
|
| 34 | + ], |
|
| 35 | + ], |
|
| 36 | + 'visibility' => [ |
|
| 37 | + 'exclude' => 0, |
|
| 38 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility', |
|
| 39 | + 'config' => [ |
|
| 40 | + 'type' => 'select', |
|
| 41 | + 'renderType' => 'selectSingle', |
|
| 42 | + 'items' => [ |
|
| 43 | + ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.everyone', 0], |
|
| 44 | + ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.private', 1], |
|
| 45 | + ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.admin_only', 2], |
|
| 46 | + ], |
|
| 47 | + 'size' => 1, |
|
| 48 | + 'maxitems' => 1, |
|
| 49 | + 'minitems' => 1, |
|
| 50 | + ], |
|
| 51 | + ], |
|
| 52 | + 'name' => [ |
|
| 53 | + 'exclude' => 0, |
|
| 54 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:name', |
|
| 55 | + 'config' => [ |
|
| 56 | + 'type' => 'input', |
|
| 57 | + 'size' => 30, |
|
| 58 | + 'eval' => 'trim,required' |
|
| 59 | + ], |
|
| 60 | + ], |
|
| 61 | + 'data_type' => [ |
|
| 62 | + 'exclude' => 0, |
|
| 63 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:data_type', |
|
| 64 | + 'config' => [ |
|
| 65 | + 'type' => 'input', |
|
| 66 | + 'size' => 30, |
|
| 67 | + 'eval' => 'trim,required' |
|
| 68 | + ], |
|
| 69 | + ], |
|
| 70 | + 'query' => [ |
|
| 71 | + 'exclude' => 0, |
|
| 72 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:query', |
|
| 73 | + 'config' => [ |
|
| 74 | + 'type' => 'text', |
|
| 75 | + 'rows' => 5, |
|
| 76 | + 'cols' => 5, |
|
| 77 | + ], |
|
| 78 | + ], |
|
| 79 | + 'speaking_query' => [ |
|
| 80 | + 'exclude' => 0, |
|
| 81 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:speaking_query', |
|
| 82 | + 'config' => [ |
|
| 83 | + 'type' => 'text', |
|
| 84 | + 'rows' => 5, |
|
| 85 | + 'cols' => 5, |
|
| 86 | + ], |
|
| 87 | + ], |
|
| 88 | + ], |
|
| 89 | 89 | ]; |