(no commit message)
[atutor.git] / mods / _core / imscc / include / ims_template.inc.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002 - 2009                                            */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
15
16 // This function gets files from html tag @import
17 function get_import_files($text)
18 {
19         $text = strtolower($text);
20         $tag = '@import';
21         $files = array();
22         
23         while (strpos(strtolower($text), strtolower($tag)) > 0)
24         {
25                 $start_pos      = strpos($text, $tag);
26                 if ($start_pos !== false) 
27                 {
28                         $text = substr($text, $start_pos);
29                         $start_pos = strlen($tag);
30                         $len = strpos($text, ';') - strlen($tag);
31                         
32                         $file = substr(trim($text), $start_pos, $len);
33                         
34                         // remove these characters from file name: url, (, ), ", '
35                         $file = trim(preg_replace('/(\'|\"|url|\(|\))/', '', $file));
36                         
37                         // strip processed tag
38                         $text = substr($text, $start_pos);
39                         array_push($files, $file);
40                 }
41         
42         }       
43         return $files;
44 }
45         
46 function print_organizations($parent_id,
47                                                          &$_menu, 
48                                                          $depth, 
49                                                          $path='',
50                                                          $children,
51                                                          &$string) {
52         
53         global $html_content_template, $default_html_style, $zipfile, $resources, $ims_template_xml, $parser, $my_files;
54         global $used_glossary_terms, $course_id, $course_language_charset, $course_language_code;
55         static $paths, $zipped_files;
56         global $glossary;
57         global $test_list, $test_zipped_files, $test_files, $test_xml_items, $use_a4a;
58         /* added by bologna*///TODO***********BOLOGNA**************REMOVE ME*****************/
59         global $db,$forum_list;//forum_list contiene tutti i forum distinti associati ai contenuti. poich� la funzione in questione � ricorsiva deve essere globale in modo che in fase di creazione dell'archivio zip i file descrittori dei forum non vengano ripetuti
60
61         $space  = '    ';
62         $prefix = '                    ';
63
64         if ($depth == 0) {
65                 $string .= '<ul>';
66         }
67         $top_level = $_menu[$parent_id];
68         if (!is_array($paths)) {
69                 $paths = array();
70         }
71         if (!is_array($zipped_files)) {
72                 $zipped_files = array();
73         }
74         if ( is_array($top_level) ) {
75                 
76                 $counter = 1;
77                 $num_items = count($top_level);
78                 
79                 foreach ($top_level as $garbage => $content) {
80                         $link = '';
81                         //XSL characters handling
82                         $content['title'] = str_replace('&', '&amp;', $content['title']);
83                                 
84                         if ($content['content_path'] && (substr($content['content_path'],-1)!='/')) {
85                                 $content['content_path'] .= '/';
86                         }
87
88                         /* 
89                          * generate weblinks 
90                          * Reason to put it here is cause we don't want the content to be overwrittened.
91                          */
92                         if ($content['content_type']==CONTENT_TYPE_WEBLINK){
93                                 $wl = new Weblinks($content['title'], $content['text']);
94                                 $wlexport = new WeblinksExport($wl);
95                                 $wl_xml = $wlexport->export();
96                                 $wl_filename = 'weblinks_'.$content['content_id'].'.xml';
97                                 $zipfile->add_file($wl_xml , 'Weblinks/'.$wl_filename, $content['u_ts']);
98                                 $resources .= str_replace(      array('{PATH}', '{CONTENT_ID}'), 
99                                                                                         array($wl_filename, $content['content_id']), 
100                                                                                         $ims_template_xml['resource_weblink']);
101                                 //Done.
102 //                              continue;
103                         }
104
105                         if ($content['content_type']==CONTENT_TYPE_FOLDER){
106                                 $link .= $prefix.'<item identifier="MANIFEST01_FOLDER'.$content['content_id'].'">'."\n";
107                                 $link .= $prefix.$space.'<title>'.$content['title'].'</title>'."\n";
108                         } else {
109                                 $link .= '<item identifier="MANIFEST01_ITEM'.$content['content_id'].'" identifierref="MANIFEST01_RESOURCE'.$content['content_id'].'">'."\n";
110                                 $link .= $prefix.$space.'<title>'.$content['title'].'</title>'."\n$prefix$space";
111                         }
112                         $html_link = '<a href="resources/'.$content['content_path'].$content['content_id'].'.html" target="body">'.$content['title'].'</a>';
113                         
114                         /* save the content as HTML files */
115                         /* @See: include/lib/format_content.inc.php */
116                         $content['text'] = str_replace('CONTENT_DIR/', '', $content['text']);
117                         /* get all the glossary terms used */
118                         $terms = find_terms($content['text']);
119                         if (is_array($terms)) {
120                                 foreach ($terms[2] as $term) {
121                                         $used_glossary_terms[] = $term;
122                                 }
123                         }
124
125
126                     //TODO**************BOLOGNA****************REMOVE ME************/
127                     $f_count = count($forum_list); //count all distinct forum_id associated to a content page
128                                                 //la funzione è ricorsiva quindi lo devo ricavare attraverso la variabile globale forum_list
129
130                     /* TODO *************BOLOGNA*************REMOVE ME*********/
131                     //recupero i forum associati al contenuto corrente
132                     $sql = "SELECT cf.forum_id, f.title, f.description FROM (SELECT * FROM ".TABLE_PREFIX."content_forums_assoc WHERE content_id=$content[content_id]) AS cf LEFT JOIN ".TABLE_PREFIX."forums f ON cf.forum_id=f.forum_id";
133                     $result_cf = mysql_query($sql,$db);
134                     $cf_count = mysql_num_rows($result_cf);
135    
136                     //per ogni forum ottenuto controllo se è già stato caricato nell'array
137                     //necessario mantenerlo distinto poichè NON si prevedono funzioni sul
138                     //controllo dei nomi nell'inserimento di file nell'archivio.
139                     $find=false;
140                     $forums_dependency='';  //template for associate Discussion Topic to the current content into the manifest
141                     while($current_forum = mysql_fetch_assoc($result_cf)) {
142                         for($j=0;$j<$f_count;$j++) {
143                             if($forum_list[$j]['id'] == $current_forum['forum_id'])
144                                 $find= true;
145                         }
146                         if(!$find) {
147
148                             $forum_list[$f_count]['id']=$current_forum['forum_id'];
149                             $forum_list[$f_count]['title']=$current_forum['title'];
150                             $forum_list[$f_count]['description']=$current_forum['description'];
151                             $find=false;
152                             $f_count++;
153                         }
154                         $forums_dependency .= $prefix.$space.'<dependency identifierref="Forum'.$current_forum['forum_id'].'_R" />';
155                     }
156
157                          /** Test dependency **/
158                          $sql = 'SELECT * FROM '.TABLE_PREFIX.'content_tests_assoc WHERE content_id='.$content['content_id'];
159                          $result = mysql_query($sql, $db);
160                          while ($row = mysql_fetch_assoc($result)){
161                                 //add test dependency on top of forum dependency
162                                 $forums_dependency .= $prefix.$space.'<dependency identifierref="MANIFEST01_RESOURCE_QTI'.$row['test_id'].'" />';
163                          }
164
165
166                         /* calculate how deep this page is: */
167                         $path = '../';
168                         if ($content['content_path']) {
169                                 $depth = substr_count($content['content_path'], '/');
170
171                                 $path .= str_repeat('../', $depth);
172                         }
173                         $content['text'] = format_content($content['text'], $content['formatting'], $glossary, $path);
174
175                         /* add HTML header and footers to the files */
176                         
177                         /* use default style if <style> is not in imported html head */
178                         $head = '';
179                         if ($content['use_customized_head'])
180                         {
181                                 if (strpos(strtolower($content['head']), '<style') > 0)
182                                 {
183                                         $head = $content['head'];
184                                 }
185                                 else
186                                 {
187                                         if (strlen($content['head']) > 0)  
188                                                 $head = $content['head'] . $default_html_style;
189                                         else 
190                                                 $head = $default_html_style;
191                                 }
192                         }
193
194                         $content['text'] = str_replace( array('{TITLE}',        '{CONTENT}', '{KEYWORDS}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}', '{HEAD}'),
195                                                                         array($content['title'],        $content['text'], $content['keywords'], $course_language_charset, $course_language_code, $head),
196                                                                         $html_content_template);
197                                                                 
198                         /* duplicate the paths in the content_path field in the zip file */
199                         if ($content['content_path']) {
200                                 if (!in_array($content['content_path'], $paths)) {
201                                         $zipfile->create_dir('resources/'.$content['content_path'], time());
202                                         $paths[] = $content['content_path'];
203                                 }
204                         }
205                         //add the file iff it's a content file
206                         if($content['content_type']==CONTENT_TYPE_CONTENT){
207                                 $zipfile->add_file($content['text'], 'resources/'.$content['content_path'].$content['content_id'].'.html', $content['u_ts']);
208                         }
209                         $content['title'] = htmlspecialchars($content['title']);
210
211                         /* add the resource dependancies */                     
212                         if ($my_files == null) $my_files = array();
213                         $content_files = "\n";
214                         $parser->parse($content['text']);
215
216                         /* generate the IMS QTI resource and files */
217                         global $contentManager;
218                         //check if test export is allowed.
219                         if ($contentManager->allowTestExport($content['content_id'])){
220                                 $content_test_rs = $contentManager->getContentTestsAssoc($content['content_id']);       
221                                 $test_ids = array();            //reset test ids
222                                 //$my_files = array();          //reset myfiles.
223                                 while ($content_test_row = mysql_fetch_assoc($content_test_rs)){
224                                         //export
225                                         $test_ids[] = $content_test_row['test_id'];
226                                         //the 'added_files' is for adding into the manifest file in this zip
227                                         $added_files = test_qti_export($content_test_row['test_id'], '', $zipfile);
228                                         foreach($added_files as $xml_file=>$chunk){
229                                                 foreach ($chunk as $xml_filename){
230                                                         $added_files_xml .= str_replace('{FILE}', 'resources/'.$xml_filename, $ims_template_xml['xml']);
231                                                 }
232                                         }
233                                         //Save all the xml files in this array, and then print_organizations will add it to the manifest file.
234                                         $resources .= str_replace(      array('{TEST_ID}', '{PATH}', '{FILES}'),
235                                                                                                 array($content_test_row['test_id'], 'tests_'.$content_test_row['test_id'].'.xml', $added_files_xml),
236                                                                                                 $ims_template_xml['resource_test']); 
237 /*      Taken out since we are gonna use dependency instead
238                                         $test_xml_items .= str_replace( array('{TEST_ID}'),
239                                                                                                 array($content_test_row['test_id']),
240                                                                                                 $ims_template_xml['test']); 
241 */
242                                         foreach($test_files as $filename=>$realfilepath){
243                                                 $zipfile->add_file(@file_get_contents($realfilepath), 'resources/'.$filename, filemtime($realfilepath));
244                                         }
245                                 }
246                         }
247
248                         /* generate the a4a files */
249                         $a4a_xml_array = array();
250             //don't export a4a if this is in plain text, plain text has no media
251             //http://atutor.ca/atutor/mantis/view.php?id=4593
252             if ($content['formatting']===0){
253                 $use_a4a = false;
254             }
255                         if ($use_a4a == true){
256                                 $a4aExport = new A4aExport($content['content_id']);
257 //                              $a4aExport->setRelativePath('resources/'.$content['content_path']);
258                                 $secondary_files = $a4aExport->getAllSecondaryFiles();
259                                 $a4a_xml_array = $a4aExport->exportA4a();
260                                 $my_files = array_merge($my_files, $a4aExport->getAllSecondaryFiles());
261                         }
262
263                         /* handle @import */
264                         $import_files = get_import_files($content['text']);
265
266                         if (count($import_files) > 0) $my_files = array_merge($my_files, $import_files);
267                         foreach ($my_files as $file) {
268                                 /* filter out full urls */
269                                 $url_parts = @parse_url($file);
270 //                              if (isset($url_parts['scheme'])) {
271 //                                      continue;
272 //                              }
273
274                                 /* file should be relative to content. let's double check */
275                                 if ((substr($file, 0, 1) == '/')) {
276                                         continue;
277                                 }
278
279                                 if (substr($file, 0, 7) != 'http://' && substr($file, 0, 8) != 'https://') {
280                                         $file_path = realpath(AT_CONTENT_DIR . $course_id . '/' . $content['content_path'] . $file);
281                                         /* check if the path contains AT_CONTENT_DIR in it, if not, skip it, it's trying to scan through 
282                                          * the file system */
283                                         if (strpos($file_path, AT_CONTENT_DIR)!==0){
284                                                 continue; //skip
285                                         }
286                     
287                                         /* check if this file exists in the content dir, if not don't include it */
288                                         if (file_exists($file_path) &&  is_file($file_path) && !in_array($file_path, $zipped_files)) {
289                                                 $zipped_files[] = $file_path;
290                                                 $dir = substr(dirname($file_path), strlen(AT_CONTENT_DIR . $course_id));
291         
292                                                 if (!in_array($dir, $paths) && $dir) {
293                                                         $dir = str_replace('\\', '/', substr($dir, 1));
294                                                         $zipfile->create_dir('resources/' . $dir, time());
295                                                         
296                                                         $paths[] = $dir;
297                                                 }
298         
299                                                 $file_info = stat( $file_path );
300         
301                                                 //remove relative path in the content_path.     
302                                                 $filepath_array = explode('/', 'resources/' . $content['content_path'] . $file);
303                                                 $new_filepath_array = array();
304                                                 if (in_array('..', $filepath_array)){
305                                                         while (!empty($filepath_array)){
306                                                                 $temp = array_shift($filepath_array);
307                                                                 if ($temp == '..'){
308                                                                         array_pop($new_filepath_array);
309                                                                 } else {
310                                                                         array_push($new_filepath_array, $temp);
311                                                                 }
312                                                         }
313                                                         $zip_path = implode('/', $new_filepath_array);
314                                                 } else {
315                                                         $zip_path = 'resources/' . $content['content_path'] . $file;
316                                                 }
317         
318                                                 $zipfile->add_file(@file_get_contents($file_path), $zip_path, $file_info['mtime']);
319                                         }
320                                 }
321                                 //a4a secondary files have mapping, save the ones that we want in order to add the tag in
322                                 $a4a_secondary_files = array();
323                                 foreach ($a4a_xml_array as $a4a_filename=>$a4a_filearray){
324                                         if (preg_match('/(.*)\sto\s(.*)/', $a4a_filename, $matches)){
325                                                 //save the actual file name
326                                                 $a4a_secondary_files[$matches[1]][] = $a4a_filename;    //values are holders
327                                         }
328                                 }
329
330                 /**
331                  * A hack to fix youtube links.  one uses youtube.com?watch=xxx, the other uses youtube.com/v/xxx,
332                  * in which both points to the same file, but needed different links to play.
333                  * in A4a, these youtube links are always stored as "?watch=xxx", however, output.inc.php converted
334                  * these to /v/xxx for rendering purposes.  Convert it back if youtube exists in url.
335                  * http://atutor.ca/atutor/mantis/view.php?id=4548
336                  * @harris 9/30/2010
337                  */
338                 if (strpos($file, 'youtube.com')!==false){
339                     //apply the conversion before linking the alternatives. Otherwise it will not be added.
340                     $file = convert_youtube_playURL_to_watchURL($file);
341                 }
342                                 // If this file has a4a alternatives, link it.
343                                 if (isset($a4a_xml_array[$file]) || isset($a4a_secondary_files[$file])){
344                                         //if this is an array, meaning that it has more than 1 alternatives, print all
345                                         if (substr($file, 0, 7) == 'http://' || substr($file, 0, 8) == 'https://') {
346                                                 $name_in_file_meta = $file;
347                                         } else {
348                                                 $name_in_file_meta = 'resources/'.$content['content_path'] . $file;
349                                         }
350                                         if (is_array($a4a_secondary_files[$file])){
351                                                 $all_secondary_files_md = '';   //reinitialize string to null
352                                                 foreach ($a4a_secondary_files[$file] as $v){
353                                                         foreach($a4a_xml_array[$v] as $v2){
354                                                                 $all_secondary_files_md .= $v2; //all the meta data             
355                                                         }                                                               
356                                                 }
357                                                 $content_files .= str_replace(  array('{FILE}', '{FILE_META_DATA}'), 
358                                                 array($name_in_file_meta, $all_secondary_files_md), 
359                                                 $ims_template_xml['file_meta']);
360                                         } else {
361                                                 $content_files .= str_replace(  array('{FILE}', '{FILE_META_DATA}'), 
362                                                 array($name_in_file_meta, $a4a_xml_array[$file]), 
363                                                 $ims_template_xml['file_meta']);
364                                         }
365                                 } else {
366                                         //if this file is in the test array, add an extra link to the direct file, 
367                                         if (!empty($test_zipped_files) && in_array($file_path, $test_zipped_files)){
368                                                 $content_files .= str_replace('{FILE}', $file, $ims_template_xml['file']);
369                                         } else {
370                                                 if (preg_match('/^http[s]?\:/', $file) == 1){
371                                                         $content_files .= str_replace('{FILE}', $file, $ims_template_xml['xml']);
372                                                 } elseif (file_exists($file_path) && is_file($file_path)) {
373                                                         //http://www.atutor.ca/atutor/mantis/view.php?id=4313
374                                                         //relative link that goes beyond get.php shouldn't be added
375                                                         //relative link that does not exist shouldn't be added.
376                                                         $content_files .= str_replace('{FILE}', $content['content_path'] . $file, $ims_template_xml['file']);
377                                                 }
378                                         }
379                                 }
380                                 /* check if this file is one of the test xml file, if so, we need to add the dependency
381                                  * Note:  The file has already been added to the archieve before this is called.
382                                  */
383                                 if (preg_match('/tests\_[0-9]+\.xml$/', $file) && !in_array($file, $test_zipped_files)){
384                                         $content_files .= str_replace('{FILE}', 'QTI/'.$file, $ims_template_xml['xml']);
385                                         $test_zipped_files[] = $file;
386                                 }
387                         }
388                         /******************************
389                          * http://www.atutor.ca/atutor/mantis/view.php?id=4383 
390                      */
391                         $my_files = array();
392
393                         /******************************/
394                         //add it to the resources section if it hasn't been added.  
395                         //Weblinks have been added.
396                         //Folders aren't resourecs, they shouldn't be added
397                         if($content['content_type']==CONTENT_TYPE_CONTENT){
398                                 $resources .= str_replace(      array('{CONTENT_ID}', '{PATH}', '{FILES}','{DEPENDENCY}'),
399                                                                                         array($content['content_id'], $content['content_path'], $content_files, $forums_dependency),
400                                                                                         $ims_template_xml['resource']); 
401                         }
402
403                         for ($i=0; $i<$depth; $i++) {
404                                 $link .= $space;
405                         }
406
407                         if ( is_array($_menu[$content['content_id']]) ) {
408                                 /* has children */
409
410                                 $html_link = '<li>'.$html_link.'<ul>';
411                                 for ($i=0; $i<$depth; $i++) {
412                                         if ($children[$i] == 1) {
413                                                 echo $space;
414                                                 //$html_link = $space.$html_link;
415                                         } else {
416                                                 echo $space;
417                                                 //$html_link = $space.$html_link;
418                                         }
419                                 }
420
421                         } else {
422                                 /* doesn't have children */
423
424                                 $html_link = '<li>'.$html_link.'</li>';
425                                 if ($counter == $num_items) {
426                                         for ($i=0; $i<$depth; $i++) {
427                                                 if ($children[$i] == 1) {
428                                                         echo $space;
429                                                         //$html_link = $space.$html_link;
430                                                 } else {
431                                                         echo $space;
432                                                         //$html_link = $space.$html_link;
433                                                 }
434                                         }
435                                 } else {
436                                         for ($i=0; $i<$depth; $i++) {
437                                                 echo $space;
438                                                 //$html_link = $space.$html_link;
439                                         }
440                                 }
441                                 $title = $space.$title;
442                         }
443
444                         echo $prefix.$link;
445 //                      echo $title;
446                         echo "\n";
447
448                         $string .= $html_link."\n";
449
450                         $depth ++;
451                         print_organizations($content['content_id'],
452                                                                 $_menu, 
453                                                                 $depth, 
454                                                                 $path.$counter.'.', 
455                                                                 $children,
456                                                                 $string);
457                         $depth--;
458
459                         $counter++;
460                         for ($i=0; $i<$depth; $i++) {
461                                 echo $space;
462                         }
463 //debug($_menu, $content['content_id']);
464 //                      if (!empty($_menu[$content['content_id']])){
465                         echo $prefix.'</item>';
466 //                      }
467                         echo "\n";
468                 }  
469
470                 $string .= '</ul>';
471                 if ($depth > 0) {
472                         $string .= '</li>';
473                 }
474
475         } 
476 }
477
478
479 //TODO***************BOLOGNA******************REMOVE ME***************/
480 /* Export Forum */
481 function print_resources_forum() {
482
483     global $forum_list, $zipfile, $resources;           //$forum_list contiene tutti i forum DISTINTI associati ai contenuti. caricato in print_organizations()
484
485     $ims_template_xml['resource_forum'] =
486
487         '<resource identifier="Forum{FORUMID}_R" type="imsdt_xmlv1p0">
488             <metadata/>
489             <file href="Forum{FORUMID}/FileDescriptorForum{FORUMID}.xml"/>
490         </resource>
491         '."\n";
492
493     foreach ($forum_list as $f){
494     // per ogni forum associato ad uno o pi� contenuti del corso viene aggiunto un elemento resource in imsmanifest.xml
495         $resources .= str_replace("{FORUMID}", $f['id'], $ims_template_xml['resource_forum']);
496
497         //viene generato il file descrittore
498         //file Descrittore con la descrzione del forum
499         $fileDesDT_D = '<?xml version="1.0" encoding="UTF-8"?>
500
501                     <topic
502                         xmlns="http://www.imsglobal.org/xsd/imsdt_v1p0"
503                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsdt_v1p0 http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_6/imsdt_v1p0_localised.xsd">
504
505                         <title>{TitleDiscussionTopic}</title>
506
507                         <text texttype="text/plain">{DescriptionDiscussionTopic}</text>
508
509                     </topic>';
510
511         //file Descrittore senza la descrizione del forum
512         $fileDesDT = '<?xml version="1.0" encoding="UTF-8"?>
513
514                     <topic
515                         xmlns="http://www.imsglobal.org/xsd/imsdt_v1p0"
516                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsdt_v1p0 http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_6/imsdt_v1p0_localised.xsd">
517
518                         <title>{TitleDiscussionTopic}</title>
519
520                         <text/>
521
522                     </topic>';
523
524                 $f['title'] = htmlspecialchars($f['title']);
525                 $f['description'] = htmlspecialchars($f['description']);
526         if (empty($f['description']))
527             $text_file_des_xml = str_replace (array('{TitleDiscussionTopic}', '{DescriptionDiscussionTopic}'), array($f['title'], $f['description']), $fileDesDT);
528         else
529             $text_file_des_xml = str_replace (array('{TitleDiscussionTopic}', '{DescriptionDiscussionTopic}'), array($f['title'], $f['description']), $fileDesDT_D);
530
531         $zipfile->add_file($text_file_des_xml,  'Forum'.$f['id'].'/'.'FileDescriptorForum'.$f['id'].'.xml');
532     }
533     //$zipfile->add_file(file_get_contents('../../images/home-forums_sm.png'),  'resources/home-forums_sm.png');
534 }
535
536
537 $ims_template_xml['header'] = '<?xml version="1.0" encoding="{COURSE_PRIMARY_LANGUAGE_CHARSET}"?>
538 <!--This is an ATutor IMS Common Cartridge 1.0 document-->
539 <!--Created from the ATutor Content Package Generator - http://www.atutor.ca-->
540 <manifest identifier="MANIFEST-'.md5($cid).'" 
541 xmlns="http://www.imsglobal.org/xsd/imscc/imscp_v1p1" 
542 xmlns:imsmd="http://ltsc.ieee.org/xsd/imscc/LOM" 
543 xmlns:lomimscc="http://ltsc.ieee.org/xsd/imscc/LOM" 
544 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
545 xsi:schemaLocation="http://www.imsglobal.org/xsd/imscc/imscp_v1p1 http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/imscp_v1p2_localised.xsd http://ltsc.ieee.org/xsd/imscc/LOM http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_1/lomLoose_localised.xsd" version="IMS Common Cartridge 1.0.0">
546         <metadata>
547                 <schema>IMS Common Cartridge</schema>
548             <schemaversion>1.0.0</schemaversion>
549                 <lomimscc:lom>
550       <lomimscc:general>
551         <lomimscc:identifier>          
552                         <lomimscc:catalog>ATutor</lomimscc:catalog>
553                         <lomimscc:entry></lomimscc:entry>
554         </lomimscc:identifier>
555         <lomimscc:title>
556                         <lomimscc:string language="{COURSE_PRIMARY_LANGUAGE_CODE}">{COURSE_TITLE}</lomimscc:string>
557         </lomimscc:title>
558         <lomimscc:language>en</lomimscc:language>
559         <lomimscc:description> 
560                         <lomimscc:string language="{COURSE_PRIMARY_LANGUAGE_CODE}">{COURSE_DESCRIPTION}</lomimscc:string>
561         </lomimscc:description>
562         <lomimscc:keyword>
563                         <lomimscc:string language="{COURSE_PRIMARY_LANGUAGE_CODE}">{KEYWORDS}</lomimscc:string>
564         </lomimscc:keyword>
565       </lomimscc:general>
566     </lomimscc:lom>
567         </metadata>'
568 ;
569
570 $ims_template_xml['resource'] = '               <resource identifier="MANIFEST01_RESOURCE{CONTENT_ID}" type="webcontent" href="resources/{PATH}{CONTENT_ID}.html">
571                         <metadata/>
572                         <file href="resources/{PATH}{CONTENT_ID}.html"/>{FILES}
573                         {DEPENDENCY}
574                 </resource>
575 '."\n";
576 $ims_template_xml['resource_glossary'] = '              <resource identifier="MANIFEST01_RESOURCE_GLOSSARY" type="associatedcontent/imscc_xmlv1p0/learning-application-resource" href="resources/GlossaryItem/glossary.xml">
577                         <metadata/>
578                         <file href="resources/GlossaryItem/glossary.xml"/>
579                 </resource>
580 '."\n";
581 $ims_template_xml['resource_test'] = '          <resource identifier="MANIFEST01_RESOURCE_QTI{TEST_ID}" type="imsqti_xmlv1p2/imscc_xmlv1p0/assessment">
582                         <metadata/>
583                         <file href="QTI/{PATH}"/>{FILES}
584                 </resource>
585 '."\n";
586 $ims_template_xml['resource_weblink'] = '               <resource identifier="MANIFEST01_RESOURCE{CONTENT_ID}" type="imswl_xmlv1p0">
587                         <metadata/>
588                         <file href="Weblinks/{PATH}"/>
589                 </resource>
590 '."\n";
591 $ims_template_xml['file'] = '                   <file href="resources/{FILE}"/>'."\n";
592 $ims_template_xml['xml'] = '                    <file href="{FILE}"/>'."\n";
593 $ims_template_xml['glossary'] = '                       <item identifier="GlossaryItem" identifierref="MANIFEST01_RESOURCE_GLOSSARY">
594                                 <title>Glossary</title>
595                         </item>';
596 $ims_template_xml['test'] = '                   <item identifier="QTI{TEST_ID}" identifierref="MANIFEST01_RESOURCE_QTI{TEST_ID}">
597                                 <title>Test {TEST_ID}</title>
598                         </item>';
599 $ims_template_xml['file_meta'] = '                      <file href="{FILE}">
600                                 <metadata>
601                                 {FILE_META_DATA}
602                                 </metadata>
603                         </file>'."\n";
604
605 $ims_template_xml['final'] = '
606         <organizations>
607                 <organization identifier="MANIFEST01_ORG1" structure="rooted-hierarchy">
608                         <item identifier="resources">           
609                 {ORGANIZATIONS}
610                     </item>
611                 </organization>
612         </organizations>
613         <resources>
614 {RESOURCES}
615         </resources>
616 </manifest>';
617
618 $html_template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
619     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
620 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
621 <head>
622         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
623         <title>{TITLE}</title>
624         <meta name="Generator" content="ATutor">
625         <meta name="Keywords" content="{KEYWORDS}">
626 </head>
627 <body>{CONTENT}</body>
628 </html>';
629
630 $html_content_template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
631     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
632 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
633 <head>
634         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
635         {HEAD}
636         <title>{TITLE}</title>
637         <meta name="Generator" content="ATutor">
638         <meta name="Keywords" content="{KEYWORDS}">
639 </head>
640 <body>{CONTENT}</body>
641 </html>';
642
643 $default_html_style = ' <style type="text/css">
644         body { font-family: Verdana, Arial, Helvetica, sans-serif;}
645         a.at-term {     font-style: italic; }
646         </style>';
647         
648 //output this as header.html
649 $html_mainheader = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
650     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
651 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
652 <head>
653         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
654         <link rel="stylesheet" type="text/css" href="ims.css"/>
655         <title>{COURSE_TITLE}</title>
656 </head>
657 <body class="headerbody"><h3>{COURSE_TITLE}</h3></body></html>';
658
659
660 $html_toc = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
661     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
662 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
663 <head>
664         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
665         <link rel="stylesheet" type="text/css" href="ims.css" />
666         <title></title>
667 </head>
668 <body>{TOC}</body></html>';
669
670 // index.html
671 $html_frame = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
672    "http://www.w3.org/TR/html4/frameset.dtd">
673 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
674         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
675         <title>{COURSE_TITLE}</title>
676 </head>
677 <frameset rows="50,*,50">
678 <frame src="header.html" name="header" title="header" scrolling="no">
679         <frameset cols="25%, *" frameborder="1" framespacing="3">
680                 <frame frameborder="2" marginwidth="0" marginheight="0" src="toc.html" name="frame" title="TOC">
681                 <frame frameborder="2" src="resources/{PATH}{FIRST_ID}.html" name="body" title="{COURSE_TITLE}">
682         </frameset>
683 <frame src="footer.html" name="footer" title="footer" scrolling="no">
684         <noframes>
685                 <h1>{COURSE_TITLE}</h1>
686       <p><a href="toc.html">Table of Contents</a> | <a href="footer.html">About</a><br />
687           </p>
688   </noframes>
689 </frameset>
690 </html>';
691
692
693
694 $glossary_xml = '<?xml version="1.0" encoding="{COURSE_PRIMARY_LANGUAGE_CHARSET}"?>
695 <!--This is an ATutor Glossary terms document-->
696 <!--Created from the ATutor Content Package Generator - http://www.atutor.ca-->
697 <glossary:glossary xmlns:glossary="http://www.atutor.ca/xsd/glossary" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
698       {GLOSSARY_TERMS}
699 </glossary:glossary>
700 ';
701
702 $glossary_term_xml = '  <item>
703                 <term>{TERM}</term>
704                 <definition>{DEFINITION}</definition>
705         </item>';
706
707 $glossary_body_html = '<h2>Glossary</h2>
708         <ul>
709 {BODY}
710 </ul>';
711
712 $glossary_term_html = ' <li><a name="{ENCODED_TERM}"></a><strong>{TERM}</strong><br />
713                 {DEFINITION}<br /><br /></li>';
714
715 ?>