diff options
-rw-r--r-- | classes/BiblioIsisDb.php | 43 | ||||
-rw-r--r-- | schemas/tupi.yaml | 6 | ||||
-rw-r--r-- | tests/index.php | 2 |
3 files changed, 45 insertions, 6 deletions
diff --git a/classes/BiblioIsisDb.php b/classes/BiblioIsisDb.php index 7b81211..8d98569 100644 --- a/classes/BiblioIsisDb.php +++ b/classes/BiblioIsisDb.php @@ -132,16 +132,49 @@ class BiblioIsisDb implements IsisDb { * * @return * Tagged database result. - * - * @todo - * Subfields. */ function tag($results) { foreach ($results as $key => $value) { - $name = $this->format['fields'][$key]['name']; - $data[$name] = $value; + // Key '000' used to hold MFN. + if ($key != '000') { + $name = $this->format['fields'][$key]['name']; + $data[$name] = $this->repetition($key, $value); + + // Subfield handling. + if (isset($this->format['fields'][$key]['subfields']) && is_array($data[$name])) { + foreach ($data[$name] as $subkey => $subvalue) { + $subname = $this->format['fields'][$key]['subfields'][$subkey]; + $data[$name][$subname] = $subvalue; + unset($data[$name][$subkey]); + } + } + } } return $data; } + + /** + * Deals with repetition. + * + * As Biblio::Isis always return field values as arrays, we + * have to check the database schema to see if we have to + * convert then to a single value. + * + * @param $field + * Database field. + * + * @param $value + * Query field result. + * + * @return + * The value according to the repetition config. + */ + function repetition($field, $value) { + if (isset($this->format['fields'][$field]['repeat']) && + $this->format['fields'][$key]['repeat'] == FALSE) { + return $value[0]; + } + return $value; + } } diff --git a/schemas/tupi.yaml b/schemas/tupi.yaml index a970c54..ee96360 100644 --- a/schemas/tupi.yaml +++ b/schemas/tupi.yaml @@ -51,6 +51,8 @@ fields: name: identidades 29: name: ndxlib + 40: + name: materiais 45: name: materiais 55: @@ -107,6 +109,10 @@ fields: name: loc.prod.lan 86: name: dat.prod.lan + repeat: No + subfields: + a: ano + d: data 87: name: lab/est/locacoes 88: diff --git a/tests/index.php b/tests/index.php index 6d91f43..7297b40 100644 --- a/tests/index.php +++ b/tests/index.php @@ -7,7 +7,7 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> - <meta http-equiv="Content-Type" content="text/html; charset=cp850" /> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> |