Source for file WLogicButton.class.php

Documentation is available at WLogicButton.class.php

  1. <?php
  2. /**
  3. * @since 5/31/06
  4. * @package polyphony.wizard
  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: WLogicButton.class.php,v 1.8 2007/09/19 14:04:51 adamfranco Exp $
  10. */
  11.  
  12. require_once(POLYPHONY."/main/library/Wizard/Components/WLogicRule.class.php");
  13. /**
  14. * Buttons of this class tree are used in logic wizards to control wizard flow.
  15. *
  16. * @since 5/31/06
  17. * @package polyphony.wizard
  18. *
  19. * @copyright Copyright &copy; 2005, Middlebury College
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  21. *
  22. * @version $Id: WLogicButton.class.php,v 1.8 2007/09/19 14:04:51 adamfranco Exp $
  23. */
  24. class WLogicButton extends WEventButton {
  25. var $_logic = null;
  26. var $_label = "NO LABEL";
  27. var $_pressed = false;
  28. var $_onclick = null;
  29. /**
  30. * virtual constructor
  31. *
  32. * @param ref object WLogicController $controller
  33. * @param string $label
  34. * @return ref object
  35. * @access public
  36. * @since 5/31/06
  37. */
  38. function withLogicAndLabel ($controller, $label) {
  39. $button = new WLogicButton();
  40. $button->setLogicAndLabel($controller, $label);
  41. return $button;
  42. }
  43.  
  44. /**
  45. * virtual constructor
  46. *
  47. * @param string $label
  48. * @return ref object
  49. * @access public
  50. * @since 5/31/06
  51. */
  52. function withLabel ($label) {
  53. $button = new WLogicButton();
  54. $button->setLabel($label);
  55. return $button;
  56. }
  57. /**
  58. * Sets the logic controller and label for the button
  59. *
  60. * @param ref object WLogicController $controller
  61. * @param string $label
  62. * @return void
  63. * @access public
  64. * @since 5/31/06
  65. */
  66. function setLogicAndLabel ($controller, $label) {
  67. $this->_logic =$controller;
  68. $this->_label = $label;
  69. }
  70. /**
  71. * Sets the logic controller for the button
  72. *
  73. * @param ref object WLogicController $controller
  74. * @return void
  75. * @access public
  76. * @since 7/31/06
  77. */
  78. function setLogic ($controller) {
  79. $this->_logic =$controller;
  80. }
  81.  
  82. /**
  83. * Sets the label for the button.
  84. * @param string $label
  85. * @param optional string $textDomain the gettext() text domain to use for the label.
  86. * @access public
  87. * @return void
  88. */
  89. function setLabel ($label) {
  90. $this->_label = $label;
  91. }
  92. /**
  93. * Sets the on-click javascript to be called.
  94. * @param string $javascript
  95. * @access public
  96. * @return void
  97. */
  98. function addOnClick ($javascript) {
  99. $this->_onclick .= " ".$javascript;
  100. }
  101. /**
  102. * Tells the wizard component to update itself - this may include getting
  103. * form post data or validation - whatever this particular component wants to
  104. * do every pageload.
  105. * @param string $fieldName The field name to use when outputting form data or
  106. * similar parameters/information.
  107. * @access public
  108. * @return boolean - TRUE if everything is OK
  109. */
  110. function update ($fieldName) {
  111. $val = RequestContext::value($fieldName);
  112. if ($val) {
  113. $wizard =$this->getWizard();
  114. $stepContaner =$wizard->_stepContainer;
  115. $stepContaner->nextStep($this);
  116. $this->_pressed = true;
  117. }
  118. }
  119. /**
  120. * Gets the logic controller for the button
  121. *
  122. * @return ref object WLogicController the controller
  123. * @access public
  124. * @since 7/31/06
  125. */
  126. function getLogicRule () {
  127. return $this->_logic;
  128. }
  129. /**
  130. * Returns the values of wizard-components. Should return an array if children are involved,
  131. * otherwise a whatever type of object is expected.
  132. * @access public
  133. * @return mixed
  134. */
  135. function getAllValues () {
  136. $val = $this->_pressed;
  137. $this->_pressed = false;
  138. return $val;
  139. }
  140. /**
  141. * Returns a block of XHTML-valid code that contains markup for this specific
  142. * component.
  143. * @param string $fieldName The field name to use when outputting form data or
  144. * similar parameters/information.
  145. * @access public
  146. * @return string
  147. */
  148. function getMarkup ($fieldName) {
  149. $name = RequestContext::name($fieldName);
  150. $label = htmlspecialchars($this->_label, ENT_QUOTES);
  151. $onclick = '';
  152. if ($this->_onclick) $onclick = addslashes($this->_onclick) . ";";
  153. $m = "<input type='hidden' name='$name' id='$name' value='0' />\n";
  154. $m .= "<input type='button' value='$label' onclick='$onclick if (validateWizard(this.form)) { getWizardElement(\"$name\").value=\"1\"; this.form.submit(); }'".($this->isEnabled()?"":" disabled='disabled'")." />";
  155. return $m;
  156. }
  157.  
  158. }
  159.  
  160. ?>

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