Skip to content
Snippets Groups Projects
Commit 280f1b50 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #26891 : add cdatas in EAD export generation

parent c9459397
Branches
Tags
2 merge requests!987Hotline master,!979Hotline#26891 export ead lacking cdatas
- ticket #26891 : Correction de l'export EAD
\ No newline at end of file
......@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_Album_ExportEadVisitor extends Zend_View_Helper_Abstract {
......@@ -24,65 +24,69 @@ class ZendAfi_View_Helper_Album_ExportEadVisitor extends Zend_View_Helper_Abstr
public function album_exportEadVisitor() {
$this->_builder = new Class_Xml_Builder();
$top_level_categories = Class_AlbumCategorie::findAllBy(['parent_id' => 0]);
$xml_categories = $this->_constructXmlCategories($top_level_categories);
$xml_content= $this->_constructXml($xml_categories);
$xml_content = $this->_constructXml($xml_categories);
$dom = new DOMDocument;
$dom->preserveWhiteSpace = FALSE;
$dom = new DOMDocument();
$dom->preserveWhiteSpace = true;
$dom->loadXML($xml_content);
$dom->formatOutput = TRUE;
$dom->formatOutput = true;
return $dom->saveXml();
}
public function _constructXml($content) {
$xml_content = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$xml_content.=$this->_builder->ead( ['xmlns' => "urn:isbn:1-931666-22-9"],
$this->_builder->eadheader( ['countryencoding' => 'utf8',
'repositoryencoding' => 'utf8',
'langencoding' => 'utf8'], $this->_builder->eadid(['countrycode' => 'FR']).
'<filedesc><titlestmt><titleproper>Bibliothèque numérique BOKEH</titleproper><author>'.$_SERVER["SERVER_NAME"].'</author>
</titlestmt>
<publicationstmt>
<date>'.date('Y-m-d').'</date> </publicationstmt> </filedesc>').$content);
return $xml_content;
}
public function _constructXml($content) {
$b = $this->_builder;
return '<?xml version="1.0" encoding="UTF-8"?>'."\n"
. $b->ead(['xmlns' => "urn:isbn:1-931666-22-9"],
$b->eadheader(['countryencoding' => 'utf8',
'repositoryencoding' => 'utf8',
'langencoding' => 'utf8'],
$b->eadid(['countrycode' => 'FR'])
. $b->filedesc($b->titlestmt($b->titleproper($b->cdata('Bibliothèque numérique BOKEH')
. $b->author($b->cdata($_SERVER['SERVER_NAME']))))
. $b->publicationstmt($b->date(date('Y-m-d')))))
. $content);
}
public function _constructAlbumsContent($categorie_id) {
$all_albums = Class_Album::findAllBy(['cat_id' => $categorie_id]);
$album_content='';
while (count($all_albums)>0) {
$album = array_pop($all_albums);
$this->_ressources=[];
$album->acceptVisitor($this);
$album_content.= $this->_builder->c01([ 'id' => $album->getIdEad(),
'level' => 'file'],
$this->_constructDid($album)
.implode($this->_ressources));
public function _constructAlbumsContent($categorie_id) {
$albums = Class_Album::findAllBy(['cat_id' => $categorie_id]);
$content = '';
$b = $this->_builder;
while (count($albums) > 0) {
$album = array_pop($albums);
$this->_ressources = [];
$album->acceptVisitor($this);
$content .= $b->c01(['id' => $album->getIdEad(),
'level' => 'file'],
$this->_constructDid($album)
. implode($this->_ressources));
Class_AlbumRessource::clearCache();
}
Class_Album::clearCache();
return $album_content;
return $content;
}
protected function _constructXmlCategories($categories) {
$xml = '';
Class_AlbumCategorie::clearCache();
$b = $this->_builder;
while (count($categories) > 0) {
$categorie = array_pop($categories);
$xml .= $this->_builder->archdesc(['level'=>'collection'],
$this->_constructDidCategorie($categorie).
$this->_builder->dsc(['type'=>'combined'],
$this->_constructAlbumsContent($categorie->getId())
.$this->_constructXmlCategories($categorie->getSousCategories())));
$xml .= $b->archdesc(['level'=>'collection'],
$this->_constructDidCategorie($categorie).
$b->dsc(['type'=>'combined'],
$this->_constructAlbumsContent($categorie->getId())
.$this->_constructXmlCategories($categorie->getSousCategories())));
}
return $xml;
......@@ -90,64 +94,66 @@ public function _constructXml($content) {
public function _constructDidCategorie($categorie) {
return $this->_builder->did($this->_builder->unitid(
['type'=> 'collection'],$categorie->getIdEad())
.$this->_builder->unittitle($categorie->getLibelle()));
$b = $this->_builder;
return $b->did($b->unitid(['type'=> 'collection'], $categorie->getIdEad())
. $b->unittitle($b->cdata($categorie->getLibelle())));
}
public function _constructDid($album) {
return $this->_builder->did($this->_builder->unitid(
['type'=> 'numéro_de_notice'],$album->getCote())
.$this->_builder->unittitle($album->getTitre())
.$this->_builder->unitdate($album->getNote('305$a'))
.$this->_builder->langmaterial($this->_builder->language(['langcode'=>$album->getIdLangue()]))
.$this->_builder->physdesc(
$this->_builder->physfacet( ['type'=>'support'],
$album->getNote('200$b'))
.$this->_builder->physfacet( ['type'=>'reliure'],
$album->getNote('316$a'))
))
.$this->_builder->custodhist($this->_builder->p($album->getProvenance()))
.$this->_constructControlAccess($album->getMatiere(),$album);
$b = $this->_builder;
return $b
->did($b->unitid(['type'=> 'numéro_de_notice'], $album->getCote())
. $b->unittitle($b->cdata($album->getTitre()))
. $b->unitdate($album->getNote('305$a'))
. $b->langmaterial($b->language(['langcode' => $album->getIdLangue()]))
. $b->physdesc($b->physfacet(['type'=>'support'], $album->getNote('200$b'))
. $b->physfacet(['type'=>'reliure'], $album->getNote('316$a'))))
. $b->custodhist($b->p($b->cdata($album->getProvenance())))
. $this->_constructControlAccess($album->getMatiere(), $album);
}
protected function _constructControlAccess($matieres_str,$album) {
$controlaccess='';
protected function _constructControlAccess($matieres_str, $album) {
$controlaccess = '';
if (!isset($matieres_str))
return '';
$b = $this->_builder;
$matieres = explode(';', $matieres_str);
foreach ($matieres as $matiere_id) {
$matiere = Class_Matiere::find($matiere_id);
if (!$matiere) continue;
$controlaccess.=$this->_builder->controlaccess($this->_builder->subject($matiere->getLibelle())
.$this->_builder->title($album->getTitre())
.$this->_builder->persname($album->getAuteur()));
if (!$matiere)
continue;
$controlaccess .= $b->controlaccess($b->subject($b->cdata($matiere->getLibelle()))
. $b->title($b->cdata($album->getTitre()))
. $b->persname($b->cdata($album->getAuteur())));
}
return $controlaccess;
}
protected function _constructDidC2($ressource) {
return $this->_builder->did($this->_builder->unitid(
['type'=> 'division'],$ressource->getFolio())
.$this->_builder->unittitle($ressource->getTitre())
);
$b = $this->_builder;
return $b->did($b->unitid(['type'=> 'division'], $ressource->getFolio())
. $b->unittitle($b->cdata($ressource->getTitre())));
}
public function visitAlbum($album) {
public function visitAlbum($album) {
}
public function visitRessource($ressource, $index) {
$this->_ressources []= $this->_builder->c02([ 'id' => $ressource->getIdEad(),
'level' => 'otherlevel',
],$this->_constructDidC2($ressource));
$this->_ressources[] = $this->_builder->c02(['id' => $ressource->getIdEad(),
'level' => 'otherlevel'],
$this->_constructDidC2($ressource));
}
}
?>
\ No newline at end of file
}
\ 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