BxDolStudioForms.php 1.9 KB

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