Browse Source

ISLANDORA-278 Updated files to meet Coder standards. Mostly t() tags. Also renamed a couple of functions. I did a find / replace for the 3 function name changes.

validPid to valid_pid
validDsid to valid_dsid
fixDsid to fix_dsid

One of the changes I've made has caused a minor bug in the islandora module. There are extra spaces in the collections URL.
pull/7/head^2
Nelson Hart 14 years ago
parent
commit
2bd1e56ebd
  1. 7
      CollectionClass.inc
  2. 11
      CollectionPolicy.inc
  3. 1
      ConnectionHelper.inc
  4. 57
      ContentModel.inc
  5. 2
      MimeClass.inc
  6. 12
      ObjectHelper.inc
  7. 9
      SearchClass.inc
  8. 6
      SecurityClass.inc
  9. 13
      XMLDatastream.inc
  10. 3
      api/dublin_core.inc
  11. 5
      api/fedora_collection.inc
  12. 59
      api/fedora_export.inc
  13. 16
      api/fedora_item.inc
  14. 6
      api/fedora_utils.inc
  15. 3
      api/rels-ext.inc
  16. 2
      api/tagging.inc
  17. 16
      fedora_repository.module
  18. 1
      fedora_repository.solutionpacks.inc
  19. 3
      formClass.inc
  20. 93
      form_elements/includes/autocomplete.inc
  21. 5
      form_elements/includes/creative_commons.inc
  22. 18
      form_elements/includes/filechooser.inc
  23. 64
      form_elements/includes/people.inc
  24. 6
      ilives/image_rotator_tagger_block.inc
  25. 2
      plugins/Refworks.inc
  26. 2
      plugins/ShowStreamsInFieldSets.inc

7
CollectionClass.inc

@ -2,7 +2,8 @@
/* /**
* @file
* Created on 18-Feb-08 * Created on 18-Feb-08
* *
* To change the template for this generated file go to * To change the template for this generated file go to
@ -284,7 +285,7 @@ class CollectionClass {
$thisClass = new $phpClass (); $thisClass = new $phpClass ();
$returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext); $returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext);
if (!$returnValue) { if (!$returnValue) {
drupal_set_message('Error! Failed running content model method !m !rv', array('!m' => $phpMethod, '!rv' => $returnValue)); drupal_set_message(t('Error! Failed running content model method !m !rv'), array('!m' => $phpMethod, '!rv' => $returnValue));
return FALSE; return FALSE;
} }
} }
@ -393,7 +394,7 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass'); module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass');
$personalCollectionClass = new PersonalCollectionClass(); $personalCollectionClass = new PersonalCollectionClass();
if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) { if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) {
drupal_set_message("Did not create a personal collection object for !u", array('!u' => $user->name)); drupal_set_message(t("Did not create a personal collection object for !u"), array('!u' => $user->name));
return FALSE; //creation failed don't save the collection pid in drupal db return FALSE; //creation failed don't save the collection pid in drupal db
} }
user_save($user, $personal_collection_pid); user_save($user, $personal_collection_pid);

11
CollectionPolicy.inc

@ -1,6 +1,9 @@
<?php <?php
/**
* @file
*
*/
module_load_include('inc', 'fedora_repository', 'XMLDatastream'); module_load_include('inc', 'fedora_repository', 'XMLDatastream');
@ -34,7 +37,7 @@ class CollectionPolicy extends XMLDatastream {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
try { try {
if (self::validPid($pid)) { if (self::valid_pid($pid)) {
$dsid = CollectionPolicy::getDefaultDSID(); $dsid = CollectionPolicy::getDefaultDSID();
if ($preFetch) { if ($preFetch) {
@ -357,7 +360,7 @@ class CollectionPolicy extends XMLDatastream {
*/ */
public function getNextPid($dsid) { public function getNextPid($dsid) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && $this->validate()) { if (self::valid_dsid($dsid) && $this->validate()) {
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); $content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model');
$namespace = FALSE; $namespace = FALSE;
for ($i = 0; $namespace === FALSE && $i < $content_models->length; $i++) { for ($i = 0; $namespace === FALSE && $i < $content_models->length; $i++) {
@ -568,7 +571,7 @@ class CollectionPolicy extends XMLDatastream {
function addModel($cm, $namespace) { function addModel($cm, $namespace) {
$ret = FALSE; $ret = FALSE;
if (self::validPid($namespace) && $this->validate() && $cm->validate()) { if (self::valid_pid($namespace) && $this->validate() && $cm->validate()) {
$contentmodelsEl = $this->xml->getElementsByTagName('content_models'); $contentmodelsEl = $this->xml->getElementsByTagName('content_models');
$models = $contentmodelsEl->item(0)->getElementsByTagName('content_model'); $models = $contentmodelsEl->item(0)->getElementsByTagName('content_model');
$found = FALSE; $found = FALSE;

1
ConnectionHelper.inc

@ -3,6 +3,7 @@
/* /*
* @file
* Created on Jan 24, 2008 * Created on Jan 24, 2008
* *
* To change the template for this generated file go to * To change the template for this generated file go to

57
ContentModel.inc

@ -1,6 +1,9 @@
<?php <?php
/**
* @file
*
*/
module_load_include('inc', 'fedora_repository', 'XMLDatastream'); module_load_include('inc', 'fedora_repository', 'XMLDatastream');
@ -31,7 +34,7 @@ class ContentModel extends XMLDatastream {
*/ */
public static function loadFromObject($pid) { public static function loadFromObject($pid) {
$ret = FALSE; $ret = FALSE;
if (self::validPid($pid)) { if (self::valid_pid($pid)) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
@ -192,9 +195,9 @@ class ContentModel extends XMLDatastream {
$ret = FALSE; $ret = FALSE;
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
try { try {
if (self::validPid($pid)) { if (self::valid_pid($pid)) {
$fedoraItem = new Fedora_Item($pid); $fedoraItem = new Fedora_Item($pid);
$dsid = ($dsid != NULL && self::validDsid($dsid)) ? $dsid : ContentModel::getDefaultDSID(); $dsid = ($dsid != NULL && self::valid_dsid($dsid)) ? $dsid : ContentModel::getDefaultDSID();
$ds = $fedoraItem->get_datastream_dissemination($dsid); $ds = $fedoraItem->get_datastream_dissemination($dsid);
if (!empty($ds)) { if (!empty($ds)) {
$ret = new ContentModel($ds, $pid, $dsid, $pid_namespace, $name); $ret = new ContentModel($ds, $pid, $dsid, $pid_namespace, $name);
@ -468,7 +471,7 @@ class ContentModel extends XMLDatastream {
*/ */
private function getDSModel($dsid) { private function getDSModel($dsid) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && $this->validate()) { if (self::valid_dsid($dsid) && $this->validate()) {
$result = $this->xml->getElementsByTagName('datastreams'); $result = $this->xml->getElementsByTagName('datastreams');
if ($result->length > 0) { if ($result->length > 0) {
$result = $result->item(0)->getElementsByTagName('datastream'); $result = $result->item(0)->getElementsByTagName('datastream');
@ -579,23 +582,23 @@ class ContentModel extends XMLDatastream {
$elementsEl = $this->xml->getElementsbyTagName('ingest_form')->item(0)->getElementsByTagName('form_elements')->item(0); $elementsEl = $this->xml->getElementsbyTagName('ingest_form')->item(0)->getElementsByTagName('form_elements')->item(0);
$elements = $elementsEl->getElementsByTagName('element'); $elements = $elementsEl->getElementsByTagName('element');
$found = FALSE; $found = FALSE;
$refEl = FALSE; $ref_el = FALSE;
for ($i = 0; $found === FALSE && $i < $elements->length; $i++) { for ($i = 0; $found === FALSE && $i < $elements->length; $i++) {
if ($elements->item($i)->getAttribute('name') == trim($name)) { if ($elements->item($i)->getAttribute('name') == trim($name)) {
if ($reorder == 'inc') { if ($reorder == 'inc') {
$found = $elements->item($i); $found = $elements->item($i);
$refEl = ($i > 0) ? $elements->item($i - 1) : false; $ref_el = ($i > 0) ? $elements->item($i - 1) : FALSE;
} }
else { else {
$found = ($i + 1 < $elements->length) ? $elements->item($i + 1) : FALSE; $found = ($i + 1 < $elements->length) ? $elements->item($i + 1) : FALSE;
$refEl = $elements->item($i); $ref_el = $elements->item($i);
} }
} }
} }
if ($found !== FALSE) { if ($found !== FALSE) {
$elementsEl->removeChild($found); $elementsEl->removeChild($found);
$elementsEl->insertBefore($found, $refEl); $elementsEl->insertBefore($found, $ref_el);
$ret = TRUE; $ret = TRUE;
} }
} }
@ -867,23 +870,23 @@ class ContentModel extends XMLDatastream {
$items = $authListEl->getElementsByTagName('item'); $items = $authListEl->getElementsByTagName('item');
$found = FALSE; $found = FALSE;
$refEl = FALSE; $ref_el = FALSE;
for ($i = 0; $found === FALSE && $i < $items->length; $i++) { for ($i = 0; $found === FALSE && $i < $items->length; $i++) {
if ($items->item($i)->nodeValue == $value) { if ($items->item($i)->nodeValue == $value) {
if ($reorder == 'inc') { if ($reorder == 'inc') {
$refEl = ($i > 0) ? $items->item($i - 1) : FALSE; $ref_el = ($i > 0) ? $items->item($i - 1) : FALSE;
$found = $items->item($i); $found = $items->item($i);
} }
else { else {
$refEl = $items->item($i); $ref_el = $items->item($i);
$found = ($i + 1 < $items->length) ? $items->item($i + 1) : FALSE; $found = ($i + 1 < $items->length) ? $items->item($i + 1) : FALSE;
} }
} }
} }
if ($found !== FALSE && $refEl !== FALSE) { if ($found !== FALSE && $ref_el !== FALSE) {
$authListEl->removeChild($found); $authListEl->removeChild($found);
$authListEl->insertBefore($found, $refEl); $authListEl->insertBefore($found, $ref_el);
$ret = TRUE; $ret = TRUE;
} }
} }
@ -1077,7 +1080,7 @@ class ContentModel extends XMLDatastream {
*/ */
public function buildEditMetadataForm($pid, $dsid) { public function buildEditMetadataForm($pid, $dsid) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && $this->validate()) { if (self::valid_dsid($dsid) && $this->validate()) {
$method = $this->xml->getElementsByTagName('edit_metadata_method'); $method = $this->xml->getElementsByTagName('edit_metadata_method');
if ($method->length > 0 && $method->item(0)->getAttribute('dsid') == $dsid) { if ($method->length > 0 && $method->item(0)->getAttribute('dsid') == $dsid) {
$method = $method->item(0); $method = $method->item(0);
@ -1210,7 +1213,7 @@ class ContentModel extends XMLDatastream {
*/ */
public function updateEditMetadataMethod($module, $file, $class, $method, $handler, $dsid) { public function updateEditMetadataMethod($module, $file, $class, $method, $handler, $dsid) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && $this->validate()) { if (self::valid_dsid($dsid) && $this->validate()) {
$methodEl = $this->xml->getElementsByTagName('content_model')->item(0)->getElementsByTagName('edit_metadata_method'); $methodEl = $this->xml->getElementsByTagName('content_model')->item(0)->getElementsByTagName('edit_metadata_method');
if ($methodEl->length > 0) { if ($methodEl->length > 0) {
$methodEl = $methodEl->item(0); $methodEl = $methodEl->item(0);
@ -1240,7 +1243,7 @@ class ContentModel extends XMLDatastream {
*/ */
public function execAddDatastreamMethods($dsid, $file) { public function execAddDatastreamMethods($dsid, $file) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && $this->validate() && ($ds = $this->getDSModel($dsid)) !== FALSE) { if (self::valid_dsid($dsid) && $this->validate() && ($ds = $this->getDSModel($dsid)) !== FALSE) {
$addMethod = $ds->getElementsByTagName('add_datastream_method'); $addMethod = $ds->getElementsByTagName('add_datastream_method');
if ($addMethod->length > 0) { if ($addMethod->length > 0) {
$addMethod = $addMethod->item(0); $addMethod = $addMethod->item(0);
@ -1567,7 +1570,7 @@ class ContentModel extends XMLDatastream {
public function addDs($dsid, $display_in_fieldset = FALSE) { public function addDs($dsid, $display_in_fieldset = FALSE) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) === FALSE) { if (self::valid_dsid($dsid) && ($ds = $this->getDSModel($dsid)) === FALSE) {
$datastreamsEl = $this->xml->getElementsByTagName('datastreams'); $datastreamsEl = $this->xml->getElementsByTagName('datastreams');
if ($datastreamsEl->length > 0) { if ($datastreamsEl->length > 0) {
$datastreamsEl = $datastreamsEl->item(0); $datastreamsEl = $datastreamsEl->item(0);
@ -1591,7 +1594,7 @@ class ContentModel extends XMLDatastream {
public function removeDs($dsid) { public function removeDs($dsid) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) { if (self::valid_dsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
$datastreamsEl = $this->xml->getElementsByTagName('datastreams')->item(0); $datastreamsEl = $this->xml->getElementsByTagName('datastreams')->item(0);
$datastreamsEl->removeChild($ds); $datastreamsEl->removeChild($ds);
$ret = TRUE; $ret = TRUE;
@ -1601,7 +1604,7 @@ class ContentModel extends XMLDatastream {
public function displayInFieldset($dsid) { public function displayInFieldset($dsid) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) { if (self::valid_dsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
$ret = strtolower($ds->getAttribute('display_in_fieldset')) == 'true'; $ret = strtolower($ds->getAttribute('display_in_fieldset')) == 'true';
} }
return $ret; return $ret;
@ -1609,7 +1612,7 @@ class ContentModel extends XMLDatastream {
public function setDisplayInFieldset($dsid, $value = TRUE) { public function setDisplayInFieldset($dsid, $value = TRUE) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) { if (self::valid_dsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
if ($value == FALSE && $ds->attributes->getNamedItem('display_in_fieldset') !== NULL) { if ($value == FALSE && $ds->attributes->getNamedItem('display_in_fieldset') !== NULL) {
$ds->removeAttribute('display_in_fieldset'); $ds->removeAttribute('display_in_fieldset');
$ret = TRUE; $ret = TRUE;
@ -1625,7 +1628,7 @@ class ContentModel extends XMLDatastream {
public function setDefaultDispMeth($dsid, $module, $file, $class, $method) { public function setDefaultDispMeth($dsid, $module, $file, $class, $method) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) { if (self::valid_dsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
$found = FALSE; $found = FALSE;
$dispMethods = $ds->getElementsByTagName('display_method'); $dispMethods = $ds->getElementsByTagName('display_method');
for ($i = 0; !$found && $i < $dispMethods->length; $i++) { for ($i = 0; !$found && $i < $dispMethods->length; $i++) {
@ -1654,7 +1657,7 @@ class ContentModel extends XMLDatastream {
public function removeDispMeth($dsid, $module, $file, $class, $method) { public function removeDispMeth($dsid, $module, $file, $class, $method) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) { if (self::valid_dsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
$found = FALSE; $found = FALSE;
$dispMethods = $ds->getElementsByTagName('display_method'); $dispMethods = $ds->getElementsByTagName('display_method');
for ($i = 0; !$found && $i < $dispMethods->length; $i++) { for ($i = 0; !$found && $i < $dispMethods->length; $i++) {
@ -1676,7 +1679,7 @@ class ContentModel extends XMLDatastream {
public function addDispMeth($dsid, $module, $file, $class, $method, $default = FALSE) { public function addDispMeth($dsid, $module, $file, $class, $method, $default = FALSE) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) { if (self::valid_dsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
$dispMethEl = $this->xml->createElement('display_method'); $dispMethEl = $this->xml->createElement('display_method');
$dispMethEl->setAttribute('module', $module); $dispMethEl->setAttribute('module', $module);
$dispMethEl->setAttribute('file', $file); $dispMethEl->setAttribute('file', $file);
@ -1757,7 +1760,7 @@ class ContentModel extends XMLDatastream {
public function addIngestMethod($rule_id, $module, $file, $class, $method, $dsid, $modified_files_ext) { public function addIngestMethod($rule_id, $module, $file, $class, $method, $dsid, $modified_files_ext) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && ($rule = $this->getIngestRule($rule_id)) !== FALSE) { if (self::valid_dsid($dsid) && ($rule = $this->getIngestRule($rule_id)) !== FALSE) {
$methodsEl = $rule->getElementsByTagName('ingest_methods')->item(0); $methodsEl = $rule->getElementsByTagName('ingest_methods')->item(0);
$meth = $this->xml->createElement('ingest_method'); $meth = $this->xml->createElement('ingest_method');
$meth->setAttribute('module', $module); $meth->setAttribute('module', $module);
@ -1883,7 +1886,7 @@ class ContentModel extends XMLDatastream {
public function addIngestRule($applies_to, $module, $file, $class, $method, $dsid, $modified_files_ext) { public function addIngestRule($applies_to, $module, $file, $class, $method, $dsid, $modified_files_ext) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && $this->validate()) { if (self::valid_dsid($dsid) && $this->validate()) {
$ingestRulesEl = $this->xml->getElementsByTagName('ingest_rules')->item(0); $ingestRulesEl = $this->xml->getElementsByTagName('ingest_rules')->item(0);
$rule = $this->xml->createElement('rule'); $rule = $this->xml->createElement('rule');
$ingestMethodsEl = $this->xml->createElement('ingest_methods'); $ingestMethodsEl = $this->xml->createElement('ingest_methods');
@ -1949,7 +1952,7 @@ class ContentModel extends XMLDatastream {
public function editIngestFormAttributes($dsid, $page, $hide_file_chooser = FALSE, $redirect = TRUE) { public function editIngestFormAttributes($dsid, $page, $hide_file_chooser = FALSE, $redirect = TRUE) {
$ret = FALSE; $ret = FALSE;
if (self::validDsid($dsid) && $this->validate()) { if (self::valid_dsid($dsid) && $this->validate()) {
$ingest_formEl = $this->xml->getElementsByTagName('ingest_form')->item(0); $ingest_formEl = $this->xml->getElementsByTagName('ingest_form')->item(0);
$ingest_formEl->setAttribute('dsid', $dsid); $ingest_formEl->setAttribute('dsid', $dsid);
$ingest_formEl->setAttribute('page', $page); $ingest_formEl->setAttribute('page', $page);

2
MimeClass.inc

@ -3,7 +3,7 @@
/** /**
* * @file
* This class inspired by Chris Jean's work, here: * This class inspired by Chris Jean's work, here:
* http://chrisjean.com/2009/02/14/generating-mime-type-in-php-is-not-magic/ * http://chrisjean.com/2009/02/14/generating-mime-type-in-php-is-not-magic/
* *

12
ObjectHelper.inc

@ -3,8 +3,8 @@
/* /*
* @file
* Created on Feb 1, 2008 * Created on Feb 1, 2008
*
* To change the template for this generated file go to * To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates * Window - Preferences - PHPeclipse - PHP - Code Templates
*/ */
@ -48,7 +48,7 @@ class ObjectHelper {
} }
$headers = module_invoke_all('file_download', "/fedora/repository/$pid/$dsID"); $headers = module_invoke_all('file_download', "/fedora/repository/$pid/$dsID");
if (in_array(-1, $headers)) { if (in_array(-1, $headers)) {
drupal_set_message('hello'); drupal_set_message(t('hello'));
drupal_access_denied(); drupal_access_denied();
return ' '; return ' ';
@ -346,7 +346,7 @@ class ObjectHelper {
$input = new DomDocument(); $input = new DomDocument();
$input->loadXML(trim($xmlstr)); $input->loadXML(trim($xmlstr));
} catch (exception $e) { } catch (exception $e) {
watchdog(t("Fedora_Repository"), t("Problem loading XSL file: !e", array('!e' => $e)), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), "Problem loading XSL file: !e", array('!e' => $e), NULL, WATCHDOG_ERROR);
} }
$xsl = $proc->importStylesheet($xsl); $xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input); $newdom = $proc->transformToDoc($input);
@ -521,7 +521,7 @@ class ObjectHelper {
try { try {
$sxml = new SimpleXMLElement($content_models); $sxml = new SimpleXMLElement($content_models);
} catch (exception $e) { } catch (exception $e) {
watchdog(t("Fedora_Repository"), t("Could not find a parent object for %s", $pid), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), "Could not find a parent object for %s", $pid, NULL, WATCHDOG_ERROR);
return $pids; return $pids;
} }
@ -899,8 +899,8 @@ class ObjectHelper {
$warnMess = "Creation of one or more datastreams failed.<hr width='40%' align = 'left'/>"; $warnMess = "Creation of one or more datastreams failed.<hr width='40%' align = 'left'/>";
$configMess = "Please ensure that %app is installed and configured for this site. "; $configMess = "Please ensure that %app is installed and configured for this site. ";
drupal_set_message($warnMess, 'warning', false); drupal_set_message($warnMess, 'warning', FALSE);
drupal_set_message(t($configMess . "<br />" . $messMap[$app] . "<hr width='40%' align = 'left'/>", array('%app' => $app)), 'warning', false); drupal_set_message(t($configMess . "<br />" . $messMap[$app] . "<hr width='40%' align = 'left'/>", array('%app' => $app)), 'warning', FALSE);
} }
} }

9
SearchClass.inc

@ -1,6 +1,9 @@
<?php <?php
/**
* @file
*
*/
class SearchClass { class SearchClass {
@ -17,7 +20,7 @@ class SearchClass {
try { try {
$implementation = new $solrClass(); $implementation = new $solrClass();
} catch (Exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("Error getting solr search results class: !message", array('!message' => $e->getMessage())), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), "Error getting solr search results class: !message", array('!message' => $e->getMessage()), NULL, WATCHDOG_ERROR);
return 'Error getting solr search results class. Check watchdog for more info.'; return 'Error getting solr search results class. Check watchdog for more info.';
} }
return $implementation->$solrFunction($query, $startPage, $fq, $dismax); return $implementation->$solrFunction($query, $startPage, $fq, $dismax);
@ -363,7 +366,7 @@ class SearchClass {
try { try {
$proc = new XsltProcessor(); $proc = new XsltProcessor();
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error loading results xslt! ') . $e->getMessage()); drupal_set_message(t('Error loading results xslt!') . " " . $e->getMessage());
return ' '; return ' ';
} }

6
SecurityClass.inc

@ -3,8 +3,8 @@
/* /*
* @file
* Created on 22-Oct-08 * Created on 22-Oct-08
*
* To change the template for this generated file go to * To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates * Window - Preferences - PHPeclipse - PHP - Code Templates
*/ */
@ -58,7 +58,7 @@ class SecurityClass {
try { try {
$xml = new SimpleXMLElement($policyStream); $xml = new SimpleXMLElement($policyStream);
} catch (Exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("No roles found in security policy, could not parse policy stream."), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), "No roles found in security policy, could not parse policy stream.", NULL, WATCHDOG_ERROR);
//we may not want to send this to the screen. //we may not want to send this to the screen.
drupal_set_message(t('No roles found in security policy, could not parse policy stream: !message', array('!message' => $e->getMessage())), 'error'); drupal_set_message(t('No roles found in security policy, could not parse policy stream: !message', array('!message' => $e->getMessage())), 'error');
return NULL; return NULL;
@ -104,7 +104,7 @@ class SecurityClass {
try { try {
$doc->load(drupal_get_path('module', 'Fedora_Repository') . '/policies/noObjectEditPolicy.xml'); $doc->load(drupal_get_path('module', 'Fedora_Repository') . '/policies/noObjectEditPolicy.xml');
} catch (exception $e) { } catch (exception $e) {
watchdog(t("Fedora_Repository"), t("Problem loading policy file."), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), "Problem loading policy file.", NULL, WATCHDOG_ERROR);
} }
$conditions = $doc->getElementsByTagName('Condition'); $conditions = $doc->getElementsByTagName('Condition');
foreach ($conditions as $condition) { foreach ($conditions as $condition) {

13
XMLDatastream.inc

@ -1,6 +1,9 @@
<?php <?php
/**
* @file
*
*/
abstract class XMLDatastream { abstract class XMLDatastream {
@ -23,7 +26,7 @@ abstract class XMLDatastream {
} }
/** /**
* validPid * valid_pid
* Validates a fedora PID based on the regexp provided in the fedora * Validates a fedora PID based on the regexp provided in the fedora
* 3.3 documentation. * 3.3 documentation.
* http://www.fedora-commons.org/confluence/display/FCR30/Fedora+Identifiers * http://www.fedora-commons.org/confluence/display/FCR30/Fedora+Identifiers
@ -31,7 +34,7 @@ abstract class XMLDatastream {
* @param String $pid * @param String $pid
* @return boolean $valid * @return boolean $valid
*/ */
public static function validPid($pid) { public static function valid_pid($pid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) { if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) {
$valid = TRUE; $valid = TRUE;
@ -41,7 +44,7 @@ abstract class XMLDatastream {
} }
/** /**
* validDsid * valid_dsid
* Validates a fedora Dsid based on the the allowed XML standard NCName. * Validates a fedora Dsid based on the the allowed XML standard NCName.
* The regexp is a "regular" subset of names allowed, it excludes some extended hex characters that are * The regexp is a "regular" subset of names allowed, it excludes some extended hex characters that are
* technically permitted. * technically permitted.
@ -50,7 +53,7 @@ abstract class XMLDatastream {
* @param String $pid * @param String $pid
* @return boolean $valid * @return boolean $valid
*/ */
public static function validDsid($dsid) { public static function valid_dsid($dsid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) { if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) {
$valid = TRUE; $valid = TRUE;

3
api/dublin_core.inc

@ -2,7 +2,8 @@
/* /**
* @file
* Implements a simple class for working with Dublin Core data and exporting it * Implements a simple class for working with Dublin Core data and exporting it
* back to XML. Inspiration and design shamelessly stolen from the pyfedora * back to XML. Inspiration and design shamelessly stolen from the pyfedora
* project at http://pypi.python.org/pypi/pyfedora/0.1.0 * project at http://pypi.python.org/pypi/pyfedora/0.1.0

5
api/fedora_collection.inc

@ -2,7 +2,8 @@
/* /**
* @file
* Operations that affect a Fedora repository at a collection level. * Operations that affect a Fedora repository at a collection level.
*/ */
@ -53,7 +54,7 @@ function export_collection($collection_pid, $relationship = 'isMemberOfCollectio
} }
} }
else { else {
drupal_set_message("Error creating temp directory for batch export.", 'error'); drupal_set_message(t("Error creating temp directory for batch export."), 'error');
return FALSE; return FALSE;
} }
return TRUE; return TRUE;

59
api/fedora_export.inc

@ -1,6 +1,9 @@
<?php <?php
/**
* @file
*
*/
define('FOXML_10', 'info:fedora/fedora-system:FOXML-1.0'); define('FOXML_10', 'info:fedora/fedora-system:FOXML-1.0');
define('FOXML_11', 'info:fedora/fedora-system:FOXML-1.1'); define('FOXML_11', 'info:fedora/fedora-system:FOXML-1.1');
@ -74,14 +77,14 @@ function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $re
// Remove rdf elements added during ingest (if present) // Remove rdf elements added during ingest (if present)
if ($remove_islandora) { if ($remove_islandora) {
$xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); $xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
$descNode = $xpath->query("//rdf:RDF/rdf:Description")->item(0); $desc_node = $xpath->query("//rdf:RDF/rdf:Description")->item(0);
if ($model = $descNode->getElementsByTagName('hasModel')->item(0)) { if ($model = $desc_node->getElementsByTagName('hasModel')->item(0)) {
$descNode->removeChild($model); $desc_node->removeChild($model);
} }
if ($member = $descNode->getElementsByTagName('rel:isMemberOfCollection')->item(0)) { if ($member = $desc_node->getElementsByTagName('rel:isMemberOfCollection')->item(0)) {
$descNode->removeChild($member); $desc_node->removeChild($member);
} }
} }
@ -95,24 +98,24 @@ function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $re
// Update datastream uris // Update datastream uris
$xpath->registerNamespace('foxml', 'info:fedora/fedora-system:def/foxml#'); $xpath->registerNamespace('foxml', 'info:fedora/fedora-system:def/foxml#');
foreach ($xpath->query("//foxml:datastream[@ID]") as $dsNode) { foreach ($xpath->query("//foxml:datastream[@ID]") as $ds_node) {
// Don't update datastreams having external uris // Don't update datastreams having external uris
if (in_array($dsNode->getAttribute('CONTROL_GROUP'), $disallowed_groups)) { if (in_array($ds_node->getAttribute('CONTROL_GROUP'), $disallowed_groups)) {
continue; continue;
} }
$dsId = $dsNode->getAttribute('ID'); $ds_id = $ds_node->getAttribute('ID');
// Remove QUERY datastream // Remove QUERY datastream
if ($dsId == "QUERY") { if ($ds_id == "QUERY") {
$parentNode = $xpath->query('/foxml:digitalObject')->item(0); $parent_node = $xpath->query('/foxml:digitalObject')->item(0);
$parentNode->removeChild($dsNode); $parent_node->removeChild($ds_node);
} }
foreach ($dsNode->getElementsByTagName('*') as $contentNode) { foreach ($ds_node->getElementsByTagName('*') as $content_node) {
if ($str = $contentNode->getAttribute('REF')) { if ($str = $content_node->getAttribute('REF')) {
$contentNode->setAttribute('REF', url($paths[$dsId], array('absolute' => TRUE))); $content_node->setAttribute('REF', url($paths[$ds_id], array('absolute' => TRUE)));
} }
} }
} }
@ -122,29 +125,29 @@ function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $re
case METS_11: case METS_11:
// Update datastream uris // Update datastream uris
$xpath->registerNamespace('METS', 'http://www.loc.gov/METS/'); $xpath->registerNamespace('METS', 'http://www.loc.gov/METS/');
foreach ($xpath->query('//METS:fileGrp[@ID="DATASTREAMS"]/METS:fileGrp') as $dsNode) { foreach ($xpath->query('//METS:fileGrp[@ID="DATASTREAMS"]/METS:fileGrp') as $ds_node) {
$dsId = $dsNode->getAttribute('ID'); $ds_id = $ds_node->getAttribute('ID');
// Remove QUERY datastream // Remove QUERY datastream
if ($dsId == "QUERY") { if ($ds_id == "QUERY") {
$parentNode = $xpath->query('//METS:fileGrp[@ID="DATASTREAMS"]')->item(0); $parent_node = $xpath->query('//METS:fileGrp[@ID="DATASTREAMS"]')->item(0);
$parentNode->removeChild($dsNode); $parent_node->removeChild($ds_node);
} }
$xpath->registerNamespace('xlink', 'http://www.loc.gov/METS/'); $xpath->registerNamespace('xlink', 'http://www.loc.gov/METS/');
foreach ($xpath->query('METS:file[@OWNERID!="E"][@OWNERID!="R"]/METS:FLocat[@xlink:href]', $dsNode) as $Floc) { foreach ($xpath->query('METS:file[@OWNERID!="E"][@OWNERID!="R"]/METS:FLocat[@xlink:href]', $ds_node) as $floc) {
$Floc->setAttribute('xlink:href', url($paths[$dsId], array('absolute' => TRUE))); $floc->setAttribute('xlink:href', url($paths[$ds_id], array('absolute' => TRUE)));
} }
/* /*
foreach ($dsNode->getElementsByTagName('METS:file') as $contentNode) { foreach ($ds_node->getElementsByTagName('METS:file') as $content_node) {
// Don't update datastreams having external uris // Don't update datastreams having external uris
if (in_array($dsNode->getAttribute('OWNERID'), $disallowed_groups)) { if (in_array($ds_node->getAttribute('OWNERID'), $disallowed_groups)) {
continue; continue;
} }
foreach ($xpath->('METS:FLocat[@xlink:href]', $contentNode) as $Floc) { foreach ($xpath->('METS:FLocat[@xlink:href]', $content_node) as $floc) {
$Floc->setAttribute('xlink:href', url($paths[$dsId], array('absolute' => true))); $floc->setAttribute('xlink:href', url($paths[$ds_id], array('absolute' => true)));
} }
`} `}
*/ */
@ -170,8 +173,8 @@ function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $re
return TRUE; return TRUE;
} }
function get_file_extension($mimeType) { function get_file_extension($mime_type) {
return substr(strstr($mimeType, '/'), 1); return substr(strstr($mime_type, '/'), 1);
} }
function log_line($msg, $severity = 'info', $sep = "\t") { function log_line($msg, $severity = 'info', $sep = "\t") {

16
api/fedora_item.inc

@ -1,6 +1,10 @@
<?php <?php
/**
* @file
*
*/
define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#'); define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#');
define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#'); define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#');
@ -475,7 +479,7 @@ class Fedora_Item {
try { try {
$relsext = $this->get_datastream_dissemination('RELS-EXT'); $relsext = $this->get_datastream_dissemination('RELS-EXT');
} catch (exception $e) { } catch (exception $e) {
drupal_set_message("Error retrieving RELS-EXT of object $pid", 'error'); drupal_set_message(t("Error retrieving RELS-EXT of object $pid"), 'error');
return $relationships; return $relationships;
} }
@ -516,7 +520,7 @@ class Fedora_Item {
foreach ($relationships as $rel) { foreach ($relationships as $rel) {
if (empty($rel['subject']) || empty($rel['predicate']) || empty($rel['object']) || $rel['subject'] != 'info:fedora/' . $this->pid) { if (empty($rel['subject']) || empty($rel['predicate']) || empty($rel['object']) || $rel['subject'] != 'info:fedora/' . $this->pid) {
// drupal_set_message should use parameterized variables, not interpolated. // drupal_set_message should use parameterized variables, not interpolated.
drupal_set_message("Error with relationship format: " . $rel['subject'] . " - " . $rel['predicate'] . ' - ' . $rel['object'], "error"); drupal_set_message(t("Error with relationship format: " . $rel['subject'] . " - " . $rel['predicate'] . ' - ' . $rel['object']), "error");
return FALSE; return FALSE;
} }
} }
@ -683,7 +687,7 @@ class Fedora_Item {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array)); $result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
} }
else { else {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection.")); watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL; return NULL;
} }
} catch (exception $e) { } catch (exception $e) {
@ -696,7 +700,7 @@ class Fedora_Item {
drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error'); drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error');
} }
watchdog(t("FEDORA_REPOSITORY"), t("Error Trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e)), NULL, WATCHDOG_ERROR); watchdog(t("FEDORA_REPOSITORY"), "Error Trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e), NULL, WATCHDOG_ERROR);
} }
return NULL; return NULL;
} }
@ -709,13 +713,13 @@ class Fedora_Item {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array)); $result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
} }
else { else {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection.")); watchdog(t("FEDORA_REPOSITORY"), "Error trying to get SOAP client connection.");
return NULL; return NULL;
} }
} catch (exception $e) { } catch (exception $e) {
if (!$quiet) { if (!$quiet) {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e)), NULL, WATCHDOG_ERROR); watchdog(t("FEDORA_REPOSITORY"), "Error trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e), NULL, WATCHDOG_ERROR);
} }
return NULL; return NULL;
} }

6
api/fedora_utils.inc

@ -87,7 +87,7 @@ function fix_encoding($in_str) {
} }
} }
function validPid($pid) { function valid_pid($pid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) { if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) {
$valid = TRUE; $valid = TRUE;
@ -96,7 +96,7 @@ function validPid($pid) {
return $valid; return $valid;
} }
function validDsid($dsid) { function valid_dsid($dsid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) { if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) {
$valid = TRUE; $valid = TRUE;
@ -105,7 +105,7 @@ function validDsid($dsid) {
return $valid; return $valid;
} }
function fixDsid($dsid) { function fix_dsid($dsid) {
$new_dsid = trim($dsid); $new_dsid = trim($dsid);
$find = '/[^a-zA-Z0-9\.\_\-]/'; $find = '/[^a-zA-Z0-9\.\_\-]/';

3
api/rels-ext.inc

@ -2,7 +2,8 @@
/* /**
* @file
* To change this template, choose Tools | Templates * To change this template, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */

2
api/tagging.inc

@ -62,7 +62,7 @@ class TagSet {
$this->item->modify_datastream_by_value($tagdoc->saveXML(), $this->tagsDSID, 'Tags', 'text/xml', 'X'); $this->item->modify_datastream_by_value($tagdoc->saveXML(), $this->tagsDSID, 'Tags', 'text/xml', 'X');
} }
} catch (exception $e) { } catch (exception $e) {
drupal_set_message('There was an error saving the tags datastream: !e', array('!e' => $e), 'error'); drupal_set_message(t('There was an error saving the tags datastream: !e'), array('!e' => $e), 'error');
return FALSE; return FALSE;
} }
return TRUE; return TRUE;

16
fedora_repository.module

@ -94,8 +94,8 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
return ''; return '';
} }
if (!validPid($collection_pid)) { if (!valid_pid($collection_pid)) {
if (validPid(urldecode($collection_pid))) { if (valid_pid(urldecode($collection_pid))) {
$collection_pid = urldecode($collection_pid); $collection_pid = urldecode($collection_pid);
} }
else { else {
@ -275,7 +275,7 @@ function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NUL
function add_stream($collection_pid=NULL, $collectionName=NULL) { function add_stream($collection_pid=NULL, $collectionName=NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!validPid($collection_pid)) { if (!valid_pid($collection_pid)) {
drupal_set_message(t("This PID is not valid!"), 'error'); drupal_set_message(t("This PID is not valid!"), 'error');
return ' '; return ' ';
} }
@ -680,12 +680,12 @@ function fedora_repository_access($op, $node, $account) {
*/ */
function makeObject($pid, $dsID) { function makeObject($pid, $dsID) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!validPid($pid)) { if (!valid_pid($pid)) {
drupal_set_message(t("Invalid PID!"), 'error'); drupal_set_message(t("Invalid PID!"), 'error');
return ' '; return ' ';
} }
if (!validDsid($dsID)) { if (!valid_dsid($dsID)) {
drupal_set_message(t("Invalid dsID!"), 'error'); drupal_set_message(t("Invalid dsID!"), 'error');
return ' '; return ' ';
} }
@ -724,13 +724,13 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
return ''; return '';
} }
if ($pid & !validPid($pid)) { if ($pid & !valid_pid($pid)) {
drupal_set_message(t("Invalid PID!"), 'error'); drupal_set_message(t("Invalid PID!"), 'error');
return ' '; return ' ';
} }
if ($dsId & !validDsid($dsId)) { if ($dsId & !valid_dsid($dsId)) {
drupal_set_message(t("Invalid dsID!"), 'error'); drupal_set_message(t("Invalid dsID!"), 'error');
return ' '; return ' ';
} }
@ -1964,7 +1964,7 @@ function fedora_repository_batch_reingest_object($object, &$context) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!empty($object) && is_array($object)) { if (!empty($object) && is_array($object)) {
$pid = $object['pid']; $pid = $object['pid'];
if (!validPid($pid)) { if (!valid_pid($pid)) {
return NULL; return NULL;
} }
// Does the object exist? If so, purge it. // Does the object exist? If so, purge it.

1
fedora_repository.solutionpacks.inc

@ -1,6 +1,7 @@
<?php <?php
/** /**
* @file
* Invokes a hook to any dependent modules asking them if their installations require * Invokes a hook to any dependent modules asking them if their installations require
* any fedora objects to be present. Modules implementing this hook should return an array * any fedora objects to be present. Modules implementing this hook should return an array
* of arrays of the form: * of arrays of the form:

3
formClass.inc

@ -3,6 +3,7 @@
/* /*
* @file
* Created on Jan 22, 2008 * Created on Jan 22, 2008
*/ */
@ -442,7 +443,7 @@ class formClass {
try { try {
$object = $client->__soapCall('ModifyDatastreamByValue', array($params)); $object = $client->__soapCall('ModifyDatastreamByValue', array($params));
} catch (exception $e) { } catch (exception $e) {
drupal_set_message(t("Error updating metadata ") . $e->getMessage(), 'error'); drupal_set_message(t("Error updating metadata") . " " . $e->getMessage(), 'error');
} }
} }

93
form_elements/includes/autocomplete.inc

@ -1,6 +1,9 @@
<?php <?php
/**
* @file
*
*/
function ife_autocomplete_person($string) { function ife_autocomplete_person($string) {
$string = trim(strtolower($string)); $string = trim(strtolower($string));
@ -9,23 +12,23 @@ function ife_autocomplete_person($string) {
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'); $app_name = variable_get('islandora_solr_search_block_app_name', 'solr');
$requestHandler = variable_get("islandora_solr_search_block_request_handler", t("standard")); $request_handler = variable_get("islandora_solr_search_block_request_handler", t("standard"));
$solr = new Apache_Solr_Service($host, $port, '/' . $appName . '/'); $solr = new Apache_Solr_Service($host, $port, '/' . $app_name . '/');
$string = $solr->escape($string); $string = $solr->escape($string);
$query = 'name_personal_t:' . $string . '* OR name_organization_t:' . $string . '* OR name_conference_t:' . $string . '*'; $query = 'name_personal_t:' . $string . '* OR name_organization_t:' . $string . '* OR name_conference_t:' . $string . '*';
$additionalParams = array( $additional_params = array(
'facet' => 'false', 'facet' => 'false',
'qt' => $requestHandler, 'qt' => $request_handler,
); );
try { try {
$results = $solr->search($query, 0, 10, $additionalParams); $results = $solr->search($query, 0, 10, $additional_params);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('error searching ') . $e->getMessage()); drupal_set_message(t('error searching') ." " . $e->getMessage());
} }
if (empty($results)) { if (empty($results)) {
drupal_set_message(t('Error searching solr index. Is the solr search block configured properly?'), 'error'); drupal_set_message(t('Error searching solr index. Is the solr search block configured properly?'), 'error');
@ -41,15 +44,15 @@ function ife_autocomplete_person($string) {
$mods = $item->get_datastream_dissemination('MODS'); $mods = $item->get_datastream_dissemination('MODS');
if (trim($mods) != '') { if (trim($mods) != '') {
$modsDom = new DomDocument(); $mods_dom = new DomDocument();
$modsDom->loadXML($mods); $mods_dom->loadXML($mods);
$xpath = new DOMXPath($modsDom); $xpath = new DOMXPath($mods_dom);
$xpath->registerNamespace("php", "http://php.net/xpath"); $xpath->registerNamespace("php", "http://php.net/xpath");
$xpath->registerPHPFunctions(); $xpath->registerPHPFunctions();
// echo $mods; // echo $mods;
$nodeList = $xpath->evaluate('/mods:mods/mods:name'); $node_list = $xpath->evaluate('/mods:mods/mods:name');
foreach ($nodeList as $node) { foreach ($node_list as $node) {
$type = $node->getAttribute('type'); $type = $node->getAttribute('type');
$title = NULL; $title = NULL;
@ -57,8 +60,8 @@ function ife_autocomplete_person($string) {
$given = NULL; $given = NULL;
$family = NULL; $family = NULL;
$date = NULL; $date = NULL;
$nameParts = $node->getElementsByTagName('namePart'); $name_parts = $node->getElementsByTagName('namePart');
foreach ($nameParts as $part) { foreach ($name_parts as $part) {
switch ($part->getAttribute('type')) { switch ($part->getAttribute('type')) {
case 'given': $given = $part->nodeValue; case 'given': $given = $part->nodeValue;
break; break;
@ -78,9 +81,9 @@ function ife_autocomplete_person($string) {
} }
$role = NULL; $role = NULL;
$roleTerm = $node->getElementsByTagName('roleTerm'); $role_term = $node->getElementsByTagName('roleTerm');
if ($roleTerm->length > 0) { if ($role_term->length > 0) {
$role = $roleTerm->item(0)->nodeValue; $role = $role_term->item(0)->nodeValue;
} }
if (strpos(strtolower($name), $string) !== FALSE) { if (strpos(strtolower($name), $string) !== FALSE) {
@ -95,7 +98,7 @@ function ife_autocomplete_person($string) {
} }
function ife_autocomplete_marcrelator($collection, $string='') { function ife_autocomplete_marcrelator($collection, $string='') {
$moduleRoot = drupal_get_path('module', 'islandora_form_elements'); $module_root = drupal_get_path('module', 'islandora_form_elements');
if ($string == '') { if ($string == '') {
$string = $collection; $string = $collection;
@ -104,30 +107,30 @@ function ife_autocomplete_marcrelator($collection, $string='') {
$string = ucfirst(trim($string)); $string = ucfirst(trim($string));
$dom = DOMDocument::load($moduleRoot . '/xml/relators.rdf'); $dom = DOMDocument::load($module_root . '/xml/relators.rdf');
$rootEl = $dom->getElementsByTagName('RDF'); $root_el = $dom->getElementsByTagName('RDF');
if ($rootEl->length > 0) { if ($root_el->length > 0) {
$rootEl = $rootEl->item(0); $root_el = $root_el->item(0);
$xpath = new DOMXPath($dom); $xpath = new DOMXPath($dom);
$xpath->registerNamespace('skos', $rootEl->getAttribute('xmlns:skos')); $xpath->registerNamespace('skos', $root_el->getAttribute('xmlns:skos'));
$xpath->registerNamespace('rdf', $rootEl->getAttribute('xmlns:rdf')); $xpath->registerNamespace('rdf', $root_el->getAttribute('xmlns:rdf'));
$result = $xpath->query('/rdf:RDF/rdf:Description[starts-with(skos:prefLabel, "' . $string . '")]'); $result = $xpath->query('/rdf:RDF/rdf:Description[starts-with(skos:prefLabel, "' . $string . '")]');
$terms = array(); $terms = array();
foreach ($result as $term) { foreach ($result as $term) {
$termVal = $term->getElementsByTagName('prefLabel')->item(0)->nodeValue; $term_val = $term->getElementsByTagName('prefLabel')->item(0)->nodeValue;
$termVal = preg_replace('/\s+/', ' ', $termVal); $term_val = preg_replace('/\s+/', ' ', $term_val);
$terms[$term->getElementsByTagName('notation')->item(0)->nodeValue] = $termVal; $terms[$term->getElementsByTagName('notation')->item(0)->nodeValue] = $term_val;
} }
echo drupal_json($terms); echo drupal_json($terms);
} }
} }
function ife_autocomplete_gacs($collection, $string='') { function ife_autocomplete_gacs($collection, $string='') {
$moduleRoot = drupal_get_path('module', 'islandora_form_elements'); $module_root = drupal_get_path('module', 'islandora_form_elements');
if ($string == '') { if ($string == '') {
$string = $collection; $string = $collection;
@ -136,13 +139,13 @@ function ife_autocomplete_gacs($collection, $string='') {
$string = ucwords(trim($string)); $string = ucwords(trim($string));
$dom = DOMDocument::load($moduleRoot . '/xml/gacs.xml'); $dom = DOMDocument::load($module_root . '/xml/gacs.xml');
$rootEl = $dom->getElementsByTagName('codelist'); $root_el = $dom->getElementsByTagName('codelist');
if ($rootEl->length > 0) { if ($root_el->length > 0) {
$rootEl = $rootEl->item(0); $root_el = $root_el->item(0);
$xpath = new DOMXPath($dom); $xpath = new DOMXPath($dom);
$xpath->registerNamespace('a', $rootEl->getAttribute('xmlns')); $xpath->registerNamespace('a', $root_el->getAttribute('xmlns'));
$result = $xpath->query('/a:codelist/a:gacs/a:gac[starts-with(a:name, "' . $string . '")]'); $result = $xpath->query('/a:codelist/a:gacs/a:gac[starts-with(a:name, "' . $string . '")]');
@ -155,7 +158,7 @@ function ife_autocomplete_gacs($collection, $string='') {
} }
function ife_autocomplete_language($collection, $string='') { function ife_autocomplete_language($collection, $string='') {
$moduleRoot = drupal_get_path('module', 'islandora_form_elements'); $module_root = drupal_get_path('module', 'islandora_form_elements');
if ($string == '') { if ($string == '') {
$string = $collection; $string = $collection;
@ -164,13 +167,13 @@ function ife_autocomplete_language($collection, $string='') {
$string = ucwords(trim($string)); $string = ucwords(trim($string));
$dom = DOMDocument::load($moduleRoot . '/xml/languages.xml'); $dom = DOMDocument::load($module_root . '/xml/languages.xml');
$rootEl = $dom->getElementsByTagName('codelist'); $root_el = $dom->getElementsByTagName('codelist');
if ($rootEl->length > 0) { if ($root_el->length > 0) {
$rootEl = $rootEl->item(0); $root_el = $root_el->item(0);
$xpath = new DOMXPath($dom); $xpath = new DOMXPath($dom);
$xpath->registerNamespace('a', $rootEl->getAttribute('xmlns')); $xpath->registerNamespace('a', $root_el->getAttribute('xmlns'));
$result = $xpath->query('/a:codelist/a:languages/a:language[starts-with(a:name, "' . $string . '")]'); $result = $xpath->query('/a:codelist/a:languages/a:language[starts-with(a:name, "' . $string . '")]');
@ -192,10 +195,10 @@ function ife_autocomplete($field, $collection, $string='') {
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'); $app_name = variable_get('islandora_solr_search_block_app_name', 'solr');
$solr = new Apache_Solr_Service($host, $port, '/' . $appName . '/'); $solr = new Apache_Solr_Service($host, $port, '/' . $app_name . '/');
$additionalParams = array( $additional_params = array(
'fl' => $field 'fl' => $field
); );
@ -206,9 +209,9 @@ function ife_autocomplete($field, $collection, $string='') {
} }
try { try {
$results = $solr->search($query, 0, 10, $additionalParams); $results = $solr->search($query, 0, 10, $additional_params);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('error searching ') . $e->getMessage()); drupal_set_message(t('error searching') . " " . $e->getMessage());
} }
$docs = $results->response->docs; $docs = $results->response->docs;

5
form_elements/includes/creative_commons.inc

@ -1,5 +1,10 @@
<?php <?php
/**
* @file
*
*/
class CreativeCommons { class CreativeCommons {
public static $cc_jurisdiction_vals = array( public static $cc_jurisdiction_vals = array(

18
form_elements/includes/filechooser.inc

@ -1,5 +1,9 @@
<?php <?php
/**
* @file
*
*/
function theme_filechooser($element) { function theme_filechooser($element) {
@ -15,7 +19,7 @@ function theme_filechooser($element) {
drupal_add_css($path . '/css/filechooser.css'); drupal_add_css($path . '/css/filechooser.css');
module_load_include('inc', 'fedora_repository', 'ContentModel'); module_load_include('inc', 'fedora_repository', 'ContentModel');
$contentModelPid = ContentModel::getPidFromIdentifier($element['#model_pid']); $content_model_pid = ContentModel::getPidFromIdentifier($element['#model_pid']);
$output = '<div class="carousel"> $output = '<div class="carousel">
@ -26,7 +30,7 @@ function theme_filechooser($element) {
</div> </div>
<br clear="all"/> <br clear="all"/>
<a href="#" class="prev">Prev</a> <a href="#" class="next">Next</a> <a href="#" class="prev">Prev</a> <a href="#" class="next">Next</a>
<input type="hidden" id="model_pid" value="' . $contentModelPid . '"/> <input type="hidden" id="model_pid" value="' . $content_model_pid . '"/>
<input type="hidden" name="' . $element['#name'] . '" value="' . check_plain($element['#value']) . '" id="fileField"/></div>'; <input type="hidden" name="' . $element['#name'] . '" value="' . check_plain($element['#value']) . '" id="fileField"/></div>';
return theme('form_element', $element, $output); return theme('form_element', $element, $output);
} }
@ -36,7 +40,7 @@ function ife_filechooser_get_thumbnail($cp_pid, $cm_pid, $file) {
module_load_include('inc', 'fedora_repository', 'ContentModel'); module_load_include('inc', 'fedora_repository', 'ContentModel');
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
$mimeClass = new MimeClass(); $mime_class = new MimeClass();
$cm = ContentModel::loadFromModel($cm_pid); $cm = ContentModel::loadFromModel($cm_pid);
$cp = CollectionPolicy::loadFromCollection($cp_pid); $cp = CollectionPolicy::loadFromCollection($cp_pid);
@ -45,7 +49,7 @@ function ife_filechooser_get_thumbnail($cp_pid, $cm_pid, $file) {
if ($cm !== FALSE && $cp !== FALSE) { if ($cm !== FALSE && $cp !== FALSE) {
if (is_file($path . $file)) { if (is_file($path . $file)) {
$mime = $mimeClass->getType($path . $file); $mime = $mime_class->getType($path . $file);
$allowed_types = $cm->getMimetypes(); $allowed_types = $cm->getMimetypes();
@ -57,7 +61,7 @@ function ife_filechooser_get_thumbnail($cp_pid, $cm_pid, $file) {
$thumbnail = $_SESSION['fedora_ingest_files']['TN']; $thumbnail = $_SESSION['fedora_ingest_files']['TN'];
} }
$thumbmime = $mimeClass->getType($thumbnail); $thumbmime = $mime_class->getType($thumbnail);
header('Pragma: no-cache'); header('Pragma: no-cache');
header('Content-Type: ' . $thumbmime); header('Content-Type: ' . $thumbmime);
@ -85,7 +89,7 @@ function ife_filechooser_generate_thumbnails($cp_pid, $cm_pid) {
exit(); exit();
} }
$mimeClass = new MimeClass(); $mime_class = new MimeClass();
$path = $cp->getStagingArea() . '/'; $path = $cp->getStagingArea() . '/';
$start = isset($_GET['start']) ? intval($_GET['start']) : 0; $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
$end = isset($_GET['end']) ? intval($_GET['end']) : 50; $end = isset($_GET['end']) ? intval($_GET['end']) : 50;
@ -97,7 +101,7 @@ function ife_filechooser_generate_thumbnails($cp_pid, $cm_pid) {
$dir = opendir($path); $dir = opendir($path);
for ($i = $start; $i < $end && ($file = readdir($dir)) !== FALSE;) { for ($i = $start; $i < $end && ($file = readdir($dir)) !== FALSE;) {
if (is_file($path . $file)) { if (is_file($path . $file)) {
$mime = $mimeClass->getType($path . $file); $mime = $mime_class->getType($path . $file);
if (in_array($mime, $allowed_types)) { if (in_array($mime, $allowed_types)) {
$thumbnail = FALSE; $thumbnail = FALSE;

64
form_elements/includes/people.inc

@ -1,11 +1,15 @@
<?php <?php
/**
// this is a bit of a hack. It iterates through the * @file
// form and assigns a dummy value to any field in the $post *
// data that is marked as #required. This is so that the *
// AHAH method can still function with required fields that * this is a bit of a hack. It iterates through the
// are first passed to the core form validation function. * form and assigns a dummy value to any field in the $post
* data that is marked as #required. This is so that the
* AHAH method can still function with required fields that
* are first passed to the core form validation function.
*/
function _dummy_post_info($form, $post, $key = '') { function _dummy_post_info($form, $post, $key = '') {
$children = element_children($form); $children = element_children($form);
if (count($children) > 0) { if (count($children) > 0) {
@ -82,17 +86,17 @@ function ife_remove_person_submit($form, &$form_state) {
$keys = array(); $keys = array();
$qt_form = _ife_find_people_element($form, $keys); $qt_form = _ife_find_people_element($form, $keys);
$peopleVals = &$form_state['values']; $people_vals = &$form_state['values'];
while (count($keys) > 0) { while (count($keys) > 0) {
$key = array_pop($keys); $key = array_pop($keys);
if (isset($peopleVals[$key])) { if (isset($people_vals[$key])) {
$peopleVals = &$peopleVals[$key]; $people_vals = &$people_vals[$key];
} }
} }
$people = array(); $people = array();
$i = 0; $i = 0;
foreach ($peopleVals['people'] as $key => $val) { foreach ($people_vals['people'] as $key => $val) {
if ($key != $delta) { if ($key != $delta) {
$people[] = $val; $people[] = $val;
} }
@ -115,24 +119,24 @@ function ife_add_person_submit($form, &$form_state) {
$people = array(); $people = array();
$keys = array(); $keys = array();
$qt_form = _ife_find_people_element($form, $keys); $qt_form = _ife_find_people_element($form, $keys);
$peopleVals = &$form_state['values']; $people_vals = &$form_state['values'];
while (count($keys) > 0) { while (count($keys) > 0) {
$key = array_pop($keys); $key = array_pop($keys);
if (isset($peopleVals[$key])) { if (isset($people_vals[$key])) {
$peopleVals = &$peopleVals[$key]; $people_vals = &$people_vals[$key];
} }
} }
if (!is_array($peopleVals['people'])) if (!is_array($people_vals['people']))
$peopleVals['people'] = array(); $people_vals['people'] = array();
foreach ($peopleVals['people'] as $val) { foreach ($people_vals['people'] as $val) {
$people[] = $val; $people[] = $val;
} }
//only add new person if we are not adding from repository. //only add new person if we are not adding from repository.
$elName = isset($qt_form['entity0']['#parents'][0]) ? $qt_form['entity0']['#parents'][0] : NULL; $el_name = 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']) == '') { if ($el_name == NULL || !isset($form_state['clicked_button']['#post'][$el_name]['add_from_repository']) || trim($form_state['clicked_button']['#post'][$el_name]['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']);
@ -148,19 +152,19 @@ function ife_add_org_submit($form, &$form_state) {
$people = array(); $people = array();
$keys = array(); $keys = array();
$qt_form = _ife_find_people_element($form, $keys); $qt_form = _ife_find_people_element($form, $keys);
$peopleVals = &$form_state['values']; $people_vals = &$form_state['values'];
while (count($keys) > 0) { while (count($keys) > 0) {
$key = array_pop($keys); $key = array_pop($keys);
if (isset($peopleVals[$key])) { if (isset($people_vals[$key])) {
$peopleVals = &$peopleVals[$key]; $people_vals = &$people_vals[$key];
} }
} }
if (!is_array($peopleVals['people'])) if (!is_array($people_vals['people']))
$peopleVals['people'] = array(); $people_vals['people'] = array();
foreach ($peopleVals['people'] as $val) { foreach ($people_vals['people'] as $val) {
$people[] = $val; $people[] = $val;
} }
$people[] = array('role' => '', 'organization' => ''); $people[] = array('role' => '', 'organization' => '');
@ -178,17 +182,17 @@ function ife_add_conf_submit($form, &$form_state) {
$people = array(); $people = array();
$keys = array(); $keys = array();
$qt_form = _ife_find_people_element($form, $keys); $qt_form = _ife_find_people_element($form, $keys);
$peopleVals = &$form_state['values']; $people_vals = &$form_state['values'];
while (count($keys) > 0) { while (count($keys) > 0) {
$key = array_pop($keys); $key = array_pop($keys);
if (isset($peopleVals[$key])) { if (isset($people_vals[$key])) {
$peopleVals = &$peopleVals[$key]; $people_vals = &$people_vals[$key];
} }
} }
if (!is_array($peopleVals['people'])) if (!is_array($people_vals['people']))
$peopleVals['people'] = array(); $people_vals['people'] = array();
foreach ($peopleVals['people'] as $val) { foreach ($people_vals['people'] as $val) {
$people[] = $val; $people[] = $val;
} }

6
ilives/image_rotator_tagger_block.inc

@ -2,7 +2,7 @@
/* /**
* @file image_rotator_tagger_block.inc * @file image_rotator_tagger_block.inc
*/ */
@ -67,8 +67,12 @@ function _fedora_image_rotator_tagger_block_content() {
$image_item = new Fedora_Item($result['pid']); $image_item = new Fedora_Item($result['pid']);
} }
if (!empty($result)) { if (!empty($result)) {
$image = theme_image( . $base_url . '/fedora/imageapi/' . $result['pid'] . '/JPG?op=scale&height=500&width=300');
return '<p>' return '<p>'
. l('<img src="' . $base_url . '/fedora/imageapi/' . $result['pid'] . '/JPG?op=scale&height=500&width=300" />', 'fedora/repository/' . $result['pid'], array('html' => TRUE, 'alias' => TRUE)) . l('<img src="' . $base_url . '/fedora/imageapi/' . $result['pid'] . '/JPG?op=scale&height=500&width=300" />', 'fedora/repository/' . $result['pid'], array('html' => TRUE, 'alias' => TRUE))
//. l(t("!image", array(image => $image))
. '<p>This image is from ' . l($result['title'], 'fedora/ilives_book_viewer/' . substr($image_item->pid, 0, strrpos($image_item->pid, '-')), array('html' => TRUE, 'alias' => TRUE)) . '.' . '<p>This image is from ' . l($result['title'], 'fedora/ilives_book_viewer/' . substr($image_item->pid, 0, strrpos($image_item->pid, '-')), array('html' => TRUE, 'alias' => TRUE)) . '.'
. drupal_get_form('fedora_repository_image_tagging_form', $result['pid']) . '</p>'; . drupal_get_form('fedora_repository_image_tagging_form', $result['pid']) . '</p>';
} }

2
plugins/Refworks.inc

@ -72,7 +72,7 @@ class Refworks {
//$dom = dom_import_simplexml($xml);//test to see if it behaves better //$dom = dom_import_simplexml($xml);//test to see if it behaves better
//$xml = new SimpleXMLElement(trim(file_get_contents($file))); //$xml = new SimpleXMLElement(trim(file_get_contents($file)));
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error processing Refworks file:') . $e->getMessage()); drupal_set_message(t('Error processing Refworks file:') . " " . $e->getMessage());
return FALSE; return FALSE;
} }
$this->referenceList = array(); $this->referenceList = array();

2
plugins/ShowStreamsInFieldSets.inc

@ -84,7 +84,7 @@ class ShowStreamsInFieldSets {
} }
$dc_html = $objectHelper->getFormattedDC($item); $dc_html = $objectHelper->getFormattedDC($item);
$dl_link = l(t('<div style="float:left; padding: 10px"><img src="' . $tn_url . '"><br />View Document</div>'), 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE)); $dl_link = l('<div style="float:left; padding: 10px"><img src="' . $tn_url . '"><br />View Document</div>', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE));
$tabset['first_tab']['tabs']['view'] = array( $tabset['first_tab']['tabs']['view'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',

Loading…
Cancel
Save