Module.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php declare(strict_types = 0);
  2. /*
  3. ** WeCom Center / ROMAN 定制中心 - a portable, multi-language Zabbix module.
  4. ** Adds a configuration center for alert optimisation, WeCom robot/key/media,
  5. ** template import, map coordinates, and the L2 physical topology feature
  6. ** (DB-backed history, configurable collection & display, live web map).
  7. */
  8. namespace Modules\WecomCenter;
  9. use Zabbix\Core\CModule;
  10. use APP;
  11. use CMenuItem;
  12. use CView;
  13. use Modules\WecomCenter\Lib\I18n;
  14. use Modules\WecomCenter\Lib\L2Store;
  15. class Module extends CModule {
  16. public function init(): void {
  17. // Register this module's own view directory so CView can find:
  18. // modules/WecomCenter/views/wecom.center.view.php, topology.view.php
  19. CView::registerDirectory($this->getRelativePath().'/views');
  20. // Load translations for the current language (falls back to English).
  21. I18n::init($this->getRelativePath().'/locale');
  22. // Make sure the L2 tables exist (idempotent, never fatal).
  23. L2Store::ensureSchema();
  24. $menu = APP::Component()->get('menu.main');
  25. // Configuration center under Administration.
  26. $menu->findOrAdd(_('Administration'))
  27. ->getSubMenu()
  28. ->add(
  29. (new CMenuItem(I18n::t('menu.title')))
  30. ->setAction('wecom.center.view')
  31. );
  32. // L2 physical topology under Monitoring.
  33. $menu->findOrAdd(_('Monitoring'))
  34. ->getSubMenu()
  35. ->add(
  36. (new CMenuItem(I18n::t('menu.l2')))
  37. ->setAction('l2.topology.view')
  38. );
  39. }
  40. }