extender.php 765 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Elgg Entity Extender.
  4. * This file contains ways of extending an Elgg entity in custom ways.
  5. *
  6. * @package Elgg.Core
  7. * @subpackage DataModel.Extender
  8. */
  9. /**
  10. * Detect the value_type for a given value.
  11. * Currently this is very crude.
  12. *
  13. * @todo Make better!
  14. *
  15. * @param mixed $value The value
  16. * @param string $value_type If specified, overrides the detection.
  17. *
  18. * @return string
  19. */
  20. function detect_extender_valuetype($value, $value_type = "") {
  21. if ($value_type != "" && ($value_type == 'integer' || $value_type == 'text')) {
  22. return $value_type;
  23. }
  24. // This is crude
  25. if (is_int($value)) {
  26. return 'integer';
  27. }
  28. // Catch floating point values which are not integer
  29. if (is_numeric($value)) {
  30. return 'text';
  31. }
  32. return 'text';
  33. }