";
$c .= '
';
$c .= '
';
$w = waramu_get();
$wid = get_input('resourceid');
if ( !$wid )
$wid = null;
$obj = waramu_getResource("", $wid);
$su = $obj->getAnnotationByName('indpwork');
$cr = $obj->getAnnotationByName('keecm');
$th = $obj->getAnnotationByName('thsupport');
$suitable_for_student = $su ? $su->value() : 0;
$competition_resource = $cr ? $cr->value() : 0;
$tiger_leap_supported = $th ? $th->value() : 0;
$fulltd = $w->describeType($obj->getSchema());
$td = $fulltd->listFields();
$langs = $obj->getAllLanguages();
if ( count($langs) == 0 ) {
$langs[] = "et";
}
if ( !is_null($wid) )
$c .= '
';
if ( get_input('r') == '1' )
$c .= '
';
$c .= '
';
foreach($langs as $l) {
$c .= '
';
}
$combine = array(array('min', 'max'));
function fieldhelp($id, $text, $button=true) {
if ($button)
$help = '
?';
$htitle = elgg_echo('koolielu:'.$id);
$help .= '
';
/*translation:Help*/
$help .= '';
$help .= '
';
$help .= '
'.$htitle.'
';
$help .= $text.'
';
$help .= '
';
return $help;
}
function fieldstart($id, $printable, $lang) {
$fid = $id;
if ( !is_null($lang) ) {
$fid = $lang.'_'.$id;
}
$res = "";
$res .= '
';
$res .= '
';
$trans = elgg_echo("koolielu:".$id);
if ( $trans == "koolielu:".$id )
$trans = $printable;
$res .= '';
$helptext = elgg_echo('koolielu:'.$id.'_helptext');
$res .= fieldhelp($id, $helptext);
if (in_array($id, array("title", "desc", "keywords", "curriculumSubject")))
$res .= ' ' . elgg_view('koolielu/ke_required_field', array());
$res .= '
';
$res .= '
';
return $res;
}
function fieldend() {
$res = "";
$res .= '
';
$res .= '
';
return $res;
}
function generate_html($obj, $td, $multilingual, $w, $lang) {
$combine = array(array('min', 'max'));
$advancedFields = getAdvancedFields();
$default_vals = array('mdLanguage'=>'et', 'LREkeywords'=>'', 'intendedEndUserRole'=>'learner', 'context'=>'compulsory education');
$res = "";
foreach( $td as $field) {
$name = $field['@attributes']['name'];
$skipme = false;
foreach($combine as $co) {
if ( in_array($name, $co)) {
$skipme = true;
break;
}
}
if ( $skipme )
continue;
$printable = $field['title'][0][0];
$multi = $field['@attributes']['multiLingual'];
if ( !$multilingual && $multi == '1' ) {
continue;
}
if ( $multilingual && ($multi == '0' || is_null($multi))) {
continue;
}
$ftype = $field['@attributes']['type'];
$voc = $field['@attributes']['vocabulary'];
$autoval = $field['@attributes']['autovalue'];
$fixedVoc = $field['@attributes']['fixedVocabulary'];
if ( $autoval == '1' ) {
continue;
}
if (!in_array($name, $advancedFields) ) {
$rf = fieldstart($name, $printable, $lang);
$viewParams = array(
'mode' => 'edit',
'waramu' => $w,
'fieldname' => $name,
'fieldtype' => $ftype,
'fixedVocabulary' => $fixedVoc,
'vocabulary' => $voc,
'language' => $lang,
'object' => $obj
);
if ( elgg_view_exists('waramu/field_'.$name) ) {
$rf .= elgg_view('waramu/field_'.$name, $viewParams);
} else {
$rf .= elgg_view('waramu/field_'.$ftype, $viewParams);
}
$rf .= fieldend();
$res .= $rf;
} else if ($name == 'LREkeywords') {
$fval = $obj->get($name);
$fvv = "";
foreach($fval as $fx) {
$fvv .= $fx[0].",";
}
if (strlen($fvv)>0) {
$fvv = substr($fvv, 0, strlen($fvv)-1);
}
$res .= '
';
} else {
$res .= '
';
}
}
return $res;
}
function have_ml_fields($td) {
foreach( $td as $field) {
$multi = $field['@attributes']['multiLingual'];
if ( $multi == '1' )
return true;
}
return false;
}
if ( have_ml_fields($td) ) {
/*translation:Metadata language helptext*/
$helptext = elgg_echo('koolielu:mdLanguage_helptext');
$c .= fieldHelp('mdLanguage', $helptext, false);
$c .= '
';
$c .= '
';
$c .= '
?';
$c .= '
';
foreach($langs as $l) {
$c .= '
'.elgg_echo("koolielu:langcode:".$l).'
';
}
$c .= '
';
$c .= '
';
foreach($langs as $l) {
$c .= '
';
$generated_html = generate_html($obj, $td, true, $w, $l);
$c .= $generated_html;
$c .= '
';
}
$c .= '
';
}
$generated_html = generate_html($obj, $td, false, $w, null);
$c .= $generated_html;
function find_field($td, $fname) {
foreach ($td as $field) {
$name = $field['@attributes']['name'];
if ( $name == $fname )
return $field;
}
}
//if ($fulltd['description'][0]['info'][0]['attachable'][0][0] == "1") {
if ($obj->uid) {
$c .= fieldstart('files', 'Files');
$viewParams = array(
'mode' => 'edit',
'waramu' => $w,
'fieldname' => 'attachments',
'object' => $obj
);
$c .= elgg_view('waramu/field_attachments', $viewParams);
$c .= fieldend();
}
foreach($combine as $co) {
$fname = implode("", $co);
$class_from_age_range = array(
/*translation:pre-school education*/
elgg_echo('koolielu:preschool'),
/*translation:pre-school education*/
elgg_echo('koolielu:preschool'),
/*translation:pre-school education*/
elgg_echo('koolielu:preschool'),
/*translation:pre-school education*/
elgg_echo('koolielu:preschool'),
/*translation:pre-school education*/
elgg_echo('koolielu:preschool'),
/*translation:pre-school education*/
elgg_echo('koolielu:preschool'),
/*translation:pre-school education*/
elgg_echo('koolielu:preschool'),
/*translation:1st grade*/
elgg_echo('koolielu:1st_grade'),
/*translation:2nd grade*/
elgg_echo('koolielu:2nd_grade'),
/*translation:3rd grade*/
elgg_echo('koolielu:3rd_grade'),
/*translation:4th grade*/
elgg_echo('koolielu:4th_grade'),
/*translation:5th grade*/
elgg_echo('koolielu:5th_grade'),
/*translation:6th grade*/
elgg_echo('koolielu:6th_grade'),
/*translation:7th grade*/
elgg_echo('koolielu:7th_grade'),
/*translation:8th grade*/
elgg_echo('koolielu:8th_grade'),
/*translation:9th grade*/
elgg_echo('koolielu:9th_grade'),
/*translation:10th grade*/
elgg_echo('koolielu:10th_grade'),
/*translation:11th grade*/
elgg_echo('koolielu:11th_grade'),
/*translation:12th grade*/
elgg_echo('koolielu:12th_grade'),
/*translation:adult education*/
elgg_echo('koolielu:adult_educ'),
/*translation:adult education*/
elgg_echo('koolielu:adult_educ')
);
$agerange_help = '
?';
$viewParams = array(
/*translation:agerange*/
'label' => elgg_echo('koolielu:agerange').$agerange_help,
'min' => 0,
'max' => 20,
'left' => find_field($td, $co[0]),
'right' => find_field($td, $co[1]),
'object' => $obj,
'mode' => 'edit',
'ranges' => $class_from_age_range
);
/*translation:Agerange helptext*/
$agerange_help = elgg_echo('koolielu:agerange_helptext');
$c .= fieldhelp('agerange', $agerange_help, false);
$c .= "
".elgg_view('waramu/field_'.$fname, $viewParams)."
";
}
// suitable for student checkbox area
$student_opts = "";
if ($suitable_for_student == 1) {
$student_opts = 'checked="checked" ';
}
/*translation:Suitable for student*/
$suitable_for_student = '
';
/*translation:Suitable for student helptext*/
$suitable_help = elgg_echo('koolielu:suitable_student_helptext');
$suitable_for_student .= fieldHelp('suitable_student', $suitable_help);
$suitable_for_student .= '
';
// competition resource checkbox area
$competition_opts = "";
if ($competition_resource == 1) {
$competition_opts = 'checked="checked" ';
}
/*translation:Competition resource*/
$competition_res = '
';
/*translation:Competition resource helptext*/
$competition_help = elgg_echo('koolielu:competition_resource_helptext');
$competition_res .= fieldHelp('competition_resource', $competition_help);
$competition_res .= '
';
// tiger leap supported checkbox area
$tiger_support_opts = "";
if ($tiger_leap_supported == 1) {
$tiger_support_opts = 'checked="checked" ';
}
/*translation:Created with support from Tiger Leap Foundation*/
$tiger_supported = '
';
/*translation:Created with support from Tiger Leap Foundation helptext*/
$tiger_support_help = elgg_echo('koolielu:tiger_leap_supported_helptext');
$tiger_supported .= fieldHelp('tiger_leap_supported', $tiger_support_help);
$tiger_supported .= '
';
$more_metadata = "";
$more_metadata .= $suitable_for_student;
$more_metadata .= $competition_res;
$more_metadata .= $tiger_supported;
$c .= '
'.$more_metadata.'
';
/*translation:Save*/
$c .= elgg_view('input/submit', array('internalname' => 'savebutton', 'js' => 'onclick="controlFields();return false;"', 'value' => elgg_echo('koolielu:Save')));
$c .= "
";
$form = elgg_view('input/form', array('action' => $CONFIG->wwwroot.'action/waramu/saveMetadata', 'body' => $c, 'head' => '', 'internalname' => 'saveform'));
$body = elgg_view_layout('two_column_left_sidebar', "", $form);
page_draw($title, $body);
?>