1
0

BxDevFunctions.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <? 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 Developer Developer
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolStudioUtils');
  12. class BxDevFunctions {
  13. function __construct() {}
  14. /*
  15. * Is needed to change fields in "Form's Field" creation form.
  16. *
  17. * @see BxDevFormsField
  18. */
  19. public static function changeFormField($aParams, &$aInputs, &$oDb) {
  20. $aInputs['module']['type'] = 'select';
  21. $aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_frm_txt_select_module')), BxDolStudioUtils::getModules());
  22. $aInputs['module']['value'] = $aParams['module'];
  23. $aForms = array();
  24. $oDb->getForms(array('type' => 'by_module', 'value' => $aParams['module']), $aForms, false);
  25. foreach($aForms as $aForm)
  26. $aInputs['object']['values'][$aForm['object']] = _t($aForm['title']);
  27. asort($aInputs['object']['values']);
  28. $aInputs['object']['type'] = 'select';
  29. $aInputs['object']['values'] = array_merge(array('' => _t('_bx_dev_frm_txt_select_object')), $aInputs['object']['values']);
  30. $aInputs['object']['value'] = $aParams['object'];
  31. $sTrlTypePostfix = '_translatable';
  32. $sTrlCheckFuncPostfix = 'Translatable';
  33. foreach($aInputs as $sName => $aInput)
  34. if(isset($aInput['type']) && stripos($aInput['type'], $sTrlTypePostfix) !== false) {
  35. $aInputs[$sName]['type'] = str_ireplace($sTrlTypePostfix, '', $aInput['type']);
  36. if(isset($aInput['checker']['func']) && stripos($aInput['checker']['func'], $sTrlCheckFuncPostfix) !== false)
  37. $aInputs[$sName]['checker']['func'] = str_ireplace($sTrlCheckFuncPostfix, '', $aInput['checker']['func']);
  38. }
  39. }
  40. public static function serializeString($sValue) {
  41. if(empty($sValue))
  42. return '';
  43. $aValue = array();
  44. @eval("\$aValue = " . $sValue . ";");
  45. if(empty($aValue) || !is_array($aValue))
  46. return '';
  47. return serialize($aValue);
  48. }
  49. public static function unserializeString($sValue) {
  50. if(empty($sValue))
  51. return '';
  52. $aValue = @unserialize($sValue);
  53. if(empty($aValue) || !is_array($aValue))
  54. return '';
  55. return var_export($aValue, true);
  56. }
  57. }
  58. /** @} */