Source for file MainWindowAction.class.php

Documentation is available at MainWindowAction.class.php

  1. <?php
  2. /**
  3. * @package polyphony.AbstractActions
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: MainWindowAction.class.php,v 1.13 2007/09/19 14:04:41 adamfranco Exp $
  9. */
  10.  
  11. require_once(dirname(__FILE__)."/WizardAction.class.php");
  12. require_once(HARMONI."GUIManager/Container.class.php");
  13. require_once(HARMONI."GUIManager/Layouts/XLayout.class.php");
  14. require_once(HARMONI."GUIManager/Layouts/YLayout.class.php");
  15. require_once(HARMONI."GUIManager/Layouts/TableLayout.class.php");
  16. require_once(HARMONI."GUIManager/Components/Block.class.php");
  17. require_once(HARMONI."GUIManager/Components/UnstyledBlock.class.php");
  18. require_once(HARMONI."GUIManager/Components/Menu.class.php");
  19. require_once(HARMONI."GUIManager/Components/MenuItemHeading.class.php");
  20. require_once(HARMONI."GUIManager/Components/MenuItemLink.class.php");
  21. require_once(HARMONI."GUIManager/Components/Heading.class.php");
  22. require_once(HARMONI."GUIManager/Components/Footer.class.php");
  23.  
  24. /**
  25. * The MainWindowAction is an abstract class that provides a standard way of setting
  26. * up and executing an action in the main window of the application. It provides
  27. * a structure for accessing various parts of this main window, as well as delegating
  28. * the implementation of some methods to decendent classes.
  29. *
  30. * @package polyphony.AbstractActions
  31. *
  32. * @copyright Copyright &copy; 2005, Middlebury College
  33. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  34. *
  35. * @version $Id: MainWindowAction.class.php,v 1.13 2007/09/19 14:04:41 adamfranco Exp $
  36. */
  37. class MainWindowAction
  38. extends WizardAction {
  39.  
  40. /*******************************************************
  41. * Instance Variables
  42. *********************************************************/
  43.  
  44. /**
  45. * @var object $_actionRows;
  46. * @access private
  47. * @since 7/7/05
  48. */
  49. var $_actionRows;
  50. /*******************************************************
  51. * Instance Methods
  52. *********************************************************/
  53.  
  54.  
  55. /**
  56. * Build the content for this action.
  57. *
  58. * @return void
  59. * @access public
  60. * @since 4/26/05
  61. */
  62. function buildContent () {
  63. throwError(new Error(__CLASS__."::".__FUNCTION__."() must be overridded in child classes."));
  64. }
  65. /**
  66. * Execute this action. This is a template method that handles setting up
  67. * components of the screen as well as authorization, delegating the various
  68. * parts to descendent classes.
  69. *
  70. * @return mixed
  71. * @access public
  72. * @since 4/25/05
  73. */
  74. function execute () {
  75. $harmoni = Harmoni::instance();
  76. $pageTitle = $harmoni->config->get('programTitle');
  77. // Our Rows for action content
  78. $actionRows =$this->getActionRows();
  79. // Check authorization
  80. if (!$this->isAuthorizedToExecute()) {
  81. $actionRows->add(new Block($this->getUnauthorizedMessage(), EMPHASIZED_BLOCK),
  82. "100%", null, CENTER, TOP);
  83. return $actionRows;
  84. }
  85. // Add a heading if specified
  86. if ($headingText = $this->getHeadingText()) {
  87. $actionRows->add(
  88. new Heading($headingText, 1),
  89. "100%",
  90. null,
  91. LEFT,
  92. CENTER);
  93. $pageTitle .= ": ".$headingText;
  94. }
  95. // Set the page title and other new header items
  96. $outputHandler =$harmoni->getOutputHandler();
  97. ob_start();
  98. // Remove any existing title tags from the head text
  99. print preg_replace("/<title>[^<]*<\/title>/", "", $outputHandler->getHead());
  100. //Add our new title
  101. print "\n\t\t<title>";
  102. print strip_tags(preg_replace("/<(\/)?(em|i|b|strong)>/", "*", $pageTitle));
  103. print "</title>";
  104. // Add our common Harmoni javascript libraries
  105. require(POLYPHONY_DIR."/main/library/Harmoni.js.inc.php");
  106. $outputHandler->setHead(ob_get_clean());
  107. // Pass content generation off to our child classes
  108. $this->buildContent();
  109. return $actionRows;
  110. }
  111. /**
  112. * Return the actionRows container
  113. *
  114. * @return object Container
  115. * @access public
  116. * @since 4/26/05
  117. */
  118. function getActionRows () {
  119. if (!is_object($this->_actionRows))
  120. $this->_actionRows = new Container(new YLayout(), BLOCK, BACKGROUND_BLOCK);
  121. return $this->_actionRows;
  122. }
  123. }
  124.  
  125. ?>

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