Source for file PrimitiveIO_numeric.classes.php

Documentation is available at PrimitiveIO_numeric.classes.php

  1. <?php
  2. /**
  3. * @package polyphony.datamanager_gui
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: PrimitiveIO_numeric.classes.php,v 1.10 2007/09/19 14:04:44 adamfranco Exp $
  9. */
  10.  
  11. /**
  12. * Require all of our necessary files
  13. *
  14. */
  15. require_once(POLYPHONY."/main/library/DataManagerGUI/PrimitiveIO/IOClasses/PrimitiveIO_strings.classes.php");
  16.  
  17. /**
  18. *
  19. * @package polyphony.datamanager_gui
  20. */
  21. class PrimitiveIO_integer extends PrimitiveIO_shortstring {
  22.  
  23. function PrimitiveIO_integer() {
  24. $this->setErrorText(dgettext("polyphony", "Enter a valid integer (no commas)."));
  25. $this->setErrorRule(new WECRegex("^[0-9]+\$"));
  26. }
  27.  
  28. /**
  29. * Sets the value of this Component to the {@link SObject} passed.
  30. * @param ref object $value The {@link SObject} value to use.
  31. *
  32. * @return void
  33. ***/
  34. function setValue($value)
  35. {
  36. parent::setValue($value);
  37. }
  38.  
  39. /**
  40. * Sets the value of this Component to the {@link SObject} passed.
  41. * @param ref object $value The {@link SObject} value to use.
  42. *
  43. * @return void
  44. ***/
  45. function setValueFromSObject($value)
  46. {
  47. $this->setValue($value);
  48. }
  49.  
  50. /**
  51. * Returns the values of wizard-components. Should return an array if children are involved,
  52. * otherwise a whatever type of object is expected.
  53. * @access public
  54. * @return mixed
  55. */
  56. function getAllValues () {
  57. $obj = Integer::withValue($this->_value?intval($this->_value):0);
  58. return $obj;
  59. }
  60. /**
  61. * Returns true if this component (and all child components if applicable) have valid values.
  62. * By default, this will just return TRUE. Validate should be called usually before a save event
  63. * is handled, to make sure everything went smoothly.
  64. * @access public
  65. * @return boolean
  66. */
  67. function validate () {
  68. $val = ereg("^[0-9]+\$", $this->_value);
  69. if (!$val) $this->_showError = true;
  70. return $val;
  71. }
  72. }
  73.  
  74. /**
  75. *
  76. * @package polyphony.datamanager_gui
  77. */
  78. class PrimitiveIO_float extends PrimitiveIO_integer {
  79.  
  80. function PrimitiveIO_float() {
  81. $this->setErrorText(dgettext("polyphony", "Enter a valid integer (no commas)."));
  82. $this->setErrorRule(new WECRegex("^[0-9\\.]+\$"));
  83. }
  84.  
  85. /**
  86. * Sets the value of this Component to the {@link SObject} passed.
  87. * @param ref object $value The {@link SObject} value to use.
  88. *
  89. * @return void
  90. ***/
  91. function setValue($value)
  92. {
  93. parent::setValue($value->asString());
  94. }
  95.  
  96. /**
  97. * Sets the value of this Component to the {@link SObject} passed.
  98. * @param ref object $value The {@link SObject} value to use.
  99. *
  100. * @return void
  101. ***/
  102. function setValueFromSObject($value)
  103. {
  104. $this->setValue($value);
  105. }
  106.  
  107. /**
  108. * Returns the values of wizard-components. Should return an array if children are involved,
  109. * otherwise a whatever type of object is expected.
  110. * @access public
  111. * @return mixed
  112. */
  113. function getAllValues () {
  114. $obj = Float::withValue($this->_value?floatval($this->_value):0);
  115. return $obj;
  116. }
  117. /**
  118. * Returns true if this component (and all child components if applicable) have valid values.
  119. * By default, this will just return TRUE. Validate should be called usually before a save event
  120. * is handled, to make sure everything went smoothly.
  121. * @access public
  122. * @return boolean
  123. */
  124. function validate () {
  125. $val = ereg("^[0-9\\.]+\$", $this->_value);
  126. if (!$val) $this->_showError = true;
  127. return $val;
  128. }
  129. }

Documentation generated on Wed, 19 Sep 2007 10:25:40 -0400 by phpDocumentor 1.3.0RC3