source: pmb4.2/trunk/fuentes/pmb/admin/netbase/reindex_rdfstore.inc.php @ 815

Last change on this file since 815 was 815, checked in by jrpelegrina, 4 years ago

Initial release of pmb 4.2

  • Property svn:executable set to *
File size: 4.1 KB
Line 
1<?php
2// +-------------------------------------------------+
3// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
4// +-------------------------------------------------+
5// $Id: reindex_rdfstore.inc.php,v 1.5 2015-04-03 11:16:18 jpermanne Exp $
6
7if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) die("no access");
8
9
10// la taille d'un paquet de notices
11$lot = REINDEX_PAQUET_SIZE; // defini dans ./params.inc.php
12
13// taille de la jauge pour affichage
14$jauge_size = GAUGE_SIZE;
15$jauge_size .= "px";
16
17// initialisation de la borne de départ
18if (!isset($start)) {
19        $start=0;
20        //remise a zero de la table au début
21        pmb_mysql_query("TRUNCATE rdfstore_index",$dbh);
22}
23
24$v_state=urldecode($v_state);
25
26if (!$count) {
27        $q_count = "select count(1) from rdfstore_triple t, rdfstore_id2val l where t.o_type=2 and t.o_lang_dt=l.id and length(l.val)<3";
28        $r_count = pmb_mysql_query($q_count, $dbh);
29        $count = pmb_mysql_result($r_count, 0, 0);
30}
31
32print "<br /><br /><h2 align='center'>".htmlentities($msg["nettoyage_rdfstore_reindexation"], ENT_QUOTES, $charset)."</h2>";
33
34$q_sel = "
35select t.t as num_triple, s.val as subject_uri, p.val as predicat_uri, o.id as num_object, o.val as object_val, l.val as object_lang
36from rdfstore_triple t, rdfstore_s2val s, rdfstore_id2val p, rdfstore_o2val o, rdfstore_id2val l 
37where t.o_type=2 and t.o_lang_dt=l.id and length(l.val)<3 and t.s=s.id and t.p=p.id and t.o=o.id
38order by t.t LIMIT $start, $lot";
39$r_sel = pmb_mysql_query($q_sel,$dbh);
40
41if(pmb_mysql_num_rows($r_sel)) {
42       
43        // définition de l'état de la jauge
44        $state = floor($start / ($count / $jauge_size));
45        $state .= "px";
46        // mise à jour de l'affichage de la jauge
47        print "<table border='0' align='center' width='$jauge_size' cellpadding='0'><tr><td class='jauge' width='100%'>";
48        print "<img src='../../images/jauge.png' width='$state' height='16px'></td></tr></table>";
49               
50        // calcul pourcentage avancement
51        $percent = floor(($start/$count)*100);
52       
53        // affichage du % d'avancement et de l'état
54        print "<div align='center'>$percent%</div>";
55
56        require_once("$class_path/rdf/ontology.class.php");
57        $op = new ontology_parser("$class_path/rdf/skos_pmb.rdf");
58        $sh = new skos_handler($op);
59
60        while(($triple = pmb_mysql_fetch_object($r_sel))){
61                $type=$sh->op->from_ns($sh->get_object_type($triple->subject_uri));
62                $q_ins = "insert ignore into rdfstore_index ";
63                $q_ins.= "set num_triple='".$triple->num_triple."', ";
64                $q_ins.= "subject_uri='".addslashes($triple->subject_uri)."', ";
65                $q_ins.= "subject_type='".addslashes($type)."', ";
66                $q_ins.= "predicat_uri='".addslashes($triple->predicat_uri)."', ";
67                $q_ins.= "num_object='".$triple->num_object."', "; 
68                $q_ins.= "object_val ='".addslashes($triple->object_val)."', ";
69                $q_ins.= "object_index=' ".strip_empty_chars($triple->object_val)." ', ";
70                $q_ins.= "object_lang ='".addslashes($triple->object_lang)."' ";
71
72                $r_ins = pmb_mysql_query($q_ins,$dbh);
73        }
74       
75        $next = $start + $lot;
76        print "
77                <form class='form-$current_module' name='current_state' action='./clean.php' method='post'>
78                <input type='hidden' name='v_state' value=\"".urlencode($v_state)."\">
79                <input type='hidden' name='spec' value=\"$spec\">
80                <input type='hidden' name='start' value=\"$next\">
81                <input type='hidden' name='count' value=\"$count\">
82                </form>
83                <script type=\"text/javascript\"><!--
84                setTimeout(\"document.forms['current_state'].submit()\",1000);
85                -->
86                </script>";
87} else {
88        $spec = $spec - INDEX_RDFSTORE;
89        $not = pmb_mysql_query("select count(1) from rdfstore_triple where o_type=2", $dbh);
90        $compte = pmb_mysql_result($not, 0, 0);
91        $v_state .= "<br /><img src=../../images/d.gif hspace=3>".htmlentities($msg['nettoyage_rdfstore_reindexation'], ENT_QUOTES, $charset)." : ";
92        $v_state .= $compte." ".htmlentities($msg['nettoyage_rdfstore_reindex_elt'], ENT_QUOTES, $charset);
93        print "
94                <form class='form-$current_module' name='process_state' action='./clean.php' method='post'>
95                <input type='hidden' name='v_state' value=\"".urlencode($v_state)."\">
96                <input type='hidden' name='spec' value=\"$spec\">
97                </form>
98                <script type=\"text/javascript\"><!--
99                        document.forms['process_state'].submit();
100                        -->
101                </script>";
102}
103
104?>
Note: See TracBrowser for help on using the repository browser.