remove old readme
[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                                                 $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                                                     if ($use_a4a) {
371                                                             $content_files .= str_replace('{FILE}', $file, $ims_template_xml['xml']);
372                                                         }
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                                                         $filepath_array = explode('/', $content['content_path'] . $file);
378                                                     $new_filepath_array = array();
379                                                     if (in_array('..', $filepath_array)){
380                                                             while (!empty($filepath_array)){
381                                                                     $temp = array_shift($filepath_array);
382                                                                     if ($temp == '..'){
383                                                                             array_pop($new_filepath_array);
384                                                                     } else {
385                                                                             array_push($new_filepath_array, $temp);
386                                                                     }
387                                                             }
388                                                             $file = implode('/', $new_filepath_array);
389                                                     } else {
390                                                         $file = $content['content_path'] . $file;
391                             }
392                                                         $content_files .= str_replace('{FILE}', $file, $ims_template_xml['file']);
393                                                 }
394                                         }
395                                 }
396                                 /* check if this file is one of the test xml file, if so, we need to add the dependency
397                                  * Note:  The file has already been added to the archieve before this is called.
398                                  */
399                                 if (preg_match('/tests\_[0-9]+\.xml$/', $file) && !in_array($file, $test_zipped_files)){
400                                         $content_files .= str_replace('{FILE}', 'QTI/'.$file, $ims_template_xml['xml']);
401                                         $test_zipped_files[] = $file;
402                                 }
403                         }
404                         /******************************
405                          * http://www.atutor.ca/atutor/mantis/view.php?id=4383 
406                      */
407                         $my_files = array();
408
409                         /******************************/
410                         //add it to the resources section if it hasn't been added.  
411                         //Weblinks have been added.
412                         //Folders aren't resourecs, they shouldn't be added
413                         if($content['content_type']==CONTENT_TYPE_CONTENT){
414                                 $resources .= str_replace(      array('{CONTENT_ID}', '{PATH}', '{FILES}','{DEPENDENCY}'),
415                                                                                         array($content['content_id'], $content['content_path'], $content_files, $forums_dependency),
416                                                                                         $ims_template_xml['resource']); 
417                         }
418
419                         for ($i=0; $i<$depth; $i++) {
420                                 $link .= $space;
421                         }
422
423                         if ( is_array($_menu[$content['content_id']]) ) {
424                                 /* has children */
425
426                                 $html_link = '<li>'.$html_link.'<ul>';
427                                 for ($i=0; $i<$depth; $i++) {
428                                         if ($children[$i] == 1) {
429                                                 echo $space;
430                                                 //$html_link = $space.$html_link;
431                                         } else {
432                                                 echo $space;
433                                                 //$html_link = $space.$html_link;
434                                         }
435                                 }
436
437                         } else {
438                                 /* doesn't have children */
439
440                                 $html_link = '<li>'.$html_link.'</li>';
441                                 if ($counter == $num_items) {
442                                         for ($i=0; $i<$depth; $i++) {
443                                                 if ($children[$i] == 1) {
444                                                         echo $space;
445                                                         //$html_link = $space.$html_link;
446                                                 } else {
447                                                         echo $space;
448                                                         //$html_link = $space.$html_link;
449                                                 }
450                                         }
451                                 } else {
452                                         for ($i=0; $i<$depth; $i++) {
453                                                 echo $space;
454                                                 //$html_link = $space.$html_link;
455                                         }
456                                 }
457                                 $title = $space.$title;
458                         }
459
460                         echo $prefix.$link;
461 //                      echo $title;
462                         echo "\n";
463
464                         $string .= $html_link."\n";
465
466                         $depth ++;
467                         print_organizations($content['content_id'],
468                                                                 $_menu, 
469                                                                 $depth, 
470                                                                 $path.$counter.'.', 
471                                                                 $children,
472                                                                 $string);
473                         $depth--;
474
475                         $counter++;
476                         for ($i=0; $i<$depth; $i++) {
477                                 echo $space;
478                         }
479 //debug($_menu, $content['content_id']);
480 //                      if (!empty($_menu[$content['content_id']])){
481                         echo $prefix.'</item>';
482 //                      }
483                         echo "\n";
484                 }  
485
486                 $string .= '</ul>';
487                 if ($depth > 0) {
488                         $string .= '</li>';
489                 }
490
491         } 
492 }
493
494
495 //TODO***************BOLOGNA******************REMOVE ME***************/
496 /* Export Forum */
497 function print_resources_forum() {
498
499     global $forum_list, $zipfile, $resources;           //$forum_list contiene tutti i forum DISTINTI associati ai contenuti. caricato in print_organizations()
500
501     $ims_template_xml['resource_forum'] =
502
503         '<resource identifier="Forum{FORUMID}_R" type="imsdt_xmlv1p0">
504             <metadata/>
505             <file href="Forum{FORUMID}/FileDescriptorForum{FORUMID}.xml"/>
506         </resource>
507         '."\n";
508
509     foreach ($forum_list as $f){
510     // per ogni forum associato ad uno o pi� contenuti del corso viene aggiunto un elemento resource in imsmanifest.xml
511         $resources .= str_replace("{FORUMID}", $f['id'], $ims_template_xml['resource_forum']);
512
513         //viene generato il file descrittore
514         //file Descrittore con la descrzione del forum
515         $fileDesDT_D = '<?xml version="1.0" encoding="UTF-8"?>
516
517 <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">
518 <title>{TitleDiscussionTopic}</title>
519 <text texttype="text/plain">{DescriptionDiscussionTopic}</text>
520 </dt:topic>';
521
522         //file Descrittore senza la descrizione del forum
523         $fileDesDT = '<?xml version="1.0" encoding="UTF-8"?>
524 <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">
525 <title>{TitleDiscussionTopic}</title>
526 <text/>
527 </dt:topic>';
528
529                 $f['title'] = htmlspecialchars($f['title']);
530                 $f['description'] = htmlspecialchars($f['description']);
531         if (empty($f['description']))
532             $text_file_des_xml = str_replace (array('{TitleDiscussionTopic}', '{DescriptionDiscussionTopic}'), array($f['title'], $f['description']), $fileDesDT);
533         else
534             $text_file_des_xml = str_replace (array('{TitleDiscussionTopic}', '{DescriptionDiscussionTopic}'), array($f['title'], $f['description']), $fileDesDT_D);
535
536         $zipfile->add_file($text_file_des_xml,  'Forum'.$f['id'].'/'.'FileDescriptorForum'.$f['id'].'.xml');
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 ATutor IMS Common Cartridge 1.0 document-->
544 <!--Created from the ATutor 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">
551         <metadata>
552                 <schema>IMS Common Cartridge</schema>
553             <schemaversion>1.0.0</schemaversion>
554                 <lomimscc:lom>
555       <lomimscc:general>
556         <lomimscc:identifier>          
557                         <lomimscc:catalog>ATutor</lomimscc:catalog>
558                         <lomimscc:entry></lomimscc:entry>
559         </lomimscc:identifier>
560         <lomimscc:title>
561                         <lomimscc:string language="{COURSE_PRIMARY_LANGUAGE_CODE}">{COURSE_TITLE}</lomimscc:string>
562         </lomimscc:title>
563         <lomimscc:language>en</lomimscc:language>
564         <lomimscc:description> 
565                         <lomimscc:string language="{COURSE_PRIMARY_LANGUAGE_CODE}">{COURSE_DESCRIPTION}</lomimscc:string>
566         </lomimscc:description>
567         <lomimscc:keyword>
568                         <lomimscc:string language="{COURSE_PRIMARY_LANGUAGE_CODE}">{KEYWORDS}</lomimscc:string>
569         </lomimscc:keyword>
570       </lomimscc:general>
571     </lomimscc:lom>
572         </metadata>'
573 ;
574
575 $ims_template_xml['resource'] = '               <resource identifier="MANIFEST01_RESOURCE{CONTENT_ID}" type="webcontent" href="resources/{PATH}{CONTENT_ID}.html">
576                         <metadata/>
577                         <file href="resources/{PATH}{CONTENT_ID}.html"/>{FILES}
578                         {DEPENDENCY}
579                 </resource>
580 '."\n";
581 $ims_template_xml['resource_glossary'] = '              <resource identifier="MANIFEST01_RESOURCE_GLOSSARY" type="associatedcontent/imscc_xmlv1p0/learning-application-resource" href="resources/GlossaryItem/glossary.xml">
582                         <metadata/>
583                         <file href="resources/GlossaryItem/glossary.xml"/>
584                 </resource>
585 '."\n";
586 $ims_template_xml['resource_test'] = '          <resource identifier="MANIFEST01_RESOURCE_QTI{TEST_ID}" type="imsqti_xmlv1p2/imscc_xmlv1p0/assessment">
587                         <metadata/>
588                         <file href="QTI/{PATH}"/>{FILES}
589                 </resource>
590 '."\n";
591 $ims_template_xml['resource_weblink'] = '               <resource identifier="MANIFEST01_RESOURCE{CONTENT_ID}" type="imswl_xmlv1p0">
592                         <metadata/>
593                         <file href="Weblinks/{PATH}"/>
594                 </resource>
595 '."\n";
596 $ims_template_xml['file'] = '                   <file href="resources/{FILE}"/>'."\n";
597 $ims_template_xml['xml'] = '                    <file href="{FILE}"/>'."\n";
598 $ims_template_xml['glossary'] = '                       <item identifier="GlossaryItem" identifierref="MANIFEST01_RESOURCE_GLOSSARY">
599                                 <title>Glossary</title>
600                         </item>';
601 $ims_template_xml['test'] = '                   <item identifier="QTI{TEST_ID}" identifierref="MANIFEST01_RESOURCE_QTI{TEST_ID}">
602                                 <title>Test {TEST_ID}</title>
603                         </item>';
604 $ims_template_xml['file_meta'] = '                      <file href="{FILE}">
605                                 <metadata>
606                                 {FILE_META_DATA}
607                                 </metadata>
608                         </file>'."\n";
609
610 $ims_template_xml['final'] = '
611         <organizations>
612                 <organization identifier="MANIFEST01_ORG1" structure="rooted-hierarchy">
613                         <item identifier="resources">           
614                 {ORGANIZATIONS}
615                     </item>
616                 </organization>
617         </organizations>
618         <resources>
619 {RESOURCES}
620         </resources>
621 </manifest>';
622
623 $html_template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
624     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
625 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
626 <head>
627         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
628         <title>{TITLE}</title>
629         <meta name="Generator" content="ATutor">
630         <meta name="Keywords" content="{KEYWORDS}">
631 </head>
632 <body>{CONTENT}</body>
633 </html>';
634
635 $html_content_template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
636     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
637 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
638 <head>
639         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
640         {HEAD}
641         <title>{TITLE}</title>
642         <meta name="Generator" content="ATutor">
643         <meta name="Keywords" content="{KEYWORDS}">
644 </head>
645 <body>{CONTENT}</body>
646 </html>';
647
648 $default_html_style = ' <style type="text/css">
649         body { font-family: Verdana, Arial, Helvetica, sans-serif;}
650         a.at-term {     font-style: italic; }
651         </style>';
652         
653 //output this as header.html
654 $html_mainheader = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
655     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
656 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
657 <head>
658         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
659         <link rel="stylesheet" type="text/css" href="ims.css"/>
660         <title>{COURSE_TITLE}</title>
661 </head>
662 <body class="headerbody"><h3>{COURSE_TITLE}</h3></body></html>';
663
664
665 $html_toc = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
666     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
667 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
668 <head>
669         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
670         <link rel="stylesheet" type="text/css" href="ims.css" />
671         <title></title>
672 </head>
673 <body>{TOC}</body></html>';
674
675 // index.html
676 $html_frame = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
677    "http://www.w3.org/TR/html4/frameset.dtd">
678 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{COURSE_PRIMARY_LANGUAGE_CODE}" lang="{COURSE_PRIMARY_LANGUAGE_CODE}">
679         <meta http-equiv="Content-Type" content="text/html; charset={COURSE_PRIMARY_LANGUAGE_CHARSET}" />
680         <title>{COURSE_TITLE}</title>
681 </head>
682 <frameset rows="50,*,50">
683 <frame src="header.html" name="header" title="header" scrolling="no">
684         <frameset cols="25%, *" frameborder="1" framespacing="3">
685                 <frame frameborder="2" marginwidth="0" marginheight="0" src="toc.html" name="frame" title="TOC">
686                 <frame frameborder="2" src="resources/{PATH}{FIRST_ID}.html" name="body" title="{COURSE_TITLE}">
687         </frameset>
688 <frame src="footer.html" name="footer" title="footer" scrolling="no">
689         <noframes>
690                 <h1>{COURSE_TITLE}</h1>
691       <p><a href="toc.html">Table of Contents</a> | <a href="footer.html">About</a><br />
692           </p>
693   </noframes>
694 </frameset>
695 </html>';
696
697
698
699 $glossary_xml = '<?xml version="1.0" encoding="{COURSE_PRIMARY_LANGUAGE_CHARSET}"?>
700 <!--This is an ATutor Glossary terms document-->
701 <!--Created from the ATutor Content Package Generator - http://www.atutor.ca-->
702 <glossary:glossary xmlns:glossary="http://www.atutor.ca/xsd/glossary" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
703       {GLOSSARY_TERMS}
704 </glossary:glossary>
705 ';
706
707 $glossary_term_xml = '  <item>
708                 <term>{TERM}</term>
709                 <definition>{DEFINITION}</definition>
710         </item>';
711
712 $glossary_body_html = '<h2>Glossary</h2>
713         <ul>
714 {BODY}
715 </ul>';
716
717 $glossary_term_html = ' <li><a name="{ENCODED_TERM}"></a><strong>{TERM}</strong><br />
718                 {DEFINITION}<br /><br /></li>';
719
720 ?>