Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

Commit

Permalink
Changed the rendered API to return DOMDocuments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Rochester committed Aug 27, 2014
1 parent e99e41d commit 7cbff9c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
3 changes: 2 additions & 1 deletion FedoraConnectorPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ public function filterAdminNavigationMain($tabs)
*/
public function hookAdminItemsShow()
{
echo fc_displayObject(get_current_record('item'));
$dom = fc_displayObject(get_current_record('item'));
echo $dom->saveHTML();
}


Expand Down
2 changes: 1 addition & 1 deletion helpers/FedoraConnectorFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @param Item $item The item.
* @param array $params Options for the renderer.
* @return string|null The Fedora object markup.
* @return DOMDocument|null The Fedora object markup.
*/
function fc_displayObject($item=null, $params=array()) {

Expand Down
2 changes: 1 addition & 1 deletion libraries/FedoraConnector/AbstractRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract function canDisplay($datastream);
* This displays a datastream.
*
* @param Omeka_Record $datastream The data stream.
* @return string The display HTML for the datastream.
* @return DOMDocument The HTML DOM for the datastream.
*/
abstract function display($datastream, $params = null);

Expand Down
2 changes: 1 addition & 1 deletion libraries/FedoraConnector/Render.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct($rendererDir = null)
* Render a datastream.
*
* @param Omeka_Record $object The Fedora object record.
* @return string|null The output of the renderer.
* @return DOMDocument|null The output of the renderer.
*/
public function display($object, $params = null) {

Expand Down
23 changes: 13 additions & 10 deletions renderers/000-Jp2.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function canDisplay($mimeType)
* Displays an object.
*
* @param Omeka_Record $object The Fedora object record.
* @return string The display HTML for the datastream.
* @return DOMDocument The HTML DOM for the datastream.
*/
function display($object, $params = array())
{
Expand All @@ -44,24 +44,27 @@ function display($object, $params = array())
* @param Omeka_Record $object The Fedora object record.
* @param string $size The size to scale the image to.
*
* @return string The HTML for the image.
* @return DOMDocument The HTML DOM for the image.
*/
private function _display($object, $params = array())
{
if (empty($params))
$params = array('scale' => '400,0');

// Default parameters.
if (empty($params)) $params = array('scale' => '400,0');

// Get server.
$server = $object->getServer();

// Construct image URL.
$url = "{$server->url}/{$server->getService()}/{$object->pid}" .
"/methods/djatoka:jp2SDef/getRegion?". http_build_query($params);
"/methods/djatoka:jp2SDef/getRegion?" . http_build_query($params);

$dom = new DOMDocument();
$node = $dom->createElement('img');
$dom ->appendChild($node);
$node->setAttribute('class', 'fedora-renderer');
$node->setAttribute('alt', 'image');
$node->setAttribute('src', $url);

// Return the image tag.
return "<img class='fedora-renderer' alt='image' src='{$url}' />";

return $dom;
}


Expand Down
13 changes: 8 additions & 5 deletions renderers/100-Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ function canDisplay($mimeType) {
* Display an object.
*
* @param Omeka_Record $object The Fedora object record.
* @return string The display HTML for the datastream.
* @return DOMDocument The HTML DOM for the datastream.
*/
function display($object, $params = array()) {

// Construct the image URL.
$url = "{$object->getServer()->url}/objects/{$object->pid}" .
"/datastreams/SCREEN/content";

// Return the image tag.
return "<img class='fedora-renderer' alt='image' src='{$url}' />";
$dom = new DOMDocument();
$node = $dom->createElement('img');
$dom ->appendChild($node);
$node->setAttribute('class', 'fedora-renderer');
$node->setAttribute('alt', 'image');
$node->setAttribute('src', $url);

return $dom;
}


Expand Down

0 comments on commit 7cbff9c

Please sign in to comment.