BxDolStudioForms.php 2.2 KB

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