1
0

BxDolInstallModulesTools.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php defined('BX_DOL_INSTALL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinInstall Dolphin Install
  7. * @{
  8. */
  9. class BxDolInstallModulesTools
  10. {
  11. public function __construct()
  12. {
  13. }
  14. public function getModules ($sType = null) {
  15. $aModules = array();
  16. $sPath = BX_INSTALL_DIR_MODULES;
  17. if (($rHandleVendor = opendir($sPath)) !== false) {
  18. while (($sVendor = readdir($rHandleVendor)) !== false) {
  19. if (substr($sVendor, 0, 1) == '.' || !is_dir($sPath . $sVendor))
  20. continue;
  21. if (($rHandleModule = opendir($sPath . $sVendor)) !== false) {
  22. while(($sModule = readdir($rHandleModule)) !== false) {
  23. if(!is_dir($sPath . $sVendor . '/' . $sModule) || substr($sModule, 0, 1) == '.')
  24. continue;
  25. $sConfigPath = $sPath . $sVendor . '/' . $sModule . '/install/config.php';
  26. $aModuleConfig = $this->getModuleConfigByConfigPath($sConfigPath);
  27. if (empty($aModuleConfig) || ($sType && $sType != $aModuleConfig['type']))
  28. continue;
  29. $aModules[$aModuleConfig['name']] = $aModuleConfig;
  30. }
  31. closedir($rHandleModule);
  32. }
  33. }
  34. closedir($rHandleVendor);
  35. }
  36. ksort($aModules);
  37. return $aModules;
  38. }
  39. public function getModuleConfigByUri ($sUri, $aModules) {
  40. foreach ($aModules as $aModuleConfig)
  41. if ($sUri == $aModuleConfig['home_uri'])
  42. return $aModuleConfig;
  43. return null;
  44. }
  45. public function readLanguage ($aModuleConfig) {
  46. $sPath = BX_INSTALL_DIR_MODULES . $aModuleConfig['home_dir'] . 'data/langs/system.xml';
  47. if(!file_exists($sPath))
  48. return array();
  49. $oXmlParser = BxDolXmlParser::getInstance();
  50. $sXmlContent = file_get_contents($sPath);
  51. return $oXmlParser->getValues($sXmlContent, 'string');
  52. }
  53. protected function getModuleConfigByConfigPath ($sConfigPath) {
  54. if (!file_exists($sConfigPath))
  55. return array();
  56. include($sConfigPath);
  57. return $aConfig;
  58. }
  59. }
  60. /** @} */