dokeos-metadata
[ class tree: dokeos-metadata ] [ index: dokeos-metadata ] [ all elements ]

Source for file playscormmdset.inc.php

Documentation is available at playscormmdset.inc.php

  1. <?php /*                         <!-- Dokeos metadata/playscormmdset.inc.php -->
  2.                                                              <!-- 2005/11/16 -->
  3.  
  4. <!-- Copyright (C) 2005 rene.haentjens@UGent.be -  see metadata/md_funcs.php -->
  5.  
  6. */
  7.  
  8. /**
  9. ============================================================================== 
  10. *    Dokeos Metadata: include file for accessing Scorm metadata
  11. *
  12. *   This script is to be included from /coursedir/scorm/dir.../index.php,
  13. *   after setting $scormid (Dokeos document root).
  14. *
  15. *    @package dokeos.metadata
  16. ============================================================================== 
  17. */
  18.  
  19.  
  20. // PRELIMS -------------------------------------------------------------------->
  21.  
  22. if (!isset($scormid)) exit()
  23.  
  24. define('EID_TYPE''Scorm');
  25. define('BID'EID_TYPE '.' $scormid);
  26. getpar('SID''Scorm sub-id''*');
  27. define('EID_ID'(SID == '*'$scormid $scormid '.' SID);
  28. define('EID'EID_TYPE '.' EID_ID);
  29. getpar('LFN''LanguageFileName''md_' strtolower(EID_TYPE));
  30. getpar('HTT''HTML Template Text filename''mdp_' strtolower(EID_TYPE));
  31. getpar('WHF''With Header and Footer''0');
  32. define('DBG'0);  // for template debug info, set to e.g. 10000
  33. getpar('RNG''Slide range''*');
  34.  
  35. if (RNG == '*' || ($dotdot strpos(RNG'..')) === FALSE)
  36.     $id_range_first $id_range_last '';
  37. else
  38. {
  39.     $id_range_first trim(substr(RNG0$dotdot));
  40.     $id_range_last =  trim(substr(RNG$dotdot 2));
  41. }
  42.  
  43. $urlp '?dbg=' .                                              urlencode(DBG);
  44. if (LFN != 'md_' .  strtolower(EID_TYPE))   $urlp .= '&lfn=' urlencode(LFN);
  45. if (HTT != 'mdp_' strtolower(EID_TYPE))   $urlp .= '&lfn=' urlencode(HTT);
  46. if (WHF != '0')                             $urlp .= '&whf=' urlencode(WHF);
  47. if (RNG != '*')                             $urlp .= '&rng=' urlencode(RNG);
  48.  
  49. // name of the language file that needs to be included 
  50. $language_file LFN;
  51. require('../inc/global.inc.php');
  52. $nameTools get_lang('Tool');
  53.  
  54. require(api_get_path(SYS_CODE_PATH'metadata/md_funcs.php');
  55.  
  56. ($nameTools && get_lang('Sorry'))
  57.     or give_up('Language file ' LFN " doesn't define 'Tool' and 'Sorry'");
  58.  
  59. $_course api_get_course_info()isset($_courseor give_up(get_lang('Sorry'));
  60.  
  61. require(api_get_path(LIBRARY_PATH'xmd.lib.php');
  62. require(api_get_path(LIBRARY_PATH'xht.lib.php');
  63.  
  64. require(api_get_path(SYS_CODE_PATH'metadata/md_' strtolower(EID_TYPE'.php');
  65. $mdObj new mdobject($_courseEID_ID);
  66.  
  67. define('DR'$_SERVER['DOCUMENT_ROOT']);
  68. define('SELF'api_get_self());
  69. define('DIRECTORY'DR $self substr(SELF0strrpos(SELF'/')));
  70. if (!file_exists(DIRECTORY)) give_up('No such directory: ' DIRECTORY);
  71.  
  72.  
  73. // TEMPLATES FILE ------------------------------------------------------------->
  74.  
  75. $topdir strtolower(realpath(DR));  // to stop search for .htt file
  76.  
  77. if (strpos(strtolower(realpath(DIRECTORY))$topdir!== 0
  78.     give_up('Invalid directory: ' DIRECTORY);
  79.  
  80.  
  81. for ($i 0$i 10$i++)
  82.     if(!file_exists(HTT '.htt'))
  83.         if (strtolower(realpath(getcwd())) == $topdir{break;
  84.         else chdir('..');
  85.  
  86.  
  87. // XML and DB STUFF ----------------------------------------------------------->
  88.  
  89. $is_allowed_to_edit = isset($_user['user_id']&& $is_courseMember && is_allowed_to_edit();
  90.  
  91. $mdStore new mdstore($is_allowed_to_edit);
  92.  
  93. if (($mdt_rec $mdStore->mds_get(EID)) === FALSE)  // no record, default XML
  94.      $mdt $mdObj->mdo_generate_default_xml_metadata();
  95. else $mdt $mdt_rec;
  96.     
  97. $xhtxmldoc new xmddoc(explode("\n"$mdt));
  98.  
  99. (!$xhtxmldoc->erroror give_up($xhtxmldoc->error);
  100.  
  101. if (SID == $id_range_first && 
  102.         ($prv $xhtxmldoc->xmd_select_single_element('previous')) != -1)
  103.     $xhtxmldoc->xmd_remove_element($prv);
  104.  
  105. if (SID == $id_range_last && 
  106.         ($nxt $xhtxmldoc->xmd_select_single_element('next')) != -1)
  107.     $xhtxmldoc->xmd_remove_element($nxt);
  108.  
  109. $before_first $id_range_first TRUE FALSE$after_last FALSE;
  110.  
  111. foreach ($xhtxmldoc->xmd_select_elements('child'as $chEl)
  112. {
  113.     $chId $xhtxmldoc->attributes[$chEl]['identifier'];  // no get_att yet...
  114.     
  115.     if ($after_last ||
  116.         ($before_first $before_first && $chId != $id_range_first))
  117.     {
  118.         $xhtxmldoc->xmd_remove_element($chEl)continue;
  119.     }
  120.     
  121.     if (($mdt_rec $mdStore->mds_get(BID '.' $chId)) === FALSE)
  122.          $mdt $mdObj->mdo_generate_default_xml_metadata();
  123.     else $mdt $mdt_rec;
  124.         
  125.     $xhtxmldocchild new xmddoc(explode("\n"$mdt));
  126.     
  127.     (!$xhtxmldocchild->erroror give_up($chId ': ' $xhtxmldocchild->error);
  128.     
  129.     // make stuff below a parameter? copy some already in importmanifest?
  130.     $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild
  131.         $xhtxmldocchild->xmd_select_single_element('title')$chEl);
  132.     $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild
  133.         $xhtxmldocchild->xmd_select_single_element('resource')$chEl);
  134.     
  135.     $after_last $after_last || $chId == $id_range_last;
  136. }
  137.  
  138. $xhtDoc define_htt(HTT '.htt'$urlp$_course['path']);
  139. $xhtDoc->xht_xmldoc $xhtxmldoc;
  140.  
  141. $xhtDoc->xht_param['mdt'$xhtxmldoc->xmd_xml();
  142.  
  143.  
  144. // GENERATE OUTPUT ------------------------------------------------------------>
  145.  
  146. foreach (explode("\n"$xhtDoc->htt_array['HTTP']as $httpXtra)
  147.     if ($httpXtra$httpHeadXtra[$httpXtra;
  148.  
  149. $xhtDoc->xht_get_lang 'get_lang';
  150.  
  151. function resource_for($e{return $e;}  // dummy, '=/' not used here
  152. $xhtDoc->xht_resource 'resource_for';
  153.  
  154. $htmlHeadXtra[$xhtDoc->xht_fill_template('HEAD');
  155.  
  156. // $mdObj->mdo_add_breadcrump_nav();  // see 'md_' . EID_TYPE . '.php'
  157. $noPHP_SELF TRUE;  // in breadcrumps
  158.  
  159. if (WHF != '0'Display::display_header($nameTools);
  160. else
  161. {
  162.     header('Content-Type: text/html; charset='$charset)$document_language 'en';
  163.     if isset($httpHeadXtra&& $httpHeadXtra )
  164.     {
  165.         foreach($httpHeadXtra as $thisHttpHead)
  166.         {
  167.             header($thisHttpHead);
  168.         }
  169.     }
  170.     ?>
  171.     <!DOCTYPE html 
  172.          PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  173.          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  174.     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $document_language?>" lang="<?php echo $document_language?>">
  175.     <head>
  176.     <title>Scorm package
  177.     </title>
  178.     <link rel="stylesheet" href="<?php echo api_get_path(WEB_CODE_PATH)?>css/default.css" type="text/css" media="screen,projection" />
  179.     <style type="text/css" media="screen, projection">
  180.     /*<![CDATA[*/
  181.     @import "<?php echo $clarolineRepositoryWeb ?>css/default.css";
  182.     /*]]>*/
  183.     </style>
  184.     <?php
  185.     if isset($htmlHeadXtra&& $htmlHeadXtra )
  186.     {
  187.         foreach($htmlHeadXtra as $this_html_head)
  188.         {
  189.             echo($this_html_head);
  190.         }
  191.     }
  192.     ?>
  193.     </head>
  194.     <body dir="<?php echo  $text_dir ?>"
  195.     <!-- #outerframe container to control some general layout of all pages -->
  196.     <div id="outerframe">
  197.     <?php
  198. }
  199.  
  200. echo "\n";
  201.  
  202. $xhtDoc->xht_dbgn DBG;  // for template debug info, set to e.g. 10000
  203. if (($ti $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'
  204.     '<h5>Trace information</h5>' htmlspecialchars($ti);
  205.  
  206. echo $xhtDoc->xht_fill_template('METADATA')"\n";
  207.  
  208. if ($xhtDoc->xht_dbgnecho $xhtDoc->xht_dbgo;
  209.  
  210. if (WHF != '0')
  211. {
  212.     exit;
  213. }
  214.  
  215. ?>
  216.     <div class="clear">&nbsp;</div> <!-- 'clearing' div to make sure that footer stays below the main and right column sections -->
  217.     </div> <!-- end of #outerframe opened in header.inc.php -->
  218.     </body>
  219.     </html>

Documentation generated on Thu, 12 Jun 2008 09:26:08 -0500 by phpDocumentor 1.4.1