Source for file WChooseOptionButton.class.php

Documentation is available at WChooseOptionButton.class.php

  1. <?php
  2. /**
  3. * @since Jul 20, 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: WChooseOptionButton.class.php,v 1.4 2007/09/19 14:04:51 adamfranco Exp $
  10. */
  11.  
  12. require_once(dirname(__FILE__)."/WEventButton.class.php");
  13.  
  14. /**
  15. * This appears to be an implementation of EventButton that centers around a
  16. * dropdown menu.
  17. *
  18. * @since Jul 20, 2005
  19. * @package polyphony.wizard.components
  20. *
  21. * @copyright Copyright &copy; 2005, Middlebury College
  22. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  23. *
  24. * @version $Id: WChooseOptionButton.class.php,v 1.4 2007/09/19 14:04:51 adamfranco Exp $
  25. */
  26. class WChooseOptionButton
  27. extends WEventButton
  28. {
  29. var $_options = array();
  30. var $_option;
  31. /**
  32. * virtual constructor
  33. * @param string $event
  34. * @param string $label
  35. * @access public
  36. * @return ref object
  37. * @static
  38. */
  39. function withEventAndLabel ($event, $label) {
  40. $obj = new WChooseOptionButton();
  41. $obj->setEventAndLabel($event, $label);
  42. return $obj;
  43. }
  44. /**
  45. * virtual constructor - creates the button with a "nop" event
  46. * @param string $label
  47. * @access public
  48. * @return ref object
  49. */
  50. function withLabel ($label) {
  51. $obj = new WChooseOptionButton();
  52. $obj->_label = $label;
  53. return $obj;
  54. }
  55. /**
  56. * Add an array of value collections for use when adding
  57. *
  58. * @param string $name
  59. * @param mixed $value
  60. * @return void
  61. * @access public
  62. * @since 11/1/05
  63. */
  64. function addOptionValue ( $name, $value ) {
  65. $this->_options[$name] =$value;
  66. }
  67. /**
  68. * Tells the wizard component to update itself - this may include getting
  69. * form post data or validation - whatever this particular component wants to
  70. * do every pageload.
  71. * @param string $fieldName The field name to use when outputting form data or
  72. * similar parameters/information.
  73. * @access public
  74. * @return boolean - TRUE if everything is OK
  75. */
  76. function update ($fieldName) {
  77. $val = RequestContext::value($fieldName);
  78. $option = stripslashes(RequestContext::value($fieldName."_option"));
  79. if ($val) {
  80. // trigger the save event on the wizard
  81. $wizard =$this->getWizard();
  82. $wizard->triggerLater($this->_event, $wizard);
  83. $this->_pressed = true;
  84. $this->_option = $option;
  85. }
  86. }
  87. /**
  88. * Returns the values of wizard-components. Should return an array if children are involved,
  89. * otherwise a whatever type of object is expected.
  90. * @access public
  91. * @return mixed
  92. */
  93. function getAllValues () {
  94. $val = $this->_pressed;
  95. $option = $this->_option;
  96. $this->_pressed = false;
  97. $this->_option = null;
  98. $values = array();
  99. $values['pressed'] = $val;
  100. $values['option_name'] = $option;
  101. $values['option'] =$this->_options[$option];
  102. return $values;
  103. }
  104. /**
  105. * Returns a block of XHTML-valid code that contains markup for this specific
  106. * component.
  107. * @param string $fieldName The field name to use when outputting form data or
  108. * similar parameters/information.
  109. * @access public
  110. * @return string
  111. */
  112. function getMarkup ($fieldName) {
  113. $name = RequestContext::name($fieldName);
  114. $m = parent::getMarkup($fieldName);
  115. $m .= "\n<select name='".$name."_option'>";
  116. foreach (array_keys($this->_options) as $option)
  117. if ($option != '')
  118. $m .= "\n\t<option value='".addslashes($option)."'>".$option."</option>";
  119. $m .= "\n</select>";
  120. return $m;
  121. }
  122. }
  123.  
  124. ?>

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