1
0

BxDevModule.php 3.1 KB

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