Browse Source

Merge pull request #5 from bwoodhead/6.x

6.x Inline Documentation Update
pull/6/head
Ben Woodhead 13 years ago
parent
commit
6d7e84f6d1
  1. 86
      CollectionClass.inc
  2. 56
      CollectionPolicy.inc
  3. 39
      ConnectionHelper.inc
  4. 214
      ContentModel.inc
  5. 20
      MimeClass.inc
  6. 135
      ObjectHelper.inc
  7. 112
      SearchClass.inc
  8. 48
      SecurityClass.inc
  9. 17
      XMLDatastream.inc
  10. 4
      formClass.inc
  11. 9
      plugins/Flv.inc

86
CollectionClass.inc

@ -2,15 +2,18 @@
// $Id$
/*
* Created on 18-Feb-08
/**
* @file
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
* Collection Class Class
*/
/**
* This CLASS caches the streams so once you call a getstream once it will always return
* the same stream as long as you are using the instance of this class. Cached to
* prevent mutiple hits to fedora. maybe a bit confusing though if this class is used in
* a different context.
*/
// module_load_include('nc', 'CollectionClass', '');
// This CLASS caches the streams so once you call a getstream once it will always return the same stream as long as you are using the
// instance of this class. Cached to prevent mutiple hits to fedora. maybe a bit confusing though if this class is used in a different context.
class CollectionClass {
public static $COLLECTION_CLASS_COLLECTION_POLICY_STREAM = 'COLLECTION_POLICY';
@ -34,10 +37,10 @@ class CollectionClass {
}
}
/* gets objects related to this object. must include offset and limit
/**
* gets objects related to this object. must include offset and limit
* calls getRelatedItems but enforces limit and offset
*/
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper();
@ -96,6 +99,11 @@ class CollectionClass {
return $content;
}
/**
* getCollectionPolicyStream ??
* @param type $collection_pid
* @return type
*/
function getCollectionPolicyStream($collection_pid) {
if ($this->collectionPolicyStream != NULL) {
return $this->collectionPolicyStream;
@ -104,6 +112,11 @@ class CollectionClass {
return $this->collectionPolicyStream;
}
/**
* getRelationshipElement
* @param type $collection_pid
* @return type
*/
function getRelationshipElement($collection_pid) {
$stream = $this->getCollectionPolicyStream($collection_pid);
try {
@ -116,17 +129,35 @@ class CollectionClass {
return $relationship;
}
/**
* getCollectionViewStream ??
* @param type $collection_pid
* @return type
*/
function getCollectionViewStream($collection_pid) {
$this->collectionViewStream = $this->getStream($collection_pid, CollectionClass :: $COLLECTION_CLASS_COLLECTION_VIEW_STREAM, 0);
return $this->collectionViewStream;
}
/**
* getStream ??
* @param type $pid
* @param type $dsid
* @param type $showError
* @return type
*/
function getStream($pid, $dsid, $showError = 1) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new fedora_item($pid);
return isset($item->datastreams[$dsid]) ? $item->get_datastream_dissemination($dsid) : NULL;
}
/**
* getPidNameSpace ??
* @param type $pid
* @param type $dsid
* @return type
*/
function getPidNameSpace($pid, $dsid) {
$stream = $this->getCollectionPolicyStream($pid);
try {
@ -218,6 +249,12 @@ class CollectionClass {
return NULL;
}
/**
* getAllowedMimeType ??
* @param type $contentModelPid
* @param type $contentModel_dsid
* @return type
*/
function getAllowedMimeTypes($contentModelPid, $contentModel_dsid) {
$stream = $this->getContentModelStream($contentModelPid, $contentModel_dsid);
try {
@ -357,8 +394,13 @@ class CollectionClass {
return $thisClass->$phpMethod($form, $ingest_form, $form_state['values'], $form_state);
}
//this will also create a personal collection for an existing user if they don't have one
//not using this function currently
/**
* This will also create a personal collection for an existing user if they don't have one
* not using this function currently.
*
* @param type $user
* @return type
*/
function createUserCollection(& $user) {
if (isset($user->fedora_personal_pid)) {
return;
@ -414,6 +456,13 @@ class CollectionClass {
return $xslContent;
}
/**
* showFieldSets ??
* @global type $base_url
* @global type $user
* @param type $page_number
* @return string
*/
function showFieldSets($page_number) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
global $base_url;
@ -451,6 +500,11 @@ class CollectionClass {
return $tabset;
}
/**
* getIngestInterface ??
* @global type $base_url
* @return string
*/
function getIngestInterface() {
global $base_url;
$objectHelper = new ObjectHelper();
@ -474,6 +528,16 @@ class CollectionClass {
return $ingestObject;
}
/**
* renderCOllection ??
* @global type $base_url
* @param type $content
* @param type $pid
* @param type $dsId
* @param type $collection
* @param int $pageNumber
* @return type
*/
function renderCollection($content, $pid, $dsId, $collection, $pageNumber = NULL) {
$path = drupal_get_path('module', 'fedora_repository');
global $base_url;

56
CollectionPolicy.inc

@ -2,13 +2,19 @@
// $Id$
/**
* @file
* Collection Policy Class
*/
module_load_include('inc', 'fedora_repository', 'XMLDatastream');
/**
* Collection Policy class ??
*/
class CollectionPolicy extends XMLDatastream {
static $SCHEMA_URI = 'http://syn.lib.umanitoba.ca/collection_policy.xsd';
static $DEFAULT_DSID = 'COLLECTION_POLICY';
private $staging_area = NULL;
/**
@ -41,17 +47,16 @@ class CollectionPolicy extends XMLDatastream {
if ($preFetch) {
$fedoraItem = new Fedora_Item($pid);
$ds = $fedoraItem->get_datastream_dissemination($dsid);
} else {
}
else {
$ds = null;
}
}
if (!empty($ds) || !$preFetch) {
$ret = new CollectionPolicy($ds, $pid, $dsid);
}
}
catch (SOAPException $e) {
} catch (SOAPException $e) {
$ret = FALSE;
}
@ -175,13 +180,11 @@ class CollectionPolicy extends XMLDatastream {
$fedoraItem->add_datastream_from_string($cp->dumpXml(), $policyDsid, $name, 'text/xml', 'X');
$ret = $cp;
}
}
return $ret;
}
/**
* Constructor
* NOTE: Use the static constructor methods whenever possible.
@ -247,7 +250,6 @@ class CollectionPolicy extends XMLDatastream {
$this->xml = DOMDocument::loadXML($newDom->saveXml());
}
/**
* Gets the name of the relationship to use
* for members of this collection.
@ -297,7 +299,8 @@ class CollectionPolicy extends XMLDatastream {
if ($stagingEl->length > 0) {
$this->staging_area = trim($stagingEl->item(0)->nodeValue);
} elseif ($recurse) {
}
elseif ($recurse) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($this->pid);
$rels = $item->get_relationships();
@ -314,7 +317,6 @@ class CollectionPolicy extends XMLDatastream {
}
$ret = $this->staging_area;
}
return $ret;
}
@ -352,7 +354,6 @@ class CollectionPolicy extends XMLDatastream {
return $ret;
}
/**
* Gets the next available PID for the
* content model specified by the DSID
@ -392,21 +393,15 @@ class CollectionPolicy extends XMLDatastream {
$ret = array();
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model');
for ($i = 0; $i < $content_models->length; $i++) {
$cm=ContentModel::loadFromModel($content_models->item($i)->getAttribute('pid'),
$content_models->item($i)->getAttribute('dsid'),
$content_models->item($i)->getAttribute('namespace'),
$content_models->item($i)->getAttribute('name'));
$cm = ContentModel::loadFromModel($content_models->item($i)->getAttribute('pid'), $content_models->item($i)->getAttribute('dsid'), $content_models->item($i)->getAttribute('namespace'), $content_models->item($i)->getAttribute('name'));
if ($cm !== FALSE) {
$ret[] = $cm;
}
}
}
return $ret;
}
/**
* Gets a list of search terms from the Collection Policy. If asArray is set
* it will return an associative array with the value, field name, and the default value.
@ -424,7 +419,8 @@ class CollectionPolicy extends XMLDatastream {
if ($cache == TRUE && ($cache = cache_get('collection_policy_search_terms-' . $this->pid)) !== 0) {
$ret = $cache->data;
} else {
}
else {
if ($this->xml == NULL) {
$fedoraItem = new Fedora_Item($this->pid);
@ -460,13 +456,11 @@ class CollectionPolicy extends XMLDatastream {
}
}
cache_set('collection_policy_search_terms-' . $this->pid, $ret, 'cache', time() + 3600);
}
}
return $ret;
}
/**
* Adds a search term to the collection policy.
* Returns fase on failure.
@ -523,7 +517,11 @@ class CollectionPolicy extends XMLDatastream {
return $ret;
}
/**
* setDefaultTerm ??
* @param type $field
* @return boolean
*/
function setDefaultTerm($field) {
$ret = FALSE;
if ($this->validate()) {
@ -548,7 +546,6 @@ class CollectionPolicy extends XMLDatastream {
return $ret;
}
/**
* Removes the specified content model from the collection policy. This will only
* prevent future ingests of the removed model to the collection. $cm should be
@ -578,9 +575,12 @@ class CollectionPolicy extends XMLDatastream {
return $ret;
}
/**
* addModel ??
* @param type $cm
* @param type $namespace
* @return type
*/
function addModel($cm, $namespace) {
$ret = FALSE;
if (self::validPid($namespace) && $this->validate() && $cm->validate()) {
@ -606,6 +606,10 @@ class CollectionPolicy extends XMLDatastream {
return $ret;
}
/**
* getName ??
* @return type
*/
function getName() {
$ret = FALSE;
if ($this->validate()) {

39
ConnectionHelper.inc

@ -1,19 +1,32 @@
<?php
// $Id$
/*
* Created on Jan 24, 2008
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
/**
* @file
* Connection Helper Class
*/
module_load_include('inc', 'ConnectionHelper', '');
/**
* Connection Helper Class ??
*/
class ConnectionHelper {
/**
* Constructor
*/
function ConnectionHelper() {
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
}
/**
* fixURL ??
* @param type $url
* @param type $_name
* @param type $_pass
* @return string
*/
function _fixURL($url, $_name, $_pass) {
if (empty($url)) {
$url = variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
@ -35,6 +48,13 @@ class ConnectionHelper {
return $new_url;
}
/**
* getSoapClient
* @global type $user
* @param type $url
* @param type $exceptions
* @return SoapClient
*/
function getSoapClient($url = NULL, $exceptions = TRUE) {
if (empty($url)) {
$url = variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl');
@ -50,8 +70,7 @@ class ConnectionHelper {
'password' => 'anonymous',
'exceptions' => $exceptions,
));
}
catch (SoapFault $e) {
} catch (SoapFault $e) {
drupal_set_message(t("!e", array('!e' => $e->getMessage())));
return NULL;
}
@ -63,13 +82,13 @@ class ConnectionHelper {
'password' => $user->pass,
'exceptions' => TRUE,
));
}
catch (SoapFault $e) {
} catch (SoapFault $e) {
drupal_set_message(t("!e", array('!e' => $e->getMessage())));
return NULL;
}
}
return $client;
}
}

214
ContentModel.inc

@ -2,12 +2,19 @@
// $Id$
/**
* @file
* Content Model Class
*/
module_load_include('inc', 'fedora_repository', 'XMLDatastream');
/**
* Conent Model ??
*/
class ContentModel extends XMLDatastream {
static $SCHEMA_URI = 'http://localhost/islandoracm.xsd';
static $DEFAULT_DSID = 'ISLANDORACM';
private $mimes = NULL;
public $pid_namespace;
public $name;
@ -73,7 +80,6 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* Ingests a Content Model from an existing model to the specified pid/dsid .
* Returns false on failure.
@ -103,7 +109,6 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* Ingests a minimum Content Model to the specified pid/dsid.
* Returns false on failure.
@ -174,7 +179,6 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* Constructs a ContentModel object from the PID of the model in Fedora.
* If DSID is specified it will use that datastream as the model, otherwise it will
@ -203,8 +207,7 @@ class ContentModel extends XMLDatastream {
$ret = new ContentModel($ds, $pid, $dsid, $pid_namespace, $name);
}
}
}
catch (SOAPException $e) {
} catch (SOAPException $e) {
$ret = FALSE;
}
return $ret;
@ -287,7 +290,6 @@ class ContentModel extends XMLDatastream {
$ruleEl->appendChild($methodsEl);
$ingestRulesEl->appendChild($ruleEl);
}
}
$rootEl->appendChild($ingestRulesEl);
@ -411,7 +413,6 @@ class ContentModel extends XMLDatastream {
$newDom->appendChild($rootEl);
$this->xml = DOMDocument::loadXML($newDom->saveXml());
}
/**
@ -464,7 +465,6 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* Gets the element corresponding to the datastream specified
* in the <datastreams> element of the schema.
@ -706,7 +706,6 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* Gets a list of all parameters that belong to the specified ingest form element.
*
@ -801,7 +800,6 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* Add an ingest form element to the model.
*
@ -903,9 +901,9 @@ class ContentModel extends XMLDatastream {
/**
* Removes an authority list item from a form element.
@param String $elementName
@param String $value
@return boolean $success
* @param String $elementName
* @param String $value
* @return boolean $success
*/
public function removeAuthListItem($elementName, $value) {
$ret = FALSE;
@ -948,10 +946,10 @@ class ContentModel extends XMLDatastream {
/**
* Adds an authority list item to a form element.
@param String $elementName
@param String $value
@param String $label (optional)
@return boolean $success
* @param String $elementName
* @param String $value
* @param String $label (optional)
* @return boolean $success
*/
public function addAuthListItem($elementName, $value, $label = '') {
$ret = FALSE;
@ -991,7 +989,6 @@ class ContentModel extends XMLDatastream {
$ret = TRUE;
}
}
}
return $ret;
}
@ -1080,7 +1077,7 @@ class ContentModel extends XMLDatastream {
/**
* Builds an edit metadata form using the method specified in the <edit_metadata_method> element
= * The DSID specified must match the DSID attribute of <edit_metadata_method>. Returns FALSE on failure.
* The DSID specified must match the DSID attribute of <edit_metadata_method>. Returns FALSE on failure.
*
* @param string $dsid
* @return $form
@ -1164,13 +1161,11 @@ class ContentModel extends XMLDatastream {
$ret = $metaDataForm->updateMetaData($form_state['values']['form_id'], $form_state['values'], $soap_client);
$form_state['storage'] = NULL;
$form_state['redirect'] = $base_url . '/fedora/repository/' . $form_state['values']['pid'];
}
}
return $ret;
}
/**
* Gets an associative array describing the edit metadata method.
* Array has the following keys: 'file', 'class', 'method', 'handler', 'dsid'
@ -1349,7 +1344,8 @@ class ContentModel extends XMLDatastream {
self::$errors[] = 'Execute Ingest Rules: class \'' . $className . '\' does not exist.';
$ret = FALSE;
}
else $class = new $className;
else
$class = new $className;
if (!method_exists($class, $methodName)) {
self::$errors[] = 'Execute Ingest Rules: method \'' . $className . '->' . $methodName . '\' does not exist.';
$ret = FALSE;
@ -1366,7 +1362,6 @@ class ContentModel extends XMLDatastream {
}
}
}
}
return $ret;
}
@ -1532,7 +1527,6 @@ class ContentModel extends XMLDatastream {
$mimetypesEl->appendChild($newTypeEl);
$ret = TRUE;
}
}
return $ret;
}
@ -1558,11 +1552,15 @@ class ContentModel extends XMLDatastream {
$mimetypesEl->removeChild($found);
$ret = TRUE;
}
}
return $ret;
}
/**
* getDisplayMethods ??
* @param type $ds
* @return type
*/
public function getDisplayMethods($ds) {
$ret = FALSE;
if (($ds = $this->getDSModel($ds)) !== FALSE) {
@ -1579,6 +1577,12 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* addDs ??
* @param type $dsid
* @param type $display_in_fieldset
* @return boolean
*/
public function addDs($dsid, $display_in_fieldset = FALSE) {
$ret = FALSE;
@ -1603,6 +1607,11 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* removeDs ??
* @param type $dsid
* @return boolean
*/
public function removeDs($dsid) {
$ret = FALSE;
@ -1614,6 +1623,11 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* displayInFieldset ??
* @param type $dsid
* @return type
*/
public function displayInFieldset($dsid) {
$ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
@ -1622,6 +1636,12 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* setDisplayInFieldset ??
* @param type $dsid
* @param type $value
* @return boolean
*/
public function setDisplayInFieldset($dsid, $value = TRUE) {
$ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
@ -1637,6 +1657,15 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* setDefaultDispMeth ??
* @param type $dsid
* @param type $module
* @param type $file
* @param type $class
* @param type $method
* @return boolean
*/
public function setDefaultDispMeth($dsid, $module, $file, $class, $method) {
$ret = FALSE;
@ -1663,11 +1692,19 @@ class ContentModel extends XMLDatastream {
$found->setAttribute('default', 'true');
$ret = TRUE;
}
}
return $ret;
}
/**
* removeDispMeth ??
* @param type $dsid
* @param type $module
* @param type $file
* @param type $class
* @param type $method
* @return boolean
*/
public function removeDispMeth($dsid, $module, $file, $class, $method) {
$ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
@ -1686,11 +1723,20 @@ class ContentModel extends XMLDatastream {
$ds->removeChild($found);
$ret = TRUE;
}
}
return $ret;
}
/**
* addDispMeth ??
* @param type $dsid
* @param type $module
* @param type $file
* @param type $class
* @param type $method
* @param type $default
* @return boolean
*/
public function addDispMeth($dsid, $module, $file, $class, $method, $default = FALSE) {
$ret = FALSE;
if (self::validDsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
@ -1708,6 +1754,11 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* getAddDsMethod ??
* @param type $ds
* @return type
*/
public function getAddDsMethod($ds) {
$ret = FALSE;
if (($ds = $this->getDSModel($ds)) !== FALSE) {
@ -1725,6 +1776,11 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* getIngestRule ??
* @param type $rule_id
* @return type
*/
public function getIngestRule($rule_id) {
$ret = FALSE;
if ($this->validate()) {
@ -1735,6 +1791,12 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* removeAppliesTo ??
* @param type $rule_id
* @param type $type
* @return boolean
*/
public function removeAppliesTo($rule_id, $type) {
$ret = FALSE;
if (($rule = $this->getIngestRule($rule_id)) !== FALSE) {
@ -1754,6 +1816,12 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* addAppliesTo ??
* @param type $rule_id
* @param type $type
* @return boolean
*/
public function addAppliesTo($rule_id, $type) {
$ret = FALSE;
if (($rule = $this->getIngestRule($rule_id)) !== FALSE) {
@ -1772,6 +1840,17 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* addIngestMethods ??
* @param type $rule_id
* @param type $module
* @param type $file
* @param type $class
* @param type $method
* @param type $dsid
* @param type $modified_files_ext
* @return boolean
*/
public function addIngestMethod($rule_id, $module, $file, $class, $method, $dsid, $modified_files_ext) {
$ret = FALSE;
if (self::validDsid($dsid) && ($rule = $this->getIngestRule($rule_id)) !== FALSE) {
@ -1790,6 +1869,15 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* removeIngestMethod ??
* @param type $rule_id
* @param type $module
* @param type $file
* @param type $class
* @param type $method
* @return boolean
*/
public function removeIngestMethod($rule_id, $module, $file, $class, $method) {
$ret = FALSE;
if (($rule = $this->getIngestRule($rule_id)) !== FALSE) {
@ -1810,6 +1898,17 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* addIngestMethodParam ??
* @param type $rule_id
* @param type $module
* @param type $file
* @param type $class
* @param type $method
* @param type $name
* @param type $value
* @return boolean
*/
public function addIngestMethodParam($rule_id, $module, $file, $class, $method, $name, $value) {
$ret = FALSE;
if (($rule = $this->getIngestRule($rule_id)) !== FALSE) {
@ -1852,6 +1951,16 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* removeIngestMethodParam ??
* @param type $rule_id
* @param type $module
* @param type $file
* @param type $class
* @param type $method
* @param type $name
* @return boolean
*/
public function removeIngestMethodParam($rule_id, $module, $file, $class, $method, $name) {
$ret = FALSE;
if (($rule = $this->getIngestRule($rule_id)) !== FALSE) {
@ -1885,12 +1994,16 @@ class ContentModel extends XMLDatastream {
$ret = TRUE;
}
}
}
}
return $ret;
}
/**
* removeIngestRule ??
* @param type $rule_id
* @return type
*/
public function removeIngestRule($rule_id) {
$ret = FALSE;
if (($rule = $this->getIngestRule($rule_id)) !== FALSE) {
@ -1899,6 +2012,17 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* addIngestRule ??
* @param type $applies_to
* @param type $module
* @param type $file
* @param type $class
* @param type $method
* @param type $dsid
* @param type $modified_files_ext
* @return type
*/
public function addIngestRule($applies_to, $module, $file, $class, $method, $dsid, $modified_files_ext) {
$ret = FALSE;
if (self::validDsid($dsid) && $this->validate()) {
@ -1913,6 +2037,10 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* getIngestRules ??
* @return type
*/
public function getIngestRules() {
$ret = FALSE;
if ($this->validate()) {
@ -1945,7 +2073,6 @@ class ContentModel extends XMLDatastream {
}
$rule['ingest_methods'][] = $method;
}
$ret[] = $rule;
@ -1954,6 +2081,10 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* getIngestFormAttributes ??
* @return type
*/
public function getIngestFormAttributes() {
$ret = FALSE;
if ($this->validate()) {
@ -1962,11 +2093,18 @@ class ContentModel extends XMLDatastream {
'page' => $ingest_formEl->getAttribute('page'),
'hide_file_chooser' => strtolower($ingest_formEl->getAttribute('hide_file_chooser')) == 'true',
'redirect' => strtolower($ingest_formEl->getAttribute('redirect')) == 'false' ? FALSE : TRUE);
}
return $ret;
}
/**
* editIngestFormAttributes ??
* @param type $dsid
* @param type $page
* @param type $hide_file_chooser
* @param type $redirect
* @return boolean
*/
public function editIngestFormAttributes($dsid, $page, $hide_file_chooser = FALSE, $redirect = TRUE) {
$ret = FALSE;
if (self::validDsid($dsid) && $this->validate()) {
@ -1990,6 +2128,10 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* getIngestFormBuilderMethod
* @return type
*/
public function getIngestFormBuilderMethod() {
$ret = FALSE;
if ($this->validate()) {
@ -2003,6 +2145,15 @@ class ContentModel extends XMLDatastream {
return $ret;
}
/**
* editIngestFormBuilderMethod ??
* @param type $module
* @param type $file
* @param type $class
* @param type $method
* @param type $handler
* @return boolean
*/
public function editIngestFormBuilderMethod($module, $file, $class, $method, $handler) {
$ret = FALSE;
if ($this->validate()) {
@ -2131,7 +2282,6 @@ class ContentModel extends XMLDatastream {
return FALSE;
}
/**
* Edits a form element with attribute name='$name' from the 'forms' element.
*

20
MimeClass.inc

@ -1,4 +1,5 @@
<?php
// $Id$
/**
@ -20,8 +21,8 @@
* http://api.drupal.org/api/function/file_default_mimetype_mapping/7
*
*/
class MimeClass {
private $private_mime_types = array(
/**
* This is a shortlist of mimetypes which should catch most
@ -190,12 +191,14 @@ class MimeClass {
// others:
'bin' => 'application/octet-stream',
);
private $private_file_extensions;
private $system_types;
private $system_exts;
private $etc_mime_types = '/etc/mime.types';
/**
* Construtor
*/
public function __construct() {
// populate the reverse shortlist:
@ -205,13 +208,15 @@ class MimeClass {
if (is_readable('mime.types')) {
$this->etc_mime_types = 'mime.types';
}
}
/**
* function: getType
* description: An alias to get_mimetype,
* for backwards-compatibility with our old mimetype class.
*
* @param type $filename
* @return type
*/
public function getType($filename) {
return $this->get_mimetype($filename);
@ -220,6 +225,10 @@ class MimeClass {
/**
* function: get_mimetype
* description: returns a mimetype associated with the file extension of $filename
*
* @param type $filename
* @param type $debug
* @return type
*/
public function get_mimetype($filename, $debug = FALSE) {
@ -252,12 +261,15 @@ class MimeClass {
if (TRUE === $debug)
return array('mime_type' => 'application/octet-stream', 'method' => 'last_resort');
return 'application/octet-stream';
}
/**
* function: get_extension
* description: returns *one* valid file extension for a given $mime_type
*
* @param type $mime_type
* @param type $debug
* @return type
*/
public function get_extension($mime_type, $debug = FALSE) {

135
ObjectHelper.inc

@ -1,12 +1,13 @@
<?php
// $Id$
/**
* @file
* Object Helper Class
*/
/*
* Created on Feb 1, 2008
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
/**
* ObjectHelper Class ??
*/
class ObjectHelper {
@ -24,6 +25,9 @@ class ObjectHelper {
// TODO: Make this into a static member constant
public $availableDataStreamsText = 'Detailed list of content';
/**
* Constructor
*/
function ObjectHelper() {
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
@ -36,8 +40,16 @@ class ObjectHelper {
* Grabs a stream from fedora sets the mimetype and returns it. $dsID is the
* datastream id. If $forceSoap is set, the function will always buffer the datastream from fedora. Otherwise, it will
* try and use a redirect if possible.
* @param $pid String
* @param $dsID String
*
* @global type $user
* @param type $pid
* @param type $dsID
* @param type $asAttachment
* @param type $label
* @param type $filePath
* @param type $version
* @param type $forceSoap
* @return type
*/
function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = TRUE) {
global $user;
@ -85,7 +97,8 @@ class ObjectHelper {
if ($label == NULL) {
$label = $item->datastreams[$dsID]['label'];
}
} else {
}
else {
drupal_not_found();
exit();
}
@ -95,7 +108,8 @@ class ObjectHelper {
$fedoraUser = 'anonymous';
$fedoraPass = 'anonymous';
$contentSize = 0;
} else {
}
else {
$fedoraUser = $user->name;
$fedoraPass = $user->pass;
$dataStreamInfo = $item->get_datastream_info($dsID);
@ -135,7 +149,8 @@ class ObjectHelper {
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
fclose($fp);
} else {
}
else {
header("Content-type: $mimeType");
if ($contentSize > 0) {
@ -145,7 +160,8 @@ class ObjectHelper {
if ($asAttachment) {
$suggestedFileName = "$label";
$pos = strpos($suggestedFileName, '.');
/**
/*
* Here we used to take an object of, say, type application/pdf with label, say, "My Document"
* and we assemble the output filename extension based on the post-slash portion of the mimetype.
* (If the label has a period anywhere in it, we leave it alone.)
@ -168,17 +184,25 @@ class ObjectHelper {
if ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) {
curl_exec($ch);
} else {
}
else {
header('Location: ' . $url);
}
}
curl_close($ch);
} else {
}
else {
drupal_set_message(t('No curl support.'), 'error');
}
}
//Gets collection objects t
/**
* Gets collection objects t
*
* @param type $pid
* @param type $query
* @return type
*/
function getCollectionInfo($pid, $query = NULL) {
module_load_include('inc', 'fedora_repository', 'CollectionClass');
$collectionClass = new CollectionClass();
@ -188,6 +212,11 @@ class ObjectHelper {
/**
* returns the mime type
*
* @global type $user
* @param type $pid
* @param type $dsID
* @return type
*/
function getMimeType($pid, $dsID) {
global $user;
@ -217,6 +246,13 @@ class ObjectHelper {
return '';
}
/**
* getDatastreamInfo ??
* @global type $user
* @param type $pid
* @param type $dsID
* @return type
*/
function getDatastreamInfo($pid, $dsID) {
global $user;
if (empty($pid) || empty($dsID)) {
@ -267,7 +303,8 @@ class ObjectHelper {
$pid . '/' . $dataStreamValue->ID . '/' . $dataStreamValue->label . '"><img src="' . $base_url . '/' . $path .
'/images/purge.gif" alt="purge datastream" /></a>';
}
} else {
}
else {
$purgeImage = '&nbsp;';
}
$fullPath = base_path() . $path;
@ -311,6 +348,12 @@ class ObjectHelper {
return $content;
}
/**
* getFormattedDC ??
* @global type $base_url
* @param type $item
* @return type
*/
function getFormattedDC($item) {
global $base_url;
$path = drupal_get_path('module', 'fedora_repository');
@ -322,7 +365,6 @@ class ObjectHelper {
if (empty($xmlstr)) {
return '';
}
try {
@ -375,13 +417,11 @@ class ObjectHelper {
$output .= '<br /><a title = "' . t('Edit Meta Data') . '" href="' . $base_url . '/fedora/repository/' . 'editmetadata/' . $pid . '/' .
$dsid . '"><img src="' . $base_url . '/' . $path . '/images/edit.gif" alt="' . t('Edit Meta Data') . '" /></a>';
}
}
return $output;
}
/**
* Gets a list of datastreams from an object using its pid
*
@ -466,8 +506,6 @@ class ObjectHelper {
return '';
}
/**
* returns a stream from a fedora object given a pid and dsid
*
@ -499,11 +537,13 @@ class ObjectHelper {
return $content;
}
/*
/**
* gets the name of the content models for the specified object
* this now returns an array of pids as in Fedora 3 we can have more then one Cmodel for an object
* @param type $pid
* @param type $include_fedora_system_content_models
* @return array
*/
function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) {
module_load_include('inc', 'fedora_repository', 'CollectionClass');
$collectionHelper = new CollectionClass();
@ -542,11 +582,14 @@ class ObjectHelper {
return $cmodels;
}
/*
/**
* determines whether we can see the object or not
* checks PID namespace permissions, and user permissions
* @global type $user
* @param type $op
* @param type $pid
* @return type
*/
function fedora_repository_access($op, $pid) {
global $user;
@ -572,7 +615,8 @@ class ObjectHelper {
return FALSE;
}
return $user_access;
} else {
}
else {
return FALSE;
}
}
@ -633,10 +677,10 @@ class ObjectHelper {
'/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon"></a>' . t(' Add to this Collection');
}
}
} else {
}
else {
$ingestObject = '&nbsp;';
}
}
$datastreams .= $ingestObject;
@ -691,6 +735,12 @@ class ObjectHelper {
return $objects;
}
/**
* get_parent_objects_asHTML ??
* @global type $base_url
* @param type $pid
* @return string
*/
function get_parent_objects_asHTML($pid) {
global $base_url;
$parent_collections = $this->get_parent_objects($pid);
@ -722,6 +772,11 @@ class ObjectHelper {
/**
* gets a list of datastreams and related function that we should use to show datastreams in their own fieldsets
* from the content model associated with the object
*
* @param type $pid
* @param type $contentModel
* @param type $page_number
* @return type
*/
function createExtraFieldsets($pid, $contentModel, $page_number) {
//$models = $collectionHelper->getContentModels($collectionPid, FALSE);
@ -760,6 +815,9 @@ class ObjectHelper {
/**
* Get a tree of related pids - for the basket functionality
*
* @param type $pid
* @return type
*/
function get_all_related_pids($pid) {
if (!$pid) {
@ -789,6 +847,9 @@ class ObjectHelper {
/**
* Get children of PID - but only 2 levels deep
*
* @param type $pids
* @return type
*/
function get_child_pids($pids) {
// Get pid, title and description for children of object $pid
@ -834,6 +895,11 @@ class ObjectHelper {
/**
* Returns XML description of the object (export).
*
* @param type $pid
* @param type $context
* @param type $format
* @return type
*/
function getObject($pid, $context = 'archive', $format = FOXML_11) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -845,6 +911,11 @@ class ObjectHelper {
/**
* Builds an array of drupal links for use in breadcrumbs.
*
* @global type $base_url
* @param type $pid
* @param type $breadcrumbs
* @param type $level
*/
function getBreadcrumbs($pid, &$breadcrumbs, $level=10) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -853,7 +924,8 @@ class ObjectHelper {
if ($pid == variable_get('fedora_repository_pid', 'islandora:top')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url);
} else {
}
else {
$query_string = 'select $parentObject $title $content from <#ri>
where (<info:fedora/' . $pid . '> <dc:title> $title
and $parentObject <fedora-model:hasModel> $content
@ -878,13 +950,18 @@ class ObjectHelper {
if ($parent == variable_get('fedora_repository_pid', 'islandora:top')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url);
} elseif ($level > 0) {
}
elseif ($level > 0) {
$this->getBreadcrumbs($parent, $breadcrumbs, $level - 1);
}
}
}
}
/**
* warnIfMisconfigured ??
* @param type $app
*/
public static function warnIfMisconfigured($app) {
$messMap = array(
'Kakadu' => 'Full installation instructions for Kakadu can be found

112
SearchClass.inc

@ -1,8 +1,27 @@
<?php
// $Id$
/**
* @file
* SearchClass Class
*/
/**
* SearchClass ??
*/
class SearchClass {
public static $SEARCH_CLASS_ADVANCED_SEARCH_NUMBER_FIELDS = 5;
/**
* solr_search ??
* @param type $query
* @param type $startPage
* @param type $fq
* @param type $dismax
* @return type
*/
function solr_search($query, $startPage=1, $fq = NULL, $dismax = NULL) {
$solrFile = trim(variable_get('islandora_solr_search_block_handler_file', 'plugins/SolrResults.inc'));
if (strpos($solrField, '../')) { // Don't let us bust out of fedora_repository modules directory when looking for a handler
@ -19,6 +38,14 @@ class SearchClass {
}
return $implementation->$solrFunction($query, $startPage, $fq, $dismax);
}
/**
* build solr search form ??
* @param type $repeat
* @param type $pathToSearchTerms
* @param type $query
* @return type
*/
function build_solr_search_form($repeat = NULL, $pathToSearchTerms = NULL, $query = NULL) {
$types = $this->get_search_terms_array(NULL, 'solrSearchTerms.xml');
$queryArray = NULL;
@ -100,6 +127,10 @@ class SearchClass {
return $form;
}
/**
* build simple solr form ??
* @return string
*/
function build_simple_solr_form() {
//$form = array();
$form["search_query"] = array(
@ -114,6 +145,12 @@ class SearchClass {
);
return $form;
}
/**
* theme solr search form ??
* @param type $form
* @return type
*/
function theme_solr_search_form($form) {
if (!isset($repeat)) {
$repeat = variable_get('islandora_solr_search_block_repeat', t('3'));
@ -133,9 +170,17 @@ class SearchClass {
$output .= drupal_render($form['submit']);
$output .= drupal_render($form);
return $output;
}
/**
* quick search ??
* @param type $type
* @param type $query
* @param type $showForm
* @param type $orderBy
* @param type $userArray
* @return type
*/
function quickSearch($type, $query, $showForm = 1, $orderBy = 0, & $userArray) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -181,8 +226,13 @@ class SearchClass {
}
}
// gets term from a lucene index and displays them in a list
/**
* gets term from a lucene index and displays them in a list
* @param type $fieldName
* @param type $startTerm
* @param type $displayName
* @return type
*/
function getTerms($fieldName, $startTerm, $displayName = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -205,11 +255,16 @@ class SearchClass {
$output .= $this->applySpecifiedXSLT($resultData, $path . '/xsl/browseIndexToResultPage.xslt', $displayName);
//$output .= '<br />'.$alpha_out;
return $output;
}
/**
* custom search ??
* @param type $query
* @param type $startPage
* @param type $xslt
* @param type $numberOfHistPerPage
* @return type
*/
function custom_search($query, $startPage=1, $xslt= '/xsl/advanced_search_results.xsl', $numberOfHistPerPage = 50) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -242,7 +297,14 @@ class SearchClass {
}
}
/**
* apply specified xslt ??
* @global type $user
* @param type $resultData
* @param type $pathToXSLT
* @param type $displayName
* @return type
*/
function applySpecifiedXSLT($resultData, $pathToXSLT, $displayName = NULL) {
$proc = NULL;
global $user;
@ -252,8 +314,7 @@ class SearchClass {
}
try {
$proc = new XsltProcessor();
}
catch (Exception $e) {
} catch (Exception $e) {
drupal_set_message(t('Error loading ' . $pathToXSLT . ' xslt!') . $e->getMessage());
return ' ';
}
@ -291,8 +352,8 @@ class SearchClass {
return $newdom->saveXML();
}
}
//default function for lucene results
//default function for lucene results
/**
* apply an xslt to lucene gsearch search results
@ -354,7 +415,12 @@ class SearchClass {
}
}
//xslt for islandscholar these xslt functions can probably be pulled into one
/**
* xslt for islandscholar these xslt functions can probably be pulled into one
* @param type $resultData
* @param type $orderBy
* @return type
*/
function applyXSLT($resultData, $orderBy = 0) {
$path = drupal_get_path('module', 'Fedora_Repository');
$proc = NULL;
@ -398,6 +464,12 @@ class SearchClass {
}
}
/**
* theme advanced search form ??
* @param type $form
* @param type $repeat
* @return type
*/
function theme_advanced_search_form($form, $repeat=NULL) {
if (!isset($repeat)) {
$repeat = variable_get('fedora_repository_advanced_block_repeat', t('3'));
@ -419,7 +491,13 @@ class SearchClass {
return $output;
}
//build search form, custom blocks should set the number of repeats or it will use the default
/**
* build search form, custom blocks should set the number of repeats or it will use the default
* @param type $repeat
* @param type $pathToSearchTerms
* @param type $query
* @return string
*/
function build_advanced_search_form($repeat = NULL, $pathToSearchTerms = NULL, $query = NULL) {
$types = $this->get_search_terms_array($pathToSearchTerms);
$queryArray = NULL;
@ -501,7 +579,12 @@ class SearchClass {
return $form;
}
/**
* get search terms array
* @param type $path
* @param string $file
* @return type
*/
function get_search_terms_array($path = NULL, $file = NULL) {
if (!isset($path)) {
$path = drupal_get_path('module', 'Fedora_Repository');
@ -522,4 +605,5 @@ class SearchClass {
}
return $types;
}
}

48
SecurityClass.inc

@ -1,20 +1,33 @@
<?php
// $Id$
/*
* Created on 22-Oct-08
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
/**
* @file
* SecurityClass Class
*/
/**
* SecurityClass ??
*/
class SecurityClass {
public static $SECURITY_CLASS_SECURITY_STREAM = 'POLICY';
/**
* Constructor
*/
function SecurityClass() {
module_load_include('inc', 'SecurityClass', '');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
}
/**
* canIngestHere ??
* @global type $user
* @param type $collection_pid
* @return type
*/
function canIngestHere($collection_pid) {
global $user;
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -47,15 +60,18 @@ class SecurityClass {
return FALSE;
}
//parses our simple xacml policies checking for users or roles that are allowed to ingest
/**
* parses our simple xacml policies checking for users or roles that are allowed to ingest
* @param type $policyStream
* @return type
*/
function getAllowedUsersAndRoles($policyStream) {
$allowedRoles = array();
$allowedUsers = array();
$usersAndRoles = array();
try {
$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);
//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');
@ -92,17 +108,20 @@ class SecurityClass {
$usersAndRoles['users'] = $allowedUsers;
$usersAndRoles['roles'] = $allowedRoles;
return $usersAndRoles;
}
// When a user's profile is saved in drupal we will attempt to create a collection for them in Fedora
// this will be their personal space. In the IR it is editable by users with the same role in the VRE
// it probably would not be.
/**
* When a user's profile is saved in drupal we will attempt to create a collection for them in Fedora
* this will be their personal space. In the IR it is editable by users with the same role in the VRE
* it probably would not be.
* @param type $user
* @return DOMDocument
*/
function createPersonalPolicy($user) {
$doc = new DOMDocument();
try {
$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);
}
$conditions = $doc->getElementsByTagName('Condition');
@ -200,4 +219,5 @@ class SecurityClass {
// $this->collection_policy_stream = $dom->saveXML();
return $dom->saveXML();
}
}

17
XMLDatastream.inc

@ -2,6 +2,14 @@
// $Id$
/**
* @file
* XMLDatastream Abstract Class
*/
/**
* XMLDatastream class ??
*/
abstract class XMLDatastream {
static $XMLNS = 'http://www.islandora.ca';
@ -180,7 +188,8 @@ abstract class XMLDatastream {
// a subclass.
$vars = get_class_vars(get_class($this));
$schemaLocation = $vars['SCHEMA_URI'];
} elseif ($rootEl->attributes->getNamedItem('schemaLocation') !== NULL) {
}
elseif ($rootEl->attributes->getNamedItem('schemaLocation') !== NULL) {
//figure out where the schema is located and validate.
list(, $schemaLocation) = preg_split('/\s+/', $rootEl->attributes->getNamedItem('schemaLocation')->nodeValue);
}
@ -193,10 +202,12 @@ abstract class XMLDatastream {
foreach ($errors as $err) {
self::$errors[] = 'XML Error: Line ' . $err->line . ': ' . $err->message;
}
} else {
}
else {
$this->name = $rootEl->attributes->getNamedItem('name')->nodeValue;
}
} else {
}
else {
$ret = FALSE;
self::$errors[] = 'Unable to load schema.';
}

4
formClass.inc

@ -2,10 +2,6 @@
// $Id$
/*
* Created on Jan 22, 2008
*/
class formClass {
function formClass() {

9
plugins/Flv.inc

@ -38,6 +38,7 @@ class FormBuilder {
$datastream->appendChild($version);
$content = $dom->createElement("foxml:xmlContent");
$version->appendChild($content);
///begin writing qdc
$oai = $dom->createElement("oai_dc:dc");
$oai->setAttribute('xmlns:oai_dc', "http://www.openarchives.org/OAI/2.0/oai_dc/");
@ -45,10 +46,12 @@ class FormBuilder {
$oai->setAttribute('xmlns:dcterms', "http://purl.org/dc/terms/");
$oai->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
$content->appendChild($oai);
//dc elements
$previousElement = NULL; //used in case we have to nest elements for qualified dublin core
foreach ($form_values as $key => $value) {
$index = strrpos($key, '-');
if ($index > 01) {
$key = substr($key, 0, $index);
}
@ -89,10 +92,13 @@ class FormBuilder {
$rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
$rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-0.xsd");
$dom->appendChild($rootElement);
//create standard fedora stuff
$this->createStandardFedoraStuff($form_values, $dom, $rootElement);
//create relationships
$this->createRelationShips($form_values, $dom, $rootElement);
//create dublin core
$this->createQDCStream($form_values, $dom, $rootElement);
$this->createFedoraDataStreams($form_values, $dom, $rootElement);
@ -261,11 +267,13 @@ class FormBuilder {
'#type' => 'fieldset',
'#title' => t('Ingest Digital Object Step #2')
);
foreach ($ingest_form_definition->form_elements->element as $element) {
$name = strip_tags($element->name->asXML());
$title = strip_tags($element->label->asXML());
$required = strip_tags($element->required->asXML());
$required = strtolower($required);
if ($required != 'TRUE') {
$required = '0';
}
@ -273,6 +281,7 @@ class FormBuilder {
$description = strip_tags($element->description->asXML());
$type = strip_tags($element->type->asXML());
$options = array();
if ($element->type == 'select') {
foreach ($element->authoritative_list->item as $item) {
$field = strip_tags($item->field->asXML());

Loading…
Cancel
Save