BxDolModuleConfig.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. /**
  10. * Base class for Config classes in modules engine.
  11. *
  12. * The object of the class contains different basic configuration settings which are necessary for all modules.
  13. *
  14. *
  15. * Example of usage:
  16. * refer to any BoonEx module
  17. *
  18. *
  19. * Memberships/ACL:
  20. * Doesn't depend on user's membership.
  21. *
  22. *
  23. * Alerts:
  24. * no alerts available
  25. *
  26. */
  27. class BxDolModuleConfig extends BxDol
  28. {
  29. protected $_iId;
  30. protected $_sName;
  31. protected $_sVendor;
  32. protected $_sClassPrefix;
  33. protected $_sDbPrefix;
  34. protected $_sDirectory;
  35. protected $_sUri;
  36. protected $_sHomePath;
  37. protected $_sClassPath;
  38. protected $_sHomeUrl;
  39. /**
  40. * constructor
  41. */
  42. public function __construct($aModule)
  43. {
  44. parent::__construct();
  45. $this->_iId = empty($aModule['id']) ? 0 : (int)$aModule['id'];
  46. $this->_sName = isset($aModule['name']) ? $aModule['name'] : '';
  47. $this->_sVendor = $aModule['vendor'];
  48. $this->_sClassPrefix = $aModule['class_prefix'];
  49. $this->_sDbPrefix = $aModule['db_prefix'];
  50. $this->_sDirectory = $aModule['path'];
  51. $this->_sHomePath = BX_DIRECTORY_PATH_MODULES . $this->_sDirectory;
  52. $this->_sClassPath = $this->_sHomePath . 'classes/';
  53. $this->_sUri = $aModule['uri'];
  54. $this->_sHomeUrl = BX_DOL_URL_MODULES . $this->_sDirectory;
  55. }
  56. function getId()
  57. {
  58. return $this->_iId;
  59. }
  60. function getName()
  61. {
  62. return $this->_sName;
  63. }
  64. function getClassPrefix()
  65. {
  66. return $this->_sClassPrefix;
  67. }
  68. function getDbPrefix()
  69. {
  70. return $this->_sDbPrefix;
  71. }
  72. function getDirectory()
  73. {
  74. return $this->_sDirectory;
  75. }
  76. function getHomePath()
  77. {
  78. return $this->_sHomePath;
  79. }
  80. function getClassPath()
  81. {
  82. return $this->_sClassPath;
  83. }
  84. /**
  85. * Get unique URI.
  86. *
  87. * @return string with unique URI.
  88. */
  89. function getUri()
  90. {
  91. return $this->_sUri;
  92. }
  93. /**
  94. * Get base URI which depends on the Permalinks mechanism.
  95. *
  96. * example /modules/?r=module_uri or /m/module_uri
  97. * @return string with base URI.
  98. */
  99. function getBaseUri()
  100. {
  101. return BxDolPermalinks::getInstance()->permalink('modules/?r=' . $this->_sUri . '/');
  102. }
  103. /**
  104. * Get full URL.
  105. *
  106. * @return string with full URL.
  107. */
  108. function getHomeUrl()
  109. {
  110. return $this->_sHomeUrl;
  111. }
  112. }
  113. /** @} */