Source for file WStyleProperty.class.php

Documentation is available at WStyleProperty.class.php

  1. <?php
  2. /**
  3. * @since 8/09/2006
  4. * @package polyphony.guiwizardcomponents
  5. *
  6. * @copyright Copyright &copy; 2006, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: WStyleProperty.class.php,v 1.3 2007/09/19 14:04:46 adamfranco Exp $
  10. */
  11.  
  12. require_once(POLYPHONY.'/main/library/Wizard/WizardComponentWithChildren.abstract.php');
  13.  
  14. /**
  15. * This class allows for the creation of a StyleProperty GUI Wizard Component.
  16. *
  17. * @since 8/09/2006
  18. * @package polyphony.guiwizardcomponents
  19. *
  20. * @copyright Copyright &copy; 2006, Middlebury College
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  22. *
  23. * @version $Id: WStyleProperty.class.php,v 1.3 2007/09/19 14:04:46 adamfranco Exp $
  24. */
  25. class WStyleProperty
  26. extends WizardComponentWithChildren
  27. {
  28.  
  29. var $_wizardComponent;
  30. var $_getThemeCallBack;
  31. var $_collection;
  32. var $_property;
  33. function WStyleProperty ($callBack, $property, $collection) {
  34. $this->_getThemeCallBack = $callBack;
  35. $this->_collection = $collection;
  36. $this->_property = $property;
  37. $styleProperty =$this->getStyleProperty();
  38. // the list of existing SCs
  39. $scs =$styleProperty->getSCs();
  40. $i =0;
  41. foreach (array_keys($scs) as $key) {
  42. $class = get_class($scs[$key]);
  43. $scComp = new WStyleComponent($this->_getThemeCallBack, $class ,$styleProperty->getName(),$collection,true);
  44. $this->addComponent("comp".$i, $scComp);
  45. $i++;
  46. }
  47. /*
  48. $empties = array_diff($scList, array_keys($scs));
  49. // for each SC not populated create their options too
  50. foreach ($empties as $empty) {
  51. $emptySC = new $empty();
  52. $emptyComp = new WStyleComponent($emptySC,true);
  53. $wizSP->addComponent("comp".$i, $emptyComp);
  54. // table row [displayName][input][description]
  55. $s.= "<tr><td>".$emptySC->getDisplayName().":</td>";
  56. $s.= "<td>[["."comp".$i."]]</td>";
  57. $s.= "<td>".$emptySC->getDescription()."</td></tr>";
  58. $i++;
  59. }
  60. */
  61. }
  62. function getStyleProperty(){
  63.  
  64. eval('$theme = '.$this->_getThemeCallBack."();");
  65. $collection =$theme->getStyleCollection($this->_collection);
  66. return $collection->getStyleProperty($this->_property);
  67.  
  68. }
  69. /*
  70. $wizSP = new WizardStep();
  71. // the list of existing SCs
  72. $scs =$this->getSCs();
  73. // the list of SC types for this SP
  74. $scList = $this->getSCList();
  75. ob_start();
  76. print "<table border=1>";
  77. // for each existing SC built request an input for it
  78. $i = 0;
  79.  
  80. foreach (array_keys($scs) as $key) {
  81. $class = get_class($scs[$key]);
  82. //printpre($scs);
  83. //print " $key>-->'".$class."' ";
  84. $scComp = new WStyleComponent($callBack, $class ,$this->getName(),$collection,true);
  85. $wizSP->addComponent("comp".$i, $scComp);
  86. // table row [displayName][input][description]
  87. print "<tr><td>".$scs[$key]->getDisplayName().":</td>";
  88. print "<td>[["."comp".$i."]]</td>";
  89. print "<td>".$scs[$key]->getDescription()."</td></tr>";
  90. $i++;
  91. }
  92. $empties = array_diff($scList, array_keys($scs));
  93. // for each SC not populated create their options too
  94. foreach ($empties as $empty) {
  95. $emptySC = new $empty();
  96. $emptyComp = new WStyleComponent($emptySC,true);
  97. $wizSP->addComponent("comp".$i, $emptyComp);
  98. // table row [displayName][input][description]
  99. print "<tr><td>".$emptySC->getDisplayName().":</td>";
  100. print "<td>[["."comp".$i."]]</td>";
  101. print "<td>".$emptySC->getDescription()."</td></tr>";
  102. $i++;
  103. }
  104. print "</table>";
  105. $wizSP->setContent(ob_get_clean());
  106. return $wizSP;
  107. */
  108.  
  109.  
  110. /**
  111. * Tells the wizard component to update itself - this may include getting
  112. * form post data or validation - whatever this particular component wants to
  113. * do every pageload.
  114. * @param string $fieldName The field name to use when outputting form data or
  115. * similar parameters/information.
  116. * @access public
  117. * @return boolean - TRUE if everything is OK
  118. */
  119. function update ($fieldName) {
  120. $children =$this->getChildren();
  121. $ok = true;
  122. foreach (array_keys($children) as $key) {
  123. if(is_null($children[$key])){
  124. printpre(array_keys($children));
  125. print $key;
  126. throwError(new Error("prob",""));
  127. }
  128. if (!$children[$key]->update($fieldName."_".$key)) {
  129. $ok = false;
  130. }
  131. }
  132. return $ok;
  133. }
  134. /**
  135. * Returns true if this component (and all child components if applicable) have valid values.
  136. * By default, this will just return TRUE.
  137. *
  138. * @access public
  139. * @return boolean
  140. */
  141. function validate () {
  142. $children =$this->getChildren();
  143. foreach (array_keys($children) as $step) {
  144. if (!$children[$step]->validate()) {
  145. return false;
  146. }
  147. }
  148. return true;
  149. }
  150. /**
  151. * Returns a block of XHTML-valid code that contains markup for this specific
  152. * component.
  153. * @param string $fieldName The field name to use when outputting form data or
  154. * similar parameters/information.
  155. * @access public
  156. * @return string
  157. */
  158. function getMarkup ($fieldName) {
  159. $styleProperty =$this->getStyleProperty();
  160. // the list of existing SCs
  161. $scs =$styleProperty->getSCs();
  162. // the list of SC types for this SP
  163. $scList = $styleProperty->getSCList();
  164.  
  165. $s = "";
  166. $s.= "<table border=1>";
  167. // for each existing SC built request an input for it
  168. $i = 0;
  169. $children =$this->getChildren();
  170. foreach ($children as $key=>$child) {
  171. $sc =$child->getStyleComponent();
  172. // table row [displayName][input][description]
  173. $s.= "<tr><td>".$sc->getDisplayName().":</td>";
  174. $s.= "<td>".$child->getMarkup($fieldName."_".$key)."</td>";
  175. $s.= "<td>".$sc->getDescription()."</td></tr>";
  176. }
  177. /*
  178. $empties = array_diff($scList, array_keys($scs));
  179. // for each SC not populated create their options too
  180. foreach ($empties as $empty) {
  181. $emptySC = new $empty();
  182. $emptyComp = new WStyleComponent($emptySC,true);
  183. $wizSP->addComponent("comp".$i, $emptyComp);
  184. // table row [displayName][input][description]
  185. $s.= "<tr><td>".$emptySC->getDisplayName().":</td>";
  186. $s.= "<td>[["."comp".$i."]]</td>";
  187. $s.= "<td>".$emptySC->getDescription()."</td></tr>";
  188. $i++;
  189. }*/
  190. $s.= "</table>";
  191. return $s;
  192. }
  193. }
  194.  
  195. ?>

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