@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | if (!defined('TYPO3')) die ('Access denied.'); |
6 | 6 | |
7 | 7 | $tca = [ |
8 | - 'grid' => [ |
|
9 | - 'excluded_fields' => 'image, imagewidth, imageorient, imagecols, imageborder, image_noRows, image_effects, image_compression, tx_impexp_origuid, image_zoom, |
|
8 | + 'grid' => [ |
|
9 | + 'excluded_fields' => 'image, imagewidth, imageorient, imagecols, imageborder, image_noRows, image_effects, image_compression, tx_impexp_origuid, image_zoom, |
|
10 | 10 | spaceAfter, spaceBefore, |
11 | 11 | uploads_description, uploads_type, |
12 | 12 | media, assets, table_caption, table_delimiter, table_enclosure, table_header_position, table_tfoot, table_bgColor, table_border, table_cellpadding, table_cellspacing, |
@@ -16,39 +16,39 @@ discard block |
||
16 | 16 | target, linkToTop, menu_type, list_type, select_key, |
17 | 17 | file_collections, filelink_size, filelink_sorting, |
18 | 18 | external_media_ratio, external_media_source', |
19 | - 'columns' => [ |
|
20 | - '__checkbox' => [ |
|
21 | - 'renderer' => CheckBoxRenderer::class, |
|
22 | - ], |
|
23 | - 'uid' => [ |
|
24 | - 'visible' => false, |
|
25 | - 'label' => 'Id', |
|
26 | - 'width' => '5px', |
|
27 | - ], |
|
28 | - 'header' => [ |
|
29 | - 'editable' => true, |
|
30 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tt_content.xlf:header', |
|
31 | - ], |
|
32 | - 'tstamp' => [ |
|
33 | - 'visible' => false, |
|
34 | - 'format' => 'Fab\Vidi\Formatter\Date', |
|
35 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:tstamp', |
|
36 | - ], |
|
37 | - 'crdate' => [ |
|
38 | - 'visible' => false, |
|
39 | - 'format' => 'Fab\Vidi\Formatter\Date', |
|
40 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:crdate', |
|
41 | - ], |
|
42 | - 'hidden' => [ |
|
43 | - 'renderer' => 'Fab\Vidi\Grid\VisibilityRenderer', |
|
44 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active', |
|
45 | - 'width' => '3%', |
|
46 | - ], |
|
47 | - '__buttons' => [ |
|
48 | - 'renderer' => ButtonGroupRenderer::class, |
|
49 | - ], |
|
50 | - ], |
|
51 | - ], |
|
19 | + 'columns' => [ |
|
20 | + '__checkbox' => [ |
|
21 | + 'renderer' => CheckBoxRenderer::class, |
|
22 | + ], |
|
23 | + 'uid' => [ |
|
24 | + 'visible' => false, |
|
25 | + 'label' => 'Id', |
|
26 | + 'width' => '5px', |
|
27 | + ], |
|
28 | + 'header' => [ |
|
29 | + 'editable' => true, |
|
30 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tt_content.xlf:header', |
|
31 | + ], |
|
32 | + 'tstamp' => [ |
|
33 | + 'visible' => false, |
|
34 | + 'format' => 'Fab\Vidi\Formatter\Date', |
|
35 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:tstamp', |
|
36 | + ], |
|
37 | + 'crdate' => [ |
|
38 | + 'visible' => false, |
|
39 | + 'format' => 'Fab\Vidi\Formatter\Date', |
|
40 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:crdate', |
|
41 | + ], |
|
42 | + 'hidden' => [ |
|
43 | + 'renderer' => 'Fab\Vidi\Grid\VisibilityRenderer', |
|
44 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active', |
|
45 | + 'width' => '3%', |
|
46 | + ], |
|
47 | + '__buttons' => [ |
|
48 | + 'renderer' => ButtonGroupRenderer::class, |
|
49 | + ], |
|
50 | + ], |
|
51 | + ], |
|
52 | 52 | ]; |
53 | 53 | |
54 | 54 | ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['tt_content'], $tca); |
@@ -2,7 +2,9 @@ |
||
2 | 2 | use Fab\Vidi\Grid\CheckBoxRenderer; |
3 | 3 | use Fab\Vidi\Grid\ButtonGroupRenderer; |
4 | 4 | use TYPO3\CMS\Core\Utility\ArrayUtility; |
5 | -if (!defined('TYPO3')) die ('Access denied.'); |
|
5 | +if (!defined('TYPO3')) { |
|
6 | + die ('Access denied.'); |
|
7 | +} |
|
6 | 8 | |
7 | 9 | $tca = [ |
8 | 10 | 'grid' => [ |
@@ -7,110 +7,110 @@ |
||
7 | 7 | if (!defined('TYPO3')) die ('Access denied.'); |
8 | 8 | |
9 | 9 | $tca = [ |
10 | - 'ctrl' => [ |
|
11 | - // By default "searchFields" has many fields which has a performance cost when dealing with large data-set. |
|
12 | - // Override search field for performance reason. |
|
13 | - // To restore default values, just replace with this: $GLOBALS['TCA']['fe_users']['ctrl']['searchFields'] . ',usergroup', |
|
14 | - 'searchFields' => 'username, first_name, last_name, usergroup', |
|
15 | - ], |
|
16 | - 'vidi' => [ |
|
17 | - // Special case when the field name does not follow the conventions. |
|
18 | - // Vidi needs a bit of help to find the equivalence fieldName <-> propertyName. |
|
19 | - 'mappings' => [ |
|
20 | - 'lockToDomain' => 'lockToDomain', |
|
21 | - 'TSconfig' => 'tsConfig', |
|
22 | - 'felogin_redirectPid' => 'feLoginRedirectPid', |
|
23 | - 'felogin_forgotHash' => 'feLoginForgotHash', |
|
24 | - ], |
|
25 | - ], |
|
26 | - 'grid' => [ |
|
27 | - 'excluded_fields' => 'lockToDomain, TSconfig, felogin_redirectPid, felogin_forgotHash, auth_token, image', |
|
28 | - 'export' => [ |
|
29 | - 'include_files' => false, |
|
30 | - ], |
|
31 | - 'facets' => [ |
|
32 | - 'uid', |
|
33 | - 'username', |
|
34 | - 'name', |
|
35 | - 'first_name', |
|
36 | - 'last_name', |
|
37 | - 'middle_name', |
|
38 | - 'address', |
|
39 | - 'telephone', |
|
40 | - 'fax', |
|
41 | - 'email', |
|
42 | - 'title', |
|
43 | - 'zip', |
|
44 | - 'city', |
|
45 | - 'country', |
|
46 | - 'company', |
|
47 | - 'usergroup', |
|
48 | - StandardFacet::class => [ |
|
49 | - 'name' => 'disable', |
|
50 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active', |
|
51 | - 'suggestions' => [ |
|
52 | - '0' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active.0', |
|
53 | - '1' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active.1' |
|
54 | - ] |
|
55 | - ], |
|
56 | - PageFacet::class => [ |
|
57 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:facet.pid' |
|
58 | - ], |
|
59 | - ], |
|
60 | - 'columns' => [ |
|
61 | - '__checkbox' => [ |
|
62 | - 'renderer' => CheckBoxRenderer::class, |
|
63 | - ], |
|
64 | - 'uid' => [ |
|
65 | - 'visible' => false, |
|
66 | - 'label' => 'Id', |
|
67 | - 'width' => '5px', |
|
68 | - ], |
|
69 | - 'username' => [ |
|
70 | - 'visible' => true, |
|
71 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf:username', |
|
72 | - 'editable' => true, |
|
73 | - ], |
|
74 | - 'name' => [ |
|
75 | - 'visible' => true, |
|
76 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf:name', |
|
77 | - 'editable' => true, |
|
78 | - ], |
|
79 | - 'email' => [ |
|
80 | - 'visible' => true, |
|
81 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf:email', |
|
82 | - 'editable' => true, |
|
83 | - ], |
|
84 | - 'usergroup' => [ |
|
85 | - 'visible' => true, |
|
86 | - 'renderers' => [ |
|
87 | - 'Fab\Vidi\Grid\RelationEditRenderer', |
|
88 | - 'Fab\Vidi\Grid\RelationRenderer', |
|
89 | - ], |
|
90 | - 'editable' => true, |
|
91 | - 'sortable' => false, |
|
92 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf:usergroup', |
|
93 | - ], |
|
94 | - 'tstamp' => [ |
|
95 | - 'visible' => false, |
|
96 | - 'format' => 'Fab\Vidi\Formatter\Date', |
|
97 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:tstamp', |
|
98 | - ], |
|
99 | - 'crdate' => [ |
|
100 | - 'visible' => false, |
|
101 | - 'format' => 'Fab\Vidi\Formatter\Date', |
|
102 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:crdate', |
|
103 | - ], |
|
104 | - 'disable' => [ |
|
105 | - 'renderer' => 'Fab\Vidi\Grid\VisibilityRenderer', |
|
106 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active', |
|
107 | - 'width' => '3%', |
|
108 | - ], |
|
109 | - '__buttons' => [ |
|
110 | - 'renderer' => ButtonGroupRenderer::class, |
|
111 | - ], |
|
112 | - ], |
|
113 | - ], |
|
10 | + 'ctrl' => [ |
|
11 | + // By default "searchFields" has many fields which has a performance cost when dealing with large data-set. |
|
12 | + // Override search field for performance reason. |
|
13 | + // To restore default values, just replace with this: $GLOBALS['TCA']['fe_users']['ctrl']['searchFields'] . ',usergroup', |
|
14 | + 'searchFields' => 'username, first_name, last_name, usergroup', |
|
15 | + ], |
|
16 | + 'vidi' => [ |
|
17 | + // Special case when the field name does not follow the conventions. |
|
18 | + // Vidi needs a bit of help to find the equivalence fieldName <-> propertyName. |
|
19 | + 'mappings' => [ |
|
20 | + 'lockToDomain' => 'lockToDomain', |
|
21 | + 'TSconfig' => 'tsConfig', |
|
22 | + 'felogin_redirectPid' => 'feLoginRedirectPid', |
|
23 | + 'felogin_forgotHash' => 'feLoginForgotHash', |
|
24 | + ], |
|
25 | + ], |
|
26 | + 'grid' => [ |
|
27 | + 'excluded_fields' => 'lockToDomain, TSconfig, felogin_redirectPid, felogin_forgotHash, auth_token, image', |
|
28 | + 'export' => [ |
|
29 | + 'include_files' => false, |
|
30 | + ], |
|
31 | + 'facets' => [ |
|
32 | + 'uid', |
|
33 | + 'username', |
|
34 | + 'name', |
|
35 | + 'first_name', |
|
36 | + 'last_name', |
|
37 | + 'middle_name', |
|
38 | + 'address', |
|
39 | + 'telephone', |
|
40 | + 'fax', |
|
41 | + 'email', |
|
42 | + 'title', |
|
43 | + 'zip', |
|
44 | + 'city', |
|
45 | + 'country', |
|
46 | + 'company', |
|
47 | + 'usergroup', |
|
48 | + StandardFacet::class => [ |
|
49 | + 'name' => 'disable', |
|
50 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active', |
|
51 | + 'suggestions' => [ |
|
52 | + '0' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active.0', |
|
53 | + '1' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active.1' |
|
54 | + ] |
|
55 | + ], |
|
56 | + PageFacet::class => [ |
|
57 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:facet.pid' |
|
58 | + ], |
|
59 | + ], |
|
60 | + 'columns' => [ |
|
61 | + '__checkbox' => [ |
|
62 | + 'renderer' => CheckBoxRenderer::class, |
|
63 | + ], |
|
64 | + 'uid' => [ |
|
65 | + 'visible' => false, |
|
66 | + 'label' => 'Id', |
|
67 | + 'width' => '5px', |
|
68 | + ], |
|
69 | + 'username' => [ |
|
70 | + 'visible' => true, |
|
71 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf:username', |
|
72 | + 'editable' => true, |
|
73 | + ], |
|
74 | + 'name' => [ |
|
75 | + 'visible' => true, |
|
76 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf:name', |
|
77 | + 'editable' => true, |
|
78 | + ], |
|
79 | + 'email' => [ |
|
80 | + 'visible' => true, |
|
81 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf:email', |
|
82 | + 'editable' => true, |
|
83 | + ], |
|
84 | + 'usergroup' => [ |
|
85 | + 'visible' => true, |
|
86 | + 'renderers' => [ |
|
87 | + 'Fab\Vidi\Grid\RelationEditRenderer', |
|
88 | + 'Fab\Vidi\Grid\RelationRenderer', |
|
89 | + ], |
|
90 | + 'editable' => true, |
|
91 | + 'sortable' => false, |
|
92 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf:usergroup', |
|
93 | + ], |
|
94 | + 'tstamp' => [ |
|
95 | + 'visible' => false, |
|
96 | + 'format' => 'Fab\Vidi\Formatter\Date', |
|
97 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:tstamp', |
|
98 | + ], |
|
99 | + 'crdate' => [ |
|
100 | + 'visible' => false, |
|
101 | + 'format' => 'Fab\Vidi\Formatter\Date', |
|
102 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:crdate', |
|
103 | + ], |
|
104 | + 'disable' => [ |
|
105 | + 'renderer' => 'Fab\Vidi\Grid\VisibilityRenderer', |
|
106 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:active', |
|
107 | + 'width' => '3%', |
|
108 | + ], |
|
109 | + '__buttons' => [ |
|
110 | + 'renderer' => ButtonGroupRenderer::class, |
|
111 | + ], |
|
112 | + ], |
|
113 | + ], |
|
114 | 114 | ]; |
115 | 115 | |
116 | 116 | ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['fe_users'], $tca); |
@@ -4,7 +4,9 @@ |
||
4 | 4 | use Fab\Vidi\Grid\CheckBoxRenderer; |
5 | 5 | use Fab\Vidi\Grid\ButtonGroupRenderer; |
6 | 6 | use TYPO3\CMS\Core\Utility\ArrayUtility; |
7 | -if (!defined('TYPO3')) die ('Access denied.'); |
|
7 | +if (!defined('TYPO3')) { |
|
8 | + die ('Access denied.'); |
|
9 | +} |
|
8 | 10 | |
9 | 11 | $tca = [ |
10 | 12 | 'ctrl' => [ |
@@ -6,58 +6,58 @@ |
||
6 | 6 | if (!defined('TYPO3')) die ('Access denied.'); |
7 | 7 | |
8 | 8 | $tca = [ |
9 | - 'vidi' => [ |
|
10 | - // Special case when the field name does not follow the conventions. |
|
11 | - // Vidi needs a bit of help to find the equivalence fieldName <-> propertyName. |
|
12 | - 'mappings' => [ |
|
13 | - 'lockToDomain' => 'lockToDomain', |
|
14 | - 'TSconfig' => 'tsConfig', |
|
15 | - 'felogin_redirectPid' => 'feLoginRedirectPid', |
|
16 | - ], |
|
17 | - ], |
|
18 | - 'grid' => [ |
|
19 | - 'facets' => [ |
|
20 | - 'uid', |
|
21 | - 'title', |
|
22 | - 'description', |
|
23 | - PageFacet::class => [ |
|
24 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:facet.pid' |
|
25 | - ] |
|
26 | - ], |
|
27 | - 'columns' => [ |
|
28 | - '__checkbox' => [ |
|
29 | - 'renderer' => CheckBoxRenderer::class, |
|
30 | - ], |
|
31 | - 'uid' => [ |
|
32 | - 'visible' => false, |
|
33 | - 'label' => 'Id', |
|
34 | - 'width' => '5px', |
|
35 | - ], |
|
36 | - 'title' => [ |
|
37 | - 'visible' => true, |
|
38 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_groups.xlf:title', |
|
39 | - 'editable' => true, |
|
40 | - ], |
|
41 | - 'tstamp' => [ |
|
42 | - 'visible' => false, |
|
43 | - 'format' => 'Fab\Vidi\Formatter\Date', |
|
44 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:tstamp', |
|
45 | - ], |
|
46 | - 'crdate' => [ |
|
47 | - 'visible' => false, |
|
48 | - 'format' => 'Fab\Vidi\Formatter\Date', |
|
49 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:crdate', |
|
50 | - ], |
|
51 | - 'hidden' => [ |
|
52 | - 'renderer' => 'Fab\Vidi\Grid\VisibilityRenderer', |
|
53 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:visibility_abbreviation', |
|
54 | - 'width' => '3%', |
|
55 | - ], |
|
56 | - '__buttons' => [ |
|
57 | - 'renderer' => ButtonGroupRenderer::class, |
|
58 | - ], |
|
59 | - ] |
|
60 | - ] |
|
9 | + 'vidi' => [ |
|
10 | + // Special case when the field name does not follow the conventions. |
|
11 | + // Vidi needs a bit of help to find the equivalence fieldName <-> propertyName. |
|
12 | + 'mappings' => [ |
|
13 | + 'lockToDomain' => 'lockToDomain', |
|
14 | + 'TSconfig' => 'tsConfig', |
|
15 | + 'felogin_redirectPid' => 'feLoginRedirectPid', |
|
16 | + ], |
|
17 | + ], |
|
18 | + 'grid' => [ |
|
19 | + 'facets' => [ |
|
20 | + 'uid', |
|
21 | + 'title', |
|
22 | + 'description', |
|
23 | + PageFacet::class => [ |
|
24 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:facet.pid' |
|
25 | + ] |
|
26 | + ], |
|
27 | + 'columns' => [ |
|
28 | + '__checkbox' => [ |
|
29 | + 'renderer' => CheckBoxRenderer::class, |
|
30 | + ], |
|
31 | + 'uid' => [ |
|
32 | + 'visible' => false, |
|
33 | + 'label' => 'Id', |
|
34 | + 'width' => '5px', |
|
35 | + ], |
|
36 | + 'title' => [ |
|
37 | + 'visible' => true, |
|
38 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/fe_groups.xlf:title', |
|
39 | + 'editable' => true, |
|
40 | + ], |
|
41 | + 'tstamp' => [ |
|
42 | + 'visible' => false, |
|
43 | + 'format' => 'Fab\Vidi\Formatter\Date', |
|
44 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:tstamp', |
|
45 | + ], |
|
46 | + 'crdate' => [ |
|
47 | + 'visible' => false, |
|
48 | + 'format' => 'Fab\Vidi\Formatter\Date', |
|
49 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:crdate', |
|
50 | + ], |
|
51 | + 'hidden' => [ |
|
52 | + 'renderer' => 'Fab\Vidi\Grid\VisibilityRenderer', |
|
53 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:visibility_abbreviation', |
|
54 | + 'width' => '3%', |
|
55 | + ], |
|
56 | + '__buttons' => [ |
|
57 | + 'renderer' => ButtonGroupRenderer::class, |
|
58 | + ], |
|
59 | + ] |
|
60 | + ] |
|
61 | 61 | ]; |
62 | 62 | |
63 | 63 | ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['fe_groups'], $tca); |
@@ -3,7 +3,9 @@ |
||
3 | 3 | use Fab\Vidi\Grid\CheckBoxRenderer; |
4 | 4 | use Fab\Vidi\Grid\ButtonGroupRenderer; |
5 | 5 | use TYPO3\CMS\Core\Utility\ArrayUtility; |
6 | -if (!defined('TYPO3')) die ('Access denied.'); |
|
6 | +if (!defined('TYPO3')) { |
|
7 | + die ('Access denied.'); |
|
8 | +} |
|
7 | 9 | |
8 | 10 | $tca = [ |
9 | 11 | 'vidi' => [ |
@@ -19,76 +19,76 @@ |
||
19 | 19 | class SelectionRepository extends Repository |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param string $dataType |
|
24 | - * @return QueryResult |
|
25 | - */ |
|
26 | - public function findByDataTypeForCurrentBackendUser($dataType) |
|
27 | - { |
|
28 | - $query = $this->createQuery(); |
|
22 | + /** |
|
23 | + * @param string $dataType |
|
24 | + * @return QueryResult |
|
25 | + */ |
|
26 | + public function findByDataTypeForCurrentBackendUser($dataType) |
|
27 | + { |
|
28 | + $query = $this->createQuery(); |
|
29 | 29 | |
30 | - // Compute the OR part |
|
31 | - if ($this->getBackendUser()->isAdmin()) { |
|
32 | - $logicalOr = $query->logicalOr( |
|
33 | - $query->equals('visibility', Selection::VISIBILITY_EVERYONE), |
|
34 | - $query->equals('visibility', Selection::VISIBILITY_ADMIN_ONLY), |
|
35 | - $query->equals('cruser_id', $this->getBackendUser()->user['uid']) |
|
36 | - ); |
|
37 | - } else { |
|
38 | - $logicalOr = $query->logicalOr( |
|
39 | - $query->equals('visibility', Selection::VISIBILITY_EVERYONE), |
|
40 | - $query->equals('cruser_id', $this->getBackendUser()->user['uid']) |
|
41 | - ); |
|
42 | - } |
|
30 | + // Compute the OR part |
|
31 | + if ($this->getBackendUser()->isAdmin()) { |
|
32 | + $logicalOr = $query->logicalOr( |
|
33 | + $query->equals('visibility', Selection::VISIBILITY_EVERYONE), |
|
34 | + $query->equals('visibility', Selection::VISIBILITY_ADMIN_ONLY), |
|
35 | + $query->equals('cruser_id', $this->getBackendUser()->user['uid']) |
|
36 | + ); |
|
37 | + } else { |
|
38 | + $logicalOr = $query->logicalOr( |
|
39 | + $query->equals('visibility', Selection::VISIBILITY_EVERYONE), |
|
40 | + $query->equals('cruser_id', $this->getBackendUser()->user['uid']) |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | |
44 | - // Add matching criteria |
|
45 | - $query->matching( |
|
46 | - $query->logicalAnd( |
|
47 | - $query->equals('dataType', $dataType), |
|
48 | - $logicalOr |
|
49 | - ) |
|
50 | - ); |
|
44 | + // Add matching criteria |
|
45 | + $query->matching( |
|
46 | + $query->logicalAnd( |
|
47 | + $query->equals('dataType', $dataType), |
|
48 | + $logicalOr |
|
49 | + ) |
|
50 | + ); |
|
51 | 51 | |
52 | - // Set ordering |
|
53 | - $query->setOrderings( |
|
54 | - array('name' => QueryInterface::ORDER_ASCENDING) |
|
55 | - ); |
|
52 | + // Set ordering |
|
53 | + $query->setOrderings( |
|
54 | + array('name' => QueryInterface::ORDER_ASCENDING) |
|
55 | + ); |
|
56 | 56 | |
57 | - return $query->execute(); |
|
58 | - } |
|
57 | + return $query->execute(); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $dataType |
|
62 | - * @return QueryResult |
|
63 | - */ |
|
64 | - public function findForEveryone($dataType) |
|
65 | - { |
|
66 | - $query = $this->createQuery(); |
|
60 | + /** |
|
61 | + * @param string $dataType |
|
62 | + * @return QueryResult |
|
63 | + */ |
|
64 | + public function findForEveryone($dataType) |
|
65 | + { |
|
66 | + $query = $this->createQuery(); |
|
67 | 67 | |
68 | - // Add matching criteria |
|
69 | - $query->matching( |
|
70 | - $query->logicalAnd( |
|
71 | - $query->equals('dataType', $dataType), |
|
72 | - $query->equals('visibility', Selection::VISIBILITY_EVERYONE) |
|
73 | - ) |
|
74 | - ); |
|
68 | + // Add matching criteria |
|
69 | + $query->matching( |
|
70 | + $query->logicalAnd( |
|
71 | + $query->equals('dataType', $dataType), |
|
72 | + $query->equals('visibility', Selection::VISIBILITY_EVERYONE) |
|
73 | + ) |
|
74 | + ); |
|
75 | 75 | |
76 | - // Set ordering |
|
77 | - $query->setOrderings( |
|
78 | - array('name' => QueryInterface::ORDER_ASCENDING) |
|
79 | - ); |
|
76 | + // Set ordering |
|
77 | + $query->setOrderings( |
|
78 | + array('name' => QueryInterface::ORDER_ASCENDING) |
|
79 | + ); |
|
80 | 80 | |
81 | - return $query->execute(); |
|
82 | - } |
|
81 | + return $query->execute(); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Returns an instance of the current Backend User. |
|
86 | - * |
|
87 | - * @return BackendUserAuthentication |
|
88 | - */ |
|
89 | - protected function getBackendUser() |
|
90 | - { |
|
91 | - return $GLOBALS['BE_USER']; |
|
92 | - } |
|
84 | + /** |
|
85 | + * Returns an instance of the current Backend User. |
|
86 | + * |
|
87 | + * @return BackendUserAuthentication |
|
88 | + */ |
|
89 | + protected function getBackendUser() |
|
90 | + { |
|
91 | + return $GLOBALS['BE_USER']; |
|
92 | + } |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | \ No newline at end of file |
@@ -17,44 +17,44 @@ |
||
17 | 17 | class ContentRepositoryFactory implements SingletonInterface |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - static protected $instances = []; |
|
24 | - |
|
25 | - /** |
|
26 | - * Returns a class instance of a repository. |
|
27 | - * If not data type is given, get the value from the module loader. |
|
28 | - * |
|
29 | - * @param string $dataType |
|
30 | - * @param string $sourceFieldName |
|
31 | - * @return ContentRepository |
|
32 | - */ |
|
33 | - static public function getInstance($dataType = null, $sourceFieldName = '') |
|
34 | - { |
|
35 | - |
|
36 | - /** @var ModuleLoader $moduleLoader */ |
|
37 | - if (is_null($dataType)) { |
|
38 | - |
|
39 | - // Try to get the data type from the module loader. |
|
40 | - $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class); |
|
41 | - $dataType = $moduleLoader->getDataType(); |
|
42 | - } |
|
43 | - |
|
44 | - // This should not happen. |
|
45 | - if (!$dataType) { |
|
46 | - throw new \RuntimeException('No data type given nor could be fetched by the module loader.', 1376118278); |
|
47 | - } |
|
48 | - |
|
49 | - if (empty(self::$instances[$dataType])) { |
|
50 | - $className = 'Fab\Vidi\Domain\Repository\ContentRepository'; |
|
51 | - self::$instances[$dataType] = GeneralUtility::makeInstance($className, $dataType, $sourceFieldName); |
|
52 | - } |
|
53 | - |
|
54 | - /** @var ContentRepository $contentRepository */ |
|
55 | - $contentRepository = self::$instances[$dataType]; |
|
56 | - $contentRepository->setSourceFieldName($sourceFieldName); |
|
57 | - return $contentRepository; |
|
58 | - } |
|
20 | + /** |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + static protected $instances = []; |
|
24 | + |
|
25 | + /** |
|
26 | + * Returns a class instance of a repository. |
|
27 | + * If not data type is given, get the value from the module loader. |
|
28 | + * |
|
29 | + * @param string $dataType |
|
30 | + * @param string $sourceFieldName |
|
31 | + * @return ContentRepository |
|
32 | + */ |
|
33 | + static public function getInstance($dataType = null, $sourceFieldName = '') |
|
34 | + { |
|
35 | + |
|
36 | + /** @var ModuleLoader $moduleLoader */ |
|
37 | + if (is_null($dataType)) { |
|
38 | + |
|
39 | + // Try to get the data type from the module loader. |
|
40 | + $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class); |
|
41 | + $dataType = $moduleLoader->getDataType(); |
|
42 | + } |
|
43 | + |
|
44 | + // This should not happen. |
|
45 | + if (!$dataType) { |
|
46 | + throw new \RuntimeException('No data type given nor could be fetched by the module loader.', 1376118278); |
|
47 | + } |
|
48 | + |
|
49 | + if (empty(self::$instances[$dataType])) { |
|
50 | + $className = 'Fab\Vidi\Domain\Repository\ContentRepository'; |
|
51 | + self::$instances[$dataType] = GeneralUtility::makeInstance($className, $dataType, $sourceFieldName); |
|
52 | + } |
|
53 | + |
|
54 | + /** @var ContentRepository $contentRepository */ |
|
55 | + $contentRepository = self::$instances[$dataType]; |
|
56 | + $contentRepository->setSourceFieldName($sourceFieldName); |
|
57 | + return $contentRepository; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
@@ -18,36 +18,36 @@ |
||
18 | 18 | class ToolValidator extends AbstractValidator |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Check whether $tool is valid. |
|
23 | - * |
|
24 | - * @param string $tool |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function isValid($tool) |
|
28 | - { |
|
21 | + /** |
|
22 | + * Check whether $tool is valid. |
|
23 | + * |
|
24 | + * @param string $tool |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function isValid($tool) |
|
28 | + { |
|
29 | 29 | |
30 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
31 | - $isValid = ToolRegistry::getInstance()->isAllowed($dataType, $tool); |
|
30 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
31 | + $isValid = ToolRegistry::getInstance()->isAllowed($dataType, $tool); |
|
32 | 32 | |
33 | - if (!$isValid) { |
|
34 | - $message = sprintf('This Tool "%s" is not allowed for the current data type.', $tool); |
|
35 | - $this->addError($message, 1409041510); |
|
36 | - } |
|
33 | + if (!$isValid) { |
|
34 | + $message = sprintf('This Tool "%s" is not allowed for the current data type.', $tool); |
|
35 | + $this->addError($message, 1409041510); |
|
36 | + } |
|
37 | 37 | |
38 | - if (!class_exists($tool)) { |
|
39 | - $message = sprintf('I could not find class "%s"', $tool); |
|
40 | - $this->addError($message, 1409041511); |
|
41 | - } |
|
42 | - } |
|
38 | + if (!class_exists($tool)) { |
|
39 | + $message = sprintf('I could not find class "%s"', $tool); |
|
40 | + $this->addError($message, 1409041511); |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get the Vidi Module Loader. |
|
46 | - * |
|
47 | - * @return ModuleLoader|object |
|
48 | - */ |
|
49 | - protected function getModuleLoader() |
|
50 | - { |
|
51 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
52 | - } |
|
44 | + /** |
|
45 | + * Get the Vidi Module Loader. |
|
46 | + * |
|
47 | + * @return ModuleLoader|object |
|
48 | + */ |
|
49 | + protected function getModuleLoader() |
|
50 | + { |
|
51 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
52 | + } |
|
53 | 53 | } |
@@ -19,79 +19,79 @@ |
||
19 | 19 | class ClipboardController extends ActionController |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * Save data into the clipboard. |
|
24 | - * |
|
25 | - * @param array $matches |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function saveAction(array $matches = array()) |
|
29 | - { |
|
30 | - |
|
31 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
32 | - $this->getClipboardService()->save($matcher); |
|
33 | - |
|
34 | - // Fetch objects via the Content Service. |
|
35 | - $contentService = $this->getContentService()->findBy($matcher); |
|
36 | - $numberOfObjects = $contentService->getNumberOfObjects(); |
|
37 | - |
|
38 | - if ($numberOfObjects === 0) { |
|
39 | - $this->getClipboardService()->flush(); |
|
40 | - } |
|
41 | - |
|
42 | - # Json header is not automatically sent in the BE... |
|
43 | - $this->response->setHeader('Content-Type', 'application/json'); |
|
44 | - $this->response->sendHeaders(); |
|
45 | - return json_encode($numberOfObjects); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Completely flush the clipboard. |
|
50 | - * |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function flushAction() |
|
54 | - { |
|
55 | - $this->getClipboardService()->flush(); |
|
56 | - |
|
57 | - # Json header is not automatically sent in the BE... |
|
58 | - $this->response->setHeader('Content-Type', 'application/json'); |
|
59 | - $this->response->sendHeaders(); |
|
60 | - return json_encode(true); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Show the content of the clipboard. |
|
65 | - */ |
|
66 | - public function showAction() |
|
67 | - { |
|
68 | - |
|
69 | - // Retrieve matcher object from clipboard. |
|
70 | - $matcher = $this->getClipboardService()->getMatcher(); |
|
71 | - |
|
72 | - // Fetch objects via the Content Service. |
|
73 | - $contentService = $this->getContentService()->findBy($matcher); |
|
74 | - |
|
75 | - // count number of items and display it. |
|
76 | - $this->view->assign('target', GeneralUtility::_GP('id')); |
|
77 | - $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
78 | - $this->view->assign('objects', $contentService->getObjects()); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @return ClipboardService|object |
|
83 | - */ |
|
84 | - protected function getClipboardService() |
|
85 | - { |
|
86 | - return GeneralUtility::makeInstance(ClipboardService::class); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @return ContentService|object |
|
91 | - */ |
|
92 | - protected function getContentService() |
|
93 | - { |
|
94 | - return GeneralUtility::makeInstance(ContentService::class); |
|
95 | - } |
|
22 | + /** |
|
23 | + * Save data into the clipboard. |
|
24 | + * |
|
25 | + * @param array $matches |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function saveAction(array $matches = array()) |
|
29 | + { |
|
30 | + |
|
31 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
32 | + $this->getClipboardService()->save($matcher); |
|
33 | + |
|
34 | + // Fetch objects via the Content Service. |
|
35 | + $contentService = $this->getContentService()->findBy($matcher); |
|
36 | + $numberOfObjects = $contentService->getNumberOfObjects(); |
|
37 | + |
|
38 | + if ($numberOfObjects === 0) { |
|
39 | + $this->getClipboardService()->flush(); |
|
40 | + } |
|
41 | + |
|
42 | + # Json header is not automatically sent in the BE... |
|
43 | + $this->response->setHeader('Content-Type', 'application/json'); |
|
44 | + $this->response->sendHeaders(); |
|
45 | + return json_encode($numberOfObjects); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Completely flush the clipboard. |
|
50 | + * |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function flushAction() |
|
54 | + { |
|
55 | + $this->getClipboardService()->flush(); |
|
56 | + |
|
57 | + # Json header is not automatically sent in the BE... |
|
58 | + $this->response->setHeader('Content-Type', 'application/json'); |
|
59 | + $this->response->sendHeaders(); |
|
60 | + return json_encode(true); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Show the content of the clipboard. |
|
65 | + */ |
|
66 | + public function showAction() |
|
67 | + { |
|
68 | + |
|
69 | + // Retrieve matcher object from clipboard. |
|
70 | + $matcher = $this->getClipboardService()->getMatcher(); |
|
71 | + |
|
72 | + // Fetch objects via the Content Service. |
|
73 | + $contentService = $this->getContentService()->findBy($matcher); |
|
74 | + |
|
75 | + // count number of items and display it. |
|
76 | + $this->view->assign('target', GeneralUtility::_GP('id')); |
|
77 | + $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
78 | + $this->view->assign('objects', $contentService->getObjects()); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @return ClipboardService|object |
|
83 | + */ |
|
84 | + protected function getClipboardService() |
|
85 | + { |
|
86 | + return GeneralUtility::makeInstance(ClipboardService::class); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @return ContentService|object |
|
91 | + */ |
|
92 | + protected function getContentService() |
|
93 | + { |
|
94 | + return GeneralUtility::makeInstance(ContentService::class); |
|
95 | + } |
|
96 | 96 | |
97 | 97 | } |
@@ -20,46 +20,46 @@ |
||
20 | 20 | class ToolController extends ActionController |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function welcomeAction() |
|
27 | - { |
|
28 | - $items = []; |
|
29 | - $tools = ToolRegistry::getInstance()->getTools($this->getModuleLoader()->getDataType()); |
|
23 | + /** |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function welcomeAction() |
|
27 | + { |
|
28 | + $items = []; |
|
29 | + $tools = ToolRegistry::getInstance()->getTools($this->getModuleLoader()->getDataType()); |
|
30 | 30 | |
31 | - foreach ($tools as $index => $tool) { |
|
32 | - $item = []; |
|
33 | - $item['title'] = $tool->getTitle(); |
|
34 | - $item['description'] = $tool->getDescription(); |
|
31 | + foreach ($tools as $index => $tool) { |
|
32 | + $item = []; |
|
33 | + $item['title'] = $tool->getTitle(); |
|
34 | + $item['description'] = $tool->getDescription(); |
|
35 | 35 | |
36 | - $items[] = $item; |
|
37 | - } |
|
38 | - $this->view->assign('items', $items); |
|
39 | - } |
|
36 | + $items[] = $item; |
|
37 | + } |
|
38 | + $this->view->assign('items', $items); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string $tool |
|
43 | - * @param array $arguments |
|
44 | - * @return void |
|
45 | - * @Extbase\Validate("Fab\Vidi\Domain\Validator\ToolValidator", param="tool") |
|
46 | - */ |
|
47 | - public function workAction(string $tool, array $arguments = array()) |
|
48 | - { |
|
49 | - /** @var ToolInterface $tool */ |
|
50 | - $tool = GeneralUtility::makeInstance($tool); |
|
51 | - $workResult = $tool->work($arguments); |
|
52 | - $this->view->assign('result', $workResult); |
|
53 | - } |
|
41 | + /** |
|
42 | + * @param string $tool |
|
43 | + * @param array $arguments |
|
44 | + * @return void |
|
45 | + * @Extbase\Validate("Fab\Vidi\Domain\Validator\ToolValidator", param="tool") |
|
46 | + */ |
|
47 | + public function workAction(string $tool, array $arguments = array()) |
|
48 | + { |
|
49 | + /** @var ToolInterface $tool */ |
|
50 | + $tool = GeneralUtility::makeInstance($tool); |
|
51 | + $workResult = $tool->work($arguments); |
|
52 | + $this->view->assign('result', $workResult); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get the Vidi Module Loader. |
|
57 | - * |
|
58 | - * @return ModuleLoader|object |
|
59 | - */ |
|
60 | - protected function getModuleLoader() |
|
61 | - { |
|
62 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
63 | - } |
|
55 | + /** |
|
56 | + * Get the Vidi Module Loader. |
|
57 | + * |
|
58 | + * @return ModuleLoader|object |
|
59 | + */ |
|
60 | + protected function getModuleLoader() |
|
61 | + { |
|
62 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | } |
@@ -45,748 +45,748 @@ |
||
45 | 45 | class ContentController extends ActionController |
46 | 46 | { |
47 | 47 | |
48 | - /** |
|
49 | - * @var SelectionRepository |
|
50 | - * @Inject |
|
51 | - */ |
|
52 | - public $selectionRepository; |
|
53 | - |
|
54 | - /** |
|
55 | - * Initialize every action. |
|
56 | - */ |
|
57 | - public function initializeAction() |
|
58 | - { |
|
59 | - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
60 | - $pageRenderer->addInlineLanguageLabelFile('EXT:vidi/Resources/Private/Language/locallang.xlf'); |
|
61 | - |
|
62 | - // Configure property mapping to retrieve the file object. |
|
63 | - if ($this->arguments->hasArgument('columns')) { |
|
64 | - |
|
65 | - /** @var CsvToArrayConverter $typeConverter */ |
|
66 | - $typeConverter = $this->objectManager->get(CsvToArrayConverter::class); |
|
67 | - |
|
68 | - $propertyMappingConfiguration = $this->arguments->getArgument('columns')->getPropertyMappingConfiguration(); |
|
69 | - $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * List action for this controller. |
|
75 | - * |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - public function indexAction() |
|
79 | - { |
|
80 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
81 | - $selections = $this->selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
82 | - $this->view->assign('selections', $selections); |
|
83 | - |
|
84 | - $columns = Tca::grid()->getFields(); |
|
85 | - $this->view->assign('columns', $columns); |
|
86 | - $this->view->assign('numberOfColumns', count($columns)); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * List Row action for this controller. Output a json list of contents |
|
91 | - * |
|
92 | - * @param array $columns corresponds to columns to be rendered. |
|
93 | - * @param array $matches |
|
94 | - * @Validate("Fab\Vidi\Domain\Validator\ColumnsValidator", param="columns") |
|
95 | - * @Validate("Fab\Vidi\Domain\Validator\MatchesValidator", param="matches") |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - public function listAction(array $columns = [], $matches = []) |
|
99 | - { |
|
100 | - // Initialize some objects related to the query. |
|
101 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
102 | - $order = OrderObjectFactory::getInstance()->getOrder(); |
|
103 | - $pager = PagerObjectFactory::getInstance()->getPager(); |
|
104 | - |
|
105 | - // Fetch objects via the Content Service. |
|
106 | - $contentService = $this->getContentService()->findBy($matcher, $order, $pager->getLimit(), $pager->getOffset()); |
|
107 | - $pager->setCount($contentService->getNumberOfObjects()); |
|
108 | - |
|
109 | - // Assign values. |
|
110 | - $this->view->assign('columns', $columns); |
|
111 | - $this->view->assign('objects', $contentService->getObjects()); |
|
112 | - $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
113 | - $this->view->assign('pager', $pager); |
|
114 | - |
|
115 | - $this->view->assign('response', $this->responseFactory->createResponse()); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Retrieve Content objects first according to matching criteria and then "update" them. |
|
120 | - * Important to notice the field name can contains a path, e.g. metadata.title and therefore must be analysed. |
|
121 | - * |
|
122 | - * Possible values for $matches: |
|
123 | - * ----------------------------- |
|
124 | - * |
|
125 | - * $matches = array(uid => 1), will be taken as $query->equals |
|
126 | - * $matches = array(uid => 1,2,3), will be taken as $query->in |
|
127 | - * $matches = array(field_name1 => bar, field_name2 => bax), will be separated by AND. |
|
128 | - * |
|
129 | - * Possible values for $content: |
|
130 | - * ----------------------------- |
|
131 | - * |
|
132 | - * $content = array(field_name => bar) |
|
133 | - * $content = array(field_name => array(value1, value2)) <-- will be CSV converted by "value1,value2" |
|
134 | - * |
|
135 | - * @param string $fieldNameAndPath |
|
136 | - * @param array $content |
|
137 | - * @param array $matches |
|
138 | - * @param string $savingBehavior |
|
139 | - * @param int $language |
|
140 | - * @param array $columns |
|
141 | - * @throws InvalidKeyInArrayException |
|
142 | - */ |
|
143 | - public function updateAction($fieldNameAndPath, array $content, array $matches = [], $savingBehavior = SavingBehavior::REPLACE, $language = 0, $columns = []) |
|
144 | - { |
|
145 | - |
|
146 | - // Instantiate the Matcher object according different rules. |
|
147 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
148 | - $order = OrderObjectFactory::getInstance()->getOrder(); |
|
149 | - |
|
150 | - // Fetch objects via the Content Service. |
|
151 | - $contentService = $this->getContentService()->findBy($matcher, $order); |
|
152 | - |
|
153 | - // Get the real field that is going to be updated. |
|
154 | - $updatedFieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
155 | - |
|
156 | - // Get result object for storing data along the processing. |
|
157 | - $result = $this->getJsonResult(); |
|
158 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
159 | - |
|
160 | - foreach ($contentService->getObjects() as $index => $object) { |
|
161 | - |
|
162 | - $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid', $language); |
|
163 | - |
|
164 | - // It could be the identifier is not found because the translation |
|
165 | - // of the record does not yet exist when mass-editing |
|
166 | - if ((int)$identifier <= 0) { |
|
167 | - continue; |
|
168 | - } |
|
169 | - |
|
170 | - $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
171 | - |
|
172 | - $signalResult = $this->emitProcessContentDataSignal($object, $fieldNameAndPath, $content, $index + 1, $savingBehavior, $language); |
|
173 | - $contentData = $signalResult->getContentData(); |
|
174 | - |
|
175 | - // Add identifier to content data, required by TCEMain. |
|
176 | - $contentData['uid'] = $identifier; |
|
177 | - |
|
178 | - /** @var Content $dataObject */ |
|
179 | - $dataObject = GeneralUtility::makeInstance(Content::class, $dataType, $contentData); |
|
180 | - |
|
181 | - // Properly update object. |
|
182 | - ContentRepositoryFactory::getInstance($dataType)->update($dataObject); |
|
183 | - |
|
184 | - // Get the possible error messages and store them. |
|
185 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
186 | - $result->addErrorMessages($errorMessages); |
|
187 | - |
|
188 | - // We only want to see the detail result if there is one object updated. |
|
189 | - // Required for inline editing + it will display some useful info on the GUI in the flash messages. |
|
190 | - if ($contentService->getNumberOfObjects() === 1) { |
|
191 | - |
|
192 | - // Fetch the updated object from repository. |
|
193 | - $updatedObject = ContentRepositoryFactory::getInstance()->findByUid($object->getUid()); |
|
194 | - |
|
195 | - // Re-fetch the updated result. |
|
196 | - $updatedResult = $this->getContentObjectResolver()->getValue($updatedObject, $fieldNameAndPath, $updatedFieldName, $language); |
|
197 | - if (is_array($updatedResult)) { |
|
198 | - $_updatedResult = []; // reset result set. |
|
199 | - |
|
200 | - /** @var Content $contentObject */ |
|
201 | - foreach ($updatedResult as $contentObject) { |
|
202 | - $labelField = Tca::table($contentObject)->getLabelField(); |
|
203 | - $values = array( |
|
204 | - 'uid' => $contentObject->getUid(), |
|
205 | - 'name' => $contentObject[$labelField], |
|
206 | - ); |
|
207 | - $_updatedResult[] = $values; |
|
208 | - } |
|
209 | - |
|
210 | - $updatedResult = $_updatedResult; |
|
211 | - } |
|
212 | - |
|
213 | - $labelField = Tca::table($object)->getLabelField(); |
|
214 | - |
|
215 | - $processedObjectData = array( |
|
216 | - 'uid' => $object->getUid(), |
|
217 | - 'name' => $object[$labelField], |
|
218 | - 'updatedField' => $fieldNameAndPath, |
|
219 | - 'updatedValue' => $updatedResult, |
|
220 | - ); |
|
221 | - $result->setProcessedObject($processedObjectData); |
|
222 | - |
|
223 | - if (!empty($columns)) { |
|
224 | - /** @var Row $row */ |
|
225 | - $row = GeneralUtility::makeInstance(Row::class, $columns); |
|
226 | - $result->setRow($row->render($updatedObject)); |
|
227 | - } |
|
228 | - } |
|
229 | - } |
|
230 | - |
|
231 | - $response = $this->responseFactory->createResponse() |
|
232 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
233 | - $response->getBody()->write(json_encode($result)); |
|
234 | - return $response; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * Set the sorting of a record giving the previous object. |
|
239 | - * |
|
240 | - * @param array $matches |
|
241 | - * @param int $previousIdentifier |
|
242 | - */ |
|
243 | - public function sortAction(array $matches = [], $previousIdentifier = null) |
|
244 | - { |
|
245 | - |
|
246 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
247 | - |
|
248 | - // Fetch objects via the Content Service. |
|
249 | - $contentService = $this->getContentService()->findBy($matcher); |
|
250 | - |
|
251 | - // Compute the label field name of the table. |
|
252 | - $tableTitleField = Tca::table()->getLabelField(); |
|
253 | - |
|
254 | - // Get result object for storing data along the processing. |
|
255 | - $result = $this->getJsonResult(); |
|
256 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
257 | - |
|
258 | - foreach ($contentService->getObjects() as $object) { |
|
259 | - |
|
260 | - // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
261 | - if ($contentService->getNumberOfObjects() === 1) { |
|
262 | - $tableTitleValue = $object[$tableTitleField]; |
|
263 | - $processedObjectData = array( |
|
264 | - 'uid' => $object->getUid(), |
|
265 | - 'name' => $tableTitleValue, |
|
266 | - ); |
|
267 | - $result->setProcessedObject($processedObjectData); |
|
268 | - } |
|
269 | - |
|
270 | - // The $target corresponds to the pid to move the records to. |
|
271 | - // It can also be a negative value in case of sorting. The negative value would be the uid of its predecessor. |
|
272 | - $target = is_null($previousIdentifier) ? $object->getPid() : (-(int)$previousIdentifier); |
|
273 | - |
|
274 | - // Work out the object. |
|
275 | - ContentRepositoryFactory::getInstance()->move($object, $target); |
|
276 | - |
|
277 | - // Get the possible error messages and store them. |
|
278 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
279 | - $result->addErrorMessages($errorMessages); |
|
280 | - } |
|
281 | - |
|
282 | - $response = $this->responseFactory->createResponse() |
|
283 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
284 | - $response->getBody()->write(json_encode($result)); |
|
285 | - return $response; |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Returns an editing form for a given field name of a Content object. |
|
290 | - * Argument $fieldNameAndPath corresponds to the field name to be edited. |
|
291 | - * Important to notice it can contains a path, e.g. metadata.title and therefore must be analysed. |
|
292 | - * |
|
293 | - * Possible values for $matches, refer to method "updateAction". |
|
294 | - * |
|
295 | - * @param string $fieldNameAndPath |
|
296 | - * @param array $matches |
|
297 | - * @param bool $hasRecursiveSelection |
|
298 | - * @throws \Exception |
|
299 | - */ |
|
300 | - public function editAction($fieldNameAndPath, array $matches = [], $hasRecursiveSelection = false) |
|
301 | - { |
|
302 | - |
|
303 | - // Instantiate the Matcher object according different rules. |
|
304 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
305 | - |
|
306 | - // Fetch objects via the Content Service. |
|
307 | - $contentService = $this->getContentService()->findBy($matcher); |
|
308 | - |
|
309 | - $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
310 | - $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
311 | - |
|
312 | - $fieldType = Tca::table($dataType)->field($fieldName)->getType(); |
|
313 | - $this->view->assign('fieldType', ucfirst($fieldType)); |
|
314 | - $this->view->assign('dataType', $dataType); |
|
315 | - $this->view->assign('fieldName', $fieldName); |
|
316 | - $this->view->assign('matches', $matches); |
|
317 | - $this->view->assign('fieldNameAndPath', $fieldNameAndPath); |
|
318 | - $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
319 | - $this->view->assign('hasRecursiveSelection', $hasRecursiveSelection); |
|
320 | - $this->view->assign('editWholeSelection', empty($matches['uid'])); // necessary?? |
|
321 | - |
|
322 | - // Fetch content and its relations. |
|
323 | - if ($fieldType === FieldType::MULTISELECT) { |
|
324 | - |
|
325 | - $object = ContentRepositoryFactory::getInstance()->findOneBy($matcher); |
|
326 | - $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid'); |
|
327 | - $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
328 | - |
|
329 | - $content = ContentRepositoryFactory::getInstance($dataType)->findByUid($identifier); |
|
330 | - |
|
331 | - // Makes sure the object was retrieved. Security! |
|
332 | - if (!$content) { |
|
333 | - $message = sprintf('I could not retrieved content object of type "%s" with identifier %s.', $dataType, $identifier); |
|
334 | - throw new \Exception($message, 1402350182); |
|
335 | - } |
|
336 | - |
|
337 | - $relatedDataType = Tca::table($dataType)->field($fieldName)->getForeignTable(); |
|
338 | - |
|
339 | - // Initialize the matcher object. |
|
340 | - /** @var Matcher $matcher */ |
|
341 | - $matcher = GeneralUtility::makeInstance(Matcher::class, [], $relatedDataType); |
|
342 | - |
|
343 | - // Default ordering for related data type. |
|
344 | - $defaultOrderings = Tca::table($relatedDataType)->getDefaultOrderings(); |
|
345 | - /** @var Order $order */ |
|
346 | - $defaultOrder = GeneralUtility::makeInstance(Order::class, $defaultOrderings); |
|
347 | - |
|
348 | - // Fetch related contents |
|
349 | - $relatedContents = ContentRepositoryFactory::getInstance($relatedDataType)->findBy($matcher, $defaultOrder); |
|
350 | - |
|
351 | - if (Tca::table($dataType)->field($fieldName)->isRenderModeTree()) { |
|
352 | - |
|
353 | - $fieldConfiguration = Tca::table($dataType)->field($fieldName)->getConfiguration(); |
|
354 | - $parentField = $fieldConfiguration['treeConfig']['parentField']; |
|
355 | - |
|
356 | - $flatTree = []; |
|
357 | - foreach ($relatedContents as $node) { |
|
358 | - $flatTree[$node->getUid()] = array( |
|
359 | - 'item' => $node, |
|
360 | - 'parent' => $node[$parentField] ? $node[$parentField]['uid'] : null, |
|
361 | - ); |
|
362 | - } |
|
363 | - |
|
364 | - $tree = []; |
|
365 | - |
|
366 | - // If leaves are selected without its parents selected, those are shown as parent |
|
367 | - foreach ($flatTree as $id => &$flatNode) { |
|
368 | - if (!isset($flatTree[$flatNode['parent']])) { |
|
369 | - $flatNode['parent'] = null; |
|
370 | - } |
|
371 | - } |
|
372 | - |
|
373 | - foreach ($flatTree as $id => &$node) { |
|
374 | - if ($node['parent'] === null) { |
|
375 | - $tree[$id] = &$node; |
|
376 | - } else { |
|
377 | - $flatTree[$node['parent']]['children'][$id] = &$node; |
|
378 | - } |
|
379 | - } |
|
380 | - |
|
381 | - $relatedContents = $tree; |
|
382 | - } |
|
383 | - |
|
384 | - $this->view->assign('content', $content); |
|
385 | - $this->view->assign('relatedContents', $relatedContents); |
|
386 | - $this->view->assign('relatedDataType', $relatedDataType); |
|
387 | - $this->view->assign('relatedContentTitle', Tca::table($relatedDataType)->getTitle()); |
|
388 | - $this->view->assign( |
|
389 | - 'renderMode', |
|
390 | - Tca::table($dataType)->field($fieldName)->isRenderModeTree() ? FieldType::TREE : null |
|
391 | - ); |
|
392 | - } |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Retrieve Content objects first according to matching criteria and then "delete" them. |
|
397 | - * |
|
398 | - * Possible values for $matches, refer to method "updateAction". |
|
399 | - * |
|
400 | - * @param array $matches |
|
401 | - */ |
|
402 | - public function deleteAction(array $matches = []) |
|
403 | - { |
|
404 | - |
|
405 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
406 | - |
|
407 | - // Fetch objects via the Content Service. |
|
408 | - $contentService = $this->getContentService()->findBy($matcher); |
|
409 | - |
|
410 | - // Compute the label field name of the table. |
|
411 | - $tableTitleField = Tca::table()->getLabelField(); |
|
412 | - |
|
413 | - // Get result object for storing data along the processing. |
|
414 | - $result = $this->getJsonResult(); |
|
415 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
416 | - |
|
417 | - foreach ($contentService->getObjects() as $object) { |
|
418 | - |
|
419 | - // Store the first object, so that the delete message can be more explicit when deleting only one record. |
|
420 | - if ($contentService->getNumberOfObjects() === 1) { |
|
421 | - $tableTitleValue = $object[$tableTitleField]; |
|
422 | - $processedObjectData = array( |
|
423 | - 'uid' => $object->getUid(), |
|
424 | - 'name' => $tableTitleValue, |
|
425 | - ); |
|
426 | - $result->setProcessedObject($processedObjectData); |
|
427 | - } |
|
428 | - |
|
429 | - // Properly delete object. |
|
430 | - ContentRepositoryFactory::getInstance()->remove($object); |
|
431 | - |
|
432 | - // Get the possible error messages and store them. |
|
433 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
434 | - $result->addErrorMessages($errorMessages); |
|
435 | - } |
|
436 | - |
|
437 | - $response = $this->responseFactory->createResponse() |
|
438 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
439 | - $response->getBody()->write(json_encode($result)); |
|
440 | - return $response; |
|
441 | - } |
|
442 | - |
|
443 | - /** |
|
444 | - * Retrieve Content objects first according to matching criteria and then "copy" them. |
|
445 | - * |
|
446 | - * Possible values for $matches, refer to method "updateAction". |
|
447 | - * |
|
448 | - * @param string $target |
|
449 | - * @param array $matches |
|
450 | - * @throws \Exception |
|
451 | - * @return string |
|
452 | - */ |
|
453 | - public function copyAction($target, array $matches = []) |
|
454 | - { |
|
455 | - // @todo |
|
456 | - throw new \Exception('Not yet implemented', 1410192546); |
|
457 | - } |
|
458 | - |
|
459 | - /** |
|
460 | - * Retrieve Content objects from the Clipboard then "copy" them according to the target. |
|
461 | - * |
|
462 | - * @param string $target |
|
463 | - * @throws \Exception |
|
464 | - */ |
|
465 | - public function copyClipboardAction($target) |
|
466 | - { |
|
467 | - |
|
468 | - // Retrieve matcher object from clipboard. |
|
469 | - $matcher = $this->getClipboardService()->getMatcher(); |
|
470 | - |
|
471 | - // Fetch objects via the Content Service. |
|
472 | - $contentService = $this->getContentService()->findBy($matcher); |
|
473 | - |
|
474 | - // Compute the label field name of the table. |
|
475 | - $tableTitleField = Tca::table()->getLabelField(); |
|
476 | - |
|
477 | - // Get result object for storing data along the processing. |
|
478 | - $result = $this->getJsonResult(); |
|
479 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
480 | - |
|
481 | - foreach ($contentService->getObjects() as $object) { |
|
482 | - |
|
483 | - // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
484 | - if ($contentService->getNumberOfObjects() === 1) { |
|
485 | - $tableTitleValue = $object[$tableTitleField]; |
|
486 | - $processedObjectData = array( |
|
487 | - 'uid' => $object->getUid(), |
|
488 | - 'name' => $tableTitleValue, |
|
489 | - ); |
|
490 | - $result->setProcessedObject($processedObjectData); |
|
491 | - } |
|
492 | - |
|
493 | - // Work out the object. |
|
494 | - ContentRepositoryFactory::getInstance()->copy($object, $target); |
|
495 | - |
|
496 | - // Get the possible error messages and store them. |
|
497 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
498 | - $result->addErrorMessages($errorMessages); |
|
499 | - } |
|
500 | - |
|
501 | - // Flush Clipboard if told so. |
|
502 | - if (GeneralUtility::_GP('flushClipboard')) { |
|
503 | - $this->getClipboardService()->flush(); |
|
504 | - } |
|
505 | - |
|
506 | - $response = $this->responseFactory->createResponse() |
|
507 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
508 | - $response->getBody()->write(json_encode($result)); |
|
509 | - return $response; |
|
510 | - } |
|
511 | - |
|
512 | - /** |
|
513 | - * Retrieve Content objects first according to matching criteria and then "move" them. |
|
514 | - * |
|
515 | - * Possible values for $matches, refer to method "updateAction". |
|
516 | - * |
|
517 | - * @param string $target |
|
518 | - * @param array $matches |
|
519 | - */ |
|
520 | - public function moveAction($target, array $matches = []) |
|
521 | - { |
|
522 | - |
|
523 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
524 | - |
|
525 | - // Fetch objects via the Content Service. |
|
526 | - $contentService = $this->getContentService()->findBy($matcher); |
|
527 | - |
|
528 | - // Compute the label field name of the table. |
|
529 | - $tableTitleField = Tca::table()->getLabelField(); |
|
530 | - |
|
531 | - // Get result object for storing data along the processing. |
|
532 | - $result = $this->getJsonResult(); |
|
533 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
534 | - |
|
535 | - foreach ($contentService->getObjects() as $object) { |
|
536 | - |
|
537 | - // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
538 | - if ($contentService->getNumberOfObjects() === 1) { |
|
539 | - $tableTitleValue = $object[$tableTitleField]; |
|
540 | - $processedObjectData = array( |
|
541 | - 'uid' => $object->getUid(), |
|
542 | - 'name' => $tableTitleValue, |
|
543 | - ); |
|
544 | - $result->setProcessedObject($processedObjectData); |
|
545 | - } |
|
546 | - |
|
547 | - // Work out the object. |
|
548 | - ContentRepositoryFactory::getInstance()->move($object, $target); |
|
549 | - |
|
550 | - // Get the possible error messages and store them. |
|
551 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
552 | - $result->addErrorMessages($errorMessages); |
|
553 | - } |
|
554 | - |
|
555 | - $response = $this->responseFactory->createResponse() |
|
556 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
557 | - $response->getBody()->write(json_encode($result)); |
|
558 | - return $response; |
|
559 | - } |
|
560 | - |
|
561 | - /** |
|
562 | - * Retrieve Content objects from the Clipboard then "move" them according to the target. |
|
563 | - * |
|
564 | - * @param string $target |
|
565 | - */ |
|
566 | - public function moveClipboardAction($target) |
|
567 | - { |
|
568 | - |
|
569 | - // Retrieve matcher object from clipboard. |
|
570 | - $matcher = $this->getClipboardService()->getMatcher(); |
|
571 | - |
|
572 | - // Fetch objects via the Content Service. |
|
573 | - $contentService = $this->getContentService()->findBy($matcher); |
|
574 | - |
|
575 | - // Compute the label field name of the table. |
|
576 | - $tableTitleField = Tca::table()->getLabelField(); |
|
577 | - |
|
578 | - // Get result object for storing data along the processing. |
|
579 | - $result = $this->getJsonResult(); |
|
580 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
581 | - |
|
582 | - foreach ($contentService->getObjects() as $object) { |
|
583 | - |
|
584 | - // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
585 | - if ($contentService->getNumberOfObjects() === 1) { |
|
586 | - $tableTitleValue = $object[$tableTitleField]; |
|
587 | - $processedObjectData = array( |
|
588 | - 'uid' => $object->getUid(), |
|
589 | - 'name' => $tableTitleValue, |
|
590 | - ); |
|
591 | - $result->setProcessedObject($processedObjectData); |
|
592 | - } |
|
593 | - |
|
594 | - // Work out the object. |
|
595 | - ContentRepositoryFactory::getInstance()->move($object, $target); |
|
596 | - |
|
597 | - // Get the possible error messages and store them. |
|
598 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
599 | - $result->addErrorMessages($errorMessages); |
|
600 | - } |
|
601 | - |
|
602 | - // Flush Clipboard if told so. |
|
603 | - if (GeneralUtility::_GP('flushClipboard')) { |
|
604 | - $this->getClipboardService()->flush(); |
|
605 | - } |
|
606 | - |
|
607 | - $response = $this->responseFactory->createResponse() |
|
608 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
609 | - $response->getBody()->write(json_encode($result)); |
|
610 | - return $response; |
|
611 | - } |
|
612 | - |
|
613 | - /** |
|
614 | - * Retrieve Content objects first according to matching criteria and then "localize" them. |
|
615 | - * |
|
616 | - * Possible values for $matches, refer to method "updateAction". |
|
617 | - * |
|
618 | - * @param string $fieldNameAndPath |
|
619 | - * @param array $matches |
|
620 | - * @param int $language |
|
621 | - * @throws \Exception |
|
622 | - */ |
|
623 | - public function localizeAction($fieldNameAndPath, array $matches = [], $language = 0) |
|
624 | - { |
|
625 | - |
|
626 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
627 | - |
|
628 | - // Fetch objects via the Content Service. |
|
629 | - $contentService = $this->getContentService()->findBy($matcher); |
|
630 | - |
|
631 | - // Get result object for storing data along the processing. |
|
632 | - $result = $this->getJsonResult(); |
|
633 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
634 | - |
|
635 | - foreach ($contentService->getObjects() as $object) { |
|
636 | - |
|
637 | - $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid'); |
|
638 | - $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
639 | - |
|
640 | - // Fetch the source object to be localized. |
|
641 | - /** @var Content $content */ |
|
642 | - $content = ContentRepositoryFactory::getInstance($dataType)->findByIdentifier($identifier); |
|
643 | - |
|
644 | - // Makes sure the object was retrieved. Security! |
|
645 | - if (!$content) { |
|
646 | - $message = sprintf('Something went wrong when retrieving content "%s" with identifier "%s".', $dataType, $identifier); |
|
647 | - throw new \Exception($message, 1412343097); |
|
648 | - } |
|
649 | - |
|
650 | - // Handover the localization to the Repository. |
|
651 | - ContentRepositoryFactory::getInstance($dataType)->localize($content, $language); |
|
652 | - |
|
653 | - // Get the possible error messages and store them. |
|
654 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
655 | - |
|
656 | - // Redirect to TCEForm so that the BE User can do its job! |
|
657 | - if ($contentService->getNumberOfObjects() === 1) { |
|
658 | - |
|
659 | - if (!empty($errorMessages)) { |
|
660 | - $message = sprintf('Something went wrong when localizing content "%s" with identifier "%s". <br/>%s', |
|
661 | - $dataType, |
|
662 | - $identifier, |
|
663 | - implode('<br/>', $errorMessages) |
|
664 | - ); |
|
665 | - throw new \Exception($message, 1412343098); |
|
666 | - } |
|
667 | - |
|
668 | - $localizedContent = $this->getLanguageService()->getLocalizedContent($content, $language); |
|
669 | - if (empty($localizedContent)) { |
|
670 | - $message = sprintf('Oups! I could not retrieve localized content of type "%s" with identifier "%s"', |
|
671 | - $content->getDataType(), |
|
672 | - $content->getUid() |
|
673 | - ); |
|
674 | - throw new \Exception($message, 1412343099); |
|
675 | - } |
|
676 | - |
|
677 | - /** @var EditUri $uri */ |
|
678 | - $uriRenderer = GeneralUtility::makeInstance(EditUri::class); |
|
679 | - $uri = $uriRenderer->render($localizedContent); |
|
680 | - HttpUtility::redirect($uri); |
|
681 | - break; // no need to further continue |
|
682 | - } |
|
683 | - |
|
684 | - $result->addErrorMessages($errorMessages); |
|
685 | - } |
|
686 | - |
|
687 | - $response = $this->responseFactory->createResponse() |
|
688 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
689 | - $response->getBody()->write(json_encode($result)); |
|
690 | - return $response; |
|
691 | - } |
|
692 | - |
|
693 | - /** |
|
694 | - * Get the Vidi Module Loader. |
|
695 | - * |
|
696 | - * @return ContentService |
|
697 | - */ |
|
698 | - protected function getContentService() |
|
699 | - { |
|
700 | - return GeneralUtility::makeInstance(ContentService::class); |
|
701 | - } |
|
702 | - |
|
703 | - /** |
|
704 | - * @return ContentObjectResolver |
|
705 | - */ |
|
706 | - protected function getContentObjectResolver() |
|
707 | - { |
|
708 | - return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
709 | - } |
|
710 | - |
|
711 | - /** |
|
712 | - * @return FieldPathResolver |
|
713 | - */ |
|
714 | - protected function getFieldPathResolver() |
|
715 | - { |
|
716 | - return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
717 | - } |
|
718 | - |
|
719 | - /** |
|
720 | - * @return JsonResult|object |
|
721 | - */ |
|
722 | - protected function getJsonResult() |
|
723 | - { |
|
724 | - return GeneralUtility::makeInstance(JsonResult::class); |
|
725 | - } |
|
726 | - |
|
727 | - /** |
|
728 | - * Signal that is called for post-processing content data send to the server for update. |
|
729 | - * |
|
730 | - * @param Content $contentObject |
|
731 | - * @param $fieldNameAndPath |
|
732 | - * @param $contentData |
|
733 | - * @param $counter |
|
734 | - * @param $savingBehavior |
|
735 | - * @param $language |
|
736 | - * @return ProcessContentDataSignalArguments |
|
737 | - */ |
|
738 | - protected function emitProcessContentDataSignal(Content $contentObject, $fieldNameAndPath, $contentData, $counter, $savingBehavior, $language) |
|
739 | - { |
|
740 | - |
|
741 | - /** @var ProcessContentDataSignalArguments $signalArguments */ |
|
742 | - $signalArguments = GeneralUtility::makeInstance(ProcessContentDataSignalArguments::class); |
|
743 | - $signalArguments->setContentObject($contentObject) |
|
744 | - ->setFieldNameAndPath($fieldNameAndPath) |
|
745 | - ->setContentData($contentData) |
|
746 | - ->setCounter($counter) |
|
747 | - ->setSavingBehavior($savingBehavior) |
|
748 | - ->setLanguage($language); |
|
749 | - |
|
750 | - $signalResult = $this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\Controller\Backend\ContentController', 'processContentData', array($signalArguments)); |
|
751 | - return $signalResult[0]; |
|
752 | - } |
|
753 | - |
|
754 | - /** |
|
755 | - * Get the SignalSlot dispatcher. |
|
756 | - * |
|
757 | - * @return Dispatcher |
|
758 | - */ |
|
759 | - protected function getSignalSlotDispatcher() |
|
760 | - { |
|
761 | - return $this->objectManager->get(Dispatcher::class); |
|
762 | - } |
|
763 | - |
|
764 | - /** |
|
765 | - * Get the Clipboard service. |
|
766 | - * |
|
767 | - * @return ClipboardService |
|
768 | - */ |
|
769 | - protected function getClipboardService() |
|
770 | - { |
|
771 | - return GeneralUtility::makeInstance(ClipboardService::class); |
|
772 | - } |
|
773 | - |
|
774 | - /** |
|
775 | - * @return LanguageService |
|
776 | - */ |
|
777 | - protected function getLanguageService() |
|
778 | - { |
|
779 | - return GeneralUtility::makeInstance(LanguageService::class); |
|
780 | - } |
|
781 | - |
|
782 | - /** |
|
783 | - * Get the Vidi Module Loader. |
|
784 | - * |
|
785 | - * @return ModuleLoader |
|
786 | - */ |
|
787 | - protected function getModuleLoader() |
|
788 | - { |
|
789 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
790 | - } |
|
48 | + /** |
|
49 | + * @var SelectionRepository |
|
50 | + * @Inject |
|
51 | + */ |
|
52 | + public $selectionRepository; |
|
53 | + |
|
54 | + /** |
|
55 | + * Initialize every action. |
|
56 | + */ |
|
57 | + public function initializeAction() |
|
58 | + { |
|
59 | + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
60 | + $pageRenderer->addInlineLanguageLabelFile('EXT:vidi/Resources/Private/Language/locallang.xlf'); |
|
61 | + |
|
62 | + // Configure property mapping to retrieve the file object. |
|
63 | + if ($this->arguments->hasArgument('columns')) { |
|
64 | + |
|
65 | + /** @var CsvToArrayConverter $typeConverter */ |
|
66 | + $typeConverter = $this->objectManager->get(CsvToArrayConverter::class); |
|
67 | + |
|
68 | + $propertyMappingConfiguration = $this->arguments->getArgument('columns')->getPropertyMappingConfiguration(); |
|
69 | + $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * List action for this controller. |
|
75 | + * |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + public function indexAction() |
|
79 | + { |
|
80 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
81 | + $selections = $this->selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
82 | + $this->view->assign('selections', $selections); |
|
83 | + |
|
84 | + $columns = Tca::grid()->getFields(); |
|
85 | + $this->view->assign('columns', $columns); |
|
86 | + $this->view->assign('numberOfColumns', count($columns)); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * List Row action for this controller. Output a json list of contents |
|
91 | + * |
|
92 | + * @param array $columns corresponds to columns to be rendered. |
|
93 | + * @param array $matches |
|
94 | + * @Validate("Fab\Vidi\Domain\Validator\ColumnsValidator", param="columns") |
|
95 | + * @Validate("Fab\Vidi\Domain\Validator\MatchesValidator", param="matches") |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + public function listAction(array $columns = [], $matches = []) |
|
99 | + { |
|
100 | + // Initialize some objects related to the query. |
|
101 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
102 | + $order = OrderObjectFactory::getInstance()->getOrder(); |
|
103 | + $pager = PagerObjectFactory::getInstance()->getPager(); |
|
104 | + |
|
105 | + // Fetch objects via the Content Service. |
|
106 | + $contentService = $this->getContentService()->findBy($matcher, $order, $pager->getLimit(), $pager->getOffset()); |
|
107 | + $pager->setCount($contentService->getNumberOfObjects()); |
|
108 | + |
|
109 | + // Assign values. |
|
110 | + $this->view->assign('columns', $columns); |
|
111 | + $this->view->assign('objects', $contentService->getObjects()); |
|
112 | + $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
113 | + $this->view->assign('pager', $pager); |
|
114 | + |
|
115 | + $this->view->assign('response', $this->responseFactory->createResponse()); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Retrieve Content objects first according to matching criteria and then "update" them. |
|
120 | + * Important to notice the field name can contains a path, e.g. metadata.title and therefore must be analysed. |
|
121 | + * |
|
122 | + * Possible values for $matches: |
|
123 | + * ----------------------------- |
|
124 | + * |
|
125 | + * $matches = array(uid => 1), will be taken as $query->equals |
|
126 | + * $matches = array(uid => 1,2,3), will be taken as $query->in |
|
127 | + * $matches = array(field_name1 => bar, field_name2 => bax), will be separated by AND. |
|
128 | + * |
|
129 | + * Possible values for $content: |
|
130 | + * ----------------------------- |
|
131 | + * |
|
132 | + * $content = array(field_name => bar) |
|
133 | + * $content = array(field_name => array(value1, value2)) <-- will be CSV converted by "value1,value2" |
|
134 | + * |
|
135 | + * @param string $fieldNameAndPath |
|
136 | + * @param array $content |
|
137 | + * @param array $matches |
|
138 | + * @param string $savingBehavior |
|
139 | + * @param int $language |
|
140 | + * @param array $columns |
|
141 | + * @throws InvalidKeyInArrayException |
|
142 | + */ |
|
143 | + public function updateAction($fieldNameAndPath, array $content, array $matches = [], $savingBehavior = SavingBehavior::REPLACE, $language = 0, $columns = []) |
|
144 | + { |
|
145 | + |
|
146 | + // Instantiate the Matcher object according different rules. |
|
147 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
148 | + $order = OrderObjectFactory::getInstance()->getOrder(); |
|
149 | + |
|
150 | + // Fetch objects via the Content Service. |
|
151 | + $contentService = $this->getContentService()->findBy($matcher, $order); |
|
152 | + |
|
153 | + // Get the real field that is going to be updated. |
|
154 | + $updatedFieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
155 | + |
|
156 | + // Get result object for storing data along the processing. |
|
157 | + $result = $this->getJsonResult(); |
|
158 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
159 | + |
|
160 | + foreach ($contentService->getObjects() as $index => $object) { |
|
161 | + |
|
162 | + $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid', $language); |
|
163 | + |
|
164 | + // It could be the identifier is not found because the translation |
|
165 | + // of the record does not yet exist when mass-editing |
|
166 | + if ((int)$identifier <= 0) { |
|
167 | + continue; |
|
168 | + } |
|
169 | + |
|
170 | + $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
171 | + |
|
172 | + $signalResult = $this->emitProcessContentDataSignal($object, $fieldNameAndPath, $content, $index + 1, $savingBehavior, $language); |
|
173 | + $contentData = $signalResult->getContentData(); |
|
174 | + |
|
175 | + // Add identifier to content data, required by TCEMain. |
|
176 | + $contentData['uid'] = $identifier; |
|
177 | + |
|
178 | + /** @var Content $dataObject */ |
|
179 | + $dataObject = GeneralUtility::makeInstance(Content::class, $dataType, $contentData); |
|
180 | + |
|
181 | + // Properly update object. |
|
182 | + ContentRepositoryFactory::getInstance($dataType)->update($dataObject); |
|
183 | + |
|
184 | + // Get the possible error messages and store them. |
|
185 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
186 | + $result->addErrorMessages($errorMessages); |
|
187 | + |
|
188 | + // We only want to see the detail result if there is one object updated. |
|
189 | + // Required for inline editing + it will display some useful info on the GUI in the flash messages. |
|
190 | + if ($contentService->getNumberOfObjects() === 1) { |
|
191 | + |
|
192 | + // Fetch the updated object from repository. |
|
193 | + $updatedObject = ContentRepositoryFactory::getInstance()->findByUid($object->getUid()); |
|
194 | + |
|
195 | + // Re-fetch the updated result. |
|
196 | + $updatedResult = $this->getContentObjectResolver()->getValue($updatedObject, $fieldNameAndPath, $updatedFieldName, $language); |
|
197 | + if (is_array($updatedResult)) { |
|
198 | + $_updatedResult = []; // reset result set. |
|
199 | + |
|
200 | + /** @var Content $contentObject */ |
|
201 | + foreach ($updatedResult as $contentObject) { |
|
202 | + $labelField = Tca::table($contentObject)->getLabelField(); |
|
203 | + $values = array( |
|
204 | + 'uid' => $contentObject->getUid(), |
|
205 | + 'name' => $contentObject[$labelField], |
|
206 | + ); |
|
207 | + $_updatedResult[] = $values; |
|
208 | + } |
|
209 | + |
|
210 | + $updatedResult = $_updatedResult; |
|
211 | + } |
|
212 | + |
|
213 | + $labelField = Tca::table($object)->getLabelField(); |
|
214 | + |
|
215 | + $processedObjectData = array( |
|
216 | + 'uid' => $object->getUid(), |
|
217 | + 'name' => $object[$labelField], |
|
218 | + 'updatedField' => $fieldNameAndPath, |
|
219 | + 'updatedValue' => $updatedResult, |
|
220 | + ); |
|
221 | + $result->setProcessedObject($processedObjectData); |
|
222 | + |
|
223 | + if (!empty($columns)) { |
|
224 | + /** @var Row $row */ |
|
225 | + $row = GeneralUtility::makeInstance(Row::class, $columns); |
|
226 | + $result->setRow($row->render($updatedObject)); |
|
227 | + } |
|
228 | + } |
|
229 | + } |
|
230 | + |
|
231 | + $response = $this->responseFactory->createResponse() |
|
232 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
233 | + $response->getBody()->write(json_encode($result)); |
|
234 | + return $response; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Set the sorting of a record giving the previous object. |
|
239 | + * |
|
240 | + * @param array $matches |
|
241 | + * @param int $previousIdentifier |
|
242 | + */ |
|
243 | + public function sortAction(array $matches = [], $previousIdentifier = null) |
|
244 | + { |
|
245 | + |
|
246 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
247 | + |
|
248 | + // Fetch objects via the Content Service. |
|
249 | + $contentService = $this->getContentService()->findBy($matcher); |
|
250 | + |
|
251 | + // Compute the label field name of the table. |
|
252 | + $tableTitleField = Tca::table()->getLabelField(); |
|
253 | + |
|
254 | + // Get result object for storing data along the processing. |
|
255 | + $result = $this->getJsonResult(); |
|
256 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
257 | + |
|
258 | + foreach ($contentService->getObjects() as $object) { |
|
259 | + |
|
260 | + // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
261 | + if ($contentService->getNumberOfObjects() === 1) { |
|
262 | + $tableTitleValue = $object[$tableTitleField]; |
|
263 | + $processedObjectData = array( |
|
264 | + 'uid' => $object->getUid(), |
|
265 | + 'name' => $tableTitleValue, |
|
266 | + ); |
|
267 | + $result->setProcessedObject($processedObjectData); |
|
268 | + } |
|
269 | + |
|
270 | + // The $target corresponds to the pid to move the records to. |
|
271 | + // It can also be a negative value in case of sorting. The negative value would be the uid of its predecessor. |
|
272 | + $target = is_null($previousIdentifier) ? $object->getPid() : (-(int)$previousIdentifier); |
|
273 | + |
|
274 | + // Work out the object. |
|
275 | + ContentRepositoryFactory::getInstance()->move($object, $target); |
|
276 | + |
|
277 | + // Get the possible error messages and store them. |
|
278 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
279 | + $result->addErrorMessages($errorMessages); |
|
280 | + } |
|
281 | + |
|
282 | + $response = $this->responseFactory->createResponse() |
|
283 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
284 | + $response->getBody()->write(json_encode($result)); |
|
285 | + return $response; |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Returns an editing form for a given field name of a Content object. |
|
290 | + * Argument $fieldNameAndPath corresponds to the field name to be edited. |
|
291 | + * Important to notice it can contains a path, e.g. metadata.title and therefore must be analysed. |
|
292 | + * |
|
293 | + * Possible values for $matches, refer to method "updateAction". |
|
294 | + * |
|
295 | + * @param string $fieldNameAndPath |
|
296 | + * @param array $matches |
|
297 | + * @param bool $hasRecursiveSelection |
|
298 | + * @throws \Exception |
|
299 | + */ |
|
300 | + public function editAction($fieldNameAndPath, array $matches = [], $hasRecursiveSelection = false) |
|
301 | + { |
|
302 | + |
|
303 | + // Instantiate the Matcher object according different rules. |
|
304 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
305 | + |
|
306 | + // Fetch objects via the Content Service. |
|
307 | + $contentService = $this->getContentService()->findBy($matcher); |
|
308 | + |
|
309 | + $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
310 | + $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
311 | + |
|
312 | + $fieldType = Tca::table($dataType)->field($fieldName)->getType(); |
|
313 | + $this->view->assign('fieldType', ucfirst($fieldType)); |
|
314 | + $this->view->assign('dataType', $dataType); |
|
315 | + $this->view->assign('fieldName', $fieldName); |
|
316 | + $this->view->assign('matches', $matches); |
|
317 | + $this->view->assign('fieldNameAndPath', $fieldNameAndPath); |
|
318 | + $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
319 | + $this->view->assign('hasRecursiveSelection', $hasRecursiveSelection); |
|
320 | + $this->view->assign('editWholeSelection', empty($matches['uid'])); // necessary?? |
|
321 | + |
|
322 | + // Fetch content and its relations. |
|
323 | + if ($fieldType === FieldType::MULTISELECT) { |
|
324 | + |
|
325 | + $object = ContentRepositoryFactory::getInstance()->findOneBy($matcher); |
|
326 | + $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid'); |
|
327 | + $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
328 | + |
|
329 | + $content = ContentRepositoryFactory::getInstance($dataType)->findByUid($identifier); |
|
330 | + |
|
331 | + // Makes sure the object was retrieved. Security! |
|
332 | + if (!$content) { |
|
333 | + $message = sprintf('I could not retrieved content object of type "%s" with identifier %s.', $dataType, $identifier); |
|
334 | + throw new \Exception($message, 1402350182); |
|
335 | + } |
|
336 | + |
|
337 | + $relatedDataType = Tca::table($dataType)->field($fieldName)->getForeignTable(); |
|
338 | + |
|
339 | + // Initialize the matcher object. |
|
340 | + /** @var Matcher $matcher */ |
|
341 | + $matcher = GeneralUtility::makeInstance(Matcher::class, [], $relatedDataType); |
|
342 | + |
|
343 | + // Default ordering for related data type. |
|
344 | + $defaultOrderings = Tca::table($relatedDataType)->getDefaultOrderings(); |
|
345 | + /** @var Order $order */ |
|
346 | + $defaultOrder = GeneralUtility::makeInstance(Order::class, $defaultOrderings); |
|
347 | + |
|
348 | + // Fetch related contents |
|
349 | + $relatedContents = ContentRepositoryFactory::getInstance($relatedDataType)->findBy($matcher, $defaultOrder); |
|
350 | + |
|
351 | + if (Tca::table($dataType)->field($fieldName)->isRenderModeTree()) { |
|
352 | + |
|
353 | + $fieldConfiguration = Tca::table($dataType)->field($fieldName)->getConfiguration(); |
|
354 | + $parentField = $fieldConfiguration['treeConfig']['parentField']; |
|
355 | + |
|
356 | + $flatTree = []; |
|
357 | + foreach ($relatedContents as $node) { |
|
358 | + $flatTree[$node->getUid()] = array( |
|
359 | + 'item' => $node, |
|
360 | + 'parent' => $node[$parentField] ? $node[$parentField]['uid'] : null, |
|
361 | + ); |
|
362 | + } |
|
363 | + |
|
364 | + $tree = []; |
|
365 | + |
|
366 | + // If leaves are selected without its parents selected, those are shown as parent |
|
367 | + foreach ($flatTree as $id => &$flatNode) { |
|
368 | + if (!isset($flatTree[$flatNode['parent']])) { |
|
369 | + $flatNode['parent'] = null; |
|
370 | + } |
|
371 | + } |
|
372 | + |
|
373 | + foreach ($flatTree as $id => &$node) { |
|
374 | + if ($node['parent'] === null) { |
|
375 | + $tree[$id] = &$node; |
|
376 | + } else { |
|
377 | + $flatTree[$node['parent']]['children'][$id] = &$node; |
|
378 | + } |
|
379 | + } |
|
380 | + |
|
381 | + $relatedContents = $tree; |
|
382 | + } |
|
383 | + |
|
384 | + $this->view->assign('content', $content); |
|
385 | + $this->view->assign('relatedContents', $relatedContents); |
|
386 | + $this->view->assign('relatedDataType', $relatedDataType); |
|
387 | + $this->view->assign('relatedContentTitle', Tca::table($relatedDataType)->getTitle()); |
|
388 | + $this->view->assign( |
|
389 | + 'renderMode', |
|
390 | + Tca::table($dataType)->field($fieldName)->isRenderModeTree() ? FieldType::TREE : null |
|
391 | + ); |
|
392 | + } |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Retrieve Content objects first according to matching criteria and then "delete" them. |
|
397 | + * |
|
398 | + * Possible values for $matches, refer to method "updateAction". |
|
399 | + * |
|
400 | + * @param array $matches |
|
401 | + */ |
|
402 | + public function deleteAction(array $matches = []) |
|
403 | + { |
|
404 | + |
|
405 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
406 | + |
|
407 | + // Fetch objects via the Content Service. |
|
408 | + $contentService = $this->getContentService()->findBy($matcher); |
|
409 | + |
|
410 | + // Compute the label field name of the table. |
|
411 | + $tableTitleField = Tca::table()->getLabelField(); |
|
412 | + |
|
413 | + // Get result object for storing data along the processing. |
|
414 | + $result = $this->getJsonResult(); |
|
415 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
416 | + |
|
417 | + foreach ($contentService->getObjects() as $object) { |
|
418 | + |
|
419 | + // Store the first object, so that the delete message can be more explicit when deleting only one record. |
|
420 | + if ($contentService->getNumberOfObjects() === 1) { |
|
421 | + $tableTitleValue = $object[$tableTitleField]; |
|
422 | + $processedObjectData = array( |
|
423 | + 'uid' => $object->getUid(), |
|
424 | + 'name' => $tableTitleValue, |
|
425 | + ); |
|
426 | + $result->setProcessedObject($processedObjectData); |
|
427 | + } |
|
428 | + |
|
429 | + // Properly delete object. |
|
430 | + ContentRepositoryFactory::getInstance()->remove($object); |
|
431 | + |
|
432 | + // Get the possible error messages and store them. |
|
433 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
434 | + $result->addErrorMessages($errorMessages); |
|
435 | + } |
|
436 | + |
|
437 | + $response = $this->responseFactory->createResponse() |
|
438 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
439 | + $response->getBody()->write(json_encode($result)); |
|
440 | + return $response; |
|
441 | + } |
|
442 | + |
|
443 | + /** |
|
444 | + * Retrieve Content objects first according to matching criteria and then "copy" them. |
|
445 | + * |
|
446 | + * Possible values for $matches, refer to method "updateAction". |
|
447 | + * |
|
448 | + * @param string $target |
|
449 | + * @param array $matches |
|
450 | + * @throws \Exception |
|
451 | + * @return string |
|
452 | + */ |
|
453 | + public function copyAction($target, array $matches = []) |
|
454 | + { |
|
455 | + // @todo |
|
456 | + throw new \Exception('Not yet implemented', 1410192546); |
|
457 | + } |
|
458 | + |
|
459 | + /** |
|
460 | + * Retrieve Content objects from the Clipboard then "copy" them according to the target. |
|
461 | + * |
|
462 | + * @param string $target |
|
463 | + * @throws \Exception |
|
464 | + */ |
|
465 | + public function copyClipboardAction($target) |
|
466 | + { |
|
467 | + |
|
468 | + // Retrieve matcher object from clipboard. |
|
469 | + $matcher = $this->getClipboardService()->getMatcher(); |
|
470 | + |
|
471 | + // Fetch objects via the Content Service. |
|
472 | + $contentService = $this->getContentService()->findBy($matcher); |
|
473 | + |
|
474 | + // Compute the label field name of the table. |
|
475 | + $tableTitleField = Tca::table()->getLabelField(); |
|
476 | + |
|
477 | + // Get result object for storing data along the processing. |
|
478 | + $result = $this->getJsonResult(); |
|
479 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
480 | + |
|
481 | + foreach ($contentService->getObjects() as $object) { |
|
482 | + |
|
483 | + // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
484 | + if ($contentService->getNumberOfObjects() === 1) { |
|
485 | + $tableTitleValue = $object[$tableTitleField]; |
|
486 | + $processedObjectData = array( |
|
487 | + 'uid' => $object->getUid(), |
|
488 | + 'name' => $tableTitleValue, |
|
489 | + ); |
|
490 | + $result->setProcessedObject($processedObjectData); |
|
491 | + } |
|
492 | + |
|
493 | + // Work out the object. |
|
494 | + ContentRepositoryFactory::getInstance()->copy($object, $target); |
|
495 | + |
|
496 | + // Get the possible error messages and store them. |
|
497 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
498 | + $result->addErrorMessages($errorMessages); |
|
499 | + } |
|
500 | + |
|
501 | + // Flush Clipboard if told so. |
|
502 | + if (GeneralUtility::_GP('flushClipboard')) { |
|
503 | + $this->getClipboardService()->flush(); |
|
504 | + } |
|
505 | + |
|
506 | + $response = $this->responseFactory->createResponse() |
|
507 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
508 | + $response->getBody()->write(json_encode($result)); |
|
509 | + return $response; |
|
510 | + } |
|
511 | + |
|
512 | + /** |
|
513 | + * Retrieve Content objects first according to matching criteria and then "move" them. |
|
514 | + * |
|
515 | + * Possible values for $matches, refer to method "updateAction". |
|
516 | + * |
|
517 | + * @param string $target |
|
518 | + * @param array $matches |
|
519 | + */ |
|
520 | + public function moveAction($target, array $matches = []) |
|
521 | + { |
|
522 | + |
|
523 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
524 | + |
|
525 | + // Fetch objects via the Content Service. |
|
526 | + $contentService = $this->getContentService()->findBy($matcher); |
|
527 | + |
|
528 | + // Compute the label field name of the table. |
|
529 | + $tableTitleField = Tca::table()->getLabelField(); |
|
530 | + |
|
531 | + // Get result object for storing data along the processing. |
|
532 | + $result = $this->getJsonResult(); |
|
533 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
534 | + |
|
535 | + foreach ($contentService->getObjects() as $object) { |
|
536 | + |
|
537 | + // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
538 | + if ($contentService->getNumberOfObjects() === 1) { |
|
539 | + $tableTitleValue = $object[$tableTitleField]; |
|
540 | + $processedObjectData = array( |
|
541 | + 'uid' => $object->getUid(), |
|
542 | + 'name' => $tableTitleValue, |
|
543 | + ); |
|
544 | + $result->setProcessedObject($processedObjectData); |
|
545 | + } |
|
546 | + |
|
547 | + // Work out the object. |
|
548 | + ContentRepositoryFactory::getInstance()->move($object, $target); |
|
549 | + |
|
550 | + // Get the possible error messages and store them. |
|
551 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
552 | + $result->addErrorMessages($errorMessages); |
|
553 | + } |
|
554 | + |
|
555 | + $response = $this->responseFactory->createResponse() |
|
556 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
557 | + $response->getBody()->write(json_encode($result)); |
|
558 | + return $response; |
|
559 | + } |
|
560 | + |
|
561 | + /** |
|
562 | + * Retrieve Content objects from the Clipboard then "move" them according to the target. |
|
563 | + * |
|
564 | + * @param string $target |
|
565 | + */ |
|
566 | + public function moveClipboardAction($target) |
|
567 | + { |
|
568 | + |
|
569 | + // Retrieve matcher object from clipboard. |
|
570 | + $matcher = $this->getClipboardService()->getMatcher(); |
|
571 | + |
|
572 | + // Fetch objects via the Content Service. |
|
573 | + $contentService = $this->getContentService()->findBy($matcher); |
|
574 | + |
|
575 | + // Compute the label field name of the table. |
|
576 | + $tableTitleField = Tca::table()->getLabelField(); |
|
577 | + |
|
578 | + // Get result object for storing data along the processing. |
|
579 | + $result = $this->getJsonResult(); |
|
580 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
581 | + |
|
582 | + foreach ($contentService->getObjects() as $object) { |
|
583 | + |
|
584 | + // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
585 | + if ($contentService->getNumberOfObjects() === 1) { |
|
586 | + $tableTitleValue = $object[$tableTitleField]; |
|
587 | + $processedObjectData = array( |
|
588 | + 'uid' => $object->getUid(), |
|
589 | + 'name' => $tableTitleValue, |
|
590 | + ); |
|
591 | + $result->setProcessedObject($processedObjectData); |
|
592 | + } |
|
593 | + |
|
594 | + // Work out the object. |
|
595 | + ContentRepositoryFactory::getInstance()->move($object, $target); |
|
596 | + |
|
597 | + // Get the possible error messages and store them. |
|
598 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
599 | + $result->addErrorMessages($errorMessages); |
|
600 | + } |
|
601 | + |
|
602 | + // Flush Clipboard if told so. |
|
603 | + if (GeneralUtility::_GP('flushClipboard')) { |
|
604 | + $this->getClipboardService()->flush(); |
|
605 | + } |
|
606 | + |
|
607 | + $response = $this->responseFactory->createResponse() |
|
608 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
609 | + $response->getBody()->write(json_encode($result)); |
|
610 | + return $response; |
|
611 | + } |
|
612 | + |
|
613 | + /** |
|
614 | + * Retrieve Content objects first according to matching criteria and then "localize" them. |
|
615 | + * |
|
616 | + * Possible values for $matches, refer to method "updateAction". |
|
617 | + * |
|
618 | + * @param string $fieldNameAndPath |
|
619 | + * @param array $matches |
|
620 | + * @param int $language |
|
621 | + * @throws \Exception |
|
622 | + */ |
|
623 | + public function localizeAction($fieldNameAndPath, array $matches = [], $language = 0) |
|
624 | + { |
|
625 | + |
|
626 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
627 | + |
|
628 | + // Fetch objects via the Content Service. |
|
629 | + $contentService = $this->getContentService()->findBy($matcher); |
|
630 | + |
|
631 | + // Get result object for storing data along the processing. |
|
632 | + $result = $this->getJsonResult(); |
|
633 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
634 | + |
|
635 | + foreach ($contentService->getObjects() as $object) { |
|
636 | + |
|
637 | + $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid'); |
|
638 | + $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
639 | + |
|
640 | + // Fetch the source object to be localized. |
|
641 | + /** @var Content $content */ |
|
642 | + $content = ContentRepositoryFactory::getInstance($dataType)->findByIdentifier($identifier); |
|
643 | + |
|
644 | + // Makes sure the object was retrieved. Security! |
|
645 | + if (!$content) { |
|
646 | + $message = sprintf('Something went wrong when retrieving content "%s" with identifier "%s".', $dataType, $identifier); |
|
647 | + throw new \Exception($message, 1412343097); |
|
648 | + } |
|
649 | + |
|
650 | + // Handover the localization to the Repository. |
|
651 | + ContentRepositoryFactory::getInstance($dataType)->localize($content, $language); |
|
652 | + |
|
653 | + // Get the possible error messages and store them. |
|
654 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
655 | + |
|
656 | + // Redirect to TCEForm so that the BE User can do its job! |
|
657 | + if ($contentService->getNumberOfObjects() === 1) { |
|
658 | + |
|
659 | + if (!empty($errorMessages)) { |
|
660 | + $message = sprintf('Something went wrong when localizing content "%s" with identifier "%s". <br/>%s', |
|
661 | + $dataType, |
|
662 | + $identifier, |
|
663 | + implode('<br/>', $errorMessages) |
|
664 | + ); |
|
665 | + throw new \Exception($message, 1412343098); |
|
666 | + } |
|
667 | + |
|
668 | + $localizedContent = $this->getLanguageService()->getLocalizedContent($content, $language); |
|
669 | + if (empty($localizedContent)) { |
|
670 | + $message = sprintf('Oups! I could not retrieve localized content of type "%s" with identifier "%s"', |
|
671 | + $content->getDataType(), |
|
672 | + $content->getUid() |
|
673 | + ); |
|
674 | + throw new \Exception($message, 1412343099); |
|
675 | + } |
|
676 | + |
|
677 | + /** @var EditUri $uri */ |
|
678 | + $uriRenderer = GeneralUtility::makeInstance(EditUri::class); |
|
679 | + $uri = $uriRenderer->render($localizedContent); |
|
680 | + HttpUtility::redirect($uri); |
|
681 | + break; // no need to further continue |
|
682 | + } |
|
683 | + |
|
684 | + $result->addErrorMessages($errorMessages); |
|
685 | + } |
|
686 | + |
|
687 | + $response = $this->responseFactory->createResponse() |
|
688 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
689 | + $response->getBody()->write(json_encode($result)); |
|
690 | + return $response; |
|
691 | + } |
|
692 | + |
|
693 | + /** |
|
694 | + * Get the Vidi Module Loader. |
|
695 | + * |
|
696 | + * @return ContentService |
|
697 | + */ |
|
698 | + protected function getContentService() |
|
699 | + { |
|
700 | + return GeneralUtility::makeInstance(ContentService::class); |
|
701 | + } |
|
702 | + |
|
703 | + /** |
|
704 | + * @return ContentObjectResolver |
|
705 | + */ |
|
706 | + protected function getContentObjectResolver() |
|
707 | + { |
|
708 | + return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
709 | + } |
|
710 | + |
|
711 | + /** |
|
712 | + * @return FieldPathResolver |
|
713 | + */ |
|
714 | + protected function getFieldPathResolver() |
|
715 | + { |
|
716 | + return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
717 | + } |
|
718 | + |
|
719 | + /** |
|
720 | + * @return JsonResult|object |
|
721 | + */ |
|
722 | + protected function getJsonResult() |
|
723 | + { |
|
724 | + return GeneralUtility::makeInstance(JsonResult::class); |
|
725 | + } |
|
726 | + |
|
727 | + /** |
|
728 | + * Signal that is called for post-processing content data send to the server for update. |
|
729 | + * |
|
730 | + * @param Content $contentObject |
|
731 | + * @param $fieldNameAndPath |
|
732 | + * @param $contentData |
|
733 | + * @param $counter |
|
734 | + * @param $savingBehavior |
|
735 | + * @param $language |
|
736 | + * @return ProcessContentDataSignalArguments |
|
737 | + */ |
|
738 | + protected function emitProcessContentDataSignal(Content $contentObject, $fieldNameAndPath, $contentData, $counter, $savingBehavior, $language) |
|
739 | + { |
|
740 | + |
|
741 | + /** @var ProcessContentDataSignalArguments $signalArguments */ |
|
742 | + $signalArguments = GeneralUtility::makeInstance(ProcessContentDataSignalArguments::class); |
|
743 | + $signalArguments->setContentObject($contentObject) |
|
744 | + ->setFieldNameAndPath($fieldNameAndPath) |
|
745 | + ->setContentData($contentData) |
|
746 | + ->setCounter($counter) |
|
747 | + ->setSavingBehavior($savingBehavior) |
|
748 | + ->setLanguage($language); |
|
749 | + |
|
750 | + $signalResult = $this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\Controller\Backend\ContentController', 'processContentData', array($signalArguments)); |
|
751 | + return $signalResult[0]; |
|
752 | + } |
|
753 | + |
|
754 | + /** |
|
755 | + * Get the SignalSlot dispatcher. |
|
756 | + * |
|
757 | + * @return Dispatcher |
|
758 | + */ |
|
759 | + protected function getSignalSlotDispatcher() |
|
760 | + { |
|
761 | + return $this->objectManager->get(Dispatcher::class); |
|
762 | + } |
|
763 | + |
|
764 | + /** |
|
765 | + * Get the Clipboard service. |
|
766 | + * |
|
767 | + * @return ClipboardService |
|
768 | + */ |
|
769 | + protected function getClipboardService() |
|
770 | + { |
|
771 | + return GeneralUtility::makeInstance(ClipboardService::class); |
|
772 | + } |
|
773 | + |
|
774 | + /** |
|
775 | + * @return LanguageService |
|
776 | + */ |
|
777 | + protected function getLanguageService() |
|
778 | + { |
|
779 | + return GeneralUtility::makeInstance(LanguageService::class); |
|
780 | + } |
|
781 | + |
|
782 | + /** |
|
783 | + * Get the Vidi Module Loader. |
|
784 | + * |
|
785 | + * @return ModuleLoader |
|
786 | + */ |
|
787 | + protected function getModuleLoader() |
|
788 | + { |
|
789 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
790 | + } |
|
791 | 791 | |
792 | 792 | } |