diff --git a/RestConnection.inc b/RestConnection.inc index b1535ff1..3d74d85b 100644 --- a/RestConnection.inc +++ b/RestConnection.inc @@ -9,6 +9,7 @@ require_once 'sites/all/libraries/tuque/RepositoryConnection.php'; require_once 'sites/all/libraries/tuque/Cache.php'; require_once 'sites/all/libraries/tuque/RepositoryException.php'; require_once 'sites/all/libraries/tuque/Repository.php'; +require_once 'sites/all/libraries/tuque/FedoraRelationships.php'; class RestConnection { diff --git a/islandora-object-default-view.tpl.php b/islandora-object-default-view.tpl.php index dc350009..fc7a1841 100644 --- a/islandora-object-default-view.tpl.php +++ b/islandora-object-default-view.tpl.php @@ -33,11 +33,10 @@ * */ - $mods = $variables['object']; - $title = $mods['title']; + //dsm($object); print('this is the default view for '. $object->label .' ' .$object->id); - //print($object['MODS']->contentasJson->'key') + ?> diff --git a/islandora.module b/islandora.module index 5ef3741e..2a6fbae9 100644 --- a/islandora.module +++ b/islandora.module @@ -316,9 +316,6 @@ function islandora_theme() { function islandora_datastream_as_attachment($object_id, $dsid){ module_load_include('inc', 'islandora', 'RestConnection'); - //$user = new stdClass(); - //$user->name = 'fedoraAdmin'; - //$user->password = 'islandora'; global $user; try { $restConnection = new RestConnection($user); diff --git a/islandora_basic_image/islandora-basic-image-view-object.tpl.php b/islandora_basic_image/islandora-basic-image.tpl.php similarity index 85% rename from islandora_basic_image/islandora-basic-image-view-object.tpl.php rename to islandora_basic_image/islandora-basic-image.tpl.php index 6a03a0df..ee381cd5 100644 --- a/islandora_basic_image/islandora-basic-image-view-object.tpl.php +++ b/islandora_basic_image/islandora-basic-image.tpl.php @@ -24,7 +24,9 @@ ?> label); + print(''); ?> diff --git a/islandora_basic_image/islandora_basic_image.module b/islandora_basic_image/islandora_basic_image.module index ce3d5ff5..bc15c5d2 100644 --- a/islandora_basic_image/islandora_basic_image.module +++ b/islandora_basic_image/islandora_basic_image.module @@ -77,13 +77,13 @@ function theme_islandora_basic_image_view_object($variables) { */ function islandora_basic_image_theme() { return array( - 'islandora_basic_image_view_objects' => array( + 'islandora_basic_image_objects' => array( 'template' => 'islandora-basic-image-view-objects', - 'variables' => array('objects' => NULL), + 'variables' => array('islandor_objects' => NULL), ), - 'islandora_basic_image_view_object' => array( - 'template' => 'islandora-basic-image-view-object', - 'variables' => array('object' => NULL), + 'islandora_basic_image' => array( + 'template' => 'islandora-basic-image', + 'variables' => array('islandora_object' => NULL), ) ); } @@ -118,26 +118,28 @@ function islandora_basic_image_islandora_view_object($object, $user, $page_numbe if (empty($combined_list)) { return NULL;//we don't handle any of this objects cmodels } - $output = theme('islandora_basic_image_view_object', array('object' => $object)); + $output = theme('islandora_basic_image', array('islandora_object' => $object)); return $output; } -function islandora_preprocess_islandora_basic_image_view_object(&$variables){ - $object = $variables['object']; +function islandora_preprocess_islandora_basic_image(&$variables){ + $islandora_object = $variables['islandora_object']; + module_load_include('inc','islandora','utils/islandora_dublin_core'); try{ - $dc = $object['DC']->content; - $dc_xml = simplexml_load_string($dc); - $dc_json = json_decode(json_encode((array)simplexml_load_string($dc)),1); + $dc = $islandora_object['DC']->content; + //$dc_xml = simplexml_load_string($dc); + $dc_object = Dublin_Core::import_from_xml_string($dc); }catch(Exception $e){ - drupal_set_message(t('Error retrieving object %s %t', array('%s' => $object->id,'%t'=>$e->getMessage())),'error'); + drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id,'%t'=>$e->getMessage())),'error'); } - $variables['dc'] = $dc_json; - $variables['label'] = $object->label; + $variables['islandora_dublin_core'] = $dc_object; + $variables['islandora_object_label'] = $islandora_object->label; global $base_url; - $variables['image_url'] = $base_url.'islandora/object/'.$object->id.'/datastream/OBJ/view'; - $variables['thumbnail_url'] = $base_url.'islandora/object/'.$object->id.'datastream/TN/view'; - //return; + $variables['islandora_image_url'] = $base_url.'/islandora/object/'.$islandora_object->id.'/datastream/OBJ/view'; + $variables['islandora_thumbnail_url'] = $base_url.'/islandora/object/'.$islandora_object->id.'/datastream/TN/view'; + $variables['islandora_medium_size_url'] = $base_url . '/islandora/object/'.$islandora_object->id.'/datastream/MEDIUM/view'; } + ?> diff --git a/utils/islandora_dublin_core.inc b/utils/islandora_dublin_core.inc new file mode 100644 index 00000000..9ea4aa35 --- /dev/null +++ b/utils/islandora_dublin_core.inc @@ -0,0 +1,125 @@ + array(), + 'dc:creator' => array(), + 'dc:subject' => array(), + 'dc:description' => array(), + 'dc:publisher' => array(), + 'dc:contributor' => array(), + 'dc:date' => array(), + 'dc:type' => array(), + 'dc:format' => array(), + 'dc:identifier' => array(), + 'dc:source' => array(), + 'dc:language' => array(), + 'dc:relation' => array(), + 'dc:coverage' => array(), + 'dc:rights' => array(), + ); + public $owner; + + /** + * Constructs a Dublin_Core object from a Fedora_Item object and populates + * the $dc array. + * @param $item + */ + function Dublin_Core($dc_xml = NULL) { + if (!empty($dc_string)) { + $this->dc = self::import_from_xml_string($dc_xml); + } + } + + /** + * Add Elements + * @param $element_name + * @param $value + */ + function add_element($element_name, $value) { + if (is_string($value) && is_array($this->dc[$element_name])) { + $this->dc[$element_name][] = $value; + } + } + + /** + * Replace the given DC element with the values in $values + * @param string $elemnt_name + * @param array $values + */ + function set_element($element_name, $values) { + if (is_array($values)) { + $this->dc[$element_name] = $values; + } + elseif (is_string($values)) { + $this->dc[$element_name] = array($values); + } + } + + /** + * Serialize this object to XML and return it. + * @param type $with_preamble + * @return type + */ + function as_xml($with_preamble = FALSE) { + $dc_xml = new DomDocument(); + $oai_dc = $dc_xml->createElementNS('http://www.openarchives.org/OAI/2.0/oai_dc/', 'oai_dc:dc'); + $oai_dc->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + foreach ($this->dc as $dc_element => $values) { + if (is_array($values) && !empty($values)) { + foreach ($values as $value) { + $new_item = $dc_xml->createElement($dc_element, $value); + $oai_dc->appendChild($new_item); + } + } + else { + $new_item = $dc_xml->createElement($dc_element); + $oai_dc->appendChild($new_item); + } + } + $dc_xml->appendChild($oai_dc); + return $dc_xml->saveXML(); + } + + /** + * Create dc from dict ( does nothing ) + */ + static function create_dc_from_dict() { + + } + + + + /** + * Creates a new instance of the class by parsing dc_xml + * @param string $dc_xml + * @return Dublin_Core + */ + static function import_from_xml_string($dc_xml) { + $dc_doc = new DomDocument(); + if ($dc_doc->loadXML($dc_xml)) { + $oai_dc = $dc_doc->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', '*'); + $new_dc = new Dublin_Core(); + foreach ($oai_dc as $child) { + array_push($new_dc->dc[$child->nodeName], $child->nodeValue); + } + return $new_dc; + } + else { + return NULL; + } + } + +} +