Source for file WText.class.php

Documentation is available at WText.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: WText.class.php,v 1.5 2007/09/19 14:04:51 adamfranco Exp $
  10. */
  11.  
  12. require_once(POLYPHONY.'/main/library/Wizard/WizardComponent.abstract.php');
  13.  
  14. /**
  15. * This class allows for the creation of simple block of text.
  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: WText.class.php,v 1.5 2007/09/19 14:04:51 adamfranco Exp $
  24. */
  25. class WText
  26. extends WizardComponent
  27. {
  28.  
  29. var $_value;
  30. var $_style = '';
  31. /**
  32. * Virtual Constructor
  33. * @param string $value
  34. * @access public
  35. * @return ref object
  36. * @static
  37. */
  38. function withValue ($value) {
  39. $obj = new WText();
  40. $obj->_value = $value;
  41. return $obj;
  42. }
  43. /**
  44. * Virtual Constructor with fromString naming convention
  45. * @param string $aString
  46. * @access public
  47. * @return ref object
  48. * @static
  49. */
  50. function fromString ($aString) {
  51. $obj = new WText();
  52. $obj->_value = $aString;
  53. return $obj;
  54. }
  55. /**
  56. * Sets the value of this text.
  57. * @param string $value
  58. * @access public
  59. * @return void
  60. */
  61. function setValue ($value) {
  62. $this->_value = $value;
  63. }
  64. /**
  65. * Tells the wizard component to update itself - this may include getting
  66. * form post data or validation - whatever this particular component wants to
  67. * do every pageload.
  68. * @param string $fieldName The field name to use when outputting form data or
  69. * similar parameters/information.
  70. * @access public
  71. * @return boolean - TRUE if everything is OK
  72. */
  73. function update ($fieldName) {
  74. return true;
  75. }
  76. /**
  77. * Returns the values of wizard-components. Should return an array if children are involved,
  78. * otherwise a whatever type of object is expected.
  79. *
  80. * In this case, a "1" or a "0" is returned, depending on the checked state of the checkbox.
  81. * @access public
  82. * @return mixed
  83. */
  84. function getAllValues () {
  85. return $this->_value;
  86. }
  87. /**
  88. * Sets the CSS style for this span of text.
  89. * @param string $style
  90. * @return void
  91. ***/
  92. function setStyle($style)
  93. {
  94. $this->_style = $style;
  95. }
  96. /**
  97. * Returns a block of XHTML-valid code that contains markup for this specific
  98. * component.
  99. * @param string $fieldName The field name to use when outputting form data or
  100. * similar parameters/information.
  101. * @access public
  102. * @return string
  103. */
  104. function getMarkup ($fieldName) {
  105. $val = htmlspecialchars($this->_value, ENT_QUOTES);
  106. $style = str_replace('"', '\\"', $this->_style);
  107. $m = "<span style=\"$style\">$val</span>";
  108. return $m;
  109. }
  110. }
  111.  
  112. ?>

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