Source for file WStepDisplayBar.class.php

Documentation is available at WStepDisplayBar.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: WStepDisplayBar.class.php,v 1.5 2007/09/19 14:04:51 adamfranco Exp $
  10. */
  11. require_once(POLYPHONY."/main/library/Wizard/WizardComponent.abstract.php");
  12.  
  13. /**
  14. * This adds a "Next" button to the wizard and throws the appropriate event.
  15. *
  16. * @since Jul 20, 2005
  17. * @package polyphony.wizard.components
  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: WStepDisplayBar.class.php,v 1.5 2007/09/19 14:04:51 adamfranco Exp $
  23. */
  24. class WStepDisplayBar
  25. extends WizardComponent
  26. {
  27. var $_stepContainer;
  28. // var $_event = "'edu.middlebury.polyphony.wizard.step_changed";
  29. /**
  30. * Constructor
  31. * @param ref object $stepContainer A {@link WizardStepContainer} object.
  32. * @param optional string $event
  33. * @access public
  34. * @return void
  35. */
  36. function WStepDisplayBar ($stepContainer) {
  37. $this->_stepContainer =$stepContainer;
  38. }
  39. /**
  40. * Tells the wizard component to update itself - this may include getting
  41. * form post data or validation - whatever this particular component wants to
  42. * do every pageload.
  43. * @param string $fieldName The field name to use when outputting form data or
  44. * similar parameters/information.
  45. * @access public
  46. * @return boolean - TRUE if everything is OK
  47. */
  48. function update ($fieldName) {
  49. $val = RequestContext::value($fieldName);
  50. if ($val !== '' && $val !== null) {
  51. // advance the step!
  52. $this->_stepContainer->setStepByKey($val);
  53. }
  54. }
  55. /**
  56. * Returns the values of wizard-components. Should return an array if children are involved,
  57. * otherwise a whatever type of object is expected.
  58. * @access public
  59. * @return mixed
  60. */
  61. function getAllValues () {
  62. return null;
  63. }
  64. /**
  65. * Returns a block of XHTML-valid code that contains markup for this specific
  66. * component.
  67. * @param string $fieldName The field name to use when outputting form data or
  68. * similar parameters/information.
  69. * @access public
  70. * @return string
  71. */
  72. function getMarkup ($fieldName) {
  73. ob_start();
  74. print "<div>";
  75. print "<input type='hidden' name='".$fieldName."' value=''/>";
  76. $steps = $this->_stepContainer->getSteps();
  77. $currStep = $this->_stepContainer->getCurrentStep();
  78. $a = array();
  79. foreach (array_keys($steps) as $stepKey) {
  80. ob_start();
  81. if ($stepKey == $currStep)
  82. print "<b>";
  83. else {
  84. print "<a href='#' onclick=\"";
  85. print "var input = this.parentNode.firstChild; ";
  86. print "input.value = '".$stepKey."'; ";
  87. print "input.form.submit(); ";
  88. print "return false; \">";
  89. }
  90. print ($stepKey+1).". ".$steps[$stepKey]->getDisplayName();
  91. if ($stepKey == $currStep)
  92. print "</b>";
  93. else
  94. print "</a>";
  95. $a[] = ob_get_clean();
  96. }
  97. print implode("\n&raquo;\n", $a);
  98. print "</div>";
  99. return ob_get_clean();
  100. }
  101. }
  102.  
  103. ?>

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