dolibarr  20.0.0-beta
DolibarrCollector.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 use DebugBar\DataCollector\AssetProvider;
26 use DebugBar\DataCollector\DataCollector;
27 use DebugBar\DataCollector\Renderable;
28 
33 class DolibarrCollector extends DataCollector implements Renderable, AssetProvider
34 {
40  public function getName()
41  {
42  return 'dolibarr';
43  }
44 
50  public function collect()
51  {
52  return array();
53  }
54 
60  protected function getDatabaseInfo()
61  {
62  global $conf, $langs;
63 
64  $info = $langs->trans('Host').': <strong>'.$conf->db->host.'</strong><br>';
65  $info .= $langs->trans('Port').': <strong>'.$conf->db->port.'</strong><br>';
66  $info .= $langs->trans('Name').': <strong>'.$conf->db->name.'</strong><br>';
67  // @phan-suppress-next-line PhanTypeSuspiciousStringExpression
68  $info .= $langs->trans('User').': <strong>'.$conf->db->user.'</strong><br>';
69  $info .= $langs->trans('Type').': <strong>'.$conf->db->type.'</strong><br>';
70  $info .= $langs->trans('Prefix').': <strong>'.$conf->db->prefix.'</strong><br>';
71  $info .= $langs->trans('Charset').': <strong>'.$conf->db->character_set.'</strong>';
72 
73  return $info;
74  }
75 
81  protected function getDolibarrInfo()
82  {
83  global $conf, $langs;
84  global $dolibarr_main_prod, $dolibarr_nocsrfcheck;
85 
86  $info = $langs->trans('Version').': <strong>'.DOL_VERSION.'</strong><br>';
87  $info .= $langs->trans('Theme').': <strong>'.$conf->theme.'</strong><br>';
88  $info .= $langs->trans('Locale').': <strong>' . getDolGlobalString('MAIN_LANG_DEFAULT').'</strong><br>';
89  $info .= $langs->trans('Currency').': <strong>'.$conf->currency.'</strong><br>';
90  $info .= $langs->trans('Entity').': <strong>'.$conf->entity.'</strong><br>';
91  $info .= $langs->trans('MaxSizeList').': <strong>'.($conf->liste_limit ?: getDolGlobalString('MAIN_SIZE_LISTE_LIMIT')).'</strong><br>';
92  $info .= $langs->trans('MaxSizeForUploadedFiles').': <strong>' . getDolGlobalString('MAIN_UPLOAD_DOC').'</strong><br>';
93  $info .= '$dolibarr_main_prod = <strong>'.$dolibarr_main_prod.'</strong><br>';
94  $info .= '$dolibarr_nocsrfcheck = <strong>'.$dolibarr_nocsrfcheck.'</strong><br>';
95  $info .= 'MAIN_SECURITY_CSRF_WITH_TOKEN = <strong>' . getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN').'</strong><br>';
96  $info .= 'MAIN_FEATURES_LEVEL = <strong>' . getDolGlobalString('MAIN_FEATURES_LEVEL').'</strong><br>';
97 
98  return $info;
99  }
100 
106  protected function getMailInfo()
107  {
108  global $conf, $langs;
109  global $dolibarr_mailing_limit_sendbyweb, $dolibarr_mailing_limit_sendbycli, $dolibarr_mailing_limit_sendbyday;
110 
111  $info = $langs->trans('Method').': <strong>'.getDolGlobalString("MAIN_MAIL_SENDMODE").'</strong><br>';
112  $info .= $langs->trans('Server').': <strong>'.getDolGlobalString("MAIN_MAIL_SMTP_SERVER").'</strong><br>';
113  $info .= $langs->trans('Port').': <strong>'.getDolGlobalString("MAIN_MAIL_SMTP_PORT").'</strong><br>';
114  $info .= $langs->trans('ID').': <strong>'.getDolGlobalString("MAIN_MAIL_SMTPS_IDT").'</strong><br>';
115  $info .= $langs->trans('Pwd').': <strong>'.preg_replace('/./', '*', getDolGlobalString("MAIN_MAIL_SMTPS_PW")).'</strong><br>';
116  $info .= $langs->trans('TLS/STARTTLS').': <strong>'.getDolGlobalString("MAIN_MAIL_EMAIL_TLS").'</strong> / <strong>'.getDolGlobalString("MAIN_MAIL_EMAIL_STARTTLS").'</strong><br>';
117  $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': <strong>'.(!getDolGlobalString('MAIN_DISABLE_ALL_MAILS') ? $langs->trans('No') : $langs->trans('Yes')).'</strong><br>';
118  $info .= 'dolibarr_mailing_limit_sendbyweb = <strong>'.$dolibarr_mailing_limit_sendbyweb.'</strong><br>';
119  $info .= 'dolibarr_mailing_limit_sendbycli = <strong>'.$dolibarr_mailing_limit_sendbycli.'</strong><br>';
120  $info .= 'dolibarr_mailing_limit_sendbyday = <strong>'.$dolibarr_mailing_limit_sendbyday.'</strong><br>';
121 
122  return $info;
123  }
124 
130  public function getWidgets()
131  {
132  return array(
133  "database_info" => array(
134  "icon" => "database",
135  "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator",
136  "tooltip" => array(
137  "html" => $this->getDatabaseInfo(),
138  "class" => "tooltip-wide"
139  ),
140  "map" => "",
141  "default" => ""
142  ),
143  "dolibarr_info" => array(
144  "icon" => "desktop",
145  "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator",
146  "tooltip" => array(
147  "html" => $this->getDolibarrInfo(),
148  "class" => "tooltip-wide"
149  ),
150  "map" => "",
151  "default" => ""
152  ),
153  "mail_info" => array(
154  "icon" => "envelope",
155  "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator",
156  "tooltip" => array(
157  "html" => $this->getMailInfo(),
158  "class" => "tooltip-extra-wide"
159  ),
160  "map" => "",
161  "default" => ""
162  )
163  );
164  }
165 
171  public function getAssets()
172  {
173  return array(
174  'base_url' => dol_buildpath('/debugbar', 1),
175  'js' => 'js/widgets.js',
176  'css' => 'css/widgets.css'
177  );
178  }
179 }
DolibarrCollector class.
getWidgets()
Return widget settings.
getAssets()
Return collector assests.
collect()
Return collected data.
getDatabaseInfo()
Return database info as an HTML string.
getDolibarrInfo()
Return dolibarr info as an HTML string.
getMailInfo()
Return mail info as an HTML string.
getName()
Return collector name.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.