Rapporto Tecnico, Anno 7, n° 42 maggio 2012 //loads an xslt for the main book page uses mods for most of the display. // it will execute it against the book. 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 there is a $query parameter 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; } //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); $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 .= '
' . $searchClass->custom_search($pageQuery, $startPage, '/xsl/pageResults.xsl', 500) . '
'; //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."
used this query to find this page $query and new query = $pageQuery
"; return $output; } else { return $output; } } 91