* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/custom/netdiag/lib/netdiag.lib.php * \ingroup netdiag * \brief Hilfsfunktionen für das Modul NetDiag */ /** * Tabs für die Admin-Seiten des Moduls vorbereiten * * @return array> Tab-Array */ function netdiagAdminPrepareHead() { global $langs, $conf; $langs->load("netdiag@netdiag"); $h = 0; $head = array(); $head[$h][0] = dol_buildpath("/netdiag/admin/setup.php", 1); $head[$h][1] = $langs->trans("Settings"); $head[$h][2] = 'settings'; $h++; $head[$h][0] = dol_buildpath("/netdiag/admin/about.php", 1); $head[$h][1] = $langs->trans("About"); $head[$h][2] = 'about'; $h++; complete_head_from_modules($conf, $langs, null, $head, $h, 'netdiag@netdiag'); complete_head_from_modules($conf, $langs, null, $head, $h, 'netdiag@netdiag', 'remove'); return $head; } /** * Tabs für die Detailansicht eines Diagnose-Protokolls vorbereiten * * @param NetDiagProtocol $object Protokoll-Objekt * @return array> Tab-Array */ function netdiagProtocolPrepareHead($object) { global $langs, $conf; $langs->load("netdiag@netdiag"); $h = 0; $head = array(); $head[$h][0] = dol_buildpath("/netdiag/netdiagprotocol_card.php", 1).'?id='.$object->id; $head[$h][1] = $langs->trans("NetDiagProtocol"); $head[$h][2] = 'card'; $h++; complete_head_from_modules($conf, $langs, $object, $head, $h, 'netdiagprotocol@netdiag'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'netdiagprotocol@netdiag', 'remove'); return $head; } /** * Ausgabeverzeichnis des Moduls ermitteln (für PDF-Dokumente) * * @return string Absoluter Pfad zum Dokumentenverzeichnis */ function netdiagGetOutputDir() { global $conf; if (!empty($conf->netdiag->dir_output)) { return $conf->netdiag->dir_output; } return DOL_DATA_ROOT.'/netdiag'; } /** * Ein Mess-Ergebnis (JSON) lesbar als HTML aufbereiten. * * Generisch: rendert flache Schlüssel/Wert-Paare und einfache Listen, * damit auch künftige Tools ohne Code-Änderung dargestellt werden. * * @param string $json JSON-String des Ergebnisses * @return string HTML-Schnipsel */ function netdiagFormatResult($json) { if (empty($json)) { return '-'; } $data = json_decode($json, true); if ($data === null) { return dol_escape_htmltag(dol_trunc($json, 120)); } if (!is_array($data)) { return dol_escape_htmltag((string) $data); } $out = '
'; foreach ($data as $key => $val) { $label = dol_escape_htmltag(ucfirst((string) $key)); if (is_array($val)) { $flat = array(); foreach ($val as $item) { $flat[] = is_array($item) ? json_encode($item, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) : (string) $item; } $valstr = implode(', ', $flat); } elseif (is_bool($val)) { $valstr = $val ? 'ja' : 'nein'; } else { $valstr = (string) $val; } $out .= ''.$label.': '.dol_escape_htmltag(dol_trunc($valstr, 200)).' '; } $out .= '
'; return $out; }