BxDolStudioForms.php 2.3 KB

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