3 require_once 'connect.db.inc.php';
5 $globals->debug
= 0; //do not store backtraces
7 $data = implode('', file('arbo-UTF8.xml'));
8 $parser = xml_parser_create();
9 xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING
, 0);
10 xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE
, 1);
11 xml_parse_into_struct($parser, $data, $values, $tags);
12 xml_parser_free($parser);
14 XDB
::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ("Emplois", "Emplois")');
16 $opened_nodes = array();
17 $broader_ids = array(XDB
::insertId());
19 XDB
::execute('INSERT INTO profile_job_term_relation VALUES (0, {?}, "narrower", "original"), ({?}, {?}, "narrower", "computed")',
20 $broader_ids[0], $broader_ids[0], $broader_ids[0]);
22 // loop through the structures
23 foreach ($values as $val) {
24 if (($val['type'] == 'open' ||
$val['type'] == 'complete') && !empty($val['attributes']['intitule'])) {
25 $intitule = $val['attributes']['intitule'];
26 if (mb_strtoupper($intitule) == $intitule) {
27 $intitule = ucfirst(mb_strtolower($intitule));
29 $res = XDB
::execute('INSERT INTO profile_job_term_enum (name, full_name)
31 $intitule, $intitule.' (emploi'.(($val['type'] == 'open')?
's':'').')');
32 $newid = XDB
::insertId();
33 array_unshift($broader_ids, $newid);
34 array_unshift($opened_nodes, $val['tag']);
35 foreach ($broader_ids as $i => $bid) {
36 XDB
::execute('INSERT INTO profile_job_term_relation VALUES ({?}, {?}, "narrower", {?})',
37 $bid, $newid, ($i == 1)?
'original':'computed');
40 if (count($opened_nodes) > 0 && $val['tag'] == $opened_nodes[0] && ($val['type'] == 'close' ||
$val['type'] == 'complete')) {
41 array_shift($broader_ids);
42 array_shift($opened_nodes);
46 /* vim:set et sw=4 sts=4 ts=4: */