@@ -19,67 +19,67 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class ConfigurationViewHelper extends AbstractViewHelper |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Render the columns of the grid. |
|
| 24 | - * |
|
| 25 | - * @throws NotExistingFieldException |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public function render() |
|
| 29 | - { |
|
| 30 | - $output = ''; |
|
| 22 | + /** |
|
| 23 | + * Render the columns of the grid. |
|
| 24 | + * |
|
| 25 | + * @throws NotExistingFieldException |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public function render() |
|
| 29 | + { |
|
| 30 | + $output = ''; |
|
| 31 | 31 | |
| 32 | - foreach (Tca::grid()->getFields() as $fieldNameAndPath => $configuration) { |
|
| 33 | - // Early failure if field does not exist. |
|
| 34 | - if (!$this->isAllowed($fieldNameAndPath)) { |
|
| 35 | - $message = sprintf('Property "%s" does not exist!', $fieldNameAndPath); |
|
| 36 | - throw new NotExistingFieldException($message, 1375369594); |
|
| 37 | - } |
|
| 32 | + foreach (Tca::grid()->getFields() as $fieldNameAndPath => $configuration) { |
|
| 33 | + // Early failure if field does not exist. |
|
| 34 | + if (!$this->isAllowed($fieldNameAndPath)) { |
|
| 35 | + $message = sprintf('Property "%s" does not exist!', $fieldNameAndPath); |
|
| 36 | + throw new NotExistingFieldException($message, 1375369594); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - // mData vs columnName |
|
| 40 | - // ------------------- |
|
| 41 | - // mData: internal name of DataTable plugin and can not contains a path, e.g. metadata.title |
|
| 42 | - // columnName: whole field name with path |
|
| 43 | - $output .= sprintf( |
|
| 44 | - 'Vidi._columns.push({ "data": "%s", "sortable": %s, "visible": %s, "width": "%s", "class": "%s", "columnName": "%s" });' . PHP_EOL, |
|
| 45 | - $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath), // Suitable field name for the DataTable plugin. |
|
| 46 | - Tca::grid()->isSortable($fieldNameAndPath) ? 'true' : 'false', |
|
| 47 | - Tca::grid()->isVisible($fieldNameAndPath) ? 'true' : 'false', |
|
| 48 | - Tca::grid()->getWidth($fieldNameAndPath), |
|
| 49 | - Tca::grid()->getClass($fieldNameAndPath), |
|
| 50 | - $fieldNameAndPath |
|
| 51 | - ); |
|
| 52 | - } |
|
| 39 | + // mData vs columnName |
|
| 40 | + // ------------------- |
|
| 41 | + // mData: internal name of DataTable plugin and can not contains a path, e.g. metadata.title |
|
| 42 | + // columnName: whole field name with path |
|
| 43 | + $output .= sprintf( |
|
| 44 | + 'Vidi._columns.push({ "data": "%s", "sortable": %s, "visible": %s, "width": "%s", "class": "%s", "columnName": "%s" });' . PHP_EOL, |
|
| 45 | + $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath), // Suitable field name for the DataTable plugin. |
|
| 46 | + Tca::grid()->isSortable($fieldNameAndPath) ? 'true' : 'false', |
|
| 47 | + Tca::grid()->isVisible($fieldNameAndPath) ? 'true' : 'false', |
|
| 48 | + Tca::grid()->getWidth($fieldNameAndPath), |
|
| 49 | + Tca::grid()->getClass($fieldNameAndPath), |
|
| 50 | + $fieldNameAndPath |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - return $output; |
|
| 55 | - } |
|
| 54 | + return $output; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Tell whether the field looks ok to be displayed within the Grid. |
|
| 59 | - * |
|
| 60 | - * @param string $fieldNameAndPath |
|
| 61 | - * @return boolean |
|
| 62 | - */ |
|
| 63 | - protected function isAllowed($fieldNameAndPath) |
|
| 64 | - { |
|
| 65 | - $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
| 66 | - $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 57 | + /** |
|
| 58 | + * Tell whether the field looks ok to be displayed within the Grid. |
|
| 59 | + * |
|
| 60 | + * @param string $fieldNameAndPath |
|
| 61 | + * @return boolean |
|
| 62 | + */ |
|
| 63 | + protected function isAllowed($fieldNameAndPath) |
|
| 64 | + { |
|
| 65 | + $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
| 66 | + $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 67 | 67 | |
| 68 | - $isAllowed = false; |
|
| 69 | - if (Tca::grid()->hasRenderers($fieldNameAndPath)) { |
|
| 70 | - $isAllowed = true; |
|
| 71 | - } elseif (Tca::table()->field($fieldNameAndPath)->isSystem() || Tca::table($dataType)->hasField($fieldName)) { |
|
| 72 | - $isAllowed = true; |
|
| 73 | - } |
|
| 68 | + $isAllowed = false; |
|
| 69 | + if (Tca::grid()->hasRenderers($fieldNameAndPath)) { |
|
| 70 | + $isAllowed = true; |
|
| 71 | + } elseif (Tca::table()->field($fieldNameAndPath)->isSystem() || Tca::table($dataType)->hasField($fieldName)) { |
|
| 72 | + $isAllowed = true; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return $isAllowed; |
|
| 76 | - } |
|
| 75 | + return $isAllowed; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @return FieldPathResolver|object |
|
| 80 | - */ |
|
| 81 | - protected function getFieldPathResolver() |
|
| 82 | - { |
|
| 83 | - return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 84 | - } |
|
| 78 | + /** |
|
| 79 | + * @return FieldPathResolver|object |
|
| 80 | + */ |
|
| 81 | + protected function getFieldPathResolver() |
|
| 82 | + { |
|
| 83 | + return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -18,25 +18,25 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class HasRelationViewHelper extends AbstractViewHelper |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Return whether the current field name has a relation to the main content. |
|
| 23 | - * |
|
| 24 | - * @return boolean |
|
| 25 | - */ |
|
| 26 | - public function render() |
|
| 27 | - { |
|
| 28 | - $fieldNameAndPath = $this->templateVariableContainer->get('columnName'); |
|
| 29 | - $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
| 30 | - $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 31 | - $hasRelation = Tca::table($dataType)->field($fieldName)->hasRelation(); |
|
| 32 | - return $hasRelation; |
|
| 33 | - } |
|
| 21 | + /** |
|
| 22 | + * Return whether the current field name has a relation to the main content. |
|
| 23 | + * |
|
| 24 | + * @return boolean |
|
| 25 | + */ |
|
| 26 | + public function render() |
|
| 27 | + { |
|
| 28 | + $fieldNameAndPath = $this->templateVariableContainer->get('columnName'); |
|
| 29 | + $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
| 30 | + $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
| 31 | + $hasRelation = Tca::table($dataType)->field($fieldName)->hasRelation(); |
|
| 32 | + return $hasRelation; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @return FieldPathResolver|object |
|
| 37 | - */ |
|
| 38 | - protected function getFieldPathResolver() |
|
| 39 | - { |
|
| 40 | - return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 41 | - } |
|
| 35 | + /** |
|
| 36 | + * @return FieldPathResolver|object |
|
| 37 | + */ |
|
| 38 | + protected function getFieldPathResolver() |
|
| 39 | + { |
|
| 40 | + return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -17,21 +17,21 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class IsEditableViewHelper extends AbstractViewHelper |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function initializeArguments() |
|
| 24 | - { |
|
| 25 | - $this->registerArgument('name', 'string', 'The column name', true); |
|
| 26 | - } |
|
| 20 | + /** |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function initializeArguments() |
|
| 24 | + { |
|
| 25 | + $this->registerArgument('name', 'string', 'The column name', true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Return whether field name is editable in the Grid. |
|
| 30 | - * |
|
| 31 | - * @return boolean |
|
| 32 | - */ |
|
| 33 | - public function render() |
|
| 34 | - { |
|
| 35 | - return Tca::grid()->isEditable($this->arguments['name']); |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * Return whether field name is editable in the Grid. |
|
| 30 | + * |
|
| 31 | + * @return boolean |
|
| 32 | + */ |
|
| 33 | + public function render() |
|
| 34 | + { |
|
| 35 | + return Tca::grid()->isEditable($this->arguments['name']); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -17,22 +17,22 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class IsExcludedViewHelper extends AbstractViewHelper |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function initializeArguments() |
|
| 24 | - { |
|
| 25 | - $this->registerArgument('name', 'string', 'The column name', true); |
|
| 26 | - } |
|
| 20 | + /** |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function initializeArguments() |
|
| 24 | + { |
|
| 25 | + $this->registerArgument('name', 'string', 'The column name', true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Returns whether the column is excluded from the Grid. |
|
| 30 | - * |
|
| 31 | - * @return bool |
|
| 32 | - */ |
|
| 33 | - public function render() |
|
| 34 | - { |
|
| 35 | - $excludedFields = Tca::grid()->getExcludedFields(); |
|
| 36 | - return !in_array($this->arguments['name'], $excludedFields, true); |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * Returns whether the column is excluded from the Grid. |
|
| 30 | + * |
|
| 31 | + * @return bool |
|
| 32 | + */ |
|
| 33 | + public function render() |
|
| 34 | + { |
|
| 35 | + $excludedFields = Tca::grid()->getExcludedFields(); |
|
| 36 | + return !in_array($this->arguments['name'], $excludedFields, true); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -17,14 +17,14 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class TitleViewHelper extends AbstractViewHelper |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Returns a column title. |
|
| 22 | - * |
|
| 23 | - * @return string |
|
| 24 | - */ |
|
| 25 | - public function render() |
|
| 26 | - { |
|
| 27 | - $columnName = $this->templateVariableContainer->get('columnName'); |
|
| 28 | - return Tca::grid()->getLabel($columnName); |
|
| 29 | - } |
|
| 20 | + /** |
|
| 21 | + * Returns a column title. |
|
| 22 | + * |
|
| 23 | + * @return string |
|
| 24 | + */ |
|
| 25 | + public function render() |
|
| 26 | + { |
|
| 27 | + $columnName = $this->templateVariableContainer->get('columnName'); |
|
| 28 | + return Tca::grid()->getLabel($columnName); |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -17,21 +17,21 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class IsVisibleViewHelper extends AbstractViewHelper |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function initializeArguments() |
|
| 24 | - { |
|
| 25 | - $this->registerArgument('name', 'string', 'The column name', true); |
|
| 26 | - } |
|
| 20 | + /** |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function initializeArguments() |
|
| 24 | + { |
|
| 25 | + $this->registerArgument('name', 'string', 'The column name', true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Returns whether the column is visible. |
|
| 30 | - * |
|
| 31 | - * @return bool |
|
| 32 | - */ |
|
| 33 | - public function render() |
|
| 34 | - { |
|
| 35 | - return Tca::grid()->isVisible($this->arguments['name']); |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * Returns whether the column is visible. |
|
| 30 | + * |
|
| 31 | + * @return bool |
|
| 32 | + */ |
|
| 33 | + public function render() |
|
| 34 | + { |
|
| 35 | + return Tca::grid()->isVisible($this->arguments['name']); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -18,25 +18,25 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class ModulePreferencesViewHelper extends AbstractViewHelper |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function initializeArguments() |
|
| 25 | - { |
|
| 26 | - $this->registerArgument('key', 'string', 'The module key', true); |
|
| 27 | - } |
|
| 21 | + /** |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function initializeArguments() |
|
| 25 | + { |
|
| 26 | + $this->registerArgument('key', 'string', 'The module key', true); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Interface with the Module Loader |
|
| 31 | - * |
|
| 32 | - * @return string |
|
| 33 | - */ |
|
| 34 | - public function render() |
|
| 35 | - { |
|
| 36 | - $getter = 'get' . ucfirst($this->arguments['key']); |
|
| 29 | + /** |
|
| 30 | + * Interface with the Module Loader |
|
| 31 | + * |
|
| 32 | + * @return string |
|
| 33 | + */ |
|
| 34 | + public function render() |
|
| 35 | + { |
|
| 36 | + $getter = 'get' . ucfirst($this->arguments['key']); |
|
| 37 | 37 | |
| 38 | - /** @var ModulePreferences $modulePreferences */ |
|
| 39 | - $modulePreferences = GeneralUtility::makeInstance(ModulePreferences::class); |
|
| 40 | - return $modulePreferences->$getter(); |
|
| 41 | - } |
|
| 38 | + /** @var ModulePreferences $modulePreferences */ |
|
| 39 | + $modulePreferences = GeneralUtility::makeInstance(ModulePreferences::class); |
|
| 40 | + return $modulePreferences->$getter(); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -17,24 +17,24 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class LabelViewHelper extends AbstractViewHelper |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function initializeArguments() |
|
| 24 | - { |
|
| 25 | - $this->registerArgument('dataType', 'string', '', true); |
|
| 26 | - $this->registerArgument('fieldName', 'string', '', true); |
|
| 27 | - } |
|
| 20 | + /** |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function initializeArguments() |
|
| 24 | + { |
|
| 25 | + $this->registerArgument('dataType', 'string', '', true); |
|
| 26 | + $this->registerArgument('fieldName', 'string', '', true); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Returns the label of a field |
|
| 31 | - * |
|
| 32 | - * @return string |
|
| 33 | - */ |
|
| 34 | - public function render() |
|
| 35 | - { |
|
| 36 | - $dataType = $this->arguments['dataType']; |
|
| 37 | - $fieldName = $this->arguments['fieldName']; |
|
| 38 | - return Tca::table($dataType)->field($fieldName)->getLabel(); |
|
| 39 | - } |
|
| 29 | + /** |
|
| 30 | + * Returns the label of a field |
|
| 31 | + * |
|
| 32 | + * @return string |
|
| 33 | + */ |
|
| 34 | + public function render() |
|
| 35 | + { |
|
| 36 | + $dataType = $this->arguments['dataType']; |
|
| 37 | + $fieldName = $this->arguments['fieldName']; |
|
| 38 | + return Tca::table($dataType)->field($fieldName)->getLabel(); |
|
| 39 | + } |
|
| 40 | 40 | } |
@@ -17,39 +17,39 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class TableViewHelper extends AbstractViewHelper |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function initializeArguments() |
|
| 24 | - { |
|
| 25 | - $this->registerArgument('key', 'string', '', true); |
|
| 26 | - $this->registerArgument('dataType', 'string', '', false, ''); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Returns a value from the TCA Table service according to a key. |
|
| 31 | - * |
|
| 32 | - * @return string |
|
| 33 | - */ |
|
| 34 | - public function render() |
|
| 35 | - { |
|
| 36 | - $key = $this->arguments['key']; |
|
| 37 | - $dataType = $this->arguments['dataType']; |
|
| 38 | - |
|
| 39 | - $result = Tca::table($dataType)->getTca(); |
|
| 40 | - |
|
| 41 | - // Explode segment and loop around. |
|
| 42 | - $keys = explode('|', $key); |
|
| 43 | - foreach ($keys as $key) { |
|
| 44 | - if (!empty($result[$key])) { |
|
| 45 | - $result = $result[$key]; |
|
| 46 | - } else { |
|
| 47 | - // not found value |
|
| 48 | - $result = false; |
|
| 49 | - break; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - return $result; |
|
| 54 | - } |
|
| 20 | + /** |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function initializeArguments() |
|
| 24 | + { |
|
| 25 | + $this->registerArgument('key', 'string', '', true); |
|
| 26 | + $this->registerArgument('dataType', 'string', '', false, ''); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Returns a value from the TCA Table service according to a key. |
|
| 31 | + * |
|
| 32 | + * @return string |
|
| 33 | + */ |
|
| 34 | + public function render() |
|
| 35 | + { |
|
| 36 | + $key = $this->arguments['key']; |
|
| 37 | + $dataType = $this->arguments['dataType']; |
|
| 38 | + |
|
| 39 | + $result = Tca::table($dataType)->getTca(); |
|
| 40 | + |
|
| 41 | + // Explode segment and loop around. |
|
| 42 | + $keys = explode('|', $key); |
|
| 43 | + foreach ($keys as $key) { |
|
| 44 | + if (!empty($result[$key])) { |
|
| 45 | + $result = $result[$key]; |
|
| 46 | + } else { |
|
| 47 | + // not found value |
|
| 48 | + $result = false; |
|
| 49 | + break; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + return $result; |
|
| 54 | + } |
|
| 55 | 55 | } |