Source for file GUIManager.abstract.php

Documentation is available at GUIManager.abstract.php

  1. <?php
  2.  
  3. require_once(HARMONI."GUIManager/Theme.interface.php");
  4. require_once(HARMONI."GUIManager/StyleComponent.interface.php");
  5. require_once(HARMONI."GUIManager/StyleProperty.interface.php");
  6. require_once(HARMONI."GUIManager/Component.interface.php");
  7. require_once(HARMONI."GUIManager/Layout.interface.php");
  8.  
  9.  
  10. /**
  11. * This abstract provides methods for theme management: saving/loading of theme state,
  12. * obtaining information about supported GUI components, etc.
  13. *
  14. * @package harmoni.gui
  15. *
  16. * @copyright Copyright &copy; 2005, Middlebury College
  17. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  18. *
  19. * @version $Id: GUIManager.abstract.php,v 1.7 2007/09/04 20:25:21 adamfranco Exp $
  20. */
  21. class GUIManagerAbstract
  22. extends OutputHandler
  23. {
  24.  
  25. /*******************************************************
  26. * Methods defined in OutputHandler
  27. *********************************************************/
  28.  
  29. /**
  30. * Output the content that was returned from an action. This content should
  31. * have been created such that it is a type that this OutputHandler can deal
  32. * with.
  33. *
  34. * @param mixed $returnedContent Content returned by the action
  35. * @param string $printedContent Additional content printed, but not returned.
  36. * @return void
  37. * @access public
  38. * @since 4/4/05
  39. */
  40. function output ( $returnedContent, $printedContent ) {
  41. // alright, if what we got back was a layout, let's print it out!
  42. $rule = ExtendsValidatorRule::getRule("ComponentInterface");
  43. if ($rule->check($returnedContent)){
  44. $osidContext =$this->getOsidContext();
  45. $harmoni =$osidContext->getContext('harmoni');
  46. $doctypeDef = $this->_configuration->getProperty('document_type_definition');
  47. $doctype = $this->_configuration->getProperty('document_type');
  48. $characterSet = $this->_configuration->getProperty('character_set');
  49. try {
  50. $xmlns = " xmlns=\"".$this->_configuration->getProperty('xmlns')."\"";
  51. } catch (Exception $e) {
  52. $xmlns = "";
  53. }
  54. $head = $this->getHead();
  55. $this->_theme->setComponent($returnedContent);
  56. $css = $this->_theme->getCSS("\t\t\t");
  57. header("Content-type: $doctype; charset=$characterSet");
  58. print<<<END
  59. $doctypeDef
  60. <html{$xmlns}>
  61. <head>
  62. <meta http-equiv="Content-Type" content="$doctype; charset=$characterSet" />
  63. <style type="text/css">
  64. $css
  65. </style>
  66. $head
  67. </head>
  68. <body>
  69. $printedContent
  70. END;
  71.  
  72. $this->_theme->printPage();
  73. print<<<END
  74. </body>
  75. </html>
  76. END;
  77.  
  78. } else {
  79. // we got something else back... well, let's print out an error
  80. // explaining what happened.
  81. $type = gettype($content);
  82. throwError(new Error("Harmoni::execute() - The result returned from action '$pair' was unexpected. Expecting a Layout
  83. object, but got a variable of type '$type'.","Harmoni",true));
  84. }
  85. }
  86. /*******************************************************
  87. * Other general methods.
  88. *********************************************************/
  89.  
  90. /**
  91. * Sets the {@link ThemeInterface Theme} to use for output to the browser. $themeObject can
  92. * be any Theme object that follows the {@link ThemeInterface}.
  93. * @param ref object A {@link ThemeInterface Theme} object.
  94. * @access public
  95. * @return void
  96. ***/
  97. function setTheme($themeObject) {
  98. ArgumentValidator::validate($themeObject,
  99. ExtendsValidatorRule::getRule("ThemeInterface"));
  100. $this->_theme =$themeObject;
  101. }
  102. /**
  103. * Returns the current theme object.
  104. * @access public
  105. * @return ref object A {@link ThemeInterface Theme} object.
  106. ***/
  107. function getTheme() {
  108. return $this->_theme;
  109. }
  110.  
  111. /*******************************************************
  112. * Method definitions
  113. *********************************************************/
  114.  
  115. /**
  116. * Returns a list of themes supported by the GUIManager.
  117. * @access public
  118. * @return array An array of strings; each element is the class name of a theme.
  119. ***/
  120. function getSupportedThemes() {
  121. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  122. }
  123. /**
  124. * Returns the path that contains all the supported themes.
  125. * @access public
  126. * @return string The relative path to the Theme directory.
  127. ***/
  128. function getThemePath() {
  129. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  130. }
  131. /**
  132. * Returns a list of style properties supported by the GUIManager.
  133. * @access public
  134. * @return array An array of strings; each element is the class name of a style property.
  135. ***/
  136. function getSupportedSPs() {
  137. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  138. }
  139. /**
  140. * Returns the path that contains all the supported style properties.
  141. * @access public
  142. * @return string The relative path to the style property directory.
  143. ***/
  144. function getSPPath() {
  145. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  146. }
  147. /**
  148. * Returns a list of style components supported by the GUIManager.
  149. * @access public
  150. * @return array An array of strings; each element is the class name of a style components.
  151. ***/
  152. function getSupportedSCs() {
  153. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  154. }
  155. /**
  156. * Returns the path that contains all the supported style component.
  157. * @access public
  158. * @return string The relative path to the style component directory.
  159. ***/
  160. function getSCPath() {
  161. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  162. }
  163. /**
  164. * Returns a list of components supported by the GUIManager.
  165. * @access public
  166. * @return array An array of strings; each element is the class name of a component.
  167. ***/
  168. function getSupportedComponents() {
  169. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  170. }
  171. /**
  172. * Returns the path that contains all the supported components.
  173. * @access public
  174. * @return string The relative path to the Component directory.
  175. ***/
  176. function getComponentPath() {
  177. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  178. }
  179. /**
  180. * Returns a list of layouts supported by the GUIManager.
  181. * @access public
  182. * @return array An array of strings; each element is the class name of a layout.
  183. ***/
  184. function getSupportedLayouts() {
  185. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  186. }
  187. /**
  188. * Returns the path that contains all the supported layouts.
  189. * @access public
  190. * @return string The relative path to the Layout directory.
  191. ***/
  192. function getLayoutPath() {
  193. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  194. }
  195. // *************************************************************************
  196.  
  197.  
  198.  
  199.  
  200. /**
  201. * Saves the theme state to the database. The theme state is saved by
  202. * exporting the theme's style properties, and then serializing the output
  203. * and storing it into the database. If the Theme already exists, it is
  204. * merely replaced.
  205. * @access public
  206. * @param ref object theme The theme whose state needs to be saved.
  207. * @return ref object A HarmoniId objecting identifying the saved state uniquely.
  208. ***/
  209. function saveTheme($theme) {
  210. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  211. }
  212.  
  213. /**
  214. * Loads the theme state stored priorly with <code>saveThemeState()</code>. This
  215. * method reverses the steps of <code>saveThemeState()</code>. It first obtains
  216. * the database-stored theme state, unserializes it, and finally imports
  217. * it into the theme.
  218. * @access public
  219. * @param ref object stateId The id of the theme state that will be loaded.
  220. * @param ref object theme The theme whose state needs to be loaded.
  221. ***/
  222. function loadTheme($stateId, $theme) {
  223. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  224. }
  225. /**
  226. * Deletes the theme state with the given id from the database. Notice that
  227. * this does not affect the Theme whose state is being deleted in any way!
  228. * @access public
  229. * @param ref object $id A HarmoniId identifying the theme state that needs to
  230. * be deleted.
  231. ***/
  232. function deleteTheme($id) {
  233. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  234. }
  235. }
  236.  
  237. ?>

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