Source for file WMoreOptions.abstract.php

Documentation is available at WMoreOptions.abstract.php

  1. <?php
  2. /**
  3. * @package polyphony.wizard
  4. *
  5. * @copyright Copyright &copy; 2006, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: WMoreOptions.abstract.php,v 1.4 2007/09/19 14:04:51 adamfranco Exp $
  9. */
  10.  
  11. require_once(POLYPHONY."/main/library/Wizard/WizardComponentWithChildren.abstract.php");
  12.  
  13. /**
  14. * The goal here is to provide a system for having a simple view that the
  15. * user can expand to get more options.
  16. *
  17. * @package polyphony.wizard
  18. *
  19. * @copyright Copyright &copy; 2006, Middlebury College
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  21. *
  22. * @version $Id: WMoreOptions.abstract.php,v 1.4 2007/09/19 14:04:51 adamfranco Exp $
  23. * @author Gabe Schine
  24. */
  25. class WMoreOptions extends WizardComponentWithChildren {
  26. var $_usingAdvanced;
  27. function init($set = false){
  28. $this->_usingAdvanced = $set;
  29. }
  30. /**
  31. * Tells the wizard component to update itself - this may include getting
  32. * form post data or validation - whatever this particular component wants to
  33. * do every pageload.
  34. * @param string $fieldName The field name to use when outputting form data or
  35. * similar parameters/information.
  36. * @access public
  37. * @return boolean - TRUE if everything is OK
  38. */
  39. function update ($fieldName) {
  40. $val = RequestContext::value($fieldName."_morecheckbox");
  41. if ($val != null)
  42. {
  43. $this->_usingAdvanced = true;
  44. }else{
  45. $this->_usingAdvanced = false;
  46. }
  47. $children =$this->getChildren();
  48. $ok = true;
  49. foreach (array_keys($children) as $key) {
  50. if (!$children[$key]->update($fieldName."_".$key)) {
  51. $ok = false;
  52. }
  53. }
  54. return $ok;
  55. }
  56. /**
  57. * Returns the values of wizard-components. Should return an array if children are involved,
  58. * otherwise a whatever type of object is expected.
  59. * @access public
  60. * @return mixed
  61. */
  62. function getAllValues () {
  63. $array = array();
  64. $children =$this->getChildren();
  65. foreach(array_keys($children) as $key) {
  66. $array[$key] = $children[$key]->getAllValues();
  67. }
  68. $array["_morecheckbox"] = $this->_usingAdvanced;
  69. return $array;
  70. }
  71. /**
  72. * Returns a block of XHTML-valid code that contains markup for this specific
  73. * component.
  74. * @param string $fieldName The field name to use when outputting form data or
  75. * similar parameters/information.
  76. * @access public
  77. * @return string
  78. */
  79. function getMarkup ($fieldName) {
  80. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  81. }
  82. /**
  83. * Return true if we should be using the new value rather than the select
  84. *
  85. * @return boolean
  86. * @access public
  87. * @since 6/2/06
  88. */
  89. function isUsingAdvanced () {
  90. return $this->_usingAdvanced;
  91. }
  92. /**
  93. * Returns a block of XHTML-valid code that contains markup for the "advanced"
  94. * options plus the block that hides them.
  95. * @param string $fieldName The field name to use when outputting form data or
  96. * similar parameters/information.
  97. * @access public
  98. */
  99. function getOptionalComponentsMarkup($fieldName) {
  100. $m = "";
  101. $advancedId = $fieldName."_advancedfield";
  102. if ($this->isUsingAdvanced())
  103. $display = " display: block;";
  104. else
  105. $display = " display: none;";
  106. $m .= "\n\t<div id='$advancedId' style='padding: 0px; margin: 0px; $display'>";
  107. $m .= "\n\t\t".$this->advancedMarkup($fieldName);
  108. $m .= "\n\t</div>";
  109. return $m;
  110. }
  111. /**
  112. * Returns a block of XHTML-valid code that contains markup for the "advanced"
  113. * options.
  114. * @param string $fieldName The field name to use when outputting form data or
  115. * similar parameters/information.
  116. * @access public
  117. * @return string
  118. */
  119. function advancedMarkup ($fieldName) {
  120. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  121. }
  122. /**
  123. * Returns a block of XHTML-valid code that contains markup for the checkbox
  124. *
  125. * @param string $fieldName The field name to use when outputting form data or
  126. * similar parameters/information.
  127. * @access public
  128. * @return string
  129. */
  130. function getCheckboxMarkup ($fieldName) {
  131. $m ="";
  132. $boxId = $fieldName . "_morecheckbox";
  133. $advancedId = $fieldName."_advancedfield";
  134. $checked = $this->isUsingAdvanced()?" checked='checked'":"";
  135. $style = " style='cursor: pointer;'";
  136. $m .= "\n\t\t\t<input type='checkbox' ";
  137. if (!$this->isEnabled())
  138. $m .= "\n\t\t\t\tdisabled=\"disabled\"";
  139. else {
  140. $m .= "\n\t\t\t\tonclick=\"";
  141. $m .="var advancedField = getElementFromDocument('$advancedId'); if (this.checked) { advancedField.style.display = 'block'; } else { advancedField.style.display = 'none'; }";
  142. $m .= " \"";
  143. }
  144. $m .= "\n\t\t\t\tid='$boxId' name='$boxId'$checked.$style />";
  145. return $m;
  146. }
  147. }
  148.  
  149. ?>

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