Skip to content

Commit d20c263

Browse files
committed
Remove old display methods
Move ExportSearchOutput::displayData() in the class that really uses it (NamesListSearchOutput)
1 parent 4dd4064 commit d20c263

File tree

5 files changed

+79
-324
lines changed

5 files changed

+79
-324
lines changed

src/Glpi/Search/Output/AbstractSearchOutput.php

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ public static function prepareInputParams(string $itemtype, array $params): arra
5757
return $params;
5858
}
5959

60-
/**
61-
* Display some content before the search input form and results
62-
* @param class-string<CommonGLPI> $itemtype
63-
* @return void
64-
*/
65-
public static function showPreSearchDisplay(string $itemtype): void {}
66-
6760
/**
6861
* Display the search results
6962
*
@@ -74,103 +67,6 @@ public static function showPreSearchDisplay(string $itemtype): void {}
7467
**/
7568
abstract public function displayData(array $data, array $params = []);
7669

77-
/**
78-
* Print generic normal Item Cell
79-
*
80-
* @param string|null $value Value to display
81-
* @param integer &$num Column number
82-
* @param integer $row Row number
83-
* @param string $extraparam Extra parameters for display (default '')
84-
*
85-
* @return string HTML to display
86-
*
87-
* @psalm-taint-specialize (to report each unsafe usage as a distinct error)
88-
* @psalm-taint-sink html $value (string will be added to HTML source)
89-
*/
90-
abstract public static function showItem($value, &$num, $row, $extraparam = ''): string;
91-
92-
93-
/**
94-
* Print generic error
95-
*
96-
* @param string $message Message to display, if empty "no item found" will be displayed
97-
*
98-
* @return string HTML to display
99-
**/
100-
abstract public static function showError($message = ''): string;
101-
102-
103-
/**
104-
* Print generic footer
105-
*
106-
* @param string $title title of file : used for PDF (default '')
107-
* @param integer $count Total number of results
108-
*
109-
* @return string HTML to display
110-
**/
111-
abstract public static function showFooter($title = "", $count = null): string;
112-
113-
114-
/**
115-
* Print generic footer
116-
*
117-
* @param integer $rows Number of rows
118-
* @param integer $cols Number of columns
119-
* @param boolean|integer $fixed Used tab_cadre_fixe table for HTML export ? (default 0)
120-
*
121-
* @return string HTML to display
122-
**/
123-
abstract public static function showHeader($rows, $cols, $fixed = 0): string;
124-
125-
/**
126-
* Print generic Header Column
127-
*
128-
* @param string $value Value to display. This value may contain HTML data. Non-HTML content should be escaped before calling this function.
129-
* @param integer &$num Column number
130-
* @param string $linkto Link display element (HTML specific) (default '')
131-
* @param boolean|integer $issort Is the sort column ? (default 0)
132-
* @param string $order Order type ASC or DESC (defaut '')
133-
* @param string $options Options to add (default '')
134-
*
135-
* @return string HTML to display
136-
*
137-
* @psalm-taint-specialize (to report each unsafe usage as a distinct error)
138-
* @psalm-taint-sink html $value (string will be added to HTML source)
139-
*/
140-
abstract public static function showHeaderItem($value, &$num, $linkto = "", $issort = 0, $order = "", $options = ""): string;
141-
142-
/**
143-
* Print begin of header part
144-
*
145-
* @return string HTML to display
146-
**/
147-
abstract public static function showBeginHeader(): string;
148-
149-
150-
/**
151-
* Print end of header part
152-
*
153-
* @return string to display
154-
**/
155-
abstract public static function showEndHeader(): string;
156-
157-
/**
158-
* Print generic new line
159-
*
160-
* @param boolean $odd Is it a new odd line ? (false by default)
161-
* @param boolean $is_deleted Is it a deleted search ? (false by default)
162-
*
163-
* @return string HTML to display
164-
**/
165-
abstract public static function showNewLine($odd = false, $is_deleted = false): string;
166-
167-
/**
168-
* Print generic end line
169-
* @param bool $is_header_line
170-
* @return string HTML to display
171-
*/
172-
abstract public static function showEndLine(bool $is_header_line): string;
173-
17470
public function canDisplayResultsContainerWithoutExecutingSearch(): bool
17571
{
17672
return false;

src/Glpi/Search/Output/ExportSearchOutput.php

Lines changed: 0 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -78,173 +78,4 @@ public static function displayConfigItem($itemtype, $ID, $data = [])
7878

7979
return '';
8080
}
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-
}
25081
}

0 commit comments

Comments
 (0)