@@ -78,173 +78,4 @@ public static function displayConfigItem($itemtype, $ID, $data = [])
78
78
79
79
return '' ;
80
80
}
81
-
82
- public function displayData (array $ data , array $ params = [])
83
- {
84
- global $ CFG_GLPI ;
85
-
86
- if (
87
- !isset ($ data ['data ' ])
88
- || !isset ($ data ['data ' ]['totalcount ' ])
89
- || $ data ['data ' ]['count ' ] <= 0
90
- || $ data ['search ' ]['as_map ' ] != 0
91
- ) {
92
- return false ;
93
- }
94
-
95
- // Define begin and end var for loop
96
- // Search case
97
- $ begin_display = $ data ['data ' ]['begin ' ];
98
- $ end_display = $ data ['data ' ]['end ' ];
99
-
100
- // Compute number of columns to display
101
- // Add toview elements
102
- $ nbcols = count ($ data ['data ' ]['cols ' ]);
103
-
104
- // Display List Header
105
- echo static ::showHeader ($ end_display - $ begin_display + 1 , $ nbcols );
106
-
107
- // New Line for Header Items Line
108
- $ headers_line = '' ;
109
- $ headers_line_top = '' ;
110
-
111
- $ headers_line_top .= static ::showBeginHeader ();
112
- $ headers_line_top .= static ::showNewLine ();
113
-
114
- $ header_num = 1 ;
115
-
116
- // Display column Headers for toview items
117
- $ metanames = [];
118
- foreach ($ data ['data ' ]['cols ' ] as $ val ) {
119
- $ name = $ val ["name " ];
120
-
121
- // prefix by group name (corresponding to optgroup in dropdown) if exists
122
- if (isset ($ val ['groupname ' ])) {
123
- $ groupname = $ val ['groupname ' ];
124
- if (is_array ($ groupname )) {
125
- //since 9.2, getSearchOptions has been changed
126
- $ groupname = $ groupname ['name ' ];
127
- }
128
- $ name = "$ groupname - $ name " ;
129
- }
130
-
131
- // Not main itemtype add itemtype to display
132
- if ($ data ['itemtype ' ] != $ val ['itemtype ' ]) {
133
- if (!isset ($ metanames [$ val ['itemtype ' ]])) {
134
- if ($ metaitem = getItemForItemtype ($ val ['itemtype ' ])) {
135
- $ metanames [$ val ['itemtype ' ]] = $ metaitem ->getTypeName ();
136
- }
137
- }
138
- $ name = sprintf (
139
- __ ('%1$s - %2$s ' ),
140
- $ metanames [$ val ['itemtype ' ]],
141
- $ val ["name " ]
142
- );
143
- }
144
-
145
- $ headers_line .= static ::showHeaderItem (
146
- \htmlescape ($ name ),
147
- $ header_num ,
148
- '' ,
149
- (!$ val ['meta ' ]
150
- && ($ data ['search ' ]['sort ' ] == $ val ['id ' ])),
151
- $ data ['search ' ]['order ' ]
152
- );
153
- }
154
-
155
- // Add specific column Header
156
- if (isset ($ CFG_GLPI ["union_search_type " ][$ data ['itemtype ' ]])) {
157
- $ headers_line .= static ::showHeaderItem (
158
- __s ('Item type ' ),
159
- $ header_num
160
- );
161
- }
162
- // End Line for column headers
163
- $ headers_line .= static ::showEndLine (true );
164
-
165
- $ headers_line_top .= $ headers_line ;
166
- $ headers_line_top .= static ::showEndHeader ();
167
-
168
- echo $ headers_line_top ;
169
-
170
- // Num of the row (1=header_line)
171
- $ row_num = 1 ;
172
-
173
- $ typenames = [];
174
- // Display Loop
175
- foreach ($ data ['data ' ]['rows ' ] as $ row ) {
176
- // Column num
177
- $ item_num = 1 ;
178
- $ row_num ++;
179
- // New line
180
- echo static ::showNewLine (
181
- $ row_num % 2 === 1 ,
182
- $ data ['search ' ]['is_deleted ' ]
183
- );
184
-
185
- // Print other toview items
186
- foreach ($ data ['data ' ]['cols ' ] as $ col ) {
187
- $ colkey = "{$ col ['itemtype ' ]}_ {$ col ['id ' ]}" ;
188
- if (!$ col ['meta ' ]) {
189
- echo static ::showItem (
190
- $ row [$ colkey ]['displayname ' ], // `displayname` is provided by `giveItem()` and expected to be a safe HTML string
191
- $ item_num ,
192
- $ row_num ,
193
- static ::displayConfigItem (
194
- $ data ['itemtype ' ],
195
- $ col ['id ' ],
196
- $ row
197
- )
198
- );
199
- } else { // META case
200
- echo static ::showItem (
201
- $ row [$ colkey ]['displayname ' ], // `displayname` is provided by `giveItem()` and expected to be a safe HTML string
202
- $ item_num ,
203
- $ row_num
204
- );
205
- }
206
- }
207
-
208
- if (isset ($ CFG_GLPI ["union_search_type " ][$ data ['itemtype ' ]])) {
209
- if (!isset ($ typenames [$ row ["TYPE " ]])) {
210
- if ($ itemtmp = getItemForItemtype ($ row ["TYPE " ])) {
211
- $ typenames [$ row ["TYPE " ]] = $ itemtmp ->getTypeName ();
212
- }
213
- }
214
- echo static ::showItem (
215
- htmlescape ($ typenames [$ row ["TYPE " ]]),
216
- $ item_num ,
217
- $ row_num
218
- );
219
- }
220
- // End Line
221
- echo static ::showEndLine (false );
222
- }
223
-
224
- // Create title
225
- $ title = static ::computeTitle ($ data );
226
-
227
- // Display footer (close table)
228
- echo static ::showFooter ($ title , $ data ['data ' ]['count ' ]);
229
- }
230
-
231
- public static function showNewLine ($ odd = false , $ is_deleted = false ): string
232
- {
233
- return '' ;
234
- }
235
-
236
- public static function showEndHeader (): string
237
- {
238
- return '' ;
239
- }
240
-
241
- public static function showError ($ message = '' ): string
242
- {
243
- return '' ;
244
- }
245
-
246
- protected static function computeTitle (array $ data ): string
247
- {
248
- return '' ;
249
- }
250
81
}
0 commit comments