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 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;
 }
$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);
    pmb_mysql_query("ALTER TABLE faq_questions_fields_global_index ENABLE KEYS", $dbh);
}
 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;
 }