BxDolStudioForms.php 2.3 KB

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