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