1
0

BxDevModule.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php defined('BX_DOL') 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 Developer Developer
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolModule');
  12. require_once('BxDevFunctions.php');
  13. define('BX_DEV_TOOLS_SETTINGS', 'settings');
  14. define('BX_DEV_TOOLS_FORMS', 'forms');
  15. define('BX_DEV_TOOLS_PAGES', 'pages');
  16. define('BX_DEV_TOOLS_NAVIGATION', 'navigation');
  17. define('BX_DEV_TOOLS_POLYGLOT', 'polyglot');
  18. define('BX_DEV_TOOLS_PERMISSIONS', 'permissions');
  19. class BxDevModule extends BxDolModule
  20. {
  21. public $aTools;
  22. function __construct($aModule)
  23. {
  24. parent::__construct($aModule);
  25. $this->aTools = array(
  26. array('name' => BX_DEV_TOOLS_SETTINGS, 'title' => '', 'icon' => 'cogs'),
  27. array('name' => BX_DEV_TOOLS_FORMS, 'title' => '', 'icon' => 'bx-dev-mi-forms.png'),
  28. array('name' => BX_DEV_TOOLS_NAVIGATION, 'title' => '', 'icon' => 'bx-dev-mi-navigation.png'),
  29. array('name' => BX_DEV_TOOLS_PAGES, 'title' => '', 'icon' => 'bx-dev-mi-pages.png'),
  30. array('name' => BX_DEV_TOOLS_POLYGLOT, 'title' => '', 'icon' => 'bx-dev-mi-polyglot.png'),
  31. //array('name' => BX_DEV_TOOLS_PERMISSIONS, 'title' => '', 'icon' => 'bx-dev-mi-permissions.png'),
  32. );
  33. }
  34. function getToolsList()
  35. {
  36. return $this->aTools;
  37. }
  38. public function actionResetHash($sType) {
  39. $oDb = bx_instance('BxDolStudioInstallerQuery');
  40. $sResult = '';
  41. switch ($sType) {
  42. case 'system':
  43. $oHasher = bx_instance('BxDolInstallerHasher');
  44. $oDb->deleteModuleTrackFiles(BX_SYSTEM_MODULE_ID);
  45. $sResult = _t('_bx_dev_hash_' . ($oHasher->hashSystemFiles() ? 'msg' : 'err') . '_reset_hash_system');
  46. break;
  47. case 'modules':
  48. bx_import('BxDolInstallerUtils');
  49. bx_import('BxDolModuleQuery');
  50. $aModules = BxDolModuleQuery::getInstance()->getModules();
  51. $aTmplVarsModules = array();
  52. foreach($aModules as $aModule) {
  53. if($aModule['name'] == 'system')
  54. continue;
  55. $aConfig = BxDolInstallerUtils::getModuleConfig($aModule);
  56. $sPathInstaller = BX_DIRECTORY_PATH_MODULES . $aModule['path'] . 'install/installer.php';
  57. if(empty($aConfig) || !file_exists($sPathInstaller))
  58. continue;
  59. require_once($sPathInstaller);
  60. $sClassName = $aConfig['class_prefix'] . 'Installer';
  61. $oInstaller = new $sClassName($aConfig);
  62. $oDb->deleteModuleTrackFiles($aModule['id']);
  63. $aFiles = array();
  64. $oInstaller->hashFiles(BX_DIRECTORY_PATH_ROOT . 'modules/' . $aModule['path'], $aFiles);
  65. foreach($aFiles as $aFile)
  66. $oDb->insertModuleTrack($aModule['id'], $aFile);
  67. $aTmplVarsModules[] = array(
  68. 'module' => $aModule['title'],
  69. 'files' => count($aFiles)
  70. );
  71. }
  72. $sResult = $this->_oTemplate->parseHtmlByName('hash_modules.html', array(
  73. 'bx_repeat:modules' => $aTmplVarsModules
  74. ));
  75. break;
  76. }
  77. echo $sResult;
  78. exit;
  79. }
  80. }
  81. /** @} */