Source for file BrowseHistoryManager.class.php

Documentation is available at BrowseHistoryManager.class.php

  1. <?php
  2.  
  3. /**
  4. * Keeps track of the last important page the user visited, and returns them there
  5. * when called upon to do so.
  6. *
  7. * @package harmoni.architecture
  8. *
  9. * @copyright Copyright &copy; 2005, Middlebury College
  10. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  11. *
  12. * @version $Id: BrowseHistoryManager.class.php,v 1.7 2007/09/04 20:25:30 adamfranco Exp $
  13. ***/
  14.  
  15. class BrowseHistoryManager {
  16.  
  17. /**
  18. * Marks the current return-point after an operation has completed. The
  19. * function can take three forms:
  20. *
  21. * void markReturnURL(string $op) - takes the current URL from Harmoni::request
  22. * void markReturnURL(string $op, string $url) - take a URL as a string
  23. * void markReturnURL(string $op, URLWriter $obj) - takes a {@link URLWriter} object and creates
  24. * the URL from that
  25. *
  26. * @return void
  27. * @param string $operation The label (or operation) under which to store the URL.
  28. * Later, a script may call goBack($operation) to return
  29. * the browser to this URL.
  30. * @param optional mixed $arg Either a string, an object ({@link URLWriter}), or nothing.
  31. * @access public
  32. */
  33. function markReturnURL($operation, $arg = null) {
  34. $url = '';
  35. if ($arg == null) {
  36. $harmoni = Harmoni::instance();
  37. $urlObj =$harmoni->request->mkURLWithPassthrough();
  38. $url = $urlObj->write();
  39. } else if (is_string($arg))
  40. $url = $arg;
  41. else if (is_object($arg))
  42. $url = $arg->write(); // a URLWriter object
  43. $_SESSION['__returnURL'][$operation] = $url;
  44. // print "for operation: $operation -- $url <br>";
  45. }
  46. /**
  47. * Sends the browser to the last URL marked with {@link BrowseHistoryManager::markReturnURL markReturnURL()}.
  48. * @param string $operation The name of the operation under which the URL
  49. * is stored.
  50. * @return void
  51. * @access public
  52. */
  53. function goBack($operation) {
  54. RequestContext::sendTo($this->getReturnURL($operation));
  55. exit();
  56. }
  57. /**
  58. * Answer a marked url
  59. *
  60. * @param string $operation The name of the operation under which the URL
  61. * is stored.
  62. * @return object URLWriter
  63. * @access public
  64. * @since 6/7/05
  65. */
  66. function getReturnURL($operation) {
  67. if (isset($_SESSION['__returnURL'][$operation])) {
  68. $url = $_SESSION['__returnURL'][$operation];
  69. } else {
  70. $harmoni = Harmoni::instance();
  71. $url = $harmoni->request->quickURL(
  72. $harmoni->config->get("defaultModule"),
  73. $harmoni->config->get("defaultAction")
  74. );
  75. }
  76. return $url;
  77. }
  78. }
  79.  
  80. ?>

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