Esempio n. 1
0
     } else {
         $categ_rec = "unchecked='unchecked'";
     }
     $categ_ = str_replace("!!chk!!", $categ_rec, $categ_);
     $see_also_form .= $categ_ . "\n";
 }
 $see_also_form .= "</div>";
 $form_renvoivoiraussi = str_replace("!!renvoi_voir_aussi!!", $see_also_form, $form_renvoivoiraussi);
 $category_form = str_replace("<!-- renvoivoiraussi -->", $form_renvoivoiraussi, $category_form);
 //liaisons
 $has_link = false;
 $categ_child_content = "";
 if (noeuds::hasChild($id)) {
     $has_link = true;
     $odd_even = 1;
     if ($res = noeuds::listChilds($id, 0)) {
         $categ_child_content .= "\n\t\t\t\t<div class='row'>\n\t        \t\t<label for='' class='etiquette'>{$msg['categ_childs']}</label>\n\t        \t</div>\n\t        \t<div class='row'>\n\t        \t\t<table>";
         while ($row = mysql_fetch_object($res)) {
             $tcateg = new category($row->id_noeud);
             if ($odd_even == 0) {
                 $categ_child_content .= "\t<tr class='odd'>";
                 $odd_even = 1;
             } else {
                 if ($odd_even == 1) {
                     $categ_child_content .= "\t<tr class='even'>";
                     $odd_even = 0;
                 }
             }
             $notice_count = $tcateg->notice_count(false);
             $categ_child_content .= "<td class='colonne80'>";
             if ($tcateg->has_child) {
Esempio n. 2
0
 function cleanCategoriesPath()
 {
     global $msg, $charset, $PMBusername;
     if (SESSrights & ADMINISTRATION_AUTH) {
         // Pour tous les thésaurus, on parcours les childs
         $list_thesaurus = thesaurus::getThesaurusList();
         foreach ($list_thesaurus as $id_thesaurus => $libelle_thesaurus) {
             $thes = new thesaurus($id_thesaurus);
             $noeud_rac = $thes->num_noeud_racine;
             $r = noeuds::listChilds($noeud_rac, 0);
             while ($row = mysql_fetch_object($r)) {
                 noeuds::process_categ_path($row->id_noeud);
             }
         }
         if ($thesaurus_auto_postage_search) {
             categories::process_categ_index();
         }
         $result .= htmlentities($msg["clean_categories_path_end"], ENT_QUOTES, $charset);
     } else {
         $result .= sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername);
     }
     return $result;
 }
Esempio n. 3
0
 function cleanCategories()
 {
     global $msg, $dbh, $charset, $PMBusername;
     if ($deleted == "") {
         $deleted = 0;
     }
     if (SESSrights & ADMINISTRATION_AUTH) {
         $result .= "<h3>" . htmlentities($msg["nettoyage_suppr_categories"], ENT_QUOTES, $charset) . "</h3>";
         $list_thesaurus = thesaurus::getThesaurusList();
         foreach ($list_thesaurus as $id_thesaurus => $libelle_thesaurus) {
             $thes = new thesaurus($id_thesaurus);
             $noeud_rac = $thes->num_noeud_racine;
             $r = noeuds::listChilds($noeud_rac, 0);
             while ($row = mysql_fetch_object($r)) {
                 noeuds::process_categ($row->id_noeud);
             }
         }
         //TODO non repris >> Utilité ???
         //	$delete = mysql_query("delete from categories where categ_libelle='#deleted#'");
         $result .= $deleted . " " . htmlentities($msg["nettoyage_res_suppr_categories"], ENT_QUOTES, $charset);
         $optn = noeuds::optimize();
         $optc = categories::optimize();
     } else {
         $result .= sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername);
     }
     return $result;
 }
Esempio n. 4
0
 function getRdfConcept($idNoeud)
 {
     global $lang;
     $arrayTriples = array();
     $noeud = new noeuds($idNoeud);
     $thes = new thesaurus($noeud->num_thesaurus);
     $uriConcept = $this->baseUriConcept . $idNoeud;
     $uriThes = $this->baseUriThesaurus . $noeud->num_thesaurus;
     //Si le noeud possède un renvoi-voir, la catégorie n'est pas dans le graphe, il n'y a que son libellé en altLabel sur le renvoi
     if ($noeud->num_renvoi_voir) {
         return $arrayTriples;
     }
     //Type
     $triple = array();
     $triple[0] = '<' . $uriConcept . '>';
     $triple[1] = "rdf:type";
     $triple[2] = "skos:Concept";
     $arrayTriples[] = $triple;
     //Appartenance au schéma
     $triple = array();
     $triple[0] = '<' . $uriConcept . '>';
     $triple[1] = "skos:inScheme";
     $triple[2] = '<' . $uriThes . '>';
     $arrayTriples[] = $triple;
     //Catégorie
     $categ = new categories($idNoeud, $thes->langue_defaut);
     //Label
     $triple = array();
     $triple[0] = '<' . $uriConcept . '>';
     $triple[1] = "skos:prefLabel";
     $triple[2] = '"' . addslashes($categ->libelle_categorie) . '"';
     $arrayTriples[] = $triple;
     //Note application
     if ($tmp = trim($categ->note_application)) {
         $triple = array();
         $triple[0] = '<' . $uriConcept . '>';
         $triple[1] = "skos:scopeNote";
         $triple[2] = '"' . $tmp . '"';
         $arrayTriples[] = $triple;
     }
     //Commentaire public
     if ($tmp = trim($categ->comment_public)) {
         $triple = array();
         $triple[0] = '<' . $uriConcept . '>';
         $triple[1] = "skos:note";
         $triple[2] = '"' . $tmp . '"';
         $arrayTriples[] = $triple;
     }
     //Noeud
     if ($noeud->num_parent) {
         if ($thes->num_noeud_racine == $noeud->num_parent) {
             $triple = array();
             $triple[0] = '<' . $uriConcept . '>';
             $triple[1] = "skos:topConceptOf";
             $triple[2] = '<' . $uriThes . '>';
             $arrayTriples[] = $triple;
         } else {
             $triple = array();
             $triple[0] = '<' . $uriConcept . '>';
             $triple[1] = "skos:broader";
             $triple[2] = '<' . $this->baseUriConcept . $noeud->num_parent . '>';
             $arrayTriples[] = $triple;
         }
     }
     //Les renvois
     $res = $noeud->listTargets();
     if (mysql_num_rows($res)) {
         while ($row = mysql_fetch_array($res)) {
             $renvoi = new categories($row[0], $thes->langue_defaut);
             $triple = array();
             $triple[0] = '<' . $uriConcept . '>';
             $triple[1] = "skos:altLabel";
             $triple[2] = '"' . addslashes($renvoi->libelle_categorie) . '"';
             $arrayTriples[] = $triple;
         }
     }
     //Gestion des enfants : on veut les enfants, même avec renvois (poly-hiérarchie)
     $res = noeuds::listChilds($idNoeud, 1);
     if (mysql_num_rows($res)) {
         while ($row = mysql_fetch_array($res)) {
             $enfant = new noeuds($row[0]);
             if ($enfant->num_renvoi_voir) {
                 $triple = array();
                 $triple[0] = '<' . $uriConcept . '>';
                 $triple[1] = "skos:narrower";
                 $triple[2] = '<' . $this->baseUriConcept . $enfant->num_renvoi_voir . '>';
                 $arrayTriples[] = $triple;
             } else {
                 $triple = array();
                 $triple[0] = '<' . $uriConcept . '>';
                 $triple[1] = "skos:narrower";
                 $triple[2] = '<' . $this->baseUriConcept . $row[0] . '>';
                 $arrayTriples[] = $triple;
             }
         }
     }
     //Les voir aussi
     $res = $noeud->listUsedInSeeAlso();
     if (mysql_num_rows($res)) {
         while ($row = mysql_fetch_array($res)) {
             $triple = array();
             $triple[0] = '<' . $uriConcept . '>';
             $triple[1] = "skos:related";
             $triple[2] = '<' . $this->baseUriConcept . $row[0] . '>';
             $arrayTriples[] = $triple;
         }
     }
     return $arrayTriples;
 }
//	}
//	$req="update noeuds set path='$path' where id_noeud=$id_noeud";
//	pmb_mysql_query($req,$dbh);
//}
//function process_categ_index() {
//	global $dbh;
//
//	$q = "select * from categories ";
//	$r = pmb_mysql_query($q, $dbh);
//	while ($obj = pmb_mysql_fetch_object($r)) {
//		$thes = new categories($obj->num_noeud,$obj->langue);
//		$thes->update_index_path_word();
//	}
//}
// Pour tous les thésaurus, on parcours les childs
$list_thesaurus = thesaurus::getThesaurusList();
foreach ($list_thesaurus as $id_thesaurus => $libelle_thesaurus) {
    $thes = new thesaurus($id_thesaurus);
    $noeud_rac = $thes->num_noeud_racine;
    $r = noeuds::listChilds($noeud_rac, 0);
    while ($row = pmb_mysql_fetch_object($r)) {
        noeuds::process_categ_path($row->id_noeud);
    }
}
if ($thesaurus_auto_postage_search) {
    categories::process_categ_index();
}
$spec = $spec - CLEAN_CATEGORIES_PATH;
$v_state = urldecode($v_state);
$v_state .= "<br /><img src=../../images/d.gif hspace=3>" . htmlentities($msg["clean_categories_path_end"], ENT_QUOTES, $charset) . ".";
print "<form class='form-{$current_module}' name='process_state' action='./clean.php' method='post'>\n\t\t\t<input type='hidden' name='v_state' value=\"" . urlencode($v_state) . "\">\n\t\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>";
Esempio n. 6
0
 function replace($by = 0, $link_save = 0)
 {
     global $msg, $dbh;
     global $pmb_synchro_rdf;
     if ($this->id_noeud == $by || !$this->id_noeud || !$by) {
         return $msg["categ_imposible_remplace_elle_meme"];
     }
     $aut_link = new aut_link(AUT_TABLE_CATEG, $this->id_noeud);
     // "Conserver les liens entre autorités" est demandé
     if ($link_save) {
         // liens entre autorités
         $aut_link->add_link_to(AUT_TABLE_CATEG, $by);
     }
     $aut_link->delete();
     //synchro_rdf : on empile les noeuds impactés pour les traiter plus loin
     if ($pmb_synchro_rdf) {
         $arrayIdImpactes = array();
         $arrayThesImpactes = array();
         $thes = thesaurus::getByEltId($this->id_noeud);
         $arrayThesImpactes[] = $thes->id_thesaurus;
         //parent
         if ($this->num_parent != $thes->num_noeud_racine) {
             $arrayIdImpactes[] = $this->num_parent;
         }
         //enfants
         $res = noeuds::listChilds($this->id_noeud, 1);
         if (pmb_mysql_num_rows($res)) {
             while ($row = pmb_mysql_fetch_array($res)) {
                 $arrayIdImpactes[] = $row[0];
             }
         }
         //renvoi_voir
         if ($this->num_renvoi_voir) {
             $arrayIdImpactes[] = $this->num_renvoi_voir;
         }
     }
     $noeuds_a_garder = new noeuds($by);
     //Si les noeuds sont du même thésaurus
     if ($noeuds_a_garder->num_thesaurus == $this->num_thesaurus) {
         //On déplace les catégories qui renvoi vers l'ancien noeuds pour qu'elle renvoie vers le nouveau
         if (noeuds::isTarget($this->id_noeud)) {
             $requete = "UPDATE noeuds SET num_renvoi_voir='" . $by . "' WHERE num_renvoi_voir='" . $this->id_noeud . "' and id_noeud!='" . $by . "' ";
             @pmb_mysql_query($requete, $dbh);
         }
         //On garde les liens voir_aussi
         $requete = "UPDATE ignore voir_aussi SET num_noeud_orig='" . $by . "' WHERE num_noeud_orig='" . $this->id_noeud . "' and num_noeud_dest!='" . $by . "' ";
         @pmb_mysql_query($requete, $dbh);
         $requete = "UPDATE ignore voir_aussi SET num_noeud_dest='" . $by . "' WHERE num_noeud_dest='" . $this->id_noeud . "' and num_noeud_orig!='" . $by . "'";
         @pmb_mysql_query($requete, $dbh);
     }
     if (noeuds::isTarget($this->id_noeud)) {
         //Si le noeuds à supprimé est utilisé pour des renvois et qu'il reste des liens on les supprime
         //On supprime les renvoies
         $requete = "UPDATE noeuds SET num_renvoi_voir='0' WHERE num_renvoi_voir='" . $this->id_noeud . "'";
         @pmb_mysql_query($requete, $dbh);
     }
     //On déplace les notices liées
     $requete = "UPDATE ignore notices_categories SET num_noeud='" . $by . "' where num_noeud = '" . $this->id_noeud . "' ";
     @pmb_mysql_query($requete, $dbh);
     //nettoyage d'autorities_sources
     $query = "select * from authorities_sources where num_authority = " . $this->id_noeud . " and authority_type = 'category'";
     $result = pmb_mysql_query($query);
     if (pmb_mysql_num_rows($result)) {
         while ($row = pmb_mysql_fetch_object($result)) {
             if ($row->authority_favorite == 1) {
                 //on suprime les références si l'autorité a été importée...
                 $query = "delete from notices_authorities_sources where num_authority_source = " . $row->id_authority_source;
                 pmb_mysql_result($query);
                 $query = "delete from authorities_sources where id_authority_source = " . $row->id_authority_source;
                 pmb_mysql_result($query);
             } else {
                 //on fait suivre le reste
                 $query = "update authorities_sources set num_authority = " . $by . " where num_authority_source = " . $row->id_authority_source;
                 pmb_mysql_query($query);
             }
         }
     }
     //On supprime le noeuds
     $this->delete();
     // effacement de l'identifiant unique d'autorité
     $authority = new authority(0, $this->id_noeud, AUT_TABLE_CATEG);
     $authority->delete();
     //synchro_rdf
     if ($pmb_synchro_rdf) {
         //on ajoute les noeuds impactés par le $by
         $thesBy = thesaurus::getByEltId($by);
         if (!in_array($thesBy->id_thesaurus, $arrayThesImpactes)) {
             $arrayThesImpactes[] = $thesBy->id_thesaurus;
         }
         $arrayIdImpactes[] = $by;
         //parent
         if ($noeuds_a_garder->num_parent != $thesBy->num_noeud_racine) {
             $arrayIdImpactes[] = $noeuds_a_garder->num_parent;
         }
         //enfants
         $res = noeuds::listChilds($noeuds_a_garder->id_noeud, 1);
         if (pmb_mysql_num_rows($res)) {
             while ($row = pmb_mysql_fetch_array($res)) {
                 $arrayIdImpactes[] = $row[0];
             }
         }
         //renvoi_voir
         if ($noeuds_a_garder->num_renvoi_voir) {
             $arrayIdImpactes[] = $noeuds_a_garder->num_renvoi_voir;
         }
         //On met le tout à jour
         $synchro_rdf = new synchro_rdf();
         $synchro_rdf->delConcept($this->id_noeud);
         if (count($arrayIdImpactes)) {
             foreach ($arrayIdImpactes as $idNoeud) {
                 $synchro_rdf->delConcept($idNoeud);
                 $synchro_rdf->storeConcept($idNoeud);
             }
         }
         if (count($arrayThesImpactes)) {
             foreach ($arrayThesImpactes as $idThes) {
                 $synchro_rdf->updateAuthority($idThes, 'thesaurus');
             }
         }
     }
     return "";
 }
 function fetch_node($node_id, $OPACUserId = -1)
 {
     $node_id += 0;
     if (!$node_id) {
         return FALSE;
     }
     $node = new noeuds($node_id);
     $result = array('node_id' => $node->id_noeud, 'node_thesaurus' => $node->num_thesaurus, 'node_target_id' => 0, 'node_target_categories' => array());
     global $dbh;
     if ($node->num_renvoi_voir) {
         $result['node_target_id'] = $node->num_renvoi_voir;
         $q = "select * from categories where num_noeud = '" . $node->num_renvoi_voir . "'";
         $r = pmb_mysql_query($q, $dbh);
         $result['node_target_categories'] = array();
         while ($obj = pmb_mysql_fetch_object($r)) {
             $categ = array();
             $categ['node_id'] = $node_id;
             $categ['category_caption'] = utf8_normalize($obj->libelle_categorie);
             $categ['category_lang'] = utf8_normalize($obj->langue);
             $result['node_target_categories'][] = $categ;
         }
     }
     $q = "select * from categories where num_noeud = '" . $node_id . "'";
     $r = pmb_mysql_query($q, $dbh);
     $result['node_categories'] = array();
     while ($obj = pmb_mysql_fetch_object($r)) {
         $categ = array();
         $categ['node_id'] = $node_id;
         $categ['category_caption'] = utf8_normalize($obj->libelle_categorie);
         $categ['category_lang'] = utf8_normalize($obj->langue);
         $result['node_categories'][] = $categ;
     }
     $path_ids = noeuds::listAncestors($node_id);
     $result['node_path'] = array();
     if ($path_ids) {
         $q = "select * from categories where num_noeud IN(" . implode(',', $path_ids) . ") order by num_noeud";
         $r = pmb_mysql_query($q, $dbh);
         $result['node_path'] = array();
         $current_node_id = 0;
         $categs = array();
         while ($obj = pmb_mysql_fetch_object($r)) {
             if (!$current_node_id) {
                 $current_node_id = $obj->num_noeud;
             }
             if ($current_node_id != $obj->num_noeud) {
                 $result['node_path'][] = array('node_id' => $current_node_id, 'categories' => $categs);
                 $categs = array();
                 $current_node_id = $obj->num_noeud;
             }
             $categ = array();
             $categ['node_id'] = $current_node_id;
             $categ['category_caption'] = utf8_normalize($obj->libelle_categorie);
             $categ['category_lang'] = utf8_normalize($obj->langue);
             $categs[] = $categ;
         }
         if ($current_node_id) {
             $result['node_path'][] = array('node_id' => $current_node_id, 'categories' => $categs);
         }
     }
     $children = array();
     $children_res = noeuds::listChilds($node_id, 1);
     while ($row = pmb_mysql_fetch_assoc($children_res)) {
         $children[] = $row['id_noeud'];
     }
     $result['node_children'] = array();
     if ($children) {
         $q = "select noeuds.id_noeud, noeuds.num_renvoi_voir, categories.* from categories left join noeuds on (noeuds.id_noeud = categories.num_noeud) where noeuds.id_noeud IN(" . implode(',', $children) . ") order by num_noeud, libelle_categorie";
         $r = pmb_mysql_query($q, $dbh);
         $result['node_children'] = array();
         $current_node_id = 0;
         $current_islink = false;
         $categs = array();
         while ($obj = pmb_mysql_fetch_object($r)) {
             if (!$current_node_id) {
                 $current_node_id = $obj->num_noeud;
             }
             if ($current_node_id != $obj->num_noeud) {
                 $result['node_children'][] = array('node_id' => $current_node_id, 'categories' => $categs, 'is_link' => $current_islink);
                 $categs = array();
                 $current_node_id = $obj->num_noeud;
                 $current_islink = $obj->num_renvoi_voir > 0 ? true : false;
             }
             $categ = array();
             $categ['node_id'] = $current_node_id;
             $categ['category_caption'] = utf8_normalize($obj->libelle_categorie);
             $categ['category_lang'] = utf8_normalize($obj->langue);
             $categs[] = $categ;
         }
         if ($current_node_id) {
             $result['node_children'][] = array('node_id' => $current_node_id, 'categories' => $categs, 'is_link' => $current_islink);
         }
     }
     $result['node_seealso'] = array();
     $q = "select voir_aussi.num_noeud_dest, categories.* from voir_aussi left join categories on (voir_aussi.num_noeud_dest = categories.num_noeud) where num_noeud_orig = " . $node_id . " order by voir_aussi.num_noeud_dest";
     $r = pmb_mysql_query($q, $dbh);
     $current_node_id = 0;
     $categs = array();
     while ($obj = pmb_mysql_fetch_object($r)) {
         if (!$current_node_id) {
             $current_node_id = $obj->num_noeud;
         }
         if ($current_node_id != $obj->num_noeud) {
             $result['node_seealso'][] = array('node_id' => $current_node_id, 'categories' => $categs);
             $categs = array();
             $current_node_id = $obj->num_noeud;
         }
         $categ = array();
         $categ['node_id'] = $current_node_id;
         $categ['category_caption'] = utf8_normalize($obj->libelle_categorie);
         $categ['category_lang'] = utf8_normalize($obj->langue);
         $categs[] = $categ;
     }
     if ($current_node_id) {
         $result['node_seealso'][] = array('node_id' => $current_node_id, 'categories' => $categs);
     }
     return $result;
 }
Esempio n. 8
0
        }
    }
}
//synchro_rdf : le noeud a été créé/modifié
if ($pmb_synchro_rdf) {
    //De nouveaux noeuds impactés ?
    if (!count($arrayIdImpactes) || !in_array($id, $arrayIdImpactes)) {
        $arrayIdImpactes[] = $id;
    }
    if ($noeud->num_parent != $thes->num_noeud_racine) {
        if (!count($arrayIdImpactes) || !in_array($noeud->num_parent, $arrayIdImpactes)) {
            $arrayIdImpactes[] = $noeud->num_parent;
        }
    }
    //enfants
    $res = noeuds::listChilds($id, 1);
    if (pmb_mysql_num_rows($res)) {
        while ($row = pmb_mysql_fetch_array($res)) {
            if (!count($arrayIdImpactes) || !in_array($row[0], $arrayIdImpactes)) {
                $arrayIdImpactes[] = $row[0];
            }
        }
    }
    //renvoi_voir
    if ($noeud->num_renvoi_voir) {
        if (!count($arrayIdImpactes) || !in_array($noeud->num_renvoi_voir, $arrayIdImpactes)) {
            $arrayIdImpactes[] = $noeud->num_renvoi_voir;
        }
    }
    //on met le tout à jour
    $synchro_rdf = new synchro_rdf();
Esempio n. 9
0
 function process_categ_path($id_noeud = 0, $path = '')
 {
     global $dbh;
     if (!$id_noeud && is_object($this)) {
         $id_noeud = $this->id_noeud;
     }
     if ($path) {
         $path .= '/';
     }
     $path .= $id_noeud;
     $res = noeuds::listChilds($id_noeud, 0);
     while ($row = mysql_fetch_object($res)) {
         // la categorie a des filles qu'on va traiter
         $this->process_categ_path($row->id_noeud, $path);
     }
     $req = "update noeuds set path='{$path}' where id_noeud='{$id_noeud}' ";
     mysql_query($req, $dbh);
 }