Skip to content
Snippets Groups Projects
Commit 090b0d35 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #79470 : context refacto + doc types script

parent d101c71f
3 merge requests!2905Hotline,!2872Hotline#79470 moisonnage et sso cours tout apprendre via la plateforme biblio on demand qui ne fonctionne pas,!2791[WIP] Sandbox record from yaz
Pipeline #5155 passed with stage
in 57 minutes and 13 seconds
......@@ -159,30 +159,13 @@ class Bibliondemand_Lib_Context {
if ($this->_where_records_with_not_mapped_dc_types)
return $this->_where_records_with_not_mapped_dc_types;
$profile = $this->getDataProfile();
if (empty($attribs = unserialize($profile->getAttributs())))
if (!$doc_types_prefs = $this->getDataProfile()->getItemDocTypesPrefs())
return $this->_where_records_with_not_mapped_dc_types = '1=0';
$facets = [];
$dc_type_thesaurus_root = $this->_getDcTypeThesaurus();
foreach ($attribs[0]['type_doc'] as $doc_type) {
if (!$bokeh_doc_type = Class_TypeDoc::find($doc_type['code']))
continue;
if (!$dc_type = $doc_type['type'])
continue;
foreach(explode(';', $dc_type) as $code) {
if (isset($this->_doc_types_by_dc_types_cache[$code]))
continue;
if (!$child = $dc_type_thesaurus_root->getChild($code))
continue;
$this->_doc_types_by_dc_types_cache[$child->asFacet()] = $bokeh_doc_type->asFacet();
$facets[] = $child->asFacet();
}
}
foreach ($doc_types_prefs as $doc_type_pref)
$facets = $this->_addDocTypeFacetFrom($doc_type_pref, $facets);
if (!$facets)
return $this->_where_records_with_not_mapped_dc_types = '1=0';
......@@ -194,6 +177,35 @@ class Bibliondemand_Lib_Context {
}
protected function _addDocTypeFacetFrom($prefs, $facets) {
if (!$bokeh_doc_type = Class_TypeDoc::find($prefs['code']))
return $facets;
if (!$dc_type = $prefs['type'])
return $facets;
foreach(explode(';', $dc_type) as $code)
$facets = $this->_addDocTypeFacetFromDcType($code, $facets, $bokeh_doc_type);
return $facets;
}
protected function _addDocTypeFacetFromDcType($code, $facets, $bokeh_doc_type) {
if (isset($this->_doc_types_by_dc_types_cache[$code]))
return $facets;
if (!$child = $this->_getDcTypeThesaurus()->getChild($code))
return $facets;
$this->_doc_types_by_dc_types_cache[$child->asFacet()] = $bokeh_doc_type->asFacet();
$facets[] = $child->asFacet();
return $facets;
}
public function docTypeFacetForRecord($record) {
if (!$record)
......
<?php
require(__DIR__.'/../../../../console.php');
(new Bibliondemand_Lib_IndexDocTypes)
->setLogger(function($message)
{
echo $message;
})
->run();
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment