helpers
1 week ago
tables
1 week ago
aIProviderInterface.php
1 week ago
assets.php
1 week ago
baseObject.php
1 week ago
builderBlock.php
1 week ago
controller.php
1 week ago
date.php
1 week ago
db.php
1 week ago
dispatcher.php
1 week ago
errors.php
1 week ago
field.php
1 week ago
fieldAdapter.php
1 week ago
frame.php
1 week ago
helper.php
1 week ago
html.php
1 week ago
installer.php
1 week ago
installerDbUpdater.php
1 week ago
integration.php
1 week ago
modInstaller.php
1 week ago
model.php
1 week ago
module.php
1 week ago
req.php
1 week ago
response.php
1 week ago
table.php
1 week ago
uri.php
1 week ago
user.php
1 week ago
utils.php
1 week ago
validator.php
1 week ago
view.php
1 week ago
fieldAdapter.php
52 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | /** |
| 6 | * Class to adapt field before display and save/get DB |
| 7 | * return ONLY htmlParams property |
| 8 | * |
| 9 | * @see field |
| 10 | */ |
| 11 | class WaicFieldAdapter { |
| 12 | const DB = 'WaicDb'; |
| 13 | const HTML = 'WaicHtml'; |
| 14 | const STR = 'str'; |
| 15 | public static $userfieldDest = array('registration', 'shipping', 'billing'); |
| 16 | public static $countries = array(); |
| 17 | public static $states = array(); |
| 18 | /** |
| 19 | * Executes field Adaption process |
| 20 | * |
| 21 | * @param object type field or value $fieldOrValue if DB adaption - this must be a value of field, elase if html - field object |
| 22 | */ |
| 23 | public static function _( $fieldOrValue, $method, $type ) { |
| 24 | if (method_exists('WaicFieldAdapter', $method)) { |
| 25 | switch ($type) { |
| 26 | case self::DB: |
| 27 | return self::$method($fieldOrValue); |
| 28 | break; |
| 29 | case self::HTML: |
| 30 | self::$method($fieldOrValue); |
| 31 | break; |
| 32 | case self::STR: |
| 33 | return self::$method($fieldOrValue); |
| 34 | break; |
| 35 | } |
| 36 | } |
| 37 | return $fieldOrValue; |
| 38 | } |
| 39 | public static function intToDB( $val ) { |
| 40 | return intval($val); |
| 41 | } |
| 42 | public static function floatToDB( $val ) { |
| 43 | return floatval($val); |
| 44 | } |
| 45 | public static function userFieldDestToDB( $value ) { |
| 46 | return WaicUtils::jsonEncode($value); |
| 47 | } |
| 48 | public static function userFieldDestFromDB( $value ) { |
| 49 | return WaicUtils::jsonDecode($value); |
| 50 | } |
| 51 | } |
| 52 |