scormbuilderbrowse.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /*
  3. ----------------------------------------------------------------------
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) Denes Nagy (darkden@freemail.hu)
  7. For a full list of contributors, see "credits.txt".
  8. The full license can be read in "license.txt".
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. See the GNU General Public License for more details.
  14. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  15. ----------------------------------------------------------------------
  16. */
  17. /**
  18. ==============================================================================
  19. * The table of contents manager file of the Scorm Builder tool
  20. *
  21. * @author Denes Nagy <darkden@freemail.hu>
  22. * @version v 0.1
  23. * @access public
  24. * @package dokeos.scorm
  25. ==============================================================================
  26. */
  27. $langFile = "scorm";
  28. include('../inc/global.inc.php');
  29. $this_section=SECTION_COURSES;
  30. header('Content-Type: text/html; charset='. $charset); ?>
  31. <html><head>
  32. <script type='text/javascript'>
  33. /* <![CDATA[ */
  34. function additem() {
  35. var s=builderwindow.net.location.toString();
  36. //it took me 1 hour to discover that top.net.location is not a string in itself, and
  37. //as a consequence, i cannot use indexOf function to that; but no error messages appeared ! never !
  38. //I hate Javascript !!!
  39. c=s.charAt(s.length-1);
  40. if (c=='/') { s=s.slice(0,s.length-1); } //we cut the final '/' if exists
  41. last=s.lastIndexOf('/',s.length-2);
  42. amount=s.length-last-1;
  43. suggestion=s.slice(last+1, s.length);
  44. answer=prompt('Give a name to this item : ',suggestion);
  45. if (answer=='') { alert('You cannot add an item without a name !'); return false; }
  46. if (answer) {
  47. document.theform.newname.value=answer;
  48. document.theform.newaddress.value=top.net.location;
  49. }
  50. document.theform.submit();
  51. builderwindow=open(s,'');
  52. }
  53. function addchaptertitle() {
  54. answer=prompt('Write in the chapter title : ','');
  55. if (answer=='') { alert('You cannot add an empty chapter title !'); return false; }
  56. if (answer) {
  57. document.theform.newname.value=answer;
  58. document.theform.newaddress.value='';
  59. }
  60. document.theform.submit();
  61. }
  62. /* ]]> */
  63. </script>
  64. <link rel='stylesheet' type='text/css' href='../css/scorm.css' />
  65. </head>
  66. <body bgcolor='#EEEEEE'>
  67. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" name='theform'>
  68. <div align='left'>
  69. <FIELDSET>
  70. <LEGEND>Other building tools</LEGEND>
  71. <br />
  72. &nbsp;<a href='#' onclick="addchaptertitle()" class='menu'>Add chapter title</a><br>
  73. &nbsp;<a href='#' onclick="javascript:document.theform.action.value='clear';document.theform.submit();"; class='menu'>Clear Path</a><br />
  74. <br />
  75. </FIELDSET>
  76. <br />
  77. </div>
  78. <div align='center'>
  79. <?php
  80. echo "</div>",
  81. "<input type='hidden' name='newaddress'><input type='hidden' name='newname'><input type='hidden' name='action'></form>";
  82. if (($newaddress != '') || ($newname != '')) {
  83. $newelement['url']=$newaddress; $newelement['name']=$newname; $items[]=$newelement;
  84. }
  85. if (($move == 'up') and ($index != 0)) {
  86. $temp=$items[$index-1];
  87. $items[$index-1]=$items[$index];
  88. $items[$index]=$temp;
  89. }
  90. if (($move == 'down') and ($index != count($items)-1)) {
  91. $temp=$items[$index+1];
  92. $items[$index+1]=$items[$index];
  93. $items[$index]=$temp;
  94. }
  95. if ($delete != '') {
  96. array_splice($items,$delete,1);
  97. }
  98. if ($action=='clear') {
  99. api_session_unregister('items');
  100. unset($items);
  101. api_session_register('items');
  102. }
  103. echo "<table width='245' cellpadding='0' cellspacing='0' border='0'>";
  104. for ($i=0; $i<count($items); $i++) {
  105. echo "<tr><td>";
  106. if ($items[$i]['url'] != '') {
  107. echo "&nbsp;&nbsp;<a href='{$items[$i]['url']}' target='net'>{$items[$i]['name']}</a>";
  108. } else {
  109. echo "{$items[$i]['name']}";
  110. }
  111. echo "</td><td>";
  112. if ($i != 0) { echo "<a href='".$_SERVER['PHP_SELF']."?move=up&index=$i'><img src='../img/up.gif' border='0' alt='Move up'></a>"; }
  113. echo "</td><td>";
  114. if ($i != count($items)-1) { echo "<a href='".$_SERVER['PHP_SELF']."?move=down&index=$i' alt='Move down'><img src='../img/down.gif' border=0></a>"; }
  115. echo "</td><td><a href='".$_SERVER['PHP_SELF']."?delete=$i'><img src='../img/delete.gif' border='0' alt='Delete'></a><td>",
  116. "<img src='../img/scormpre.gif' border=0 alt='Prerequirements'>",
  117. "</td></tr>";
  118. }
  119. echo "</table>";
  120. //print_r($items);
  121. ?>
  122. </body></html>