BxDolStudioForms.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaStudio UNA Studio
  7. * @{
  8. */
  9. define('BX_DOL_STUDIO_FORM_TYPE_FORMS', 'forms');
  10. define('BX_DOL_STUDIO_FORM_TYPE_DISPLAYS', 'displays');
  11. define('BX_DOL_STUDIO_FORM_TYPE_FIELDS', 'fields');
  12. define('BX_DOL_STUDIO_FORM_TYPE_PRE_LISTS', 'pre_lists');
  13. define('BX_DOL_STUDIO_FORM_TYPE_PRE_VALUES', 'pre_values');
  14. define('BX_DOL_STUDIO_FORM_TYPE_DEFAULT', BX_DOL_STUDIO_FORM_TYPE_FORMS);
  15. class BxDolStudioForms extends BxTemplStudioPage
  16. {
  17. protected $sPage;
  18. function __construct($sPage = "")
  19. {
  20. parent::__construct('builder_forms');
  21. $this->oDb = new BxDolStudioFormsQuery();
  22. $this->sPage = BX_DOL_STUDIO_FORM_TYPE_DEFAULT;
  23. if(is_string($sPage) && !empty($sPage))
  24. $this->sPage = $sPage;
  25. }
  26. public function init()
  27. {
  28. if(($sAction = bx_get('form_action')) === false)
  29. return;
  30. $sAction = bx_process_input($sAction);
  31. $aResult = array('code' => 1, 'message' => _t('_adm_form_err_cannot_process_action'));
  32. switch($sAction) {
  33. case 'get-page-by-type':
  34. $sValue = bx_process_input(bx_get('form_value'));
  35. if(empty($sValue))
  36. break;
  37. $this->sPage = $sValue;
  38. $aResult = array('code' => 0, 'content' => $this->getPageCode());
  39. break;
  40. default:
  41. $sMethod = 'action' . $this->getClassName($sAction);
  42. if(method_exists($this, $sMethod))
  43. $aResult = $this->$sMethod();
  44. }
  45. echo json_encode($aResult);
  46. exit;
  47. }
  48. protected function getSystemName($sValue)
  49. {
  50. return str_replace(' ', '_', strtolower($sValue));
  51. }
  52. protected function getClassName($sValue)
  53. {
  54. return bx_gen_method_name($sValue);
  55. }
  56. }
  57. /** @} */