From: Pascal Corpet Date: Sun, 4 Jul 2010 23:04:33 +0000 (+0200) Subject: Prepares database for job terms. X-Git-Tag: xorg/1.0.1~248 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=468c1813bdfc759bed5beba57325ea2e6df6aa2a;p=platal.git Prepares database for job terms. Tokenize job terms for search --- diff --git a/include/profil.func.inc.php b/include/profil.func.inc.php new file mode 100644 index 0000000..e8ecb59 --- /dev/null +++ b/include/profil.func.inc.php @@ -0,0 +1,379 @@ + $bvar) { + if (isset($a[$val])) { + if ($a[$val] == $bvar) + unset($c[$val]); + else { + switch ($val) { + case 'adr' : if (!($c['adr'] = diff_user_addresses($a[$val], $bvar, $view))) unset($c['adr']); break; + case 'adr_pro' : if (!($c['adr_pro'] = diff_user_pros($a[$val], $bvar, $view))) unset($c['adr_pro']); break; + case 'tels' : if (!($c['tels'] = diff_user_tels($a[$val], $bvar, $view))) unset($c['tels']); break; + } + } + } + } + // don't modify freetext if you don't have the right + if (isset($b['freetext_pub']) && !has_user_right($b['freetext_pub'], $view) && isset($c['freetext'])) + unset($c['freetext']); + if (!count($c)) + return false; + return $c; +} + +function same_tel(&$a, &$b) { + $numbera = format_phone_number((string) $a); + $numberb = format_phone_number((string) $b); + return $numbera === $numberb; +} +function same_address(&$a, &$b) { + return + (same_field($a['adr1'],$b['adr1'])) && + (same_field($a['adr2'],$b['adr2'])) && + (same_field($a['adr3'],$b['adr3'])) && + (same_field($a['postcode'],$b['postcode'])) && + (same_field($a['city'],$b['city'])) && + (same_field($a['countrytxt'],$b['countrytxt'])) && + true; +} +function same_pro(&$a, &$b) { + return + (same_field($a['entreprise'],$b['entreprise'])) && + (same_field($a['fonction'],$b['fonction'])) && + true; +} +function same_field(&$a, &$b) { + if ($a == $b) return true; + if (is_array($a)) { + if (!is_array($b) || count($a) != count($b)) return false; + foreach ($a as $val => $avar) + if (!isset($b[$val]) || !same_field($avar, $b[$val])) return false; + return true; + } elseif (is_string($a)) + return (mb_strtoupper($a) == mb_strtoupper($b)); +} +function diff_user_tel(&$a, &$b) { + $c = $a; + if (isset($b['tel_pub']) && isset($a['tel_pub']) && has_user_right($b['tel_pub'], $a['tel_pub'])) + $c['tel_pub'] = $b['tel_pub']; + foreach ($b as $val => $bvar) { + if (isset($a[$val])) { + if ($a[$val] == $bvar) + unset($c[$val]); + } + } + if (!count($c)) + return false; + $c['telid'] = $a['telid']; + return $c; +} + +function diff_user_tels(&$a, &$b) +{ + $c = $a; + $telids_b = array(); + foreach ($b as $i => $telb) $telids_b[$telb['telid']] = $i; + + foreach ($a as $j => $tela) { + if (isset($tela['telid'])) { + // if b has a tel with the same telid, compute diff + if (isset($telids_b[$tela['telid']])) { + if (!($c[$j] = diff_user_tel($tela, $b[$telids_b[$tela['adrid']]]))) { + unset($c[$j]); + } + unset($telids_b[$tela['telid']]); + } + } else { + // try to find a match in b + foreach ($b as $i => $telb) { + if (same_tel($tela['tel'], $telb['tel'])) { + $tela['telid'] = $telb['telid']; + if (!($c[$j] = diff_user_tel($tela, $telb))) { + unset($c[$j]); + } + unset($telids_b[$tela['telid']]); + break; + } + } + } + } + + foreach ($telids_b as $telidb => $i) + $c[] = array('telid' => $telidb, 'remove' => 1); + return $c; +} + +function diff_user_address($a, $b) { + if (isset($b['pub']) && isset($a['pub']) && has_user_right($b['pub'], $a['pub'])) + $a['pub'] = $b['pub']; + if (isset($b['tels'])) { + if (isset($a['tels'])) { + $avar = $a['tels']; + } else { + $avar = array(); + } + $ctels = diff_user_tels($avar, $b['tels']); + + if (!count($ctels)) { + $b['tels'] = $avar; + } else { + $a['tels'] = $ctels; + } + } + + foreach ($a as $val => $avar) { + if (!isset($b[$val]) || !same_field($avar,$b[$val])) { + return $a; + } + } + return false; +} + +// $b need to use adrids +function diff_user_addresses(&$a, &$b) { + $c = $a; + $adrids_b = array(); + foreach ($b as $i => $adrb) $adrids_b[$adrb['adrid']] = $i; + + foreach ($a as $j => $adra) { + if (isset($adra['adrid'])) { + // if b has an address with the same adrid, compute diff + if (isset($adrids_b[$adra['adrid']])) { + if (!($c[$j] = diff_user_address($adra, $b[$adrids_b[$adra['adrid']]]))) + unset($c[$j]); + unset($adrids_b[$adra['adrid']]); + } + } else { + // try to find a match in b + foreach ($b as $i => $adrb) { + if (same_address($adra, $adrb)) { + $adra['adrid'] = $adrb['adrid']; + if (!($c[$j] = diff_user_address($adra, $adrb))) + unset($c[$j]); + if ($c[$j]) $c[$j]['adrid'] = $adra['adrid']; + unset($adrids_b[$adra['adrid']]); + break; + } + } + } + } + + foreach ($adrids_b as $adridb => $i) + $c[] = array('adrid' => $adridb, 'remove' => 1); + + if (!count($c)) return false; + return $c; +} + +function diff_user_pro($a, &$b, $view = 'private') { + if (isset($b['pub']) && isset($a['pub']) && has_user_right($b['pub'], $a['pub'])) + $a['pub'] = $b['pub']; + if (isset($b['adr_pub']) && !has_user_right($b['adr_pub'], $view)) { + unset($a['adr1']); + unset($a['adr2']); + unset($a['adr3']); + unset($a['postcode']); + unset($a['city']); + unset($a['countrytxt']); + unset($a['region']); + } + if (isset($b['adr_pub']) && isset($a['adr_pub']) && has_user_right($b['adr_pub'], $a['adr_pub'])) + $a['adr_pub'] = $b['adr_pub']; + if (isset($b['tels'])) { + if (isset($a['tels'])) + $avar = $a['tels']; + else + $avar = array(); + $ctels = diff_user_tels($avar, $b['tels']); + + if (!count($ctels)) { + $b['tels'] = $avar; + } else + $a['tels'] = $ctels; + } + if (isset($b['email_pub']) && !has_user_right($b['email_pub'], $view)) + unset($a['email']); + if (isset($b['email_pub']) && isset($a['email_pub']) && has_user_right($b['email_pub'], $a['email_pub'])) + $a['email_pub'] = $b['email_pub']; + foreach ($a as $val => $avar) { + if (($avar && !isset($b[$val])) || !same_field($avar,$b[$val])) { + return $a; + } + } + return false; +} + +// $b need to use entrids +function diff_user_pros(&$a, &$b, $view = 'private') { + $c = $a; + $entrids_b = array(); + foreach ($b as $i => $prob) $entrids_b[$prob['entrid']] = $i; + + foreach ($a as $j => $proa) { + if (isset($proa['entrid'])) { + // if b has an address with the same adrid, compute diff + if (isset($entrids_b[$proa['entrid']])) { + if (!($c[$j] = diff_user_pro($proa, $b[$entrids_b[$proa['entrid']]], $view))) + unset($c[$j]); + unset($entrids_b[$proa['entrid']]); + } + } else { + // try to find a match in b + foreach ($b as $i => $prob) { + if (same_pro($proa, $prob)) { + $proa['entrid'] = $prob['entrid']; + if (!($c[$j] = diff_user_pro($proa, $prob, $view))) + unset($c[$j]); + if ($c[$j]) $c[$j]['entrid'] = $proa['entrid']; + unset($entrids_b[$proa['entrid']]); + break; + } + } + } + } + + foreach ($entrids_b as $entridb => $i) + $c[] = array('entrid' => $entridb, 'remove' => 1); + + if (!count($c)) return false; + return $c; +} + +function format_phone_number($tel) +{ + $tel = trim($tel); + if (substr($tel, 0, 3) === '(0)') { + $tel = '33' . $tel; + } + $tel = preg_replace('/\(0\)/', '', $tel); + $tel = preg_replace('/[^0-9]/', '', $tel); + if (substr($tel, 0, 2) === '00') { + $tel = substr($tel, 2); + } else if(substr($tel, 0, 1) === '0') { + $tel = '33' . substr($tel, 1); + } + return $tel; +} + +function format_display_number($tel, &$error, $format = array('format'=>'','phoneprf'=>'')) +{ + $error = false; + $ret = ''; + $tel_length = strlen($tel); + if((!isset($format['phoneprf'])) || ($format['phoneprf'] == '')) { + $res = XDB::query("SELECT phonePrefix AS phoneprf, phoneFormat AS format + FROM geoloc_countries + WHERE phonePrefix = {?} OR phonePrefix = {?} OR phonePrefix = {?} + LIMIT 1", + substr($tel, 0, 1), substr($tel, 0, 2), substr($tel, 0, 3)); + if ($res->numRows() == 0) { + $error = true; + return '+' . $tel; + } + $format = $res->fetchOneAssoc(); + } + if ($format['format'] == '') { + $format['format'] = '+p'; + } + $j = 0; + $i = strlen($format['phoneprf']); + $length_format = strlen($format['format']); + while (($i < $tel_length) && ($j < $length_format)){ + if ($format['format'][$j] == '#'){ + $ret .= $tel[$i]; + $i++; + } else if ($format['format'][$j] == 'p') { + $ret .= $format['phoneprf']; + } else { + $ret .= $format['format'][$j]; + } + $j++; + } + for (; $i < $tel_length - 1; $i += 2) { + $ret .= ' ' . substr($tel, $i, 2); + } + //appends last alone number to the last block + if ($i < $tel_length) { + $ret .= substr($tel, $i); + } + return $ret; +} + +/** + * Extract search token from term + * @param $term a utf-8 string that can contain any char + * @param an array of elementary tokens + */ +function tokenize_job_term($term) +{ + $term = mb_strtoupper(replace_accent($term)); + $term = str_replace(array('/', ',', '(', ')', '"', '&', '»', '«'), ' ', $term); + $tokens = explode(' ', $term); + static $not_tokens = array('ET','AND','DE','DES','DU','D\'','OU','L\'','LA','LE','LES','PAR','AU','AUX','EN','SUR','UN','UNE','IN'); + foreach ($tokens as &$t) { + if (substr($t, 1, 1) == '\'' && in_array(substr($t, 0, 2), $not_tokens)) { + $t = substr($t, 2); + } + if (strlen($t) == 1 || in_array($t, $not_tokens)) { + $t = false; + continue; + } + } + return array_filter($tokens); +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/upgrade/1.0.1/00_job.sql b/upgrade/1.0.1/00_job.sql index 7b6e6ad..79c721b 100644 --- a/upgrade/1.0.1/00_job.sql +++ b/upgrade/1.0.1/00_job.sql @@ -4,4 +4,63 @@ ALTER TABLE profile_job_enum MODIFY COLUMN email VARCHAR(255) DEFAULT NULL; ALTER TABLE profile_job_enum MODIFY COLUMN NAF_code CHAR(5) DEFAULT NULL; ALTER TABLE profile_job_enum MODIFY COLUMN AX_code BIGINT(10) DEFAULT NULL; +CREATE TABLE `profile_job_term_enum` ( + `jtid` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'term id', + `name` varchar(255) NOT NULL COMMENT 'name used in hierarchical context', + `full_name` varchar(255) NOT NULL COMMENT 'name to use whithout context', + PRIMARY KEY (`jtid`) +) ENGINE=InnoDB, CHARSET=utf8, COMMENT='job terms'; + +CREATE TABLE `profile_job_term_relation` ( + `jtid_1` int unsigned NOT NULL COMMENT 'first term id', + `jtid_2` int unsigned NOT NULL COMMENT 'second term id', + `rel` enum('narrower','related') NOT NULL DEFAULT 'narrower' COMMENT 'relation between the second to the first term (second is narrower than first)', + `computed` enum('original','computed') NOT NULL DEFAULT 'original' COMMENT 'relations can be computed from two original relations', + PRIMARY KEY (`jtid_1`, `computed`, `jtid_2`), + FOREIGN KEY (`jtid_1`) REFERENCES `profile_job_term_enum` (`jtid`) ON DELETE CASCADE ON UPDATE CASCADE, + INDEX `jtid_2` (`jtid_2`), + FOREIGN KEY (`jtid_2`) REFERENCES `profile_job_term_enum` (`jtid`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB, CHARSET=utf8, COMMENT='job terms relations'; + +CREATE TABLE `profile_job_term_search` ( + `search` varchar(50) NOT NULL COMMENT 'search token for a term', + `jtid` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'term id', + PRIMARY KEY (`search`, `jtid`), + INDEX `jtid` (`jtid`), + FOREIGN KEY (`jtid`) REFERENCES `profile_job_term_enum` (`jtid`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB, CHARSET=utf8, COMMENT='search tokens of job terms'; + +CREATE TABLE `profile_job_term` ( + `pid` int NOT NULL COMMENT 'profile id', + `jid` tinyint unsigned NOT NULL COMMENT 'job id in profile', + `jtid` int unsigned NOT NULL COMMENT 'term id', + `computed` enum('original','computed') NOT NULL DEFAULT 'original' COMMENT 'terms can be added by user or computed from entreprise', + PRIMARY KEY (`pid`, `jid`, `jtid`), + INDEX `jtid` (`jtid`), + FOREIGN KEY (`pid`, `jid`) REFERENCES `profile_job` (`pid`, `id`) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`jtid`) REFERENCES `profile_job_term_enum` (`jtid`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB, CHARSET=utf8, COMMENT='job terms for jobs in profiles'; + +CREATE TABLE `profile_mentor_term` ( + `pid` int NOT NULL COMMENT 'profile id', + `jtid` int unsigned NOT NULL COMMENT 'term id', + PRIMARY KEY (`pid`, `jtid`), + INDEX `jtid` (`jtid`), + FOREIGN KEY (`pid`) REFERENCES `profiles` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`jtid`) REFERENCES `profile_job_term_enum` (`jtid`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB, CHARSET=utf8, COMMENT='job terms for mentorship in profiles'; + +CREATE TABLE `profile_job_entreprise_term` ( + `eid` int unsigned NOT NULL COMMENT 'entreprise id', + `jtid` int unsigned NOT NULL COMMENT 'term id', + PRIMARY KEY (`eid`, `jtid`), + INDEX `jtid` (`jtid`), + FOREIGN KEY (`eid`) REFERENCES `profile_job_enum` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`jtid`) REFERENCES `profile_job_term_enum` (`jtid`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB, CHARSET=utf8, COMMENT='job terms associated to entreprises'; + +-- Adds the root term -- +INSERT INTO `profile_job_term_enum` (`jtid`, `name`) VALUES (0, ''); +UPDATE `profile_job_term_enum` SET `jtid` = 0 WHERE `name` = ''; + -- vim:set syntax=mysql: diff --git a/upgrade/1.0.1/alternate_subsubsectors.php b/upgrade/1.0.1/alternate_subsubsectors.php deleted file mode 100755 index e94dadd..0000000 --- a/upgrade/1.0.1/alternate_subsubsectors.php +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/php5 -debug = 0; //do not store backtraces - -$data = implode('', file('arbo-UTF8.xml')); -$parser = xml_parser_create(); -xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); -xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); -xml_parse_into_struct($parser, $data, $values, $tags); -xml_parser_free($parser); - -// loop through the structures -foreach ($values as $val) { - if ($val['tag'] == 'grand-domaine' && $val['type'] == 'open') { - $res = XDB::execute('INSERT INTO profile_job_sector_enum (name) - VALUES ({?})', - ucfirst(mb_strtolower($val['attributes']['intitule']))); - $sectorid = XDB::insertId(); - } - if ($val['tag'] == 'domaine' && $val['type'] == 'open') { - $res = XDB::execute('INSERT INTO profile_job_subsector_enum (sectorid, name) - VALUES ({?}, {?})', - $sectorid, $val['attributes']['intitule']); - $subsectorid = XDB::insertId(); - } - if ($val['tag'] == 'domaine-intermediaire' && $val['type'] == 'open') { - $res = XDB::execute('INSERT INTO profile_job_subsector_enum (sectorid, name, flags) - VALUES ({?}, {?}, \'optgroup\')', - $sectorid, $val['attributes']['intitule']); - } - if ($val['tag'] == 'fiche' && $val['type'] == 'open') { - $res = XDB::execute('INSERT INTO profile_job_subsubsector_enum (sectorid, subsectorid, name) - VALUES ({?}, {?}, {?})', - $sectorid, $subsectorid, $val['attributes']['intitule']); - $subsubsectorid = XDB::insertId(); - $id = 0; - } - if ($val['tag'] == 'appellation' && $val['type'] == 'complete') { - $res = XDB::execute('INSERT INTO profile_job_alternates (id, subsubsectorid, name) - VALUES ({?}, {?}, {?})', - $id, $subsubsectorid, $val['attributes']['intitule']); - ++$id; - } -} - -/* vim:set et sw=4 sts=4 ts=4: */ -?> diff --git a/upgrade/1.0.1/arbo-UTF8.xml b/upgrade/1.0.1/arbo-UTF8.xml new file mode 100644 index 0000000..991afe0 --- /dev/null +++ b/upgrade/1.0.1/arbo-UTF8.xml @@ -0,0 +1,12917 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/upgrade/1.0.1/positions_as_terms.php b/upgrade/1.0.1/positions_as_terms.php new file mode 100755 index 0000000..d69a485 --- /dev/null +++ b/upgrade/1.0.1/positions_as_terms.php @@ -0,0 +1,47 @@ +#!/usr/bin/php5 +debug = 0; //do not store backtraces + +$data = implode('', file('arbo-UTF8.xml')); +$parser = xml_parser_create(); +xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); +xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); +xml_parse_into_struct($parser, $data, $values, $tags); +xml_parser_free($parser); + +XDB::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ("Emplois", "Emplois")'); + +$opened_nodes = array(); +$broader_ids = array(XDB::insertId()); + +XDB::execute('INSERT INTO profile_job_term_relation VALUES (0, {?}, "narrower", "original"), ({?}, {?}, "narrower", "computed")', + $broader_ids[0], $broader_ids[0], $broader_ids[0]); + +// loop through the structures +foreach ($values as $val) { + if (($val['type'] == 'open' || $val['type'] == 'complete') && !empty($val['attributes']['intitule'])) { + $intitule = $val['attributes']['intitule']; + if (mb_strtoupper($intitule) == $intitule) { + $intitule = ucfirst(mb_strtolower($intitule)); + } + $res = XDB::execute('INSERT INTO profile_job_term_enum (name, full_name) + VALUES ({?}, {?})', + $intitule, $intitule.' (emploi'.(($val['type'] == 'open')?'s':'').')'); + $newid = XDB::insertId(); + array_unshift($broader_ids, $newid); + array_unshift($opened_nodes, $val['tag']); + foreach ($broader_ids as $i => $bid) { + XDB::execute('INSERT INTO profile_job_term_relation VALUES ({?}, {?}, "narrower", {?})', + $bid, $newid, ($i == 1)?'original':'computed'); + } + } + if (count($opened_nodes) > 0 && $val['tag'] == $opened_nodes[0] && ($val['type'] == 'close' || $val['type'] == 'complete')) { + array_shift($broader_ids); + array_shift($opened_nodes); + } +} + +/* vim:set et sw=4 sts=4 ts=4: */ +?> diff --git a/upgrade/1.0.1/sectors_as_terms.php b/upgrade/1.0.1/sectors_as_terms.php new file mode 100755 index 0000000..7e21a35 --- /dev/null +++ b/upgrade/1.0.1/sectors_as_terms.php @@ -0,0 +1,70 @@ +#!/usr/bin/php5 +debug = 0; //do not store backtraces + +XDB::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ("Secteurs d\'activité", "Secteurs d\'activité")'); +$root_sector_id = XDB::insertId(); +XDB::execute('INSERT INTO `profile_job_term_relation` VALUES (0, {?}, "narrower", "original"), ({?}, {?}, "narrower", "computed")', + $root_sector_id, $root_sector_id, $root_sector_id); + +// loops through sectors +$sectors = XDB::iterator('SELECT `id`, `name` FROM `profile_job_sector_enum`'); +while ($oldsector = $sectors->next()) { + // adds sector as term + XDB::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ( {?}, {?} )', $oldsector['name'], $oldsector['name'].' (secteur)'); + $sector_id = XDB::insertId(); + // links to root for sectors + XDB::execute('INSERT INTO `profile_job_term_relation` VALUES ({?}, {?}, "narrower", "original"), ({?}, {?}, "narrower", "computed")', + $root_sector_id, $sector_id, $sector_id, $sector_id); + // adds sector term to linked jobs and linked mentorships + XDB::execute('INSERT INTO `profile_job_term` + SELECT `pid`, `id`, {?}, "original" + FROM `profile_job` + WHERE `sectorid` = {?} AND `subsectorid` = 0', + $sector_id, $oldsector['id']); + XDB::execute('INSERT INTO `profile_mentor_term` + SELECT `pid`, {?} + FROM `profile_mentor_sector` + WHERE `sectorid` = {?} AND `subsectorid` = 0', + $sector_id, $oldsector['id']); + // loops through subsectors + $subsectors = XDB::iterator('SELECT `id`, `name` FROM `profile_job_subsector_enum` WHERE sectorid = {?}', $oldsector['id']); + while ($oldsubsector = $subsectors->next()) { + if ($oldsubsector['name'] == $oldsector['name']) { + // adds sector term to jobs and mentorships linked to subsector with same name as sector + XDB::execute('INSERT INTO `profile_job_term` + SELECT `pid`, `id`, {?}, "original" + FROM `profile_job` + WHERE `sectorid` = {?} AND `subsectorid` = {?}', + $sector_id, $oldsector['id'], $oldsubsector['id']); + XDB::execute('INSERT INTO `profile_mentor_term` + SELECT `pid`, {?} + FROM `profile_mentor_sector` + WHERE `sectorid` = {?} AND `subsectorid` = {?}', + $sector_id, $oldsector['id'], $oldsubsector['id']); + continue; + } + // adds subsector as term + XDB::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ( {?}, {?} )', $oldsubsector['name'], $oldsubsector['name'].' (secteur)'); + $subsector_id = XDB::insertId(); + // links to root for sectors and to sector + XDB::execute('INSERT INTO `profile_job_term_relation` VALUES ({?}, {?}, "narrower", "computed"), ({?}, {?}, "narrower", "original"), ({?}, {?}, "narrower", "computed")', + $root_sector_id, $subsector_id, $sector_id, $subsector_id, $subsector_id, $subsector_id); + // adds subsector term to linked jobs and mentorships + XDB::execute('INSERT INTO `profile_job_term` + SELECT `pid`, `id`, {?}, "original" + FROM `profile_job` + WHERE `sectorid` = {?} AND `subsectorid` = {?}', + $subsector_id, $oldsector['id'], $oldsubsector['id']); + XDB::execute('INSERT INTO `profile_mentor_term` + SELECT `pid`, {?} + FROM `profile_mentor_sector` + WHERE `sectorid` = {?} AND `subsectorid` = {?}', + $subsector_id, $oldsector['id'], $oldsubsector['id']); + } +} + +/* vim:set et sw=4 sts=4 ts=4: */ +?> diff --git a/upgrade/1.0.1/tokenize_job_terms.php b/upgrade/1.0.1/tokenize_job_terms.php new file mode 100755 index 0000000..31bea52 --- /dev/null +++ b/upgrade/1.0.1/tokenize_job_terms.php @@ -0,0 +1,22 @@ +#!/usr/bin/php5 +debug = 0; //do not store backtraces + +$terms = XDB::iterator('SELECT `jtid`, `name` FROM `profile_job_term_enum`'); +while ($term = $terms->next()) { + $tokens = array_unique(tokenize_job_term($term['name'])); + if (!count($tokens)) { + continue; + } + $values = array(); + foreach ($tokens as $t) { + $values[] = '('.XDB::escape($t).','.XDB::escape($term['jtid']).')'; + } + XDB::execute('INSERT IGNORE INTO `profile_job_term_search` (`search`,`jtid`) VALUES '.implode(',',$values)); +} + +/* vim:set et sw=4 sts=4 ts=4: */ +?>