Source for file WBackgroundEditor.class.php

Documentation is available at WBackgroundEditor.class.php

  1. <?php
  2. /**
  3. * @since 8/15/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: WBackgroundEditor.class.php,v 1.4 2007/09/19 14:04:45 adamfranco Exp $
  10. */
  11.  
  12.  
  13.  
  14. /**
  15. * This class allows for the modification of the layout of a font.
  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: WBackgroundEditor.class.php,v 1.4 2007/09/19 14:04:45 adamfranco Exp $
  24. */
  25.  
  26. class WBackgroundEditor
  27. extends WMoreOptions
  28. {
  29.  
  30. var $_callBack;
  31. var $_collectionName;
  32. var $_thingsToApplyCollectionTo;
  33.  
  34. /**
  35. * It is important to know that the $thingsToApplyCollectionTo is an array
  36. * of arrays. Each array should have two elements--an index at 'index', and
  37. * a type at 'type.' types might be MENU, BLOCK, HEADING and so forth.
  38. */
  39. function WBackgroundEditor ($callBack, $collectionName, $thingsToApplyCollectionTo) {
  40.  
  41. $this->init();
  42. $this->_callBack =$callBack;
  43. $this->_collectionName =$collectionName;
  44. $this->_thingsToApplyCollectionTo = $thingsToApplyCollectionTo;
  45. $this->rebuildContent();
  46. }
  47. /**
  48. * Make everything
  49. */
  50. function rebuildContent(){
  51. $callBack = $this->_callBack;
  52. $collectionName = $this->_collectionName;
  53. $thingsToApplyCollectionTo = $this->_thingsToApplyCollectionTo;
  54. //get the theme
  55. eval('$theme = '.$callBack."();");
  56.  
  57.  
  58. if(!is_object($theme)){
  59. return;
  60. }
  61. $color = GUIComponentUtility::makeColorArrays(12, 5);
  62. $marginArray = GUIComponentUtility::makeMarginAndPaddingArray();
  63. $borderSizes = GUIComponentUtility::makeBorderSizeArrays();
  64. $borderStyles =GUIComponentUtility::makeBorderStyleArrays();
  65.  
  66. $collectionSelector1 = "*.".$collectionName;
  67.  
  68. //first style collection
  69. if(!$theme->getStyleCollection($collectionSelector1)){
  70. $styleCollection1 = new StyleCollection($collectionSelector1, $collectionName,"BackGround properties", "How would you like your background to look?".$collectionName);
  71. foreach($thingsToApplyCollectionTo as $arr){
  72. $theme->addStyleForComponentType($styleCollection1,$arr['type'],$arr['index']);
  73. }
  74. }
  75.  
  76.  
  77. //first style collection GUI elements
  78. $comp = new WGUISelectList($callBack, $collectionSelector1,new BackgroundColorSP("#FFFFFF"),"ColorSC",$color['options'],$color['styles']);
  79. $this->addComponent('bgColor',$comp);
  80. $prop = new BorderSP('0px',"solid","#000000");
  81. $comp = new WGUISelectList($callBack, $collectionSelector1,$prop,"LengthSC",$borderSizes['options'],$borderSizes['styles']);
  82. $this->addComponent('borderSize',$comp);
  83. $comp = new WGUISelectList($callBack, $collectionSelector1,$prop,"BorderStyleSC",$borderStyles['options'],$borderStyles['styles']);
  84. $this->addComponent('borderStyle',$comp);
  85. $comp = new WGUISelectList($callBack, $collectionSelector1,$prop,"ColorSC",$color['options'],$color['styles']);
  86. $this->addComponent('borderColor',$comp);
  87. $comp = new WGUISelectList($callBack, $collectionSelector1,new MarginTopSP("0px"),"LengthSC",$marginArray,false);
  88. $this->addComponent('m_top',$comp);
  89. $comp = new WGUISelectList($callBack, $collectionSelector1,new MarginBottomSP("0px"),"LengthSC",$marginArray,false);
  90. $this->addComponent('m_bottom',$comp);
  91. $comp = new WGUISelectList($callBack, $collectionSelector1,new MarginLeftSP("0px"),"LengthSC",$marginArray,false);
  92. $this->addComponent('m_left',$comp);
  93. $comp = new WGUISelectList($callBack, $collectionSelector1,new MarginRightSP("0px"),"LengthSC",$marginArray,false);
  94. $this->addComponent('m_right',$comp);
  95.  
  96.  
  97. }
  98. /**
  99. * Returns a block of XHTML-valid code that contains markup for this specific
  100. * component.
  101. * @param string $fieldName The field name to use when outputting form data or
  102. * similar parameters/information.
  103. * @access public
  104. * @return string
  105. */
  106. function getMarkup ($fieldName) {
  107. //make sure we're current with the theme
  108. $this->rebuildContent();
  109. $s="";
  110.  
  111. $s.="\n<table border='1' width='100%'>";
  112. $s.="\n\t<tr><td>";
  113.  
  114.  
  115.  
  116. $s.="\n<table border='0' width='100%' cellpadding='5'>";
  117. $s.="\n\t<tr>";
  118. $s.="\t\t<td>Background Color: ";
  119. $comp =$this->getChild($name = 'bgColor');
  120. $s.="\n\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  121. $s.="\t\t<td width>Border Size: ";
  122. $comp =$this->getChild($name = 'borderSize');
  123. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  124.  
  125. $s.="\n\t\t<td>More background options: ".$this->getCheckboxMarkup($fieldName)."</td>";
  126.  
  127.  
  128.  
  129.  
  130.  
  131. $s.="\n\t</tr>";
  132. $s.="\n</table>";
  133.  
  134. $s.="\n\t</td></tr><tr><td>";
  135.  
  136. $s.= $this->getOptionalComponentsMarkup($fieldName);
  137.  
  138. $s.="\n\t</td></tr></table>";
  139.  
  140.  
  141.  
  142. return $s;
  143. }
  144.  
  145.  
  146. /**
  147. * Returns a block of XHTML-valid code that contains markup for the "advanced"
  148. * options.
  149. * @param string $fieldName The field name to use when outputting form data or
  150. * similar parameters/information.
  151. * @access public
  152. * @return string
  153. */
  154. function advancedMarkup ($fieldName) {
  155. $s="";
  156.  
  157. $s.="\n<table border='0' width='100%' cellpadding='5'>";
  158. $s.="\n\t<tr>";
  159. $s.="\t\t<td>Border Color: ";
  160. $comp =$this->getChild($name = 'borderColor');
  161. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  162. $s.="\t\t<td width>Border Style: ";
  163. $comp =$this->getChild($name = 'borderStyle');
  164. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  165. $s.="\n\t</tr><tr>";
  166.  
  167. $s.="\t\t<td>Top Margin: ";
  168. $comp =$this->getChild($name = 'm_top');
  169. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  170. $s.="\t\t<td>Bottom Margin: ";
  171. $comp =$this->getChild($name = 'm_bottom');
  172. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  173. $s.="\n\t</tr><tr>";
  174. $s.="\t\t<td>Left Margin: ";
  175. $comp =$this->getChild($name = 'm_left');
  176. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  177. $s.="\t\t<td>Right Margin: ";
  178. $comp =$this->getChild($name = 'm_right');
  179. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  180. $s.="\n\t</tr><tr>";
  181. $s.="\n\t</tr>";
  182. $s.="\n</table>";
  183.  
  184.  
  185.  
  186.  
  187.  
  188. return $s;
  189. }
  190.  
  191.  
  192. }
  193.  
  194. ?>

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