case 1:
$orig_access_mode = 'auditory';
break;
+ case 2:
+ $orig_access_mode = 'visual';
+ $representation_form = 'sign_language';
+ break;
case 3:
$orig_access_mode = 'textual';
- break;
- case 2:
+ break;
case 4:
//sign language, and visual
$orig_access_mode = 'visual';
}
?>
<originalAccessMode><?php echo $orig_access_mode; ?></originalAccessMode>
+ <?php if (isset($representation_form) && $representation_form!=''): ?>
+ <representationForm><?php echo $representation_form; ?></representationForm>
+ <?php endif; ?>
</adaptationStatement>
<?php endforeach; ?>
<?php endif; ?>
$secondary_array = array();
foreach($resources_types as $rtid){
$sec_resources['secondary_resources'] = parent::getSecondaryResources($rid);
+
//determine secondary resource type
foreach ($sec_resources['secondary_resources'] as $sec_id => $sec_resource){
$current_sec_file = $sec_resource['resource'];
if (!isset($this->original_files[$current_sec_file]) || empty($this->original_files[$current_sec_file]) ){
//TODO merge these values i think
$this->original_files[$current_sec_file ] = $sec_resource;
- $this->original_files[$current_sec_file ]['resource_type'][$prop['resource']] = parent::getSecondaryResourcesTypes($sec_id);
+ $this->original_files[$current_sec_file ]['resource_type'][$prop['resource']][] = parent::getSecondaryResourcesTypes($sec_id);
} else {
- $this->original_files[$current_sec_file ]['resource_type'][$prop['resource']] = parent::getSecondaryResourcesTypes($sec_id);
+ $this->original_files[$current_sec_file ]['resource_type'][$prop['resource']][] = parent::getSecondaryResourcesTypes($sec_id);
}
//add this primary file ref, and the resources type to the secondary file
$this->original_files[$current_sec_file]['primary_resources'][$prop['resource']] = $rtid;
// $this->original_files[$current_sec_file]['primary_resources'][$prop['resource']]['language_code'] = $sec_resource['language_code'];
-
}
$res_type['resource_type'] = $rtid; //could be 1+
$temp = array_merge($prop, $res_type, $secondary_array);
// Get original files' xml
foreach($this->original_files as $id=>$resource){
$orig_access_mode = array();
-
foreach($resource['resource_type'] as $type_id){
if (!is_array($type_id)){
//primary resource will always have just on type
$orig_access_mode[] = $this->getResourceNameById($type_id);
+ } else {
+ foreach($type_id as $k=>$type_id2){
+ $orig_access_mode[] = $this->getResourceNameById($type_id2[0]);
+ }
}
}
$savant->assign('relative_path', $this->relative_path); //the template will need the relative path
$orig_access_mode = array(); //reinitialize
foreach($resource['resource_type'][$uri] as $type_id){
$orig_access_mode[] = $this->getResourceNameById($type_id);
+ $savant->assign('orig_access_mode', $orig_access_mode);
+ $xml_array[$id.' to '.$uri][] = $savant->fetch(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4a.tmpl.php');
}
- $savant->assign('orig_access_mode', $orig_access_mode);
- $xml_array[$id.' to '.$uri] = $savant->fetch(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4a.tmpl.php');
+
}
} else {
$savant->assign('primary_resource_uri', '');
*/
function getResourceNameById($type_id){
$orig_access_mode = '';
-
+ if (is_array($type_id)) {
+ $type_id = $type_id[0];
+ }
switch($type_id){
case 1:
$orig_access_mode = 'auditory';
$orig_access_mode = 'textual';
break;
case 2:
+ $orig_access_mode = 'sign_language';
+ break;
case 4:
$orig_access_mode = 'visual';
break;
* @param array XML items generated by the IMS import
*/
function importA4a($items){
+ //imported files, keep track of what file path that's been processed. Do not add repeated ones
+ $imported_files = array();
+
//use the items array data and insert it into the database.
foreach ($items as $file_path => $a4a_resources){
foreach ($a4a_resources as $resource){
//we can safely take it out.
//@edited Dec 6th, imscc import uses relative paths, ims doesn't.
$secondary_files = $items[$this->relative_path.$secondary_resource];
+ if (in_array($this->relative_path.$secondary_resource, $imported_files)){
+ continue;
+ }
+ $imported_files[] = $this->relative_path.$secondary_resource;
if (empty($secondary_files)){
//tweak: if this is empty, then most likely it is an ims import.
$secondary_resource = preg_replace('/^\.\.\//', '', $secondary_resource);
//access_stmt_originalAccessMode cause we want the language for the secondary file.
$secondary_attr = $this->toResourceTypeId($secondary_file['access_stmt_originalAccessMode']);
$secondary_id = $this->setSecondaryResource($primary_id, $secondary_resource, $secondary_lang);
-
//insert secondary resource type associations
foreach ($secondary_attr as $secondary_resource_type_id){
$this->setSecondaryResourceType($secondary_id, $secondary_resource_type_id);
}
- break; //1-to-1 mapping, no need to go further
+ //break; //1-to-1 mapping, no need to go further
}
}
} //foreach of secondary_resources
+ $imported_files = array(); //reset the imported file for the next resource
}
} //foreach of resources
} //foreach of item array
/**
* By the given attrs array, decide which resource type it is
- * auditory = type 1
- * textual = type 3
- * visual = type 4
+ * auditory = type 1
+ * sign_language = type 2
+ * textual = type 3
+ * visual = type 4
* @param array
* return type id array
*/
if (empty($resources_attrs)){
return $result;
}
-
- if (in_array('auditory', $resources_attrs)){
- $result[] = 1;
- }
- if (in_array('textual', $resources_attrs)){
- $result[] = 3;
- }
- if (in_array('visual', $resources_attrs)){
- $result[] = 4;
- }
- return $result;
+ if (is_array($resources_attrs)) {
+ if (in_array('auditory', $resources_attrs)){
+ $result[] = 1;
+ }
+ if (in_array('sign_language', $resources_attrs)){
+ $result[] = 2;
+ }
+ if (in_array('textual', $resources_attrs)){
+ $result[] = 3;
+ }
+ if (in_array('visual', $resources_attrs)){
+ $result[] = 4;
+ }
+ } else {
+ if ($resources_attrs=='auditory'){
+ $result[] = 1;
+ } elseif ($resources_attrs=='sign_language'){
+ $result[] = 2;
+ } elseif ($resources_attrs=='textual'){
+ $result[] = 3;
+ } elseif ($resources_attrs=='visual'){
+ $result[] = 4;
+ }
+ }
+ return $result;
}
}
array_push($files, $file);
}
- }
-
+ }
return $files;
}
if (is_array($a4a_secondary_files[$file])){
$all_secondary_files_md = ''; //reinitialize string to null
foreach ($a4a_secondary_files[$file] as $v){
- $all_secondary_files_md .= $a4a_xml_array[$v]; //all the meta data
+ foreach($a4a_xml_array[$v] as $v2){
+ $all_secondary_files_md .= $v2; //all the meta data
+ }
}
$content_files .= str_replace( array('{FILE}', '{FILE_META_DATA}'),
array('resources/'.$content['content_path'] . $file, $all_secondary_files_md),
}
}
}
-
/* check if this file is one of the test xml file, if so, we need to add the dependency
* Note: The file has already been added to the archieve before this is called.
*/
if ($name=='originalAccessMode'){
if (in_array('accessModeStatement', $element_path)){
- $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['access_stmt_originalAccessMode'][] = $my_data;
+ $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['access_stmt_originalAccessMode'] = $my_data;
} elseif (in_array('adaptationStatement', $element_path)){
- $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['adapt_stmt_originalAccessMode'][] = $my_data;
- }
+ $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['adapt_stmt_originalAccessMode'] = $my_data;
+ }
} elseif (($name=='language') && in_array('accessModeStatement', $element_path)){
$items[$current_identifier]['a4a'][$last_file_name][$resource_num]['language'][] = $my_data;
} elseif ($name=='hasAdaptation') {