예제 #1
0
 function fetchNoticeListArray($noticelist, $recordCharset, $includeLinks, $includeItems)
 {
     //Je filtre les notices en fonction des droits
     $noticelist = $this->filter_tabl_notices($noticelist);
     if (!count($noticelist)) {
         return array();
     }
     $converter = new external_services_converter_notices(1, 600);
     $converter->set_params(array("include_links" => $includeLinks, "include_items" => $includeItems, "include_authorite_ids" => true));
     $keyed_results = $converter->convert_batch($noticelist, "raw_array", $recordCharset);
     $array_results = array_values($keyed_results);
     return $array_results;
 }
예제 #2
0
 function update_config_from_form()
 {
     global $dbh;
     parent::update_config_from_form();
     global $repo_name, $admin_email, $included_sets, $repositoryIdentifier, $chunksize, $token_lifeduration, $cache_complete_records, $cache_complete_records_seconds, $link_status_to_deletion, $linked_status_to_deletion, $allow_gzip_compression, $baseURL, $include_items, $suppr_feuille_xslt;
     global $deletion_management, $deletion_management_transient_duration;
     //les trucs faciles
     $this->config["repo_name"] = stripslashes($repo_name);
     $this->config["admin_email"] = stripslashes($admin_email);
     $this->config["repositoryIdentifier"] = stripslashes($repositoryIdentifier);
     $this->config["chunksize"] = $chunksize + 0;
     $this->config["token_lifeduration"] = $token_lifeduration + 0;
     $this->config["cache_complete_records"] = isset($cache_complete_records);
     $this->config["cache_complete_records_seconds"] = $cache_complete_records_seconds + 0;
     $this->config["link_status_to_deletion"] = isset($link_status_to_deletion);
     $this->config["linked_status_to_deletion"] = $linked_status_to_deletion + 0;
     $this->config["allow_gzip_compression"] = isset($allow_gzip_compression);
     $this->config["baseURL"] = stripslashes($baseURL);
     $this->config["include_items"] = isset($include_items);
     $this->config["deletion_management"] = $deletion_management;
     $this->config["deletion_management_transient_duration"] = $deletion_management_transient_duration * 1;
     if (!$_FILES['feuille_xslt']['error']) {
         $this->config['feuille_xslt'] = file_get_contents($_FILES['feuille_xslt']['tmp_name']);
         $this->config['feuille_xslt_name'] = $_FILES['feuille_xslt']['name'];
     }
     if ($suppr_feuille_xslt) {
         $this->config['feuille_xslt'] = "";
         $this->config['feuille_xslt_name'] = "";
     }
     $this->config['include_links'] = array();
     $this->config['include_links']['genere_lien'] = 0;
     global $include_path, $class_path;
     require_once $class_path . '/export_param.class.php';
     $e_param = new export_param(EXP_GLOBAL_CONTEXT);
     $this->config['include_links'] = $e_param->get_parametres(EXP_OAI_CONTEXT);
     //Vérifions que le statut proposé existe bien
     $sql = "SELECT COUNT(1) > 0 FROM notice_statut WHERE id_notice_statut = " . ($linked_status_to_deletion + 0);
     $status_exists = pmb_mysql_result(pmb_mysql_query($sql, $dbh), 0, 0);
     if (!$status_exists) {
         $this->config["linked_status_to_deletion"] = 0;
     }
     if (!$this->config["cache_complete_records_seconds"]) {
         $this->config["cache_complete_records_seconds"] = 86400;
     }
     if ($this->config["deletion_management"] == 1 && !$this->config["deletion_management_transient_duration"]) {
         $this->config["deletion_management"] = 0;
     }
     //et maintenant les sets
     if (!is_array($included_sets)) {
         $included_sets = array($included_sets);
     }
     array_walk($included_sets, create_function('&$a', '$a+=0;'));
     //Virons ce qui n'est pas entier
     //Virons ce qui n'est pas un index de set de notice
     $sql = "SELECT connector_out_set_id FROM connectors_out_sets WHERE connector_out_set_type IN (" . implode(",", $this->allowed_set_types) . ") AND connector_out_set_id IN (" . implode(",", $included_sets) . ')';
     $res = pmb_mysql_query($sql, $dbh);
     $this->config["included_sets"] = array();
     while ($row = pmb_mysql_fetch_assoc($res)) {
         $this->config["included_sets"][] = $row["connector_out_set_id"];
     }
     //Vérifions que les formats autorisés proposés existent bien
     $allowed_paths = array();
     $admin_convert_catalog = external_services_converter_notices::get_export_possibilities();
     foreach ($admin_convert_catalog as $aconvert) {
         $allowed_paths[] = $aconvert["path"];
     }
     global $allowed_admin_convert_paths;
     if (!is_array($allowed_admin_convert_paths)) {
         $allowed_admin_convert_paths = array($allowed_admin_convert_paths);
     }
     $this->config["allowed_admin_convert_paths"] = array();
     foreach ($allowed_admin_convert_paths as $apath) {
         if (!in_array($apath, $allowed_paths)) {
             continue;
         }
         $this->config["allowed_admin_convert_paths"][] = $apath;
     }
     return;
 }
    function convert_batch_to_oairecords($notices_to_convert, $format, $target_charset)
    {
        global $dbh;
        if (!$notices_to_convert) {
            //Rien à faire? On fait rien
            return;
        }
        //Allons chercher les dates et les statuts des notices
        $notice_datestamps = array();
        $notice_statuts = array();
        $notice_ids = $notices_to_convert;
        //Par paquets de 100 pour ne pas brusquer mysql
        $notice_idsz = array_chunk($notice_ids, 100);
        $iso8601 = new iso8601("YYYY-MM-DDThh:mm:ssZ");
        foreach ($notice_idsz as $anotice_ids) {
            $sql = "SELECT notice_id, UNIX_TIMESTAMP(update_date) AS datestamp, statut FROM notices WHERE notice_id IN (" . implode(",", $anotice_ids) . ")";
            $res = pmb_mysql_query($sql, $dbh);
            while ($row = pmb_mysql_fetch_assoc($res)) {
                $notice_datestamps[$row["notice_id"]] = $iso8601->unixtime_to_iso8601($row["datestamp"]);
                $notice_statuts[$row["notice_id"]] = $row["statut"];
            }
        }
        //Si il existe un status correspondant à la suppression, on génère ces enregistrements et on les supprime de la liste à générer.
        if ($this->deleted_record_statut) {
            $deleted_records = array();
            foreach ($notice_statuts as $notice_id => $anotice_statut) {
                if ($anotice_statut == $this->deleted_record_statut) {
                    $notice_sets = connector_out_set_noticecaddie::get_notice_setlist($notice_id);
                    $notice_sets = array_intersect($notice_sets, $this->source_set_ids);
                    $deleted_records = array('datestamp' => $datestamps[$notice_id], 'sets' => $notice_sets);
                    unset($notices_to_convert[array_search($notice_id, $notices_to_convert)]);
                }
            }
        } else {
            if ($this->deletion_management) {
                $deleted_records = $this->get_deleted_records($this->source_set_ids, $notices_to_convert, $iso8601);
            }
        }
        // On génère les enregistrements supprimés
        foreach ($deleted_records as $notice_id => $deleted_record) {
            $oai_record = "";
            $oai_record .= "<record>";
            $oai_record .= '<header status="deleted">
							<identifier>oai:' . XMLEntities($this->repository_identifier) . ':' . $notice_id . '</identifier>
									<datestamp>' . $deleted_record['datestamp'] . '</datestamp>';
            foreach ($deleted_record['sets'] as $aset_id) {
                $oai_record .= "<setSpec>set_" . $aset_id . "</setSpec>";
            }
            $oai_record .= '</header>';
            $oai_record .= "</record>";
            $this->results[$notice_id] = $oai_record;
        }
        //Convertissons les notices au format demandé si on ne souhaite pas uniquement les entêtes
        $only_identifier = $format == "__oai_identifier";
        if (!$only_identifier) {
            $converter = new external_services_converter_notices(1, $this->set_life_duration);
            $converter->params["include_items"] = $this->include_items;
            $converter->params["include_links"] = $this->include_links;
            $metadatas = $converter->convert_batch($notices_to_convert, $format, $target_charset, $this->xslt);
        }
        //Fabriquons les enregistrements
        foreach ($notices_to_convert as $notice_id) {
            $notice_sets = connector_out_set_noticecaddie::get_notice_setlist($notice_id);
            $notice_sets = array_intersect($notice_sets, $this->source_set_ids);
            $oai_record = "";
            if (!$only_identifier) {
                $oai_record .= "<record>";
            }
            $oai_record .= '<header>
					<identifier>oai:' . XMLEntities($this->repository_identifier) . ':' . $notice_id . '</identifier>
							<datestamp>' . $notice_datestamps[$notice_id] . '</datestamp>';
            foreach ($notice_sets as $aset_id) {
                $oai_record .= "<setSpec>set_" . $aset_id . "</setSpec>";
            }
            $oai_record .= '</header>';
            if (!$only_identifier) {
                $oai_record .= "<metadata>";
                $oai_record .= $metadatas[$notice_id];
                $oai_record .= "</metadata>";
            }
            if (!$only_identifier) {
                $oai_record .= "</record>";
            }
            $this->results[$notice_id] = $oai_record;
        }
    }
예제 #4
0
 function noticeids_to_recordformats($noticesids, $record_format, $recordcharset = 'iso-8859-1', $includeLinks = true, $includeItems = false)
 {
     $converter = new external_services_converter_notices(1, 600);
     $converter->set_params(array("include_links" => $includeLinks, "include_items" => $includeItems, "include_authorite_ids" => true));
     return $converter->convert_batch($noticesids, $record_format, $recordcharset);
 }