9f73d3a1a3f2e81db059d5b612ee98b201a50b72
[atutor.git] / docs / 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                                                 $zipfile->add_file(@file_get_contents($file_path), $zip_path, $file_info['mtime']);
318                                         }
319                                 }
320                                 //a4a secondary files have mapping, save the ones that we want in order to add the tag in
321                                 $a4a_secondary_files = array();
322                                 foreach ($a4a_xml_array as $a4a_filename=>$a4a_filearray){
323                                         if (preg_match('/(.*)\sto\s(.*)/', $a4a_filename, $matches)){
324                                                 //save the actual file name
325                                                 $a4a_secondary_files[$matches[1]][] = $a4a_filename;    //values are holders
326                                         }
327                                 }
328
329                 /**
330                  * A hack to fix youtube links.  one uses youtube.com?watch=xxx, the other uses youtube.com/v/xxx,
331                  * in which both points to the same file, but needed different links to play.
332                  * in A4a, these youtube links are always stored as "?watch=xxx", however, output.inc.php converted
333                  * these to /v/xxx for rendering purposes.  Convert it back if youtube exists in url.
334                  * http://atutor.ca/atutor/mantis/view.php?id=4548
335                  * @harris 9/30/2010
336                  */
337                 if (strpos($file, 'youtube.com')!==false){
338                     //apply the conversion before linking the alternatives. Otherwise it will not be added.
339                     $file = convert_youtube_playURL_to_watchURL($file);
340                 }
341                                 // If this file has a4a alternatives, link it.
342                                 if (isset($a4a_xml_array[$file]) || isset($a4a_secondary_files[$file])){
343                                         //if this is an array, meaning that it has more than 1 alternatives, print all
344                                         if (substr($file, 0, 7) == 'http://' || substr($file, 0, 8) == 'https://') {
345                                                 $name_in_file_meta = $file;
346                                         } else {
347                                                 $name_in_file_meta = 'resources/'.$content['content_path'] . $file;
348                                         }
349                                         if (is_array($a4a_secondary_files[$file])){
350                                                 $all_secondary_files_md = '';   //reinitialize string to null
351                                                 foreach ($a4a_secondary_files[$file] as $v){
352                                                         foreach($a4a_xml_array[$v] as $v2){
353                                                                 $all_secondary_files_md .= $v2; //all the meta data             
354                                                         }                                                               
355                                                 }
356                                                 $content_files .= str_replace(  array('{FILE}', '{FILE_META_DATA}'), 
357                                                 array($name_in_file_meta, $all_secondary_files_md), 
358                                                 $ims_template_xml['file_meta']);
359                                         } else {
360                                                 $content_files .= str_replace(  array('{FILE}', '{FILE_META_DATA}'), 
361                                                 array($name_in_file_meta, $a4a_xml_array[$file]), 
362                                                 $ims_template_xml['file_meta']);
363                                         }
364                                 } else {
365                                         //if this file is in the test array, add an extra link to the direct file, 
366                                         if (!empty($test_zipped_files) && in_array($file_path, $test_zipped_files)){
367                                                 $content_files .= str_replace('{FILE}', $file, $ims_template_xml['file']);
368                                         } else {
369                                                 if (preg_match('/^http[s]?\:/', $file) == 1){
370                                                         $content_files .= str_replace('{FILE}', $file, $ims_template_xml['xml']);
371                                                 } elseif (file_exists($file_path) && is_file($file_path)) {
372                                                         //http://www.atutor.ca/atutor/mantis/view.php?id=4313
373                                                         //relative link that goes beyond get.php shouldn't be added
374                                                         //relative link that does not exist shouldn't be added.
375                                                         $filepath_array = explode('/', $content['content_path'] . $file);
376                                                     $new_filepath_array = array();
377                                                     if (in_array('..', $filepath_array)){
378                                                             while (!empty($filepath_array)){
379                                                                     $temp = array_shift($filepath_array);
380                                                                     if ($temp == '..'){
381                                                                             array_pop($new_filepath_array);
382                                                                     } else {
383                                                                             array_push($new_filepath_array, $temp);
384                                                                     }
385                                                             }
386                                                             $file = implode('/', $new_filepath_array);
387                                                     } else {
388                                                         $file = $content['content_path'] . $file;
389                             }
390                                                         $content_files .= str_replace('{FILE}', $file, $ims_template_xml['file']);
391                                                 }
392                                         }
393                                 }
394                                 /* check if this file is one of the test xml file, if so, we need to add the dependency
395                                  * Note:  The file has already been added to the archieve before this is called.
396                                  */
397                                 if (preg_match('/tests\_[0-9]+\.xml$/', $file) && !in_array($file, $test_zipped_files)){
398                                         $content_files .= str_replace('{FILE}', 'QTI/'.$file, $ims_template_xml['xml']);
399                                         $test_zipped_files[] = $file;
400                                 }
401                         }
402                         /******************************
403                          * http://www.atutor.ca/atutor/mantis/view.php?id=4383 
404                      */
405                         $my_files = array();
406
407                         /******************************/
408                         //add it to the resources section if it hasn't been added.  
409                         //Weblinks have been added.
410                         //Folders aren't resourecs, they shouldn't be added
411                         if($content['content_type']==CONTENT_TYPE_CONTENT){
412                                 $resources .= str_replace(      array('{CONTENT_ID}', '{PATH}', '{FILES}','{DEPENDENCY}'),
413                                                                                         array($content['content_id'], $content['content_path'], $content_files, $forums_dependency),
414                                                                                         $ims_template_xml['resource']); 
415                         }
416
417                         for ($i=0; $i<$depth; $i++) {
418                                 $link .= $space;
419                         }
420
421                         if ( is_array($_menu[$content['content_id']]) ) {
422                                 /* has children */
423
424                                 $html_link = '<li>'.$html_link.'<ul>';
425                                 for ($i=0; $i<$depth; $i++) {
426                                         if ($children[$i] == 1) {
427                                                 echo $space;
428                                                 //$html_link = $space.$html_link;
429                                         } else {
430                                                 echo $space;
431                                                 //$html_link = $space.$html_link;
432                                         }
433                                 }
434
435                         } else {
436                                 /* doesn't have children */
437
438                                 $html_link = '<li>'.$html_link.'</li>';
439                                 if ($counter == $num_items) {
440                                         for ($i=0; $i<$depth; $i++) {
441                                                 if ($children[$i] == 1) {
442                                                         echo $space;
443                                                         //$html_link = $space.$html_link;
444                                                 } else {
445                                                         echo $space;
446                                                         //$html_link = $space.$html_link;
447                                                 }
448                                         }
449                                 } else {
450                                         for ($i=0; $i<$depth; $i++) {
451                                                 echo $space;
452                                                 //$html_link = $space.$html_link;
453                                         }
454                                 }
455                                 $title = $space.$title;
456                         }
457
458                         echo $prefix.$link;
459 //                      echo $title;
460                         echo "\n";
461
462                         $string .= $html_link."\n";
463
464                         $depth ++;
465                         print_organizations($content['content_id'],
466                                                                 $_menu, 
467                                                                 $depth, 
468                                                                 $path.$counter.'.', 
469                                                                 $children,
470                                                                 $string);
471                         $depth--;
472
473                         $counter++;
474                         for ($i=0; $i<$depth; $i++) {
475                                 echo $space;
476                         }
477 //debug($_menu, $content['content_id']);
478 //                      if (!empty($_menu[$content['content_id']])){
479                         echo $prefix.'</item>';
480 //                      }
481                         echo "\n";
482                 }  
483
484                 $string .= '</ul>';
485                 if ($depth > 0) {
486                         $string .= '</li>';
487                 }
488
489         } 
490 }
491
492
493 //TODO***************BOLOGNA******************REMOVE ME***************/
494 /* Export Forum */
495 function print_resources_forum() {
496
497     global $forum_list, $zipfile, $resources;           //$forum_list contiene tutti i forum DISTINTI associati ai contenuti. caricato in print_organizations()
498
499     $ims_template_xml['resource_forum'] =
500
501         '<resource identifier="Forum{FORUMID}_R" type="imsdt_xmlv1p0">
502             <metadata/>
503             <file href="Forum{FORUMID}/FileDescriptorForum{FORUMID}.xml"/>
504         </resource>
505         '."\n";
506
507     foreach ($forum_list as $f){
508     // per ogni forum associato ad uno o pi� contenuti del corso viene aggiunto un elemento resource in imsmanifest.xml
509         $resources .= str_replace("{FORUMID}", $f['id'], $ims_template_xml['resource_forum']);
510
511         //viene generato il file descrittore
512         //file Descrittore con la descrzione del forum
513         $fileDesDT_D = '<?xml version="1.0" encoding="UTF-8"?>
514
515 <dt:topic xmlns:dt="http://www.imsglobal.org/xsd/imsdt_v1p0" 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">
516 <title>{TitleDiscussionTopic}</title>
517 <text texttype="text/plain">{DescriptionDiscussionTopic}</text>
518 </dt:topic>';
519
520         //file Descrittore senza la descrizione del forum
521         $fileDesDT = '<?xml version="1.0" encoding="UTF-8"?>
522 <dt:topic xmlns:dt="http://www.imsglobal.org/xsd/imsdt_v1p0" 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">
523 <title>{TitleDiscussionTopic}</title>
524 <text/>
525 </dt:topic>';
526
527                 $f['title'] = htmlspecialchars($f['title']);
528                 $f['description'] = htmlspecialchars($f['description']);
529         if (empty($f['description']))
530             $text_file_des_xml = str_replace (array('{TitleDiscussionTopic}', '{DescriptionDiscussionTopic}'), array($f['title'], $f['description']), $fileDesDT);
531         else
532             $text_file_des_xml = str_replace (array('{TitleDiscussionTopic}', '{DescriptionDiscussionTopic}'), array($f['title'], $f['description']), $fileDesDT_D);
533
534         $zipfile->add_file($text_file_des_xml,  'Forum'.$f['id'].'/'.'FileDescriptorForum'.$f['id'].'.xml');
535     }
536     //$zipfile->add_file(file_get_contents('../../images/home-forums_sm.png'),  'resources/home-forums_sm.png');
537 }
538
539
540 $ims_template_xml['header'] = '<?xml version="1.0" encoding="{COURSE_PRIMARY_LANGUAGE_CHARSET}"?>
541 <!--This is an ATutor IMS Common Cartridge 1.0 document-->
542 <!--Created from the ATutor Content Package Generator - http://www.atutor.ca-->
543 <manifest identifier="MANIFEST-'.md5($cid).'" 
544 xmlns="http://www.imsglobal.org/xsd/imscc/imscp_v1p1" 
545 xmlns:imsmd="http://ltsc.ieee.org/xsd/imscc/LOM" 
546 xmlns:lomimscc="http://ltsc.ieee.org/xsd/imscc/LOM" 
547 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
548 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">
549         <metadata>
550                 <schema>IMS Common Cartridge</schema>
551             <schemaversion>1.0.0</schemaversion>
552                 <lomimscc:lom>
553       <lomimscc:general>
554         <lomimscc:identifier>          
555                         <lomimscc:catalog>ATutor</lomimscc:catalog>
556                         <lomimscc:entry></lomimscc:entry>
557         </lomimscc:identifier>
558         <lomimscc:title>
559                         <lomimscc:string language="{COURSE_PRIMARY_LANGUAGE_CODE}">{COURSE_TITLE}</lomimscc:string>
560         </lomimscc:title>
561         <lomimscc:language>en</lomimscc:language>
562         <lomimscc:description> 
563                         <lomimscc:string language="{COURSE_PRIMARY_LANGUAGE_CODE}">{COURSE_DESCRIPTION}</lomimscc:string>
564         </lomimscc:description>
565         <lomimscc:keyword>
566                         <lomimscc:string language="{COURSE_PRIMARY_LANGUAGE_CODE}">{KEYWORDS}</lomimscc:string>
567         </lomimscc:keyword>
568       </lomimscc:general>
569     </lomimscc:lom>
570         </metadata>'
571 ;
572
573 $ims_template_xml['resource'] = '               <resource identifier="MANIFEST01_RESOURCE{CONTENT_ID}" type="webcontent" href="resources/{PATH}{CONTENT_ID}.html">
574                         <metadata/>
575                         <file href="resources/{PATH}{CONTENT_ID}.html"/>{FILES}
576                         {DEPENDENCY}
577                 </resource>
578 '."\n";
579 $ims_template_xml['resource_glossary'] = '              <resource identifier="MANIFEST01_RESOURCE_GLOSSARY" type="associatedcontent/imscc_xmlv1p0/learning-application-resource" href="resources/GlossaryItem/glossary.xml">
580                         <metadata/>
581                         <file href="resources/GlossaryItem/glossary.xml"/>
582                 </resource>
583 '."\n";
584 $ims_template_xml['resource_test'] = '          <resource identifier="MANIFEST01_RESOURCE_QTI{TEST_ID}" type="imsqti_xmlv1p2/imscc_xmlv1p0/assessment">
585                         <metadata/>
586                         <file href="QTI/{PATH}"/>{FILES}
587                 </resource>
588 '."\n";
589 $ims_template_xml['resource_weblink'] = '               <resource identifier="MANIFEST01_RESOURCE{CONTENT_ID}" type="imswl_xmlv1p0">
590                         <metadata/>
591                         <file href="Weblinks/{PATH}"/>
592                 </resource>
593 '."\n";
594 $ims_template_xml['file'] = '                   <file href="resources/{FILE}"/>'."\n";
595 $ims_template_xml['xml'] = '                    <file href="{FILE}"/>'."\n";
596 $ims_template_xml['glossary'] = '                       <item identifier="GlossaryItem" identifierref="MANIFEST01_RESOURCE_GLOSSARY">
597                                 <title>Glossary</title>
598                         </item>';
599 $ims_template_xml['test'] = '                   <item identifier="QTI{TEST_ID}" identifierref="MANIFEST01_RESOURCE_QTI{TEST_ID}">
600                                 <title>Test {TEST_ID}</title>
601                         </item>';
602 $ims_template_xml['file_meta'] = '                      <file href="{FILE}">
603                                 <metadata>
604                                 {FILE_META_DATA}
605                                 </metadata>
606                         </file>'."\n";
607
608 $ims_template_xml['final'] = '
609         <organizations>
610                 <organization identifier="MANIFEST01_ORG1" structure="rooted-hierarchy">
611                         <item identifier="resources">           
612                 {ORGANIZATIONS}
613                     </item>
614                 </organization>
615         </organizations>
616         <resources>
617 {RESOURCES}
618         </resources>
619 </manifest>';
620
621 $html_template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
622     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
623 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
624 <head>
625         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
626         <title>{TITLE}</title>
627         <meta name="Generator" content="ATutor">
628         <meta name="Keywords" content="{KEYWORDS}">
629 </head>
630 <body>{CONTENT}</body>
631 </html>';
632
633 $html_content_template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
634     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
635 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
636 <head>
637         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
638         {HEAD}
639         <title>{TITLE}</title>
640         <meta name="Generator" content="ATutor">
641         <meta name="Keywords" content="{KEYWORDS}">
642 </head>
643 <body>{CONTENT}</body>
644 </html>';
645
646 $default_html_style = ' <style type="text/css">
647         body { font-family: Verdana, Arial, Helvetica, sans-serif;}
648         a.at-term {     font-style: italic; }
649         </style>';
650         
651 //output this as header.html
652 $html_mainheader = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
653     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
654 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
655 <head>
656         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
657         <link rel="stylesheet" type="text/css" href="ims.css"/>
658         <title>{COURSE_TITLE}</title>
659 </head>
660 <body class="headerbody"><h3>{COURSE_TITLE}</h3></body></html>';
661
662
663 $html_toc = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
664     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
665 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
666 <head>
667         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
668         <link rel="stylesheet" type="text/css" href="ims.css" />
669         <title></title>
670 </head>
671 <body>{TOC}</body></html>';
672
673 // index.html
674 $html_frame = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
675    "http://www.w3.org/TR/html4/frameset.dtd">
676 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
677         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
678         <title>{COURSE_TITLE}</title>
679 </head>
680 <frameset rows="50,*,50">
681 <frame src="header.html" name="header" title="header" scrolling="no">
682         <frameset cols="25%, *" frameborder="1" framespacing="3">
683                 <frame frameborder="2" marginwidth="0" marginheight="0" src="toc.html" name="frame" title="TOC">
684                 <frame frameborder="2" src="resources/{PATH}{FIRST_ID}.html" name="body" title="{COURSE_TITLE}">
685         </frameset>
686 <frame src="footer.html" name="footer" title="footer" scrolling="no">
687         <noframes>
688                 <h1>{COURSE_TITLE}</h1>
689       <p><a href="toc.html">Table of Contents</a> | <a href="footer.html">About</a><br />
690           </p>
691   </noframes>
692 </frameset>
693 </html>';
694
695
696
697 $glossary_xml = '<?xml version="1.0" encoding="{COURSE_PRIMARY_LANGUAGE_CHARSET}"?>
698 <!--This is an ATutor Glossary terms document-->
699 <!--Created from the ATutor Content Package Generator - http://www.atutor.ca-->
700 <glossary:glossary xmlns:glossary="http://www.atutor.ca/xsd/glossary" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
701       {GLOSSARY_TERMS}
702 </glossary:glossary>
703 ';
704
705 $glossary_term_xml = '  <item>
706                 <term>{TERM}</term>
707                 <definition>{DEFINITION}</definition>
708         </item>';
709
710 $glossary_body_html = '<h2>Glossary</h2>
711         <ul>
712 {BODY}
713 </ul>';
714
715 $glossary_term_html = ' <li><a name="{ENCODED_TERM}"></a><strong>{TERM}</strong><br />
716                 {DEFINITION}<br /><br /></li>';
717
718 ?>