BxDolStudioForms.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_SEARCH_FORMS', 'search_forms');
  15. define('BX_DOL_STUDIO_FORM_TYPE_SEARCH_FIELDS', 'search_fields');
  16. define('BX_DOL_STUDIO_FORM_TYPE_LABELS', 'labels');
  17. define('BX_DOL_STUDIO_FORM_TYPE_DEFAULT', BX_DOL_STUDIO_FORM_TYPE_FORMS);
  18. class BxDolStudioForms extends BxTemplStudioPage
  19. {
  20. protected $sPage;
  21. function __construct($sPage = "")
  22. {
  23. parent::__construct('builder_forms');
  24. $this->oDb = new BxDolStudioFormsQuery();
  25. $this->sPage = BX_DOL_STUDIO_FORM_TYPE_DEFAULT;
  26. if(is_string($sPage) && !empty($sPage))
  27. $this->sPage = $sPage;
  28. }
  29. public function init()
  30. {
  31. if(($sAction = bx_get('form_action')) === false)
  32. return;
  33. $sAction = bx_process_input($sAction);
  34. $aResult = array('code' => 1, 'message' => _t('_adm_form_err_cannot_process_action'));
  35. switch($sAction) {
  36. case 'get-page-by-type':
  37. $sValue = bx_process_input(bx_get('form_value'));
  38. if(empty($sValue))
  39. break;
  40. $this->sPage = $sValue;
  41. $aResult = array('code' => 0, 'content' => $this->getPageCode());
  42. break;
  43. default:
  44. $sMethod = 'action' . $this->getClassName($sAction);
  45. if(method_exists($this, $sMethod))
  46. $aResult = $this->$sMethod();
  47. }
  48. echo json_encode($aResult);
  49. exit;
  50. }
  51. protected function getSystemName($sValue)
  52. {
  53. return str_replace(' ', '_', strtolower($sValue));
  54. }
  55. protected function getClassName($sValue)
  56. {
  57. return bx_gen_method_name($sValue);
  58. }
  59. }
  60. /** @} */