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

dev #73934 : remove const duplications

parent b8a2bc1e
Branches
Tags
3 merge requests!2660Master,!2619Dev#73934 explo suivi bibliondemand,!2610dev #73934 : explo bibliondemand , cosmogrammme can handle bibliondemand xml file
Pipeline #3953 passed with stage
in 52 minutes and 46 seconds
...@@ -23,29 +23,20 @@ ...@@ -23,29 +23,20 @@
* Bokeh translation from cosmogramme API cosmogramme/php/classes/classe_parseur.php * Bokeh translation from cosmogramme API cosmogramme/php/classes/classe_parseur.php
*/ */
abstract class Class_Cosmogramme_FileParser { abstract class Class_Cosmogramme_FileParser {
use Trait_StaticFileSystem; use Trait_StaticFileSystem, Trait_Translator;
const FORMAT_UNIMARC = 0;
const FORMAT_ASCII_TAB = 1;
const FORMAT_ASCII_COMMA = 2;
const FORMAT_ASCII_PIPE = 3;
const FORMAT_XML = 4;
const FORMAT_CSV = 5;
const FORMAT_MARC21 = 6;
const FORMAT_AVENIO = 8;
const FORMAT_DUBLIN_CORE =11;
protected static $_format_parsers = protected static $_format_parsers =
[self::FORMAT_UNIMARC => 'Marc', [
self::FORMAT_ASCII_TAB => 'Ascii_Tab', Class_IntProfilDonnees::FORMAT_UNIMARC => 'Marc',
self::FORMAT_ASCII_COMMA => 'Ascii_Comma', Class_IntProfilDonnees::FORMAT_TABBED_ASCII => 'Ascii_Tab',
self::FORMAT_ASCII_PIPE => 'Ascii_Pipe', Class_IntProfilDonnees::FORMAT_SEMI_COLON_ASCII => 'Ascii_Comma',
self::FORMAT_XML => 'Xml', Class_IntProfilDonnees::FORMAT_PIPED_ASCII => 'Ascii_Pipe',
self::FORMAT_CSV => 'Csv', Class_IntProfilDonnees::FORMAT_XML => 'Xml',
self::FORMAT_MARC21 => 'Marc', Class_IntProfilDonnees::FORMAT_CSV => 'Csv',
self::FORMAT_AVENIO => 'Ascii_Tab', Class_IntProfilDonnees::FORMAT_MARC21 => 'Marc',
self::FORMAT_DUBLIN_CORE => 'OaiDC']; Class_IntProfilDonnees::FORMAT_AVENIO => 'Ascii_Tab',
Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND => 'OaiDC',
];
protected $_file_handle, $_position, $_file_size, $_profil; protected $_file_handle, $_position, $_file_size, $_profil;
protected $_errors = []; protected $_errors = [];
...@@ -54,7 +45,7 @@ abstract class Class_Cosmogramme_FileParser { ...@@ -54,7 +45,7 @@ abstract class Class_Cosmogramme_FileParser {
public static function openFor($file, $position, $profil) { public static function openFor($file, $position, $profil) {
$format = $profil->getFormat(); $format = $profil->getFormat();
if (!in_array($format, array_keys(static::$_format_parsers))) if (!in_array($format, array_keys(static::$_format_parsers)))
throw new RuntimeException('Format ' . $format . ' non pris en charge'); throw new RuntimeException($this->_('Format %s non pris en charge', $format));
$class = 'Class_Cosmogramme_FileParser_' . static::$_format_parsers[$format]; $class = 'Class_Cosmogramme_FileParser_' . static::$_format_parsers[$format];
return new $class($file, $position, $profil); return new $class($file, $position, $profil);
...@@ -133,7 +124,7 @@ class Class_Cosmogramme_FileParser_Marc extends Class_Cosmogramme_FileParser { ...@@ -133,7 +124,7 @@ class Class_Cosmogramme_FileParser_Marc extends Class_Cosmogramme_FileParser {
break; break;
} }
$record = $fileSystem->fread($this->_file_handle, self::READ_SIZE); $record = $fileSystem->fread($this->_file_handle, static::READ_SIZE);
if ($fileSystem->feof($this->_file_handle) if ($fileSystem->feof($this->_file_handle)
&& !$record) { && !$record) {
$at_end = true; $at_end = true;
......
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