BxDolStudioInstallerUtils.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  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 DolphinStudio Dolphin Studio
  7. * @{
  8. */
  9. defined('BX_DOL') or die('hack attempt');
  10. bx_import('BxDolInstallerUtils');
  11. class BxDolStudioInstallerUtils extends BxDolInstallerUtils {
  12. function BxDolStudioInstallerUtils() {
  13. if(isset($GLOBALS['bxDolClasses'][get_class($this)]))
  14. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  15. parent::BxDolInstallerUtils();
  16. }
  17. /**
  18. * Prevent cloning the instance
  19. */
  20. public function __clone() {
  21. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  22. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  23. }
  24. /**
  25. * Get singleton instance of the class
  26. */
  27. function getInstance() {
  28. if(!isset($GLOBALS['bxDolClasses'][__CLASS__]))
  29. $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolStudioInstallerUtils();
  30. return $GLOBALS['bxDolClasses'][__CLASS__];
  31. }
  32. function perform($sDirectory, $sOperation, $aParams = array()) {
  33. $sConfigFile = 'install/config.php';
  34. $sInstallerFile = 'install/installer.php';
  35. $sInstallerClass = 'Installer';
  36. $sPathConfig = BX_DIRECTORY_PATH_MODULES . $sDirectory . $sConfigFile;
  37. $sPathInstaller = BX_DIRECTORY_PATH_MODULES . $sDirectory . $sInstallerFile;
  38. if(file_exists($sPathConfig) && file_exists($sPathInstaller)) {
  39. include($sPathConfig);
  40. require_once($sPathInstaller);
  41. $sClassName = $aConfig['class_prefix'] . $sInstallerClass;
  42. $oInstaller = new $sClassName($aConfig);
  43. $aResult = $oInstaller->$sOperation($aParams);
  44. $aResult = array(
  45. 'code' => $aResult['result'] ? 0 : 1,
  46. 'message' => $aResult['message'],
  47. );
  48. }
  49. else
  50. $aResult = array(
  51. 'code' => 2,
  52. 'message' => _t('_adm_mod_err_process_operation_failed', $sOperation, $sDirectory),
  53. );
  54. return $aResult;
  55. }
  56. }
  57. /** @} */