function update_index() { global $dbh, $include_path; $query = "select id_faq_question from faq_questions where faq_question_num_theme = " . $this->id_liste; $result = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($result)) { $index = new indexation($include_path . "/indexation/faq/question.xml", "faq_questions"); while ($row = pmb_mysql_fetch_object($result)) { $index->maj($row->id_faq_question, "theme"); } } }
static function update_index($id) { global $dbh; global $include_path; $indexation_authority = new indexation_authority($include_path . "/indexation/authorities/categories/champs_base.xml", "authorities", AUT_TABLE_CATEG); $indexation_authority->maj($id); //ajout des mots des termes dans la table words pour l autoindexation $q = "select trim(index_categorie) as index_categorie, langue from categories where num_noeud=" . $id; $r = pmb_mysql_query($q, $dbh); $i = 0; $t_words = array(); if (pmb_mysql_num_rows($r)) { while ($row = pmb_mysql_fetch_object($r)) { $t_row = explode(' ', $row->index_categorie); if (is_array($t_row) && count($t_row)) { $t_row = array_unique($t_row); foreach ($t_row as $w) { if ($w) { $t_words[$i]['word'] = $w; $t_words[$i]['lang'] = $row->langue; $i++; } } } } } if (count($t_words)) { //calcul de stem et double_metaphone foreach ($t_words as $i => $w) { $q1 = "select id_word from words where word='" . addslashes($w['word']) . "' and lang='" . addslashes($w['lang']) . "' limit 1"; $r1 = pmb_mysql_query($q1, $dbh); if (pmb_mysql_num_rows($r1)) { //le mot existe $t_words[$i]['allready_exists'] = 1; } else { //le mot n'existe pas $dmeta = new DoubleMetaPhone($w['word']); if ($dmeta->primary || $dmeta->secondary) { $t_words[$i]['double_metaphone'] = $dmeta->primary . " " . $dmeta->secondary; } if ($w['lang'] == 'fr_FR') { $stemming = new stemming($w['word']); $t_words[$i]['stem'] = $stemming->stem; } else { $t_words[$i]['stem'] = ''; } } } foreach ($t_words as $i => $w) { if (!$w['allready_exists']) { $q2 = "insert ignore into words (word, lang, double_metaphone, stem) values ('" . $w['word'] . "', '" . $w['lang'] . "', '" . $w['double_metaphone'] . "', '" . $w['stem'] . "') "; pmb_mysql_query($q2, $dbh); } } } // On cherche tous les n-uplet de la table notice correspondant à cette catégorie. $found = pmb_mysql_query("select distinct notcateg_notice from notices_categories where num_noeud='" . $id . "' ", $dbh); // Pour chaque n-uplet trouvés on met a jour la table notice_global_index avec l'auteur modifié : $num = pmb_mysql_num_rows($found); for ($j = 0; $j < $num; $j++) { $mesNotices = pmb_mysql_fetch_object($found); $notice_id = $mesNotices->notcateg_notice; notice::majNoticesGlobalIndex($notice_id); notice::majNoticesMotsGlobalIndex($notice_id, 'subject'); } //on cherche les questions correspondantes... $query = "select num_faq_question from faq_questions_categories where num_categ = " . $id; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $index = new indexation($include_path . "/indexation/faq/question.xml", "faq_questions"); while ($row = pmb_mysql_fetch_object($result)) { $index->maj($row->num_faq_question, "categories"); } } }
public function maj($object_id, $object_uri = "", $datatype = "all") { if ($object_id == 0 && $object_uri != "") { $object_id = onto_common_uri::get_id($object_uri); } if ($object_id != 0 && !$object_uri) { $object_uri = onto_common_uri::get_uri($object_id); } if (!count($this->tab_code_champ)) { $this->init(); } $tab_words_insert = $tab_fields_insert = array(); $this->get_sparql_result($object_uri); $this->delete_index($object_id, $datatype); //on a un tableau de résultat, on peut le travailler... foreach ($this->tab_code_champ as $field_id => $element) { foreach ($element as $column => $infos) { if (isset($this->sparql_result[$column])) { $field_order = 1; foreach ($this->sparql_result[$column] as $key => $values) { foreach ($values as $key2 => $value) { if (is_string($value)) { $language = $key; //fields (contenu brut) $tab_fields_insert[] = "('" . $object_id . "','" . $infos['champ'] . "','" . $infos['ss_champ'] . "','" . $field_order . "','" . addslashes($value) . "','" . $language . "','" . $infos['pond'] . "','" . $autority_num . "')"; //words (contenu éclaté) $tab_tmp = explode(' ', strip_empty_words($value)); $word_position = 1; foreach ($tab_tmp as $word) { $num_word = indexation::add_word($word, $language); $tab_words_insert[] = "(" . $object_id . "," . $infos["champ"] . "," . $infos["ss_champ"] . "," . $num_word . "," . $infos["pond"] . ",{$field_order},{$word_position})"; $word_position++; } } else { $language = $key2; $autority_num = onto_common_uri::get_id($key); foreach ($value as $val) { //fields (contenu brut) $tab_fields_insert[] = "('" . $object_id . "','" . $infos['champ'] . "','" . $infos['ss_champ'] . "','" . $field_order . "','" . addslashes($val) . "','" . $language . "','" . $infos['pond'] . "','" . $autority_num . "')"; //words (contenu éclaté) $tab_tmp = explode(' ', strip_empty_words($val)); $word_position = 1; foreach ($tab_tmp as $word) { $num_word = indexation::add_word($word, $language); $tab_words_insert[] = "(" . $object_id . "," . $infos["champ"] . "," . $infos["ss_champ"] . "," . $num_word . "," . $infos["pond"] . ",{$field_order},{$word_position})"; $word_position++; } } } $field_order++; } } } else { continue; } } } $this->save_elements($tab_words_insert, $tab_fields_insert); return true; }
} print "<br /><br /><h2 align='center'>" . htmlentities($msg["nettoyage_reindex_faq"], ENT_QUOTES, $charset) . "</h2>"; $NoIndex = 1; $query = pmb_mysql_query("select id_faq_question from faq_questions order by id_faq_question LIMIT {$start}, {$lot}"); if (pmb_mysql_num_rows($query)) { // définition de l'état de la jauge $state = floor($start / ($count / $jauge_size)); $state .= "px"; // mise à jour de l'affichage de la jauge print "<table border='0' align='center' width='{$jauge_size}' cellpadding='0'><tr><td class='jauge' width='100%'>"; print "<img src='../../images/jauge.png' width='{$state}' height='16px'></td></tr></table>"; // calcul pourcentage avancement $percent = floor($start / $count * 100); // affichage du % d'avancement et de l'état print "<div align='center'>{$percent}%</div>"; $indexation = new indexation($include_path . "/indexation/faq/question.xml", "faq_questions"); while ($row = pmb_mysql_fetch_assoc($query)) { // permet de charger la bonne langue, mot vide... $info = $indexation->maj($row['id_faq_question']); } pmb_mysql_free_result($query); $next = $start + $lot; print "\n\t<form class='form-{$current_module}' name='current_state' action='./clean.php' method='post'>\n\t<input type='hidden' name='v_state' value=\"" . urlencode($v_state) . "\">\n\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t<input type='hidden' name='start' value=\"{$next}\">\n\t<input type='hidden' name='count' value=\"{$count}\">\n\t</form>\n\t<script type=\"text/javascript\"><!-- \n\tsetTimeout(\"document.forms['current_state'].submit()\",1000); \n\t-->\n\t</script>"; } else { $spec = $spec - INDEX_FAQ; $not = pmb_mysql_query("SELECT count(distinct id_faq_question) FROM faq_questions_words_global_index", $dbh); $compte = pmb_mysql_result($not, 0, 0); $v_state .= "<br /><img src=../../images/d.gif hspace=3>" . htmlentities($msg["nettoyage_reindex_faq"], ENT_QUOTES, $charset) . " :"; $v_state .= $compte . " " . htmlentities($msg["nettoyage_res_reindex_faq"], ENT_QUOTES, $charset); print "\n\t\t<form class='form-{$current_module}' name='process_state' action='./clean.php' method='post'>\n\t\t<input type='hidden' name='v_state' value=\"" . urlencode($v_state) . "\">\n\t\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t\t</form>\n\t\t<script type=\"text/javascript\"><!--\n\t\t\tdocument.forms['process_state'].submit();\n\t\t\t-->\n\t\t</script>"; pmb_mysql_query("ALTER TABLE faq_questions_words_global_index ENABLE KEYS", $dbh);
public function __construct($xml_filepath, $table_prefix, $type) { parent::__construct($xml_filepath, $table_prefix); $this->type = $type; }
public function save() { global $include_path; global $dbh; if ($this->id) { $query = "update "; $where = " where id_faq_question = " . $this->id; } else { $query = "insert into "; $where = ""; } $query .= "faq_questions set "; $query .= "faq_question_num_type = " . $this->num_type . ","; $query .= "faq_question_num_theme = " . $this->num_theme . ","; $query .= "faq_question_num_demande = " . $this->num_demande . ","; $query .= "faq_question_question = '" . addslashes($this->question) . "',"; $query .= "faq_question_question_date = '" . addslashes($this->question_date) . "',"; $query .= "faq_question_question_userdate = '" . addslashes(detectFormatDate($this->question_userdate)) . "',"; $query .= "faq_question_answer = '" . addslashes($this->answer) . "',"; $query .= "faq_question_answer_userdate = '" . addslashes($this->answer_userdate) . "',"; $query .= "faq_question_answer_date = '" . addslashes(detectFormatDate($this->answer_userdate)) . "',"; $query .= "faq_question_statut = " . $this->statut . ""; $result = pmb_mysql_query($query . $where, $dbh); if (!$this->id) { $this->id = pmb_mysql_insert_id($dbh); } if ($result) { $query = "delete from faq_questions_categories where num_faq_question = " . $this->id; $result = pmb_mysql_query($query, $dbh); if ($result) { $query = "insert into faq_questions_categories (num_faq_question,num_categ,categ_order) values "; $insert = ""; for ($i = 0; $i < count($this->descriptors); $i++) { if ($insert) { $insert .= ", "; } $insert .= "(" . $this->id . "," . $this->descriptors[$i] . "," . $i . ")"; } if ($insert) { $result = pmb_mysql_query($query . $insert, $dbh); } } } if ($result) { $xmlpath = $include_path . "/indexation/faq/question.xml"; $index = new indexation($xmlpath, "faq_questions"); $index->maj($this->id); } return $result; }
public static function add_word($word, $lang) { global $dbh; $query = "select id_word from words where word = '" . $word . "' and lang = '" . $lang . "'"; $result = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($result)) { $num_word = pmb_mysql_result($result, 0, 0); } else { $double_metaphone = indexation::calc_double_metephone($word, $lang); $stem = indexation::calc_stem($word, $lang); $element_to_update = ""; if ($double_metaphone) { $element_to_update .= "double_metaphone = '" . $double_metaphone . "'"; } if ($element_to_update) { $element_to_update .= ","; } $element_to_update .= "stem = '" . $stem . "'"; $query = "insert into words set word = '" . $word . "', lang = '" . $lang . "'" . ($element_to_update ? ", " . $element_to_update : ""); pmb_mysql_query($query, $dbh); $num_word = pmb_mysql_insert_id($dbh); } return $num_word; }
function cleanFAQ() { global $msg, $dbh, $charset, $PMBusername; global $include_path; if (SESSrights & ADMINISTRATION_AUTH) { $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_faq"], ENT_QUOTES, $charset) . "</h3>"; //remise a zero de la table au début pmb_mysql_query("TRUNCATE faq_questions_words_global_index", $dbh); pmb_mysql_query("ALTER TABLE faq_questions_words_global_index DISABLE KEYS", $dbh); pmb_mysql_query("TRUNCATE faq_questions_fields_global_index", $dbh); pmb_mysql_query("ALTER TABLE faq_questions_fields_global_index DISABLE KEYS", $dbh); $query = "select id_faq_question from faq_questions order by id_faq_question"; $faq_questions = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($faq_questions)) { $indexation = new indexation($include_path . "/indexation/faq/question.xml", "faq_questions"); while ($row = pmb_mysql_fetch_object($faq_questions)) { $indexation->maj($row->id_faq_question); } } pmb_mysql_query("ALTER TABLE faq_questions_words_global_index ENABLE KEYS", $dbh); pmb_mysql_query("ALTER TABLE faq_questions_fields_global_index ENABLE KEYS", $dbh); $faq = pmb_mysql_query("SELECT count(1) FROM faq_questions", $dbh); $count = pmb_mysql_result($faq, 0, 0); $result .= $count . " " . htmlentities($msg['nettoyage_res_reindex_faq'], ENT_QUOTES, $charset); } else { $result .= sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername); } return $result; }