| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php defined('BX_DOL_INSTALL') or die('hack attempt');
- /**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup DolphinInstall Dolphin Install
- * @{
- */
- class BxDolInstallModulesTools
- {
- public function __construct()
- {
- }
-
- public function getModules ($sType = null) {
- $aModules = array();
- $sPath = BX_INSTALL_DIR_MODULES;
- if (($rHandleVendor = opendir($sPath)) !== false) {
- while (($sVendor = readdir($rHandleVendor)) !== false) {
- if (substr($sVendor, 0, 1) == '.' || !is_dir($sPath . $sVendor))
- continue;
- if (($rHandleModule = opendir($sPath . $sVendor)) !== false) {
- while(($sModule = readdir($rHandleModule)) !== false) {
- if(!is_dir($sPath . $sVendor . '/' . $sModule) || substr($sModule, 0, 1) == '.')
- continue;
- $sConfigPath = $sPath . $sVendor . '/' . $sModule . '/install/config.php';
- $aModuleConfig = $this->getModuleConfigByConfigPath($sConfigPath);
- if (empty($aModuleConfig) || ($sType && $sType != $aModuleConfig['type']))
- continue;
- $aModules[$aModuleConfig['name']] = $aModuleConfig;
- }
- closedir($rHandleModule);
- }
- }
- closedir($rHandleVendor);
- }
- ksort($aModules);
- return $aModules;
- }
- public function getModuleConfigByUri ($sUri, $aModules) {
- foreach ($aModules as $aModuleConfig)
- if ($sUri == $aModuleConfig['home_uri'])
- return $aModuleConfig;
- return null;
- }
- public function readLanguage ($aModuleConfig) {
- $sPath = BX_INSTALL_DIR_MODULES . $aModuleConfig['home_dir'] . 'data/langs/system.xml';
- if(!file_exists($sPath))
- return array();
- $oXmlParser = BxDolXmlParser::getInstance();
- $sXmlContent = file_get_contents($sPath);
- return $oXmlParser->getValues($sXmlContent, 'string');
- }
- protected function getModuleConfigByConfigPath ($sConfigPath) {
- if (!file_exists($sConfigPath))
- return array();
- include($sConfigPath);
- return $aConfig;
- }
- }
- /** @} */
|