*/ if (class_exists('ZipArchive')) { $zip = new ZipArchive(); if ($zip->open("../course/files/qimages.zip", ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) === TRUE) { foreach ($imgfiles as $file) { $zip->addFile($file, basename($file)); } } $zip->close(); } if (class_exists('ZipArchive')) { $zip = new ZipArchive(); if ($zip->open("../course/files/coursefilepack{$cid}.zip", ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) === TRUE) { foreach ($coursefiles as $file) { if ($GLOBALS['filehandertypecfiles'] == 's3') { copycoursefile($file, realpath("../course/files") . DIRECTORY_SEPARATOR . basename($file)); $zip->addFile("../course/files/" . basename($file), basename($file)); } else { $zip->addFile("../course/files/{$file}", basename($file)); } } } $zip->close(); } exit; } else { //STEP 1 DATA PROCESSING, INITIAL LOAD $query = "SELECT itemorder FROM imas_courses WHERE id='{$cid}'"; $result = mysql_query($query) or die("Query failed : " . mysql_error()); $items = unserialize(mysql_result($result, 0, 0)); $ids = array();
function getorg($it, $parent, &$res, $ind) { global $iteminfo, $newdir, $installname, $urlmode, $linktype, $urlmode, $imasroot, $ccnt, $module_meta, $htmldir, $filedir, $toplevelitems, $inmodule; global $usechecked, $checked; $out = ''; foreach ($it as $k => $item) { $canvout = ''; if (is_array($item)) { if (!$usechecked || array_search($parent . '-' . ($k + 1), $checked) !== FALSE) { if (strlen($ind) > 2) { $canvout .= '<item identifier="BLOCK' . $item['id'] . '">' . "\n"; $canvout .= '<content_type>ContextModuleSubHeader</content_type>'; $canvout .= '<title>' . htmlentities($item['name'], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>"; $ccnt++; $module_meta .= $canvout; } else { if ($inmodule) { $module_meta .= '</items></module>'; } $inmodule = true; $module_meta .= '<module identifier="BLOCK' . $item['id'] . '"> <title>' . htmlentities($item['name'], ENT_XML1, 'UTF-8', false) . '</title> <items>'; } $out .= $ind . '<item identifier="BLOCK' . $item['id'] . '">' . "\n"; $out .= $ind . ' <title>' . htmlentities($item['name'], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $out .= $ind . getorg($item['items'], $parent . '-' . ($k + 1), $res, $ind . ' '); $out .= $ind . '</item>' . "\n"; } else { $out .= $ind . getorg($item['items'], $parent . '-' . ($k + 1), $res, $ind . ' '); } } else { if ($usechecked && array_search($item, $checked) === FALSE) { continue; } if ($iteminfo[$item][0] == 'InlineText') { $query = "SELECT title,text,fileorder FROM imas_inlinetext WHERE id='{$iteminfo[$item][1]}'"; $r = mysql_query($query) or die("Query failed : " . mysql_error()); $row = mysql_fetch_row($r); if ($row[2] != '') { $files = explode(',', $row[2]); $query = "SELECT id,description,filename FROM imas_instr_files WHERE itemid='{$iteminfo[$item][1]}'"; $result = mysql_query($query) or die("Query failed : " . mysql_error()); $filesout = array(); while ($r = mysql_fetch_row($result)) { //if s3 filehandler, do files as weblinks rather than including the file itself if ($GLOBALS['filehandertypecfiles'] == 's3') { $r[2] = getcoursefileurl($r[2]); } else { //copy("../course/files/{$r[2]}",$newdir.'/'.$r[2]); copycoursefile($r[2], $newdir . '/' . $filedir . basename($r[2])); $resitem = '<resource href="' . $filedir . basename($r[2]) . '" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'file' . $r[0] . '" type="webcontent">' . "\n"; $resitem .= ' <file href="' . $filedir . basename($r[2]) . '" />' . "\n"; $resitem .= '</resource>'; $res[] = $resitem; } $filesout[$r[0]] = array($r[1], $r[2]); } } $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $out .= $ind . ' <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $out .= $ind . '</item>' . "\n"; $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $canvout .= '<content_type>WikiPage</content_type>'; $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>'; $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>"; $ccnt++; $fp = fopen($newdir . '/' . $htmldir . 'inlinetext' . $iteminfo[$item][1] . '.html', 'w'); fwrite($fp, '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">'); fwrite($fp, '<title>' . htmlentities($row[0]) . '</title>'); fwrite($fp, '<meta name="identifier" content="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '"/>'); if ($linktype == "canvas") { fwrite($fp, '<meta name="editing_roles" content="teachers"/>'); } fwrite($fp, "</head><body>"); fwrite($fp, filtercapture($row[1], $res)); if ($row[2] != '') { fwrite($fp, '<ul>'); foreach ($files as $f) { if ($GLOBALS['filehandertypecfiles'] == 's3') { fwrite($fp, '<li><a href="' . $filesout[$f][1] . '">' . htmlentities($filesout[$f][0]) . '</a></li>'); } else { fwrite($fp, '<li><a href="' . $filedir . basename($filesout[$f][1]) . '">' . htmlentities($filesout[$f][0]) . '</a></li>'); } } fwrite($fp, '</ul>'); } fwrite($fp, '</body></html>'); fclose($fp); $resitem = '<resource href="' . $htmldir . 'inlinetext' . $iteminfo[$item][1] . '.html" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="webcontent">' . "\n"; $resitem .= ' <file href="' . $htmldir . 'inlinetext' . $iteminfo[$item][1] . '.html" />' . "\n"; $resitem .= '</resource>'; $res[] = $resitem; } else { if ($iteminfo[$item][0] == 'LinkedText') { $query = "SELECT title,text,summary FROM imas_linkedtext WHERE id='{$iteminfo[$item][1]}'"; $r = mysql_query($query) or die("Query failed : " . mysql_error()); $row = mysql_fetch_row($r); //if s3 filehandler, do files as weblinks rather than including the file itself if ($GLOBALS['filehandertypecfiles'] == 's3' && substr(strip_tags($row[1]), 0, 5) == "file:") { $row[1] = getcoursefileurl(trim(substr(strip_tags($row[1]), 5))); } if (substr($row[1], 0, 4) == "http" && strpos(trim($row[1]), " ") === false) { //is a web link $alink = trim($row[1]); $fp = fopen($newdir . '/weblink' . $iteminfo[$item][1] . '.xml', 'w'); fwrite($fp, '<webLink xmlns="http://www.imsglobal.org/xsd/imsccv1p1/imswl_v1p1">'); fwrite($fp, ' <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>'); fwrite($fp, ' <url href="' . htmlentities($alink, ENT_XML1, 'UTF-8', false) . '" target="_blank"/>'); fwrite($fp, '</webLink>'); fclose($fp); $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $out .= $ind . ' <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $out .= $ind . '</item>' . "\n"; $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $canvout .= '<content_type>ExternalUrl</content_type>'; $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>'; $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $canvout .= '<url>' . htmlentities($alink, ENT_XML1, 'UTF-8', false) . '</url>'; $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>"; $ccnt++; $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="imswl_xmlv1p1">' . "\n"; $resitem .= ' <file href="weblink' . $iteminfo[$item][1] . '.xml" />' . "\n"; $resitem .= '</resource>'; $res[] = $resitem; } else { if (substr(strip_tags($row[1]), 0, 5) == "file:") { //is a file $filename = trim(substr(strip_tags($row[1]), 5)); //copy("../course/files/$filename",$newdir.'/'.$filedir.$filename); copycoursefile($filename, $newdir . '/' . $filedir . basename($filename)); $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $out .= $ind . ' <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $out .= $ind . '</item>' . "\n"; $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $canvout .= '<content_type>Attachment</content_type>'; $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>'; $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>"; $ccnt++; $resitem = '<resource href="' . $filedir . basename($filename) . '" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="webcontent">' . "\n"; $resitem .= ' <file href="' . $filedir . basename($filename) . '" />' . "\n"; $resitem .= '</resource>'; $res[] = $resitem; } else { //is text $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $out .= $ind . ' <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $out .= $ind . '</item>' . "\n"; $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $canvout .= '<content_type>WikiPage</content_type>'; $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>'; $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>"; $ccnt++; $fp = fopen($newdir . '/' . $htmldir . 'linkedtext' . $iteminfo[$item][1] . '.html', 'w'); fwrite($fp, '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">'); fwrite($fp, '<title>' . htmlentities($row[0]) . '</title>'); fwrite($fp, '<meta name="identifier" content="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '"/>'); if ($linktype == "canvas") { fwrite($fp, '<meta name="editing_roles" content="teachers"/>'); } fwrite($fp, "</head><body>"); fwrite($fp, filtercapture($row[1], $res)); fwrite($fp, '</body></html>'); fclose($fp); $resitem = '<resource href="' . $htmldir . 'linkedtext' . $iteminfo[$item][1] . '.html" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="webcontent">' . "\n"; $resitem .= ' <file href="' . $htmldir . 'linkedtext' . $iteminfo[$item][1] . '.html" />' . "\n"; $resitem .= '</resource>'; $res[] = $resitem; } } } else { if ($iteminfo[$item][0] == 'Forum') { $query = "SELECT name,description FROM imas_forums WHERE id='{$iteminfo[$item][1]}'"; $r = mysql_query($query) or die("Query failed : " . mysql_error()); $row = mysql_fetch_row($r); $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $out .= $ind . ' <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $out .= $ind . '</item>' . "\n"; $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $canvout .= '<content_type>DiscussionTopic</content_type>'; $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>'; $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>"; $ccnt++; $fp = fopen($newdir . '/forum' . $iteminfo[$item][1] . '.xml', 'w'); fwrite($fp, '<topic xmlns="http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1">'); fwrite($fp, ' <title >' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>'); fwrite($fp, ' <text texttype="text/html">' . htmlentities(filtercapture($row[1], $res)) . '</text>'); fwrite($fp, '</topic>'); fclose($fp); if ($linktype == 'canvas') { $fp = fopen($newdir . '/RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta.xml', 'w'); fwrite($fp, '<?xml version="1.0" encoding="UTF-8"?> <topicMeta xsi:schemaLocation="http://canvas.instructure.com/xsd/cccv1p0 http://canvas.instructure.com/xsd/cccv1p0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta" xmlns="http://canvas.instructure.com/xsd/cccv1p0"> <topic_id>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</topic_id> <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title> <type>topic</type> </topicMeta>'); fclose($fp); $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta" type="associatedcontent/imscc_xmlv1p1/learning-application-resource" href="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta.xml">' . "\n"; $resitem .= ' <file href="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta.xml" />' . "\n"; $resitem .= '</resource>'; $res[] = $resitem; $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="imsdt_xmlv1p1">' . "\n"; $resitem .= ' <file href="forum' . $iteminfo[$item][1] . '.xml" />' . "\n"; $resitem .= ' <dependency identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta"/>'; $resitem .= '</resource>'; } else { $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="imsdt_xmlv1p1">' . "\n"; $resitem .= ' <file href="forum' . $iteminfo[$item][1] . '.xml" />' . "\n"; $resitem .= '</resource>'; } $res[] = $resitem; } else { if ($iteminfo[$item][0] == 'Assessment') { $query = "SELECT name,summary,defpoints,itemorder FROM imas_assessments WHERE id='{$iteminfo[$item][1]}'"; $r = mysql_query($query) or die("Query failed : " . mysql_error()); $row = mysql_fetch_row($r); //echo "encoding {$row[0]} as ".htmlentities($row[0],ENT_XML1,'UTF-8',false).'<br/>'; $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $out .= $ind . ' <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $out .= $ind . '</item>' . "\n"; if ($linktype == 'canvas') { $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $canvout .= '<content_type>Assignment</content_type>'; $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>'; $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>"; $ccnt++; $aitems = explode(',', $row[3]); foreach ($aitems as $k => $v) { if (strpos($v, '~') !== FALSE) { $sub = explode('~', $v); if (strpos($sub[0], '|') === false) { //backwards compat $aitems[$k] = $sub[0]; $aitemcnt[$k] = 1; } else { $grpparts = explode('|', $sub[0]); $aitems[$k] = $sub[1]; $aitemcnt[$k] = $grpparts[0]; } } else { $aitemcnt[$k] = 1; } } $query = "SELECT points,id FROM imas_questions WHERE assessmentid='{$iteminfo[$item][1]}'"; $result2 = mysql_query($query) or die("Query failed : {$query}: " . mysql_error()); $totalpossible = 0; while ($r = mysql_fetch_row($result2)) { if (($k = array_search($r[1], $aitems)) !== false) { //only use first item from grouped questions for total pts if ($r[0] == 9999) { $totalpossible += $aitemcnt[$k] * $row[2]; //use defpoints } else { $totalpossible += $aitemcnt[$k] * $r[0]; //use points from question } } } mkdir($newdir . '/assn' . $iteminfo[$item][1]); $fp = fopen($newdir . '/assn' . $iteminfo[$item][1] . '/assignment_settings.xml', 'w'); fwrite($fp, '<assignment xmlns="http://canvas.instructure.com/xsd/cccv1p0" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://canvas.instructure.com/xsd/cccv1p0 http://canvas.instructure.com/xsd/cccv1p0.xsd">'); fwrite($fp, '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>'); fwrite($fp, '<points_possible>' . $totalpossible . '</points_possible>'); fwrite($fp, '<grading_type>points</grading_type>'); fwrite($fp, '<assignment_group_identifierref>assngroup</assignment_group_identifierref>'); fwrite($fp, '<submission_types>external_tool</submission_types>'); fwrite($fp, '<external_tool_url>' . $urlmode . $_SERVER['HTTP_HOST'] . $imasroot . '/bltilaunch.php?custom_place_aid=' . $iteminfo[$item][1] . '</external_tool_url>'); fwrite($fp, '</assignment>'); fclose($fp); $fp = fopen($newdir . '/assn' . $iteminfo[$item][1] . '/assignmenthtml' . $iteminfo[$item][1] . '.html', 'w'); fwrite($fp, '<html><body> </body></html>'); fclose($fp); $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="associatedcontent/imscc_xmlv1p1/learning-application-resource" href="assn' . $iteminfo[$item][1] . '/assignmenthtml' . $iteminfo[$item][1] . '.html">' . "\n"; $resitem .= ' <file href="assn' . $iteminfo[$item][1] . '/assignmenthtml' . $iteminfo[$item][1] . '.html" />' . "\n"; $resitem .= ' <file href="assn' . $iteminfo[$item][1] . '/assignment_settings.xml" />' . "\n"; $resitem .= '</resource>'; $res[] = $resitem; } else { $fp = fopen($newdir . '/blti' . $iteminfo[$item][1] . '.xml', 'w'); fwrite($fp, '<cartridge_basiclti_link xmlns="http://www.imsglobal.org/xsd/imslticc_v1p0" xmlns:blti="http://www.imsglobal.org/xsd/imsbasiclti_v1p0" xmlns:lticm ="http://www.imsglobal.org/xsd/imslticm_v1p0" xmlns:lticp ="http://www.imsglobal.org/xsd/imslticp_v1p0">'); fwrite($fp, '<blti:title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</blti:title>'); fwrite($fp, '<blti:description>' . htmlentities(html_entity_decode($row[1]), ENT_XML1, 'UTF-8', false) . '</blti:description>'); if ($linktype == 'url') { $urladd = '?custom_place_aid=' . $iteminfo[$item][1]; } else { fwrite($fp, '<blti:custom><lticm:property name="place_aid">' . $iteminfo[$item][1] . '</lticm:property></blti:custom>'); $urladd = ''; } fwrite($fp, '<blti:launch_url>http://' . $_SERVER['HTTP_HOST'] . $imasroot . '/bltilaunch.php' . $urladd . '</blti:launch_url>'); if ($urlmode == 'https://') { fwrite($fp, '<blti:secure_launch_url>https://' . $_SERVER['HTTP_HOST'] . $imasroot . '/bltilaunch.php' . $urladd . '</blti:secure_launch_url>'); } fwrite($fp, '<blti:vendor><lticp:code>IMathAS</lticp:code><lticp:name>' . $installname . '</lticp:name></blti:vendor>'); fwrite($fp, '</cartridge_basiclti_link>'); fclose($fp); $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="imsbasiclti_xmlv1p0">' . "\n"; $resitem .= ' <file href="blti' . $iteminfo[$item][1] . '.xml" />' . "\n"; $resitem .= '</resource>'; $res[] = $resitem; } } else { if ($iteminfo[$item][0] == 'Wiki') { $query = "SELECT name FROM imas_wikis WHERE id='{$iteminfo[$item][1]}'"; $r = mysql_query($query) or die("Query failed : " . mysql_error()); $row = mysql_fetch_row($r); $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $out .= $ind . ' <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $out .= $ind . '</item>' . "\n"; $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n"; $canvout .= '<content_type>WikiPage</content_type>'; $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>'; $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n"; $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>"; $ccnt++; $fp = fopen($newdir . '/' . $htmldir . 'wikitext' . $iteminfo[$item][1] . '.html', 'w'); fwrite($fp, '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">'); fwrite($fp, '<title>' . htmlentities($row[0]) . '</title>'); fwrite($fp, '<meta name="identifier" content="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '"/>'); if ($linktype == "canvas") { fwrite($fp, '<meta name="editing_roles" content="teachers"/>'); } fwrite($fp, "</head><body>"); $query = "SELECT revision FROM imas_wiki_revisions WHERE wikiid='{$iteminfo[$item][1]}' AND stugroupid=0 ORDER BY id DESC LIMIT 1"; $r = mysql_query($query) or die("Query failed : " . mysql_error()); if (mysql_num_rows($r) > 0) { $row = mysql_fetch_row($r); $text = $row[0]; if (strlen($text) > 6 && substr($text, 0, 6) == '**wver') { $wikiver = substr($text, 6, strpos($text, '**', 6) - 6); $text = substr($text, strpos($text, '**', 6) + 2); } fwrite($fp, filtercapture($text, $res)); } fwrite($fp, '</body></html>'); fclose($fp); $resitem = '<resource href="' . $htmldir . 'wikitext' . $iteminfo[$item][1] . '.html" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="webcontent">' . "\n"; $resitem .= ' <file href="' . $htmldir . 'wikitext' . $iteminfo[$item][1] . '.html" />' . "\n"; $resitem .= '</resource>'; $res[] = $resitem; } } } } } if (strlen($ind) > 2) { $module_meta .= $canvout; } else { $toplevelitems .= $canvout; } } } return $out; }