Source for file WStyleCollection.class.php

Documentation is available at WStyleCollection.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: WStyleCollection.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 Style Collection 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: WStyleCollection.class.php,v 1.3 2007/09/19 14:04:46 adamfranco Exp $
  24. */
  25. class WStyleCollection
  26. extends WizardComponentWithChildren
  27. {
  28.  
  29. var $_wizardComponent;
  30. var $_getThemeCallBack;
  31. var $_collection;
  32.  
  33. function WStyleCollection ($callBack, $collection) {
  34. $this->_getThemeCallBack = $callBack;
  35. $this->_collection = $collection;
  36. $styleCollection =$this->getStyleCollection();
  37. /*
  38. // the list of existing SCs
  39. $scs =$styleProperty->getSCs();
  40. foreach (array_keys($scs) as $key) {
  41. $class = get_class($scs[$key]);
  42. $scComp = new WStyleComponent($this->_callBack, $class ,$this->getName(),$collection,true);
  43. $wizSP->addComponent("comp".$i, $scComp);
  44. $i++;
  45. }
  46. */
  47.  
  48.  
  49.  
  50. // build individula SP markup chunks that can be unset
  51. $SPs =$styleCollection->getSPs();
  52. $i = 0;
  53. foreach (array_keys($SPs) as $key) {
  54. $styleProperty = new WStyleProperty($callBack, $key, $collection);
  55. $this->addComponent("property".$i, $styleProperty);
  56. $i++;
  57.  
  58. }
  59. }
  60. function getStyleCollection(){
  61. eval('$theme = '.$this->_getThemeCallBack."();");
  62. return $theme->getStyleCollection($this->_collection);
  63. }
  64. /*
  65. $wizStyle = new WizardStep();
  66. $guiManager = Services::getService('GUI');
  67. // table in buffer for WHOLE Style Collection
  68. ob_start();
  69. print "<table border=3 width='100%'>";
  70.  
  71. print "<td>".$this->getDisplayName()."</td>";
  72. print "<td><table border=2 width='100%'>";
  73.  
  74. // build individula SP markup chunks that can be unset
  75. $SPs =$this->getSPs();
  76. $i = 0;
  77. foreach (array_keys($SPs) as $key) {
  78. $spid =$SPs[$key]->getId();
  79. $wizStyle->addComponent("property_".$i,
  80. $SPs[$key]->getWizardRepresentation($callBack,$this->getSelector()));
  81. // buffer for SP markup
  82. ob_start();
  83. print "<tr><td>".$SPs[$key]->getDisplayName()."</td>";
  84. print "<td>[[property_".$i."]]</td>";
  85.  
  86. // create remove button for each SP
  87. if ($removable) {
  88. $wizStyle->addComponent('remove-'.$spid->getIdString(),
  89. WEventButton::withLabel('-'));
  90. print "<td>[[remove-property_".$i."]]</td>";
  91. }
  92. print "</tr>";
  93. $wizStyle->setContent(ob_get_clean(),
  94. $spid->getIdString());
  95. }
  96. print "</table></td>";
  97. // insert all the markup chunks that exist
  98. //foreach ($wizStyle->getMarkups() as $key => $markup) {
  99. // print $markup;
  100. //}
  101. print $wizStyle->getMarkup($this->getSelector());
  102. // create list and button for adding SPs
  103. if ($removable) {
  104. $SL =$wizStyle->addComponent('add-SP', new WSelectList());
  105. $wizStyle->addComponent('plus', WEventButton::withLabel('+'));
  106. $SupSPs = $guiManager->getSupportedSPs();
  107. $available = array_diff($SupSPs, array_keys($SPs));
  108. foreach ($available as $option) {
  109. $SL->addOption($option, $option);
  110. }
  111. ob_start();
  112. print "<tr><td>"._("Add another Property:")."</td>";
  113. print "<td>[[add-SP]]</td><td>[[plus]]</td></tr>";
  114. $wizStyle->setMarkupForComponent(ob_get_clean(), 'add-property');
  115. // why? i don't know!
  116. print $wizStyle->getMarkupForComponent('add-property');
  117. }
  118. print "</table>";
  119. $wizStyle->setContent(ob_get_clean());
  120. */
  121.  
  122.  
  123. /**
  124. * Tells the wizard component to update itself - this may include getting
  125. * form post data or validation - whatever this particular component wants to
  126. * do every pageload.
  127. * @param string $fieldName The field name to use when outputting form data or
  128. * similar parameters/information.
  129. * @access public
  130. * @return boolean - TRUE if everything is OK
  131. */
  132. function update ($fieldName) {
  133. $children =$this->getChildren();
  134. $ok = true;
  135. foreach (array_keys($children) as $key) {
  136. if(is_null($children[$key])){
  137. printpre(array_keys($children));
  138. print $key;
  139. throwError(new Error("prob",""));
  140. }
  141. if (!$children[$key]->update($fieldName."_".$key)) {
  142. $ok = false;
  143. }
  144. }
  145. return $ok;
  146. }
  147. /**
  148. * Returns true if this component (and all child components if applicable) have valid values.
  149. * By default, this will just return TRUE.
  150. *
  151. * @access public
  152. * @return boolean
  153. */
  154. function validate () {
  155. $children =$this->getChildren();
  156. foreach (array_keys($children) as $step) {
  157. if (!$children[$step]->validate()) {
  158. return false;
  159. }
  160. }
  161. return true;
  162. }
  163. /**
  164. * Returns a block of XHTML-valid code that contains markup for this specific
  165. * component.
  166. * @param string $fieldName The field name to use when outputting form data or
  167. * similar parameters/information.
  168. * @access public
  169. * @return string
  170. */
  171. function getMarkup ($fieldName) {
  172. $styleCollection =$this->getStyleCollection();
  173.  
  174.  
  175. $s = "";
  176. /*
  177. $s.= "<table border=1>";
  178. // for each existing SC built request an input for it
  179. $i = 0;
  180. $children =$this->getChildren();
  181. foreach ($children as $key=>$child) {
  182. $sc =$child->getStyleComponent();
  183. // table row [displayName][input][description]
  184. $s.= "<tr><td>".$sc->getDisplayName().":</td>";
  185. $s.= "<td>".$child->getMarkup($fieldName."_".$key)."</td>";
  186. $s.= "<td>".$sc->getDescription()."</td></tr>";
  187. }
  188. */
  189. $wizStyle = new WizardStep();
  190. $guiManager = Services::getService('GUI');
  191. // table in buffer for WHOLE Style Collection
  192. $s.= "<table border=3 width='100%'><tr>";
  193.  
  194. $s.= "<td>".$styleCollection->getDisplayName()."</td>";
  195. $s.= "<td><table border=2 width='100%'>";
  196.  
  197. // build individula SP markup chunks that can be unset
  198. $children =$this->getChildren();
  199. $i = 0;
  200. foreach ($children as $key=>$child) {
  201. $styleProperty =$child->getStyleProperty();
  202. $s.= "<tr><td>".$styleProperty->getDisplayName()."</td>";
  203. $s.= "<td>".$child->getMarkup($fieldName."_".$key)."</td>";
  204.  
  205.  
  206. $s.= "</tr>";
  207. }
  208. $s.= "</table></td>";
  209. // insert all the markup chunks that exist
  210. //foreach ($wizStyle->getMarkups() as $key => $markup) {
  211. // print $markup;
  212. //}
  213.  
  214. $s.= "</tr></table>";
  215. return $s;
  216. }
  217. }
  218.  
  219. ?>

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