Completed
Push — master ( 366a5b...a17b2a )
by
unknown
17:34 queued 14:29
created

FormEngine::displayThumbnail()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Kitodo\Dlf\Hooks;
3
4
/**
5
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
6
 *
7
 * This file is part of the Kitodo and TYPO3 projects.
8
 *
9
 * @license GNU General Public License version 3 or later.
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 */
13
14
use Kitodo\Dlf\Common\Helper;
15
16
/**
17
 * Hooks and helper for \TYPO3\CMS\Backend\Form\FormEngine
18
 *
19
 * @author Sebastian Meyer <[email protected]>
20
 * @package TYPO3
21
 * @subpackage dlf
22
 * @access public
23
 */
24
class FormEngine {
25
    /**
26
     * Helper to display document's thumbnail for table "tx_dlf_documents"
27
     *
28
     * @access public
29
     *
30
     * @param array &$params: An array with parameters
31
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
32
     *
33
     * @return string HTML <img> tag for thumbnail
34
     */
35
    public function displayThumbnail(&$params, &$pObj) {
0 ignored issues
show
Unused Code introduced by
The parameter $pObj is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
        // Simulate TCA field type "passthrough".
37
        $output = '<input type="hidden" name="'.$params['itemFormElName'].'" value="'.$params['itemFormElValue'].'" />';
38
        if (!empty($params['itemFormElValue'])) {
39
            $output .= '<img alt="" src="'.$params['itemFormElValue'].'" />';
40
        }
41
        return $output;
42
    }
43
44
    /**
45
     * Helper to get flexform's items array for plugin "tx_dlf_collection"
46
     *
47
     * @access public
48
     *
49
     * @param array &$params: An array with parameters
50
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
51
     *
52
     * @return void
53
     */
54 View Code Duplication
    public function itemsProcFunc_collectionList(&$params, &$pObj) {
0 ignored issues
show
Unused Code introduced by
The parameter $pObj is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
        $pages = self::fixPageUid($params['row']['pages']);
56
        if (!empty($pages)) {
57
            foreach ($pages as $page) {
58
                if ($page['uid'] > 0) {
59
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
60
                        'label,uid',
61
                        'tx_dlf_collections',
62
                        'pid='.intval($page['uid'])
63
                            .' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'
64
                            .Helper::whereClause('tx_dlf_collections'),
65
                        '',
66
                        'label',
67
                        ''
68
                    );
69
                    if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
70
                        while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
71
                            $params['items'][] = $resArray;
72
                        }
73
                    }
74
                }
75
            }
76
        }
77
    }
78
79
    /**
80
     * Helper to get flexform's items array for plugin "Search"
81
     *
82
     * @access public
83
     *
84
     * @param array &$params: An array with parameters
85
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
86
     *
87
     * @return void
88
     */
89 View Code Duplication
    public function itemsProcFunc_extendedSearchList(&$params, &$pObj) {
0 ignored issues
show
Unused Code introduced by
The parameter $pObj is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
        $pages = self::fixPageUid($params['row']['pages']);
91
        if (!empty($pages)) {
92
            foreach ($pages as $page) {
93
                if ($page['uid'] > 0) {
94
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
95
                        'label,index_name',
96
                        'tx_dlf_metadata',
97
                        'index_indexed=1'
98
                            .' AND pid='.intval($page['uid'])
99
                            .' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'
100
                            .Helper::whereClause('tx_dlf_metadata'),
101
                        '',
102
                        'sorting',
103
                        ''
104
                    );
105
                    if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
106
                        while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
107
                            $params['items'][] = $resArray;
108
                        }
109
                    }
110
                }
111
            }
112
        }
113
    }
114
115
    /**
116
     * Helper to get flexform's items array for plugin "Search"
117
     *
118
     * @access public
119
     *
120
     * @param array &$params: An array with parameters
121
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
122
     *
123
     * @return void
124
     */
125 View Code Duplication
    public function itemsProcFunc_facetsList(&$params, &$pObj) {
0 ignored issues
show
Unused Code introduced by
The parameter $pObj is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
126
        $pages = self::fixPageUid($params['row']['pages']);
127
        if (!empty($pages)) {
128
            foreach ($pages as $page) {
129
                if ($page['uid'] > 0) {
130
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
131
                        'label,index_name',
132
                        'tx_dlf_metadata',
133
                        'is_facet=1'
134
                            .' AND pid='.intval($page['uid'])
135
                            .' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'
136
                            .Helper::whereClause('tx_dlf_metadata'),
137
                        '',
138
                        'sorting',
139
                        ''
140
                    );
141
                    if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
142
                        while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
143
                            $params['items'][] = $resArray;
144
                        }
145
                    }
146
                }
147
            }
148
        }
149
    }
150
151
    /**
152
     * Helper to get flexform's items array for plugin "OaiPmh"
153
     *
154
     * @access public
155
     *
156
     * @param array &$params: An array with parameters
157
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
158
     *
159
     * @return void
160
     */
161 View Code Duplication
    public function itemsProcFunc_libraryList(&$params, &$pObj) {
0 ignored issues
show
Unused Code introduced by
The parameter $pObj is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
162
        $pages = self::fixPageUid($params['row']['pages']);
163
        if (!empty($pages)) {
164
            foreach ($pages as $page) {
165
                if ($page['uid'] > 0) {
166
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
167
                        'label,uid',
168
                        'tx_dlf_libraries',
169
                        'pid='.intval($page['uid'])
170
                        .' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'
171
                        .Helper::whereClause('tx_dlf_libraries'),
172
                        '',
173
                        'label',
174
                        ''
175
                    );
176
                    if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
177
                        while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
178
                            $params['items'][] = $resArray;
179
                        }
180
                    }
181
                }
182
            }
183
        }
184
    }
185
186
    /**
187
     * Helper to get flexform's items array for plugin "Search"
188
     *
189
     * @access public
190
     *
191
     * @param array &$params: An array with parameters
192
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
193
     *
194
     * @return void
195
     */
196 View Code Duplication
    public function itemsProcFunc_solrList(&$params, &$pObj) {
0 ignored issues
show
Unused Code introduced by
The parameter $pObj is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
197
        $pages = self::fixPageUid($params['row']['pages']);
198
        if (!empty($pages)) {
199
            foreach ($pages as $page) {
200
                if ($page['uid'] > 0) {
201
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
202
                        'label,uid',
203
                        'tx_dlf_solrcores',
204
                        'pid IN ('.intval($page['uid']).',0)'
205
                        .Helper::whereClause('tx_dlf_solrcores'),
206
                        '',
207
                        'label',
208
                        ''
209
                    );
210
                    if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
211
                        while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
212
                            $params['items'][] = $resArray;
213
                        }
214
                    }
215
                }
216
            }
217
        }
218
    }
219
220
    /**
221
     * Helper to get flexform's items array for plugin "Toolbox"
222
     *
223
     * @access public
224
     *
225
     * @param array &$params: An array with parameters
226
     * @param \TYPO3\CMS\Backend\Form\FormEngine &$pObj: The parent object
227
     *
228
     * @return void
229
     */
230
    public function itemsProcFunc_toolList(&$params, &$pObj) {
0 ignored issues
show
Unused Code introduced by
The parameter $pObj is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
231
        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'] as $class => $label) {
232
            $params['items'][] = [$GLOBALS['LANG']->sL($label), $class];
233
        }
234
    }
235
236
    private function fixPageUid(&$pages) {
237
        if (!is_array($pages)) {
238
            return array( array( 'uid' => $pages ));
239
        }
240
        return $pages;
241
    }
242
}
243