/[drupal]/contributions/modules/z3950/syntax/z3950_marc21.inc
ViewVC logotype

Diff of /contributions/modules/z3950/syntax/z3950_marc21.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.3, Sat Sep 1 19:56:54 2007 UTC revision 1.1.2.4, Sat Sep 1 21:31:46 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: z3950_marc21.inc,v 1.1.2.2 2007/09/01 19:52:29 douggreen Exp $  // $Id: z3950_marc21.inc,v 1.1.2.3 2007/09/01 19:56:54 douggreen Exp $
3    
4  /**  /**
5   * Implement z39.50 syntax for Marc21   * Implement z39.50 syntax for Marc21
# Line 21  function z3950_marc21($op, $id = NULL, $ Line 21  function z3950_marc21($op, $id = NULL, $
21  }  }
22    
23  function _z3950_marc21_summary($id, $pos) {  function _z3950_marc21_summary($id, $pos) {
24    $rec_array = yaz_record($id, $pos, 'array');    $marc_array = _z3950_marc21_record($id, $pos);
25    if (is_null($rec_array)) {  
26      $rec_string = yaz_record($id, $pos, 'string');    // start the summary return array
27      if (!empty($rec_string)) {    $summary = array('type' => t('metadata'), 'extra' => array());
28        return array(  
29          'type' => t('metadata'),    // add title
30          'title' => $rec_string,    if (isset($marc_array['3,245'])) {
31        );      $summary['title'] = implode(' ', array_pop($marc_array['3,245']));
     }  
32    }    }
33    else {  
34      return array(    // add snippet
35        'type' => t('metadata'),    $snippet = array();
36        'title' => $rec_array[4][1],    foreach (array('3,100', '3,260', '3,300') as $key) {
37        'snippet' => $rec_array[10][1],      if (isset($marc_array[$key])) {
38        'extra' => array(        $snippet[] = implode(' ', array_pop($marc_array[$key]));
39          'time_period' => $rec_array[13][1],      }
       ),  
     );  
40    }    }
41      $summary['snippet'] = implode(' ', $snippet);
42    
43      return $summary;
44  }  }
45    
46  function _z3950_marc21_detail($id, $pos) {  function _z3950_marc21_detail($id, $pos) {
47    // set page title    // set page title
48    $rec_array = yaz_record($id, $pos, 'array');    $marc_array = _z3950_marc21_record($id, $pos);
49    if (!is_null($rec_array)) {  
50      drupal_set_title($rec_array[4][1]);    // set the title
51      if (isset($marc_array['3,245'])) {
52        drupal_set_title(implode(' ', array_pop($marc_array['3,245'])));
53    }    }
54    
55    // return page text    // return page text
56      // @TODO: format a better page for display
57    return yaz_record($id, $pos, 'string');    return yaz_record($id, $pos, 'string');
58  }  }
59    
60    function _z3950_marc21_record($id, $pos) {
61      $marc_array = array();
62      foreach (yaz_record($id, $pos, 'array') as $yaz_element) {
63        if (isset($yaz_element[1])) {
64          // strip all non-essential chars from the key, to insure a safe eval() below
65          $key = preg_replace('/[^0-9a-z,@\(\)]/', '', $yaz_element[0]);
66    
67          // convert the parenthesis's into array brackets, and quote the array elements
68          $key = str_replace(array('(', ')'), array("['", "']"), $key);
69    
70          // store the value in the multidimensional array
71          eval('$marc_array'. $key .' = $yaz_element[1];');
72        }
73      }
74      return $marc_array;
75    }

Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

  ViewVC Help
Powered by ViewVC 1.1.2