Source for file WTextField.class.php

Documentation is available at WTextField.class.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: WTextField.class.php,v 1.15 2007/09/19 14:04:51 adamfranco Exp $
  10. */
  11.  
  12. require_once(dirname(__FILE__).'/WTextInput.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: WTextField.class.php,v 1.15 2007/09/19 14:04:51 adamfranco Exp $
  24. */
  25. class WTextField
  26. extends WTextInput
  27. {
  28.  
  29. var $_size = 30;
  30. var $_maxlength = 255;
  31. /**
  32. * Sets the size of this text field.
  33. * @param int $size
  34. * @access public
  35. * @return void
  36. */
  37. function setSize ($size) {
  38. $this->_size = $size;
  39. }
  40. /**
  41. * Sets the maxlength of the value of this field.
  42. * @param integer $maxlength
  43. * @access public
  44. * @return void
  45. */
  46. function setMaxLength ($maxlength) {
  47. $this->_maxlength = $maxlength;
  48. }
  49. /**
  50. * Returns a block of XHTML-valid code that contains markup for this specific
  51. * component.
  52. * @param string $fieldName The field name to use when outputting form data or
  53. * similar parameters/information.
  54. * @access public
  55. * @return string
  56. */
  57. function getMarkup ($fieldName) {
  58. $name = RequestContext::name($fieldName);
  59. $m = "<input type='text' \n\t\t\t\tname='$name' \n\t\t\t\tid='$fieldName' \n\t\t\t\tsize='".$this->_size."' maxlength='".$this->_maxlength."'".(!$this->isEnabled()?" readonly='readonly'":"");
  60. if ($this->_value != null && $this->_value != $this->_startingDisplay) {
  61. $m .= " value='".htmlspecialchars($this->_value, ENT_QUOTES)."'";
  62. } else if ($this->_startingDisplay) {
  63. $v = htmlspecialchars($this->_startingDisplay, ENT_QUOTES);
  64. $m .= "\n\t\t\t\tvalue='$v' style='color: #888' ";
  65. $m .= "\n\t\t\t\tonfocus='if (this.value == \"$v\") { this.value=\"\"; this.style.color=\"#000\";}'";
  66. $m .= "\n\t\t\t\tonblur='if (this.value == \"\") { this.value=\"$v\"; this.style.color=\"#888\";}'";
  67. }
  68. if ($this->_style) {
  69. $m .= "\n\t\t\t\tstyle=\"".str_replace("\"", "\\\"", $this->_style)."\"";
  70. }
  71. if ($this->_onchange) {
  72. $m .= "\n\t\t\t\tonchange=\"".str_replace("\"", "\\\"", $this->_onchange)."\"";
  73. }
  74. $m .= " />";
  75. $errText = $this->getErrorText();
  76. $errRule =$this->getErrorRule();
  77. $errStyle = $this->getErrorStyle();
  78. if ($errText && $errRule) {
  79. $m .= "\n\t\t<span id='".$fieldName."_error' style=\"padding-left: 10px; $errStyle\">&laquo; $errText</span>";
  80. $m .= Wizard::getValidationJavascript($fieldName, $errRule, $fieldName."_error", $this->_showError);
  81. $this->_showError = false;
  82. }
  83. return $m;
  84. }
  85. }
  86.  
  87. ?>

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