Source for file WSaveCancelListener.class.php

Documentation is available at WSaveCancelListener.class.php

  1. <?php
  2.  
  3. /**
  4. * @since Jul 22, 2005
  5. * @package polyphony.wizard.components
  6. *
  7. * @copyright Copyright &copy; 2005, Middlebury College
  8. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  9. *
  10. * @version $Id: WSaveCancelListener.class.php,v 1.6 2007/09/19 14:04:51 adamfranco Exp $
  11. */
  12.  
  13. /**
  14. * Supplies an event listener to a {@link Wizard} and keeps track of if a Save or Cancel event
  15. * was posted. This is useful for when saving Wizards in session to handle events.
  16. *
  17. * @since Jul 22, 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: WSaveCancelListener.class.php,v 1.6 2007/09/19 14:04:51 adamfranco Exp $
  24. */
  25. class WSaveCancelListener
  26. extends WizardEventListener
  27. {
  28. var $_save = false;
  29. var $_cancel = false;
  30. var $_added = false;
  31. /**
  32. * Sets this component's parent (some kind of {@link WizardComponentWithChildren} so that it can
  33. * have access to its information, if needed.
  34. * @param ref object $parent
  35. * @access public
  36. * @return void
  37. */
  38. function setParent ($parent) {
  39. $this->_parent =$parent;
  40. $this->_attemptAdding();
  41. }
  42. /**
  43. * Attempts to add ourselves to the parent {@link Wizard} as an {@link EventListener}.
  44. * @access public
  45. * @return void
  46. */
  47. function _attemptAdding () {
  48. if ($this->_added) return;
  49. $wz =$this->getWizard();
  50. if ($wz) {
  51. $wz->addEventListener($this);
  52. $this->_added = true;
  53. }
  54. }
  55. /**
  56. * Tells the wizard component to update itself - this may include getting
  57. * form post data or validation - whatever this particular component wants to
  58. * do every pageload.
  59. * @param string $fieldName The field name to use when outputting form data or
  60. * similar parameters/information.
  61. * @access public
  62. * @return boolean - TRUE if everything is OK
  63. */
  64. function update ($fieldName) {
  65. $this->_attemptAdding();
  66. $this->_save = $this->_cancel = false;
  67. }
  68. /**
  69. * Returns TRUE if a save event was triggered this pageload.
  70. * @access public
  71. * @return boolean
  72. */
  73. function isSaveRequested () {
  74. return $this->_save;
  75. }
  76. /**
  77. * Returns TRUE if a cancel event was triggered this pageload.
  78. * @access public
  79. * @return boolean
  80. */
  81. function isCancelRequested () {
  82. return $this->_cancel;
  83. }
  84. /**
  85. * Returns the values of wizard-components. Should return an array if children are involved,
  86. * otherwise a whatever type of object is expected.
  87. * @access public
  88. * @return mixed
  89. */
  90. function getAllValues () {
  91. return null;
  92. }
  93. /**
  94. * Returns a block of XHTML-valid code that contains markup for this specific
  95. * component.
  96. * @param string $fieldName The field name to use when outputting form data or
  97. * similar parameters/information.
  98. * @access public
  99. * @return string
  100. */
  101. function getMarkup ($fieldName) {
  102. return '';
  103. }
  104. /**
  105. * Handles an event triggered by an {@link EventTrigger}. The event type is passed in case this
  106. * particular EventListener is handling more than one type of event.
  107. * @param string $eventType
  108. * @param ref object $source The source object of the event.
  109. * @param array $context An array of contextual parameters - the content will be dependent on the thrown event.
  110. * @access public
  111. * @return void
  112. */
  113. function handleEvent ($eventType, $source, $context) {
  114. switch ($eventType) {
  115. case 'edu.middlebury.polyphony.wizard.save':
  116. $this->_save = true;
  117. $this->_cancel = false;
  118. break;
  119. case 'edu.middlebury.polyphony.wizard.cancel':
  120. $this->_save = false;
  121. $this->_cancel = true;
  122. break;
  123. }
  124. }
  125. }
  126. ?>

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