Oid-O-Matic connector

Oid-O-Matic is a web service catalogue between Museo Torino and Piedmont libraries Opac. (Site) (GitHUB)

HowTo include Oid-O-Matic harvesting in Book view tab:

  • Edit sites/all/modules/islandora_solution_pack_book/xsl/tocnr_book_view.xsl
tocnr_book_view.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:variable name="OBJECTSPAGE">
    <xsl:value-of select="$objectsPage"/>
  </xsl:variable>
  <xsl:variable name="PID">
    <xsl:value-of select="$pid"/>
  </xsl:variable>
  <xsl:variable name="MODELLO">
    <xsl:value-of select="$modello"/>
  </xsl:variable>
  <xsl:variable name="ELELIB">
    <xsl:copy-of select="$elelib"/>
  </xsl:variable>
  <xsl:variable name="RECORDID">
    <xsl:value-of select="substring-after($PID,&quot;:&quot;)"/>
  </xsl:variable>
  <xsl:variable name="COLLEZIONEID">
    <xsl:value-of select="substring-before($PID,&quot;:&quot;)"/>
  </xsl:variable>
  <xsl:template match="/">
    <table class="libromd" cellpadding="3" cellspacing="2" valign="top">
      <tr>
        <td valign="top">
          <img>
            <xsl:attribute name="src"><xsl:copy-of select="$OBJECTSPAGE"/>fedora/repository/<xsl:copy-of select="$PID"/>/TN
				</xsl:attribute>
          </img>
        </td>
        <td>
          <div style="align:left">
            <table cellpadding="3" cellspacing="2" width="90%">
              <tbody>
                <tr>
                  <td colspan="3">
                    <h3>Dublin Core - MetaData </h3>
                  </td>
                </tr>
                <xsl:for-each select="/*/*">
                  <xsl:variable name="FULLFIELD" select="name()"/>
                  <xsl:variable name="FIELD" select="substring-after(name(),':')"/>
                  <xsl:variable name="DATA" select="text()"/>
                  <xsl:if test="$DATA != ' '">
                      <tr>
                        <td valign="top">
                          <strong>
                            <xsl:value-of select="substring-after(name(),':')"/>
                          </strong>
                        </td>
                        <td>
                          <xsl:value-of select="text()"/>
                          <xsl:for-each select="*">
                            <div><xsl:value-of select="substring-after(name(),':')"/> =  <xsl:value-of select="text()"/>
		</div>
                          </xsl:for-each>
                        </td>
                      </tr>
                  </xsl:if>
                </xsl:for-each>
              </tbody>
              <tr>
                <td colspan="3">
                  <h3/>
                </td>
              </tr>
              <tr>
                <td colspan="3">
                  <h3>Download</h3>
                </td>
              </tr>
              <xsl:if test="$MODELLO = 'info:fedora/islandora:bookCModel'">
                <tr>
                  <td>
                    <strong>Full PDF</strong>
                  </td>
                  <td>
                    <a href="{$OBJECTSPAGE}fedora/repository/object_download/{$PID}/PDF/{$COLLEZIONEID}_{$RECORDID}.pdf">PDF</a>
                  </td>
                </tr>
              </xsl:if>
              <xsl:if test="$MODELLO = 'info:fedora/islandora:pageCModel'">
                <xsl:if test="not($COLLEZIONEID = 'asfiat')">
                  <tr>
                    <td>
                      <strong>Hi-Res IMAGE</strong>
                    </td>
                    <td>
                      <a href="{$OBJECTSPAGE}fedora/repository/object_download/{$PID}/TIFF/{$COLLEZIONEID}_{$RECORDID}.tif">TIFF</a>
                    </td>
                  </tr>
                </xsl:if>
                <xsl:if test="$COLLEZIONEID = 'asfiat'">
                  <tr>
                    <td>
                      <em>Only Low-Res available due to restricted rights</em>
                    </td>
                  </tr>
                </xsl:if>
                <tr>
                  <td>
                    <strong>Low-Res IMAGE</strong>
                  </td>
                  <td>
                    <a href="{$OBJECTSPAGE}fedora/repository/object_download/{$PID}/openbess:jpgldSdef/{$COLLEZIONEID}_{$RECORDID}.jpg">JPEG</a>
                  </td>
                </tr>
                <tr>
                  <td>
                    <strong>TEXT</strong>
                  </td>
                  <td>
                    <a href="{$OBJECTSPAGE}fedora/repository/object_download/{$PID}/OCR/{$COLLEZIONEID}_{$RECORDID}.txt">TXT</a>
                  </td>
                </tr>
              </xsl:if>
              <xsl:if test="$MODELLO = 'info:fedora/islandora:bookCModel'">
                <xsl:if test="$ELELIB != ''">
                  <tr>
                    <td colspan="3">
                      <h3/>
                    </td>
                  </tr>
                  <tr>
                    <td colspan="3">
                      <h3>External link</h3>
                    </td>
                  </tr>
                  <tr>
                    <td valign="top">
                      <strong>Hard copy</strong>
                    </td>
                    <td valign="top">
                      <xsl:value-of disable-output-escaping="yes" select="$ELELIB"/>
                    </td>
                  </tr>
                </xsl:if>
              </xsl:if>
            </table>
          </div>
        </td>
      </tr>
    </table>
  </xsl:template>
</xsl:stylesheet>
  • Edit sites/all/modules/islandora_solution_pack_book/islandora_book.module
<?php
// $Id$
...

Tip

function islandora_book_create_book_hardcopy($pid,$modello) {
  $elelib = '';
  if ($modello == "info:fedora/islandora:bookCModel") {
    $url="http://oidomatic.comperio.it/getinfo.xml?href=http%3A%2F%2Fwww.digibess.it%2Ffedora%2Frepository%2F".$pid;
    $k = 0;
    $oidom = new DOMDocument();
    if (@$oidom->load($url) !== false){
       if (is_object($root = $oidom->getElementsByTagName('objects'))) {
	  if (is_object($root->item(0))) {
	    if (is_object($objs = $root->item(0)->getElementsByTagName('object'))) {
	       foreach($objs as $obj) {
		  $label = $obj->getElementsByTagName('label')->item(0)->nodeValue."\n";
		  $href = $obj->getElementsByTagName('href')->item(0)->nodeValue."\n";
		  if(($label !== '') && ($href !== '')) {
		    $elelib .= "<p><a href='".htmlentities($href,ENT_COMPAT, 'UTF-8')."' target='_blank'>".htmlentities($label,ENT_COMPAT, 'UTF-8')."</a></p>";
		    $k++;
		  }
	       }
	    }
	  }
       }
    }
  }
  return $elelib;  
}
...

Tip

function islandora_book_create_book_view($pid, $query = NULL) {
  global $user;
  module_load_include('inc', 'fedora_repository', 'ObjectHelper');
  $path = drupal_get_path('module', 'islandora_book');
  $objectHelper = new ObjectHelper;
//  $xml = $objectHelper->getStream($pid, 'MODS');
  $xml = $objectHelper->getStream($pid, 'DC');
  $dc_xml = $objectHelper->getStream($pid, 'DC');
  $rels_xml = $objectHelper->getStream($pid, 'RELS-EXT');
 
  if (!$rels_xml) {
    drupal_set_message(t('Object does not exist.'), 'error');
    return '';
  }
  $simpleRELSxml = simplexml_load_string($rels_xml);
//  $modello = $simpleRELSxml->xpath('//fedora-model:hasModel@rdf:resource');
//  $modello = $simpleRELSxml->xpath('//rdf:RDF/rdf:Description/@rdf:about')."pippo";
  $modello = $simpleRELSxml->xpath('//rdf:RDF/rdf:Description/fedora-model:hasModel/@rdf:resource');
  $modello = $modello[0];
  if (!$dc_xml) {
    drupal_set_message(t('Object does not exist.'), 'error');
    return '';
  }
  $simpleDCxml = simplexml_load_string($dc_xml);
  $types = $simpleDCxml->xpath('//dc:type');
  $ingested = 'false';
  if (!empty($types)) {
    foreach ($types as $type) {
      if ($type == 'ingested') {
        $ingested = 'true';
      }
    }
  }
  if (!isset($pid)) {
    drupal_set_message(t('Error getting book view, no identifier specified.'));
    return;
  }
  $proc = NULL;
  try {
    $proc = new XsltProcessor();
  } catch (Exception $e) {
    drupal_set_message(t('Error loading Book View XSLT: $e', array('!e' => $e->getMessage())));
    return;
  }
  $elelib = islandora_book_create_book_hardcopy($pid, $modello);
  //inject into xsl stylesheet
  $proc->setParameter('', 'userID', $user->uid);
  $proc->setParameter('', 'objectsPage', base_path());
  $proc->setParameter('', 'pid', $pid);
  $proc->setParameter('', 'ingested', $ingested);
  $proc->setParameter('', 'modello', $modello);
  $proc->setParameter('', 'elelib', $elelib);
  $xsl = new DomDocument();
  $test = $xsl->load($path . '/xsl/tocnr_book_view.xsl');
  if (!isset($test)) {
    drupal_set_message(t('Error loading search results XSLT.'));
    return t('Error loading search results XSLT.');
  }
  $input = new DomDocument();
  $didLoadOk = $input->loadXML($xml);
  $output = NULL;
  if (!isset($didLoadOk)) {
    drupal_set_message(t('Error loading Book View XML.'));
    return t('Error loading Book View XML.');
  }
  else {
    $xsl = $proc->importStylesheet($xsl);
    $newdom = $proc->transformToDoc($input);
    $output .= $newdom->saveXML();
  }
  if (isset($query)) {
    module_load_include('inc', 'fedora_repository', 'SearchClass');
    $searchClass = new SearchClass();
    $pageQuery = convert_query_to_page_query($query, $pid);
    $output .= '<div>' . $searchClass->custom_search($pageQuery, $startPage, '/xsl/pageResults.xsl', 500) . '</div>'; 
    //limit results to 500 pages of a book since there is no paging if we enable paging in xslt this can be changed
    //return $output."<div>used this query to find this page $query and new query = $pageQuery</div>";
    return $output;
  }
  else {
    return $output;
  }
}
...
 
 
frontend/oidomatic.txt · Last modified: 2013/08/07 10:25 by giancarlo

Developers: CNR IRCrES IT Office and Library
Giancarlo Birello (giancarlo.birello _@_ ircres.cnr.it) and Anna Perin (anna.perin _@_ ircres.cnr.it)
DigiBess is licensed under: Creative Commons License
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Drupal Garland Theme for Dokuwiki