BxDolStudioForms.php 2.2 KB

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