|
|
|
@ -95,15 +95,15 @@ function parse_csv_data($file) |
|
|
|
|
function element_start($parser, $data) |
|
|
|
|
{ |
|
|
|
|
$data = api_utf8_decode($data); |
|
|
|
|
global $skill; |
|
|
|
|
global $current_tag; |
|
|
|
|
switch ($data) { |
|
|
|
|
case 'Skill' : |
|
|
|
|
$skill = array (); |
|
|
|
|
break; |
|
|
|
|
default : |
|
|
|
|
$current_tag = $data; |
|
|
|
|
} |
|
|
|
|
global $skill; |
|
|
|
|
global $current_tag; |
|
|
|
|
switch ($data) { |
|
|
|
|
case 'Skill': |
|
|
|
|
$skill = array(); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
$current_tag = $data; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -112,17 +112,17 @@ function element_start($parser, $data) |
|
|
|
|
function element_end($parser, $data) |
|
|
|
|
{ |
|
|
|
|
$data = api_utf8_decode($data); |
|
|
|
|
global $skill; |
|
|
|
|
global $skills; |
|
|
|
|
global $current_value; |
|
|
|
|
switch ($data) { |
|
|
|
|
case 'Skill' : |
|
|
|
|
$skills[] = $skill; |
|
|
|
|
break; |
|
|
|
|
default : |
|
|
|
|
$skill[$data] = $current_value; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
global $skill; |
|
|
|
|
global $skills; |
|
|
|
|
global $current_value; |
|
|
|
|
switch ($data) { |
|
|
|
|
case 'Skill': |
|
|
|
|
$skills[] = $skill; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
$skill[$data] = $current_value; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -142,17 +142,17 @@ function character_data($parser, $data) |
|
|
|
|
*/ |
|
|
|
|
function parse_xml_data($file) |
|
|
|
|
{ |
|
|
|
|
global $current_tag; |
|
|
|
|
global $current_value; |
|
|
|
|
global $skill; |
|
|
|
|
global $skills; |
|
|
|
|
$skills = array(); |
|
|
|
|
$parser = xml_parser_create('UTF-8'); |
|
|
|
|
xml_set_element_handler($parser, 'element_start', 'element_end'); |
|
|
|
|
xml_set_character_data_handler($parser, 'character_data'); |
|
|
|
|
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); |
|
|
|
|
xml_parse($parser, api_utf8_encode_xml(file_get_contents($file))); |
|
|
|
|
xml_parser_free($parser); |
|
|
|
|
global $current_tag; |
|
|
|
|
global $current_value; |
|
|
|
|
global $skill; |
|
|
|
|
global $skills; |
|
|
|
|
$skills = array(); |
|
|
|
|
$parser = xml_parser_create('UTF-8'); |
|
|
|
|
xml_set_element_handler($parser, 'element_start', 'element_end'); |
|
|
|
|
xml_set_character_data_handler($parser, 'character_data'); |
|
|
|
|
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); |
|
|
|
|
xml_parse($parser, api_utf8_encode_xml(file_get_contents($file))); |
|
|
|
|
xml_parser_free($parser); |
|
|
|
|
|
|
|
|
|
return $skills; |
|
|
|
|
} |
|
|
|
@ -169,73 +169,73 @@ $user_id_error = array(); |
|
|
|
|
$error_message = ''; |
|
|
|
|
|
|
|
|
|
if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) { |
|
|
|
|
$file_type = $_POST['file_type']; |
|
|
|
|
Security::clear_token(); |
|
|
|
|
$tok = Security::get_token(); |
|
|
|
|
$allowed_file_mimetype = array('csv','xml'); |
|
|
|
|
$error_kind_file = false; |
|
|
|
|
$file_type = $_POST['file_type']; |
|
|
|
|
Security::clear_token(); |
|
|
|
|
$tok = Security::get_token(); |
|
|
|
|
$allowed_file_mimetype = array('csv','xml'); |
|
|
|
|
$error_kind_file = false; |
|
|
|
|
$error_message = ''; |
|
|
|
|
|
|
|
|
|
$ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'],'.')+1)); |
|
|
|
|
$ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'],'.')+1)); |
|
|
|
|
|
|
|
|
|
if (in_array($ext_import_file,$allowed_file_mimetype)) { |
|
|
|
|
if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) { |
|
|
|
|
$skills = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
|
|
|
$errors = validate_data($skills); |
|
|
|
|
$error_kind_file = false; |
|
|
|
|
} elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) { |
|
|
|
|
$skills = parse_xml_data($_FILES['import_file']['tmp_name']); |
|
|
|
|
$errors = validate_data($skills); |
|
|
|
|
$error_kind_file = false; |
|
|
|
|
} else { |
|
|
|
|
$error_kind_file = true; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$error_kind_file = true; |
|
|
|
|
} |
|
|
|
|
if (in_array($ext_import_file,$allowed_file_mimetype)) { |
|
|
|
|
if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) { |
|
|
|
|
$skills = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
|
|
|
$errors = validate_data($skills); |
|
|
|
|
$error_kind_file = false; |
|
|
|
|
} elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) { |
|
|
|
|
$skills = parse_xml_data($_FILES['import_file']['tmp_name']); |
|
|
|
|
$errors = validate_data($skills); |
|
|
|
|
$error_kind_file = false; |
|
|
|
|
} else { |
|
|
|
|
$error_kind_file = true; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$error_kind_file = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// List skill id with error. |
|
|
|
|
$skills_to_insert = $skill_id_error = array(); |
|
|
|
|
if (is_array($errors)) { |
|
|
|
|
foreach ($errors as $my_errors) { |
|
|
|
|
$skill_id_error[] = $my_errors['SkillName']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (is_array($skills)) { |
|
|
|
|
foreach ($skills as $my_skill) { |
|
|
|
|
if (isset($my_skill['name']) && !in_array($my_skill['name'], $skill_id_error)) { |
|
|
|
|
$skills_to_insert[] = $my_skill; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// List skill id with error. |
|
|
|
|
$skills_to_insert = $skill_id_error = array(); |
|
|
|
|
if (is_array($errors)) { |
|
|
|
|
foreach ($errors as $my_errors) { |
|
|
|
|
$skill_id_error[] = $my_errors['SkillName']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (is_array($skills)) { |
|
|
|
|
foreach ($skills as $my_skill) { |
|
|
|
|
if (isset($my_skill['name']) && !in_array($my_skill['name'], $skill_id_error)) { |
|
|
|
|
$skills_to_insert[] = $my_skill; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (strcmp($file_type, 'csv') === 0) { |
|
|
|
|
save_data($skills_to_insert); |
|
|
|
|
} elseif (strcmp($file_type, 'xml') === 0) { |
|
|
|
|
save_data($skills_to_insert); |
|
|
|
|
} else { |
|
|
|
|
$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption'); |
|
|
|
|
} |
|
|
|
|
if (strcmp($file_type, 'csv') === 0) { |
|
|
|
|
save_data($skills_to_insert); |
|
|
|
|
} elseif (strcmp($file_type, 'xml') === 0) { |
|
|
|
|
save_data($skills_to_insert); |
|
|
|
|
} else { |
|
|
|
|
$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (count($errors) > 0) { |
|
|
|
|
$see_message_import = get_lang('FileImportedJustSkillsThatAreNotRegistered'); |
|
|
|
|
} else { |
|
|
|
|
$see_message_import = get_lang('FileImported'); |
|
|
|
|
} |
|
|
|
|
if (count($errors) > 0) { |
|
|
|
|
$see_message_import = get_lang('FileImportedJustSkillsThatAreNotRegistered'); |
|
|
|
|
} else { |
|
|
|
|
$see_message_import = get_lang('FileImported'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (count($errors) != 0) { |
|
|
|
|
$warning_message = '<ul>'; |
|
|
|
|
foreach ($errors as $index => $error_skill) { |
|
|
|
|
$warning_message .= '<li><b>'.$error_skill['error'].'</b>: '; |
|
|
|
|
$warning_message .= '<strong>'.$error_skill['SkillName'].'</strong> ('.$error_skill['SkillName'].')'; |
|
|
|
|
$warning_message .= '</li>'; |
|
|
|
|
} |
|
|
|
|
$warning_message .= '</ul>'; |
|
|
|
|
} |
|
|
|
|
if (count($errors) != 0) { |
|
|
|
|
$warning_message = '<ul>'; |
|
|
|
|
foreach ($errors as $index => $error_skill) { |
|
|
|
|
$warning_message .= '<li><b>'.$error_skill['error'].'</b>: '; |
|
|
|
|
$warning_message .= '<strong>'.$error_skill['SkillName'].'</strong> ('.$error_skill['SkillName'].')'; |
|
|
|
|
$warning_message .= '</li>'; |
|
|
|
|
} |
|
|
|
|
$warning_message .= '</ul>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($error_kind_file) { |
|
|
|
|
$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption'); |
|
|
|
|
} |
|
|
|
|
$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$interbreadcrumb[] = array ("url" => 'skill_list.php', "name" => get_lang('ManageSkills')); |
|
|
|
@ -243,34 +243,34 @@ $interbreadcrumb[] = array ("url" => 'skill_list.php', "name" => get_lang('Manag |
|
|
|
|
Display :: display_header($tool_name); |
|
|
|
|
|
|
|
|
|
if (!empty($error_message)) { |
|
|
|
|
Display::display_error_message($error_message); |
|
|
|
|
Display::display_error_message($error_message); |
|
|
|
|
} |
|
|
|
|
if (!empty($see_message_import)) { |
|
|
|
|
Display::display_normal_message($see_message_import); |
|
|
|
|
Display::display_normal_message($see_message_import); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$toolbar = Display::toolbarButton( |
|
|
|
|
get_lang('ManageSkills'), |
|
|
|
|
api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php', |
|
|
|
|
'list', |
|
|
|
|
'success', |
|
|
|
|
['title' => get_lang('CreateSkill')] |
|
|
|
|
get_lang('ManageSkills'), |
|
|
|
|
api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php', |
|
|
|
|
'list', |
|
|
|
|
'success', |
|
|
|
|
['title' => get_lang('CreateSkill')] |
|
|
|
|
); |
|
|
|
|
$toolbar .= ' '; |
|
|
|
|
$toolbar .= Display::toolbarButton( |
|
|
|
|
get_lang('SkillsWheel'), |
|
|
|
|
api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php', |
|
|
|
|
'bullseye', |
|
|
|
|
'primary', |
|
|
|
|
['title' => get_lang('CreateSkill')] |
|
|
|
|
get_lang('SkillsWheel'), |
|
|
|
|
api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php', |
|
|
|
|
'bullseye', |
|
|
|
|
'primary', |
|
|
|
|
['title' => get_lang('CreateSkill')] |
|
|
|
|
); |
|
|
|
|
$toolbar .= ' '; |
|
|
|
|
$toolbar .= Display::toolbarButton( |
|
|
|
|
get_lang('BadgesManagement'), |
|
|
|
|
api_get_path(WEB_CODE_PATH) . 'admin/skill_badge_list.php', |
|
|
|
|
'shield', |
|
|
|
|
'warning', |
|
|
|
|
['title' => get_lang('BadgesManagement')] |
|
|
|
|
get_lang('BadgesManagement'), |
|
|
|
|
api_get_path(WEB_CODE_PATH) . 'admin/skill_badge_list.php', |
|
|
|
|
'shield', |
|
|
|
|
'warning', |
|
|
|
|
['title' => get_lang('BadgesManagement')] |
|
|
|
|
); |
|
|
|
|
$toolbar .= '<br /><br />'; |
|
|
|
|
|
|
|
|
@ -281,7 +281,13 @@ $form->addElement('header', '', $tool_name); |
|
|
|
|
$form->addElement('hidden', 'formSent'); |
|
|
|
|
$form->addElement('file', 'import_file', get_lang('ImportFileLocation')); |
|
|
|
|
$group = array(); |
|
|
|
|
$group[] = $form->createElement('radio', 'file_type', '', 'CSV (<a href="skill_example.csv" target="_blank">'.get_lang('ExampleCSVFile').'</a>)', 'csv'); |
|
|
|
|
$group[] = $form->createElement( |
|
|
|
|
'radio', |
|
|
|
|
'file_type', |
|
|
|
|
'', |
|
|
|
|
'CSV (<a href="skill_example.csv" target="_blank">'.get_lang('ExampleCSVFile').'</a>)', |
|
|
|
|
'csv' |
|
|
|
|
); |
|
|
|
|
$form->addGroup($group, '', get_lang('FileType')); |
|
|
|
|
$form->addButtonImport(get_lang('Import')); |
|
|
|
|
$defaults['formSent'] = 1; |
|
|
|
@ -296,16 +302,16 @@ $result_xml = ''; |
|
|
|
|
$i = 0; |
|
|
|
|
$count_fields = count($extra_fields); |
|
|
|
|
if ($count_fields > 0) { |
|
|
|
|
foreach ($extra_fields as $extra) { |
|
|
|
|
$list[] = $extra[1]; |
|
|
|
|
$list_reponse[] = 'xxx'; |
|
|
|
|
$spaces = ' '; |
|
|
|
|
$result_xml .= $spaces.'<'.$extra[1].'>xxx</'.$extra[1].'>'; |
|
|
|
|
if ($i != $count_fields - 1) { |
|
|
|
|
$result_xml .= '<br/>'; |
|
|
|
|
} |
|
|
|
|
$i++; |
|
|
|
|
} |
|
|
|
|
foreach ($extra_fields as $extra) { |
|
|
|
|
$list[] = $extra[1]; |
|
|
|
|
$list_reponse[] = 'xxx'; |
|
|
|
|
$spaces = ' '; |
|
|
|
|
$result_xml .= $spaces.'<'.$extra[1].'>xxx</'.$extra[1].'>'; |
|
|
|
|
if ($i != $count_fields - 1) { |
|
|
|
|
$result_xml .= '<br/>'; |
|
|
|
|
} |
|
|
|
|
$i++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
?> |
|
|
|
|
<p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
|
|
|
|
|