Source for file WTextInput.abstract.php

Documentation is available at WTextInput.abstract.php

  1. <?php
  2. /**
  3. * @since Jul 21, 2005
  4. * @package polyphony.wizard.components
  5. *
  6. * @copyright Copyright &copy; 2005, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: WTextInput.abstract.php,v 1.11 2007/09/19 14:04:51 adamfranco Exp $
  10. */
  11.  
  12. require_once(POLYPHONY."/main/library/Wizard/ErrorCheckingWizardComponent.abstract.php");
  13.  
  14. /**
  15. * This adds an input type='text' field to a {@link Wizard}.
  16. *
  17. * @since Jul 21, 2005
  18. * @package polyphony.wizard.components
  19. *
  20. * @copyright Copyright &copy; 2005, Middlebury College
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  22. *
  23. * @version $Id: WTextInput.abstract.php,v 1.11 2007/09/19 14:04:51 adamfranco Exp $
  24. */
  25. abstract class WTextInput
  26. extends ErrorCheckingWizardComponent
  27. {
  28.  
  29. var $_style = null;
  30. var $_value = null;
  31. var $_startingDisplay = null;
  32. var $_onchange = null;
  33. var $_showError = false;
  34. /**
  35. * Sets the text of the field to display until the user enters the field.
  36. * @param string $text
  37. * @access public
  38. * @return void
  39. */
  40. function setStartingDisplayText ($text) {
  41. $this->_startingDisplay = $text;
  42. }
  43. /**
  44. * Sets the CSS style of this field.
  45. * @param string $style
  46. * @access public
  47. * @return void
  48. */
  49. function setStyle ($style) {
  50. $this->_style = $style;
  51. }
  52.  
  53. /**
  54. * Sets the value of this text field.
  55. * @param string $value
  56. * @access public
  57. * @return void
  58. */
  59. function setValue ($value) {
  60. ArgumentValidator::validate($value, OrValidatorRule::getRule(
  61. StringValidatorRule::getRule(),
  62. NumericValidatorRule::getRule()));
  63. $this->_value = $value;
  64. }
  65. /**
  66. * Tells the wizard component to update itself - this may include getting
  67. * form post data or validation - whatever this particular component wants to
  68. * do every pageload.
  69. * @param string $fieldName The field name to use when outputting form data or
  70. * similar parameters/information.
  71. * @access public
  72. * @return boolean - TRUE if everything is OK
  73. */
  74. function update ($fieldName) {
  75. $val = RequestContext::value($fieldName);
  76. if ($val !== null
  77. && (!$this->_startingDisplay || $val != $this->_startingDisplay))
  78. {
  79. $this->_value = $val;
  80. }
  81. }
  82. /**
  83. * Returns true if this component (and all child components if applicable) have valid values.
  84. * By default, this will just return TRUE.
  85. * @access public
  86. * @return boolean
  87. */
  88. function validate () {
  89. $rule =$this->getErrorRule();
  90. if (!$rule) return true;
  91. $err = $rule->checkValue($this);
  92. if (!$err){
  93. $this->_showError = true;
  94. print " fail:<br />";
  95. }
  96. return $err;
  97. }
  98. /**
  99. * Returns the values of wizard-components. Should return an array if children are involved,
  100. * otherwise a whatever type of object is expected.
  101. * @access public
  102. * @return mixed
  103. */
  104. function getAllValues () {
  105. return $this->_value;
  106. }
  107. /**
  108. * Add commands to the javascript onchange attribute.
  109. * @param string $commands
  110. * @access public
  111. * @return void
  112. */
  113. function addOnChange($commands) {
  114. $this->_onchange .= " ".$commands;
  115. }
  116. }
  117.  
  118. ?>

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