/mod/rafl/includes/top_menu/top_menu.php

https://github.com/nadavkav/MoodleTAO · PHP · 110 lines · 67 code · 16 blank · 27 comment · 4 complexity · 04d50c43c8fda5315999ac85d79ea6cb MD5 · raw file

  1. <?php
  2. //----------------------------------------------------------------------------------------------
  3. // Desc: Rafl top menu
  4. // Depd: -
  5. // Auth: Daniel Dammann <dan@smartassess.com>
  6. //----------------------------------------------------------------------------------------------
  7. class top_menu {
  8. static function display($arg_config_file) {
  9. // Logged in users get a menu
  10. if (strlen($_SESSION['USER']->id)) {
  11. // Start sessions just in case
  12. session_start();
  13. // Append url variable
  14. if (strpos($arg_config_file, '?')) {
  15. $config_url = $arg_config_file . '&this_url=' . urlencode($_SERVER['REQUEST_URI']);
  16. } else {
  17. $config_url = $arg_config_file . '?this_url=' . urlencode($_SERVER['REQUEST_URI']);
  18. }
  19. // Build configuration path
  20. $config_url = urlencode('../includes/top_menu/' . $config_url);
  21. // Base path for config path and amfphp
  22. $base_url = "main/";
  23. // Set the session string so that mac's can call urls and retain their session id's
  24. $session_string = urlencode(session_name() . "=" . session_id());
  25. // Define user id for user image in menu
  26. $user_id = $_SESSION['USER']->id;
  27. // Build string of variables to send to flash
  28. $flashVarString = "config=$config_url&base_url=$base_url&session_string=$session_string&user_id=$user_id";
  29. ?>
  30. <style type="text/css">
  31. /* Position menu and content box */
  32. #divFlashContent {
  33. position: fixed;
  34. left: 0px;
  35. top: 0px;
  36. width: 595px;
  37. height: 36px;
  38. z-index: 2;
  39. }
  40. #pageWrapper {
  41. position: absolute;
  42. top: 37px;
  43. width: 595px;
  44. z-index: 1;
  45. }
  46. </style>
  47. <div id="divFlashContent">
  48. <!-- Menu will go here -->
  49. </div>
  50. <script type="text/javascript" src="main/js/swfobject.js"></script>
  51. <script type="text/javascript">
  52. // <![CDATA[
  53. // Menu creation
  54. var so = new SWFObject("main/rtool/rtool_menubar.swf", "menubar", "100%", "100%", "9");
  55. so.addParam("scale", "noscale");
  56. so.addParam("salign", "TL");
  57. so.addParam("allowFullScreen", "true");
  58. so.addParam("allowScriptAccess", "always");
  59. so.addParam("movie", "main/rtool/rtool_menubar");
  60. so.addParam("FlashVars", "<?php echo $flashVarString; ?>");
  61. so.addParam("wmode","transparent");
  62. so.write("divFlashContent");
  63. // Menu helper functions called from flash file (browser-fix)
  64. function expandCreative() {
  65. // Expanded width
  66. document.getElementById("divFlashContent").style.height = "100%";
  67. }
  68. function collapseCreative() {
  69. // Normal width
  70. document.getElementById("divFlashContent").style.height = "36px";
  71. }
  72. // ]]>
  73. </script>
  74. <?php
  75. } else {
  76. // Not logged in, don't get a menu, cos it must be an item of a public share viewed by a public user
  77. ?>
  78. <style type="text/css">
  79. /* Position content box alone */
  80. #pageWrapper {
  81. position: absolute;
  82. top: 0px;
  83. width: 595px;
  84. z-index: 1;
  85. overflow: auto;
  86. }
  87. </style>
  88. <?php
  89. }
  90. // WORKAROUND: This is nothing to do with the top menu, it is a tooltip function that I want on every page
  91. //echo '<script type="text/javascript" src="javascripts/wz_tooltip.php"></script>';
  92. }
  93. }
  94. ?>