Browse Source

Merge branch 'ISLANDORA-148' of github.com:Islandora/islandora into ISLANDORA-148

pull/105/head
Alexander O'Neill 14 years ago
parent
commit
3776f26daf
  1. 8
      CollectionPolicy.inc
  2. 8
      api/fedora_collection.inc
  3. 67
      fedora_repository.module
  4. 16
      form_elements/includes/autocomplete.inc
  5. 13
      form_elements/includes/people.inc
  6. 12
      form_elements/islandora_form_elements.module
  7. 12
      form_elements/js/people_ahah.js
  8. 47
      ilives/fedora_ilives.module
  9. 54
      plugins/ModsFormBuilder.inc

8
CollectionPolicy.inc

@ -392,13 +392,13 @@ class CollectionPolicy extends XMLDatastream {
$ret=array(); $ret=array();
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); $content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model');
for ($i=0;$i<$content_models->length;$i++) { for ($i=0;$i<$content_models->length;$i++) {
$cm=ContentModel::loadFromModel($content_models->item($i)->getAttribute('pid'), $cm=ContentModel::loadFromModel($content_models->item($i)->getAttribute('pid'),
$content_models->item($i)->getAttribute('dsid'), $content_models->item($i)->getAttribute('dsid'),
$content_models->item($i)->getAttribute('namespace'), $content_models->item($i)->getAttribute('namespace'),
$content_models->item($i)->getAttribute('name')); $content_models->item($i)->getAttribute('name'));
if ($cm !== FALSE) { if ($cm !== FALSE) {
$ret[]=$cm; $ret[]=$cm;
} }
} }
} }

8
api/fedora_collection.inc

@ -65,7 +65,7 @@ function export_collection($collection_pid, $relationship = 'isMemberOfCollectio
* @param <type> $query * @param <type> $query
* @param <type> $query_format R * @param <type> $query_format R
*/ */
function get_related_items_as_xml($collection_pid, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL) { function get_related_items_as_xml($collection_pid, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$collection_item = new Fedora_Item($collection_pid); $collection_item = new Fedora_Item($collection_pid);
@ -104,7 +104,7 @@ function get_related_items_as_xml($collection_pid, $relationship = array('isMemb
$query_string .= ') $query_string .= ')
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title'; order by '.$orderby;
$query_string = htmlentities(urlencode($query_string)); $query_string = htmlentities(urlencode($query_string));
@ -117,8 +117,8 @@ function get_related_items_as_xml($collection_pid, $relationship = array('isMemb
return $content; return $content;
} }
function get_related_items_as_array($collection_pid, $relationship = 'isMemberOfCollection', $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL) { function get_related_items_as_array($collection_pid, $relationship = 'isMemberOfCollection', $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') {
$content = get_related_items_as_xml($collection_pid, $relationship, $limit, $offset, $active_objects_only, $cmodel); $content = get_related_items_as_xml($collection_pid, $relationship, $limit, $offset, $active_objects_only, $cmodel, $orderby);
if (empty($content)) { if (empty($content)) {
return array(); return array();
} }

67
fedora_repository.module

@ -1758,3 +1758,70 @@ function fedora_repository_display_schema($file) {
} }
return; return;
} }
/**
* Implementation of hook_requirements().
*
* @return
* An array describing the status of the site regarding available updates.
* If there is no update data, only one record will be returned, indicating
* that the status of core can't be determined. If data is available, there
* will be two records: one for core, and another for all of contrib
* (assuming there are any contributed modules or themes enabled on the
* site). In addition to the fields expected by hook_requirements ('value',
* 'severity', and optionally 'description'), this array will contain a
* 'reason' attribute, which is an integer constant to indicate why the
* given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or
* UPDATE_UNKNOWN). This is used for generating the appropriate e-mail
* notification messages during update_cron(), and might be useful for other
* modules that invoke update_requirements() to find out if the site is up
* to date or not.
*
* @see _update_message_text()
* @see _update_cron_notify()
*/
function fedora_repository_requirements($phase) {
global $base_url;
if ($phase == 'runtime') {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$requirements = array();
$requirements['fedora-repository']['title'] = t("Fedora server");
if (!fedora_available()) {
$requirements['fedora-repository']['value'] = t("Not available");
$requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR;
$requirements['fedora-repository']['description'] = t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.',
array('@collection-settings' => $base_url.'/admin/settings/fedora_repository'));
}
else {
$requirements['fedora-repository']['value'] = t("Available");
$requirements['fedora-repository']['severity'] = REQUIREMENT_OK;
}
// Check for ImageMagick
$requirements['fedora-imagemagick']['title'] = t("ImageMagick convert in \$PATH");
system('which convert', $res);
if ($res != 0) {
$requirements['fedora-imagemagick']['value'] = t('Not in $PATH');
$requirements['fedora-imagemagick']['description'] = t('Islandora will not be able to create thumbnails. Ensure that <a href="www.imagemagick.org/">ImageMagick</a> is installed and the convert command is executable by the web server user.');
$requirements['fedora-imagemagick']['severity'] = REQUIREMENT_WARNING;
}
else {
$requirements['fedora-imagemagick']['value'] = t("Available");
$requirements['fedora-imagemagick']['severity'] = REQUIREMENT_OK;
}
$requirements['fedora-kakadu']['title'] = 'Kakadu kdu_compress in $PATH';
system('which kdu_compress', $kdu_res);
if ($kdu_res != 0) {
$requirements['fedora-kakadu']['value'] = ('Not in $PATH');
$requirements['fedora-kakadu']['description'] = t('Islandora cannot convert TIFF image files to JPEG2000 format. Ensure <a href="http://www.kakadusoftware.com/">Kakadu</a> is installed and the kdu_compress command is executable by the web server user.');
$requirements['fedora-kakadu']['severity'] = REQUIREMENT_WARNING;
}
else {
$requirements['fedora-kakadu']['value'] = t("Available");
$requirements['fedora-kakadu']['severity'] = REQUIREMENT_OK;
}
}
return $requirements;
}

16
form_elements/includes/autocomplete.inc

@ -3,17 +3,19 @@
// $Id$ // $Id$
function ife_autocomplete_person($string) { function ife_autocomplete_person($string) {
$string=strtolower($string); $string=trim(strtolower($string));
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('php', 'islandora_solr_search', 'Solr/Service'); module_load_include('php', 'islandora_solr_search', 'Solr/Service');
$host = variable_get('islandora_solr_search_block_host','localhost'); $host = variable_get('islandora_solr_search_block_host','localhost');
$port = variable_get('islandora_solr_search_block_port','8080'); $port = variable_get('islandora_solr_search_block_port','8080');
$appName = variable_get('islandora_solr_search_block_app_name','solr'); $appName = variable_get('islandora_solr_search_block_app_name','solr');
$requestHandler = variable_get("islandora_solr_search_block_request_handler",t("standard")); $requestHandler = variable_get("islandora_solr_search_block_request_handler",t("standard"));
$query = 'name_personal_t:'.$string.'* OR name_organization_t:'.$string.'* OR name_conference_t:'.$string.'*';
$solr = new Apache_Solr_Service($host, $port, '/'.$appName.'/'); $solr = new Apache_Solr_Service($host, $port, '/'.$appName.'/');
$string=$solr->escape($string);
$query = 'name_personal_t:'.$string.'* OR name_organization_t:'.$string.'* OR name_conference_t:'.$string.'*';
$additionalParams = array( $additionalParams = array(
'facet' => 'false', 'facet' => 'false',
@ -129,7 +131,7 @@ function ife_autocomplete_gacs($collection, $string='') {
$collection = FALSE; $collection = FALSE;
} }
$string=ucwords($string); $string=ucwords(trim($string));
$dom = DOMDocument::load ( $moduleRoot .'/xml/gacs.xml' ); $dom = DOMDocument::load ( $moduleRoot .'/xml/gacs.xml' );
$rootEl = $dom->getElementsByTagName('codelist'); $rootEl = $dom->getElementsByTagName('codelist');
@ -159,7 +161,7 @@ function ife_autocomplete_language($collection, $string='') {
$collection = FALSE; $collection = FALSE;
} }
$string=ucwords($string); $string=ucwords(trim($string));
$dom = DOMDocument::load ( $moduleRoot .'/xml/languages.xml' ); $dom = DOMDocument::load ( $moduleRoot .'/xml/languages.xml' );
$rootEl = $dom->getElementsByTagName('codelist'); $rootEl = $dom->getElementsByTagName('codelist');
@ -197,7 +199,7 @@ function ife_autocomplete($field, $collection, $string='') {
'fl' => $field 'fl' => $field
); );
$query = $field .':'. $solr->escape(strtolower($string)) .'*'; $query = $field .':'. $solr->escape(strtolower(trim($string))) .'*';
if ($collection != FALSE) { if ($collection != FALSE) {
$query .= ' AND related_item_identifier_t:'. $solr->escape($collection); $query .= ' AND related_item_identifier_t:'. $solr->escape($collection);

13
form_elements/includes/people.inc

@ -41,7 +41,6 @@ function _ife_find_people_element($form, &$keys = array()) {
function ife_people_ahah() { function ife_people_ahah() {
if (!isset($_POST['form_build_id'])) if (!isset($_POST['form_build_id']))
return; return;
@ -58,10 +57,9 @@ function ife_people_ahah() {
$_POST = _dummy_post_info($form, $_POST); $_POST = _dummy_post_info($form, $_POST);
$form_state['post'] = $_POST; $form_state['post'] = $_POST;
$form['#post'] = $_POST; $form['#post'] = $_POST;
drupal_process_form($form_id, $form, $form_state); drupal_process_form($form_id, $form, $form_state);
// ob_start(); echo '<pre>'; echo $_POST['form_build_id']."\n"; var_dump($form_state); echo '</pre>'; $dump = ob_get_contents(); ob_end_clean(); //ob_start(); echo '<pre>'; echo $_POST['form_build_id']."\n"; var_dump($form_state); echo '</pre>'; $dump = ob_get_contents(); ob_end_clean();
$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
$qt_form = _ife_find_people_element($form); $qt_form = _ife_find_people_element($form);
@ -109,7 +107,7 @@ function ife_remove_person_submit($form, &$form_state) {
unset($form_state['submit_handlers']); unset($form_state['submit_handlers']);
form_execute_handlers('submit', $form, $form_state); form_execute_handlers('submit', $form, $form_state);
$form_state['storage']['people'] = $people; $form_state['storage']['people'] = $people;
//$form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
} }
@ -136,14 +134,14 @@ function ife_add_person_submit($form, &$form_state) {
} }
//only add new person if we are not adding from repository. //only add new person if we are not adding from repository.
if (!isset($form_state['post']['add_from_repository']) || trim($form_state['post']['add_from_repository']) == '') { $elName = isset($qt_form['entity0']['#parents'][0])?$qt_form['entity0']['#parents'][0]:null;
if ($elName == null || !isset($form_state['clicked_button']['#post'][$elName]['add_from_repository']) || trim($form_state['clicked_button']['#post'][$elName]['add_from_repository']) == '') {
$people[] = array('name' => '', 'date'=>'', 'role' => '', 'subject' => ''); $people[] = array('name' => '', 'date'=>'', 'role' => '', 'subject' => '');
} }
unset($form_state['submit_handlers']); unset($form_state['submit_handlers']);
form_execute_handlers('submit', $form, $form_state); form_execute_handlers('submit', $form, $form_state);
$form_state['storage']['people'] = $people; $form_state['storage']['people'] = $people;
// $form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
} }
@ -200,6 +198,7 @@ function ife_add_conf_submit($form, &$form_state) {
foreach ($peopleVals['people'] as $val) { foreach ($peopleVals['people'] as $val) {
$people[] = $val; $people[] = $val;
} }
$people[] = array('role' => '', 'conference' => '', 'subject' => ''); $people[] = array('role' => '', 'conference' => '', 'subject' => '');
unset($form_state['submit_handlers']); unset($form_state['submit_handlers']);

12
form_elements/islandora_form_elements.module

@ -145,15 +145,16 @@ function ife_people_process($element,$edit,&$form_state)
$people= array(); $people= array();
if (isset($form_state['storage']['people']) && !empty($form_state['storage']['people'])) { if (isset($form_state['storage']['people']) && !empty($form_state['storage']['people'])) {
foreach ($form_state['storage']['people'] as $ent) { foreach ($form_state['storage']['people'] as $ent) {
if ( trim($ent['name']) != '' || trim($ent['organization']) != '' || trim($ent['conference']) != '' || trim($ent['role']) != '' || trim($ent['date']) != '') { if ( trim($ent['name']) != '' || trim($ent['organization']) != '' || trim($ent['conference']) != '' || trim($ent['role']) != '' || trim($ent['date']) != '') {
$people[]=$ent; $people[]=$ent;
} }
} }
} }
$json = json_decode($form_state['post'][$element['#name']]['add_from_repository']); $json = json_decode($form_state['post'][$element['#name']]['add_from_repository']);
$form_state['post'][$element['#name']]['add_from_repository'] = ''; // clear so that if the form is processed multiple times, it does not add twice.
$person=array(); $person=array();
@ -182,7 +183,6 @@ function ife_people_process($element,$edit,&$form_state)
$form_state['storage']['people']=$people; $form_state['storage']['people']=$people;
} else if (!isset($form_state['storage']['people']) || empty($form_state['storage']['people'])) } else if (!isset($form_state['storage']['people']) || empty($form_state['storage']['people']))
{ {
if ( (!isset($form_state['clicked_button']) || count($form_state['clicked_button']) == 0) && isset($element['#default_value']) && is_array($element['#default_value']) ) { if ( (!isset($form_state['clicked_button']) || count($form_state['clicked_button']) == 0) && isset($element['#default_value']) && is_array($element['#default_value']) ) {

12
form_elements/js/people_ahah.js

@ -3,11 +3,13 @@
if (Drupal.jsEnabled) { if (Drupal.jsEnabled) {
$(document).ready(function() { $(document).ready(function() {
if (Drupal.ahah != undefined) { $('#edit-mods-people-add-from-repository').blur(function () {
if ($('#edit-mods-people-add-from-repository').val() != '') {
$('#edit-mods-people-add-person').mousedown();
}
});
$('#edit-mods-people-add-from-repository').change(function () { if (Drupal.ahah != undefined) {
$('#edit-mods-people-add-person').mousedown();
});
/** /**
* Override of Drupal.ahah.prototype.success. The only difference is that we * Override of Drupal.ahah.prototype.success. The only difference is that we
@ -87,4 +89,4 @@ Drupal.ahah.prototype.success = function (response, status) {
}); });
} }
})(jQuery); })(jQuery);

47
ilives/fedora_ilives.module

@ -593,5 +593,52 @@ function install_book_content_model_objects() {
if (!Fedora_Item::fedora_item_exists('ilives:CollectionModel')) { if (!Fedora_Item::fedora_item_exists('ilives:CollectionModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_CollectionModel.xml'); Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_CollectionModel.xml');
} }
}
/**
* Implementation of hook_requirements().
*
* @return
* An array describing the status of the site regarding available updates.
* If there is no update data, only one record will be returned, indicating
* that the status of core can't be determined. If data is available, there
* will be two records: one for core, and another for all of contrib
* (assuming there are any contributed modules or themes enabled on the
* site). In addition to the fields expected by hook_requirements ('value',
* 'severity', and optionally 'description'), this array will contain a
* 'reason' attribute, which is an integer constant to indicate why the
* given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or
* UPDATE_UNKNOWN). This is used for generating the appropriate e-mail
* notification messages during update_cron(), and might be useful for other
* modules that invoke update_requirements() to find out if the site is up
* to date or not.
*
* @see _update_message_text()
* @see _update_cron_notify()
*/
function fedora_ilives_requirements($phase) {
global $base_url;
if ($phase == 'runtime') {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$requirements['iiv-war'] = array();
$requirements['iiv-war']['title'] = t("Islandora OpenLayers image viewer web app");
if (!_fedora_ilives_viewer_available()) {
$requirements['iiv-war']['value'] = ("Not available");
$requirements['iiv-war']['severity'] = REQUIREMENT_ERROR;
$requirements['iiv-war']['description'] = t('Ensure that Fedora is running and that the <a href="@iiv-home">IIV</a> app is deployed.',
array('@iiv-home' => 'http://github.com/islandora/iiv'));
}
else {
$requirements['iiv-war']['value'] = ("Available");
$requirements['iiv-war']['severity'] = REQUIREMENT_OK;
}
}
return $requirements;
}
function _fedora_ilives_viewer_available() {
$url = parse_url(variable_get('fedora_base_url', 'http://localhost:8080/fedora'));
$fedora_host = ("{$url['scheme']}://{$url['host']}" . (!empty($url['port']) ? ":{$url['port']}/" : '/'));
$response = drupal_http_request("$fedora_host/iiv/images/loading.gif");
return empty($response->error);
} }

54
plugins/ModsFormBuilder.inc

@ -69,9 +69,9 @@ class ModsFormBuilder extends FormBuilder {
); );
$includeEl = true; $includeEl = true;
$name = explode('][', $element['name']); $elname = explode('][', $element['name']);
$elLocation = &$form['indicator2']; $elLocation = &$form['indicator2'];
while (isset($elLocation[$name[0]]) && ($partial = array_shift($name)) != NULL) { while (isset($elLocation[$name[0]]) && ($partial = array_shift($elname)) != NULL) {
$elLocation = &$elLocation[$partial]; $elLocation = &$elLocation[$partial];
} }
@ -136,13 +136,13 @@ class ModsFormBuilder extends FormBuilder {
$nameParts = $mname->getElementsByTagName('namePart'); $nameParts = $mname->getElementsByTagName('namePart');
foreach ($nameParts as $namePart) foreach ($nameParts as $namePart)
{ {
switch ($namePart->getAttribute('type')) { switch ($namePart->getAttribute('type')) {
case 'given': $given = $namePart->nodeValue; break; case 'given': $given = $namePart->nodeValue; break;
case 'family': $family = $namePart->nodeValue; break; case 'family': $family = $namePart->nodeValue; break;
case 'termsOfAddress': $title = $namePart->nodeValue; break; case 'termsOfAddress': $title = $namePart->nodeValue; break;
case 'date': $date = $namePart->nodeValue; break; case 'date': $date = $namePart->nodeValue; break;
default: $name = $namePart->nodeValue; break; default: $name = $namePart->nodeValue; break;
} }
} }
$person=array('role'=>$role); $person=array('role'=>$role);
@ -213,8 +213,8 @@ class ModsFormBuilder extends FormBuilder {
$el['#options']= isset($element['authoritative_list'])?$element['authoritative_list']:array(); $el['#options']= isset($element['authoritative_list'])?$element['authoritative_list']:array();
} }
if ($includeEl) { if ($includeEl) {
$elLocation[join('][', $name)] = $el; $elLocation[join('][', $elname)] = $el;
} }
} }
@ -272,8 +272,8 @@ class ModsFormBuilder extends FormBuilder {
} }
$this->createPolicy($collectionPid, &$dom, &$rootElement); $this->createPolicy($collectionPid, &$dom, &$rootElement);
// header('Content-type: application/xml'); // header('Content-type: application/xml');
// echo $dom->saveXML(); exit(); // echo $dom->saveXML(); exit();
try { try {
$object = Fedora_Item::ingest_from_FOXML($dom); $object = Fedora_Item::ingest_from_FOXML($dom);
@ -661,7 +661,7 @@ class ModsFormBuilder extends FormBuilder {
if (isset($form_values['mods_people']) && isset($form_values['mods_people']['people']) && is_array($form_values['mods_people']['people']) ) { if (isset($form_values['mods_people']) && isset($form_values['mods_people']['people']) && is_array($form_values['mods_people']['people']) ) {
foreach ($form_values['mods_people']['people'] as $key => $val) { foreach ($form_values['mods_people']['people'] as $key => $val) {
$name = $dom->createElement('mods:name'); $name = $dom->createElement('mods:name');
$appendName=FALSE;
if (isset($val['role'])) { if (isset($val['role'])) {
$role = $dom->createElement('mods:role'); $role = $dom->createElement('mods:role');
$roleTerm = $dom->createElement('mods:roleTerm', htmlspecialchars(trim($val['role']))); $roleTerm = $dom->createElement('mods:roleTerm', htmlspecialchars(trim($val['role'])));
@ -676,6 +676,7 @@ class ModsFormBuilder extends FormBuilder {
if (trim($val['organization']) != '') { if (trim($val['organization']) != '') {
$namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['organization']))); $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['organization'])));
$name->appendChild($namePart); $name->appendChild($namePart);
$appendName=TRUE;
} }
} }
elseif (isset($val['conference'])) { elseif (isset($val['conference'])) {
@ -683,6 +684,7 @@ class ModsFormBuilder extends FormBuilder {
if (trim($val['conference']) != '') { if (trim($val['conference']) != '') {
$namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['conference']))); $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['conference'])));
$name->appendChild($namePart); $name->appendChild($namePart);
$appendName=TRUE;
} }
} }
else { else {
@ -690,22 +692,24 @@ class ModsFormBuilder extends FormBuilder {
if (trim($val['name']) != '') { if (trim($val['name']) != '') {
$namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['name']))); $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['name'])));
$name->appendChild($namePart); $name->appendChild($namePart);
$appendName=TRUE;
} }
} }
if (isset($val['date'])) { if (isset($val['date'])) {
$namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['date']))); $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['date'])));
$namePart->setAttribute('type','date'); $namePart->setAttribute('type','date');
$name->appendChild($namePart); $name->appendChild($namePart);
} }
if (isset($val['subject'])) { if ($appendName) {
if (isset($val['subject'])) {
$subject->appendChild($name); $subject->appendChild($name);
$hasSubject=TRUE; $hasSubject=TRUE;
} else } else {
{
$mods->appendChild($name); $mods->appendChild($name);
} }
}
} }
} }

Loading…
Cancel
Save