1
0

BxDolStudioForms.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 DolphinStudio Dolphin 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. protected $sPage;
  19. function __construct($sPage = "") {
  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. //--- Check actions ---//
  26. if(($sAction = bx_get('form_action')) !== false) {
  27. $sAction = bx_process_input($sAction);
  28. $aResult = array('code' => 1, 'message' => _t('_adm_form_err_cannot_process_action'));
  29. switch($sAction) {
  30. case 'get-page-by-type':
  31. $sValue = bx_process_input(bx_get('form_value'));
  32. if(empty($sValue))
  33. break;
  34. $this->sPage = $sValue;
  35. $aResult = array('code' => 0, 'content' => $this->getPageCode());
  36. break;
  37. default:
  38. $sMethod = 'action' . $this->getClassName($sAction);
  39. if(method_exists($this, $sMethod))
  40. $aResult = $this->$sMethod();
  41. }
  42. $oJson = new Services_JSON();
  43. echo $oJson->encode($aResult);
  44. exit;
  45. }
  46. }
  47. protected function getSystemName($sValue) {
  48. return str_replace(' ', '_', strtolower($sValue));
  49. }
  50. protected function getClassName($sValue) {
  51. return bx_gen_method_name($sValue);
  52. }
  53. }
  54. /** @} */