DolibarrCollector.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. use DebugBar\DataCollector\AssetProvider;
  3. use DebugBar\DataCollector\DataCollector;
  4. use DebugBar\DataCollector\Renderable;
  5. use DebugBar\DebugBarException;
  6. /**
  7. * DolibarrCollector class
  8. */
  9. class DolibarrCollector extends DataCollector implements Renderable, AssetProvider
  10. {
  11. /**
  12. * Return collector name
  13. *
  14. * @return string Name
  15. */
  16. public function getName()
  17. {
  18. return 'dolibarr';
  19. }
  20. /**
  21. * Return collected data
  22. *
  23. * @return array Array
  24. */
  25. public function collect()
  26. {
  27. return array();
  28. }
  29. /**
  30. * Return database info as an HTML string
  31. *
  32. * @return string HTML string
  33. */
  34. protected function getDatabaseInfo()
  35. {
  36. global $conf, $langs;
  37. $info = $langs->trans('Host').': <strong>'.$conf->db->host.'</strong><br>';
  38. $info .= $langs->trans('Port').': <strong>'.$conf->db->port.'</strong><br>';
  39. $info .= $langs->trans('Name').': <strong>'.$conf->db->name.'</strong><br>';
  40. $info .= $langs->trans('User').': <strong>'.$conf->db->user.'</strong><br>';
  41. $info .= $langs->trans('Type').': <strong>'.$conf->db->type.'</strong><br>';
  42. $info .= $langs->trans('Prefix').': <strong>'.$conf->db->prefix.'</strong><br>';
  43. $info .= $langs->trans('Charset').': <strong>'.$conf->db->character_set.'</strong>';
  44. return $info;
  45. }
  46. /**
  47. * Return dolibarr info as an HTML string
  48. *
  49. * @return string HTML string
  50. */
  51. protected function getDolibarrInfo()
  52. {
  53. global $conf, $langs;
  54. global $dolibarr_main_prod, $dolibarr_nocsrfcheck;
  55. $info = $langs->trans('Version').': <strong>'.DOL_VERSION.'</strong><br>';
  56. $info .= $langs->trans('Theme').': <strong>'.$conf->theme.'</strong><br>';
  57. $info .= $langs->trans('Locale').': <strong>'.$conf->global->MAIN_LANG_DEFAULT.'</strong><br>';
  58. $info .= $langs->trans('Currency').': <strong>'.$conf->currency.'</strong><br>';
  59. $info .= $langs->trans('Entity').': <strong>'.$conf->entity.'</strong><br>';
  60. $info .= $langs->trans('MaxSizeList').': <strong>'.($conf->liste_limit ?: $conf->global->MAIN_SIZE_LISTE_LIMIT).'</strong><br>';
  61. $info .= $langs->trans('MaxSizeForUploadedFiles').': <strong>'.$conf->global->MAIN_UPLOAD_DOC.'</strong><br>';
  62. $info .= '$dolibarr_main_prod = <strong>'.$dolibarr_main_prod.'</strong><br>';
  63. $info .= '$dolibarr_nocsrfcheck = <strong>'.$dolibarr_nocsrfcheck.'</strong><br>';
  64. $info .= 'MAIN_SECURITY_CSRF_WITH_TOKEN = <strong>'.$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN.'</strong><br>';
  65. $info .= 'MAIN_FEATURES_LEVEL = <strong>'.$conf->global->MAIN_FEATURES_LEVEL.'</strong><br>';
  66. return $info;
  67. }
  68. /**
  69. * Return mail info as an HTML string
  70. *
  71. * @return string HTML string
  72. */
  73. protected function getMailInfo()
  74. {
  75. global $conf, $langs;
  76. global $dolibarr_mailing_limit_sendbyweb, $dolibarr_mailing_limit_sendbycli, $dolibarr_mailing_limit_sendbyday;
  77. $info = $langs->trans('Method').': <strong>'.getDolGlobalString("MAIN_MAIL_SENDMODE").'</strong><br>';
  78. $info .= $langs->trans('Server').': <strong>'.getDolGlobalString("MAIN_MAIL_SMTP_SERVER").'</strong><br>';
  79. $info .= $langs->trans('Port').': <strong>'.getDolGlobalString("MAIN_MAIL_SMTP_PORT").'</strong><br>';
  80. $info .= $langs->trans('ID').': <strong>'.getDolGlobalString("MAIN_MAIL_SMTPS_IDT").'</strong><br>';
  81. $info .= $langs->trans('Pwd').': <strong>'.preg_replace('/./', '*', getDolGlobalString("MAIN_MAIL_SMTPS_PW")).'</strong><br>';
  82. $info .= $langs->trans('TLS/STARTTLS').': <strong>'.getDolGlobalString("MAIN_MAIL_EMAIL_TLS").'</strong> / <strong>'.getDolGlobalString("MAIN_MAIL_EMAIL_STARTTLS").'</strong><br>';
  83. $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': <strong>'.(empty($conf->global->MAIN_DISABLE_ALL_MAILS) ? $langs->trans('No') : $langs->trans('Yes')).'</strong><br>';
  84. $info .= 'dolibarr_mailing_limit_sendbyweb = <strong>'.$dolibarr_mailing_limit_sendbyweb.'</strong><br>';
  85. $info .= 'dolibarr_mailing_limit_sendbycli = <strong>'.$dolibarr_mailing_limit_sendbycli.'</strong><br>';
  86. $info .= 'dolibarr_mailing_limit_sendbyday = <strong>'.$dolibarr_mailing_limit_sendbyday.'</strong><br>';
  87. return $info;
  88. }
  89. /**
  90. * Return widget settings
  91. *
  92. * @return array Array
  93. */
  94. public function getWidgets()
  95. {
  96. return array(
  97. "database_info" => array(
  98. "icon" => "database",
  99. "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator",
  100. "tooltip" => array(
  101. "html" => $this->getDatabaseInfo(),
  102. "class" => "tooltip-wide"
  103. ),
  104. "map" => "",
  105. "default" => ""
  106. ),
  107. "dolibarr_info" => array(
  108. "icon" => "desktop",
  109. "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator",
  110. "tooltip" => array(
  111. "html" => $this->getDolibarrInfo(),
  112. "class" => "tooltip-wide"
  113. ),
  114. "map" => "",
  115. "default" => ""
  116. ),
  117. "mail_info" => array(
  118. "icon" => "envelope",
  119. "indicator" => "PhpDebugBar.DebugBar.TooltipIndicator",
  120. "tooltip" => array(
  121. "html" => $this->getMailInfo(),
  122. "class" => "tooltip-extra-wide"
  123. ),
  124. "map" => "",
  125. "default" => ""
  126. )
  127. );
  128. }
  129. /**
  130. * Return collector assests
  131. *
  132. * @return array Array
  133. */
  134. public function getAssets()
  135. {
  136. return array(
  137. 'base_url' => dol_buildpath('/debugbar', 1),
  138. 'js' => 'js/widgets.js'
  139. );
  140. }
  141. }