function opigno_scorm_extract_manifest_data in Opigno 7
Extract the manifest data.
Parse the manifest XML with XML2Array (located in includes/XML2Array.php) and extract data that is relevant to us.
Parameters
string $manifest_file:
Return value
array
1 call to opigno_scorm_extract_manifest_data()
- opigno_scorm_extract in modules/
scorm/ includes/ opigno_scorm.manifest.inc - Extract the SCORM package from the file.
File
- modules/
scorm/ includes/ opigno_scorm.manifest.inc, line 178 - Manifest file extraction logic.
Code
function opigno_scorm_extract_manifest_data($manifest_file) {
$data = array();
// Get the XML as a string.
$manifest_string = file_get_contents($manifest_file);
// Parse it as an array.
$parser = new XML2Array();
$manifest = $parser
->parse($manifest_string);
// The parser returns an array of arrays - skip the first element.
$manifest = array_shift($manifest);
// Get the manifest ID, if any.
if (!empty($manifest['attrs'][OPIGNO_SCORM_MANIFEST_MANIFEST_ATTR])) {
$data['manifest_id'] = $manifest['attrs'][OPIGNO_SCORM_MANIFEST_MANIFEST_ATTR];
}
else {
$data['manifest_id'] = '';
}
// Extract the global metadata information.
$data['metadata'] = opigno_scorm_extract_manifest_metadata($manifest);
// Extract the SCOs (course items). Gets the default SCO and a list of all SCOs.
$data['scos'] = opigno_scorm_extract_manifest_scos($manifest);
// Extract the resources, so we can combine the SCOs and resources.
$data['resources'] = opigno_scorm_extract_manifest_resources($manifest);
// Combine the resources and SCOs.
$data['scos']['items'] = opigno_scorm_combine_manifest_sco_and_resources($data['scos']['items'], $data['resources']);
return $data;
}