Browse Source

Merge pull request #23 from bwoodhead/6.x

Added documentation tags back in
pull/24/merge
Ben Woodhead 13 years ago
parent
commit
e4848ed251
  1. 141
      CollectionClass.inc
  2. 4
      api/fedora_item.inc
  3. 23
      api/fedora_utils.inc

141
CollectionClass.inc

@ -1,16 +1,17 @@
<?php <?php
// $Id$ /**
* @file
*
* Collection Class Class
*/
/* /**
* Created on 18-Feb-08 * 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
* To change the template for this generated file go to * prevent mutiple hits to fedora. maybe a bit confusing though if this class is used in
* Window - Preferences - PHPeclipse - PHP - Code Templates * 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 { class CollectionClass {
public static $COLLECTION_CLASS_COLLECTION_POLICY_STREAM = 'COLLECTION_POLICY'; public static $COLLECTION_CLASS_COLLECTION_POLICY_STREAM = 'COLLECTION_POLICY';
@ -34,10 +35,15 @@ 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 * calls getRelatedItems but enforces limit and offset
* @param type $pid
* @param type $limit
* @param type $offset
* @param type $itqlquery
* @return type
*/ */
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) { function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
@ -51,6 +57,12 @@ class CollectionClass {
/** /**
* Gets objects related to this item. It will query the object for a Query stream and use that as a itql query * Gets objects related to this item. It will query the object for a Query stream and use that as a itql query
* or if there is no query stream it will use the default. If you pass a query to this method it will use the passed in query no matter what * or if there is no query stream it will use the default. If you pass a query to this method it will use the passed in query no matter what
* @global type $user
* @param type $pid
* @param type $itqlquery
* @param int $limit
* @param int $offset
* @return type
*/ */
function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) { function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -96,6 +108,11 @@ class CollectionClass {
return $content; return $content;
} }
/**
* get Collection Policy Stream ?
* @param type $collection_pid
* @return type
*/
function getCollectionPolicyStream($collection_pid) { function getCollectionPolicyStream($collection_pid) {
if ($this->collectionPolicyStream != NULL) { if ($this->collectionPolicyStream != NULL) {
return $this->collectionPolicyStream; return $this->collectionPolicyStream;
@ -104,6 +121,11 @@ class CollectionClass {
return $this->collectionPolicyStream; return $this->collectionPolicyStream;
} }
/**
* get Relationship element ?
* @param type $collection_pid
* @return type
*/
function getRelationshipElement($collection_pid) { function getRelationshipElement($collection_pid) {
$stream = $this->getCollectionPolicyStream($collection_pid); $stream = $this->getCollectionPolicyStream($collection_pid);
try { try {
@ -116,17 +138,35 @@ class CollectionClass {
return $relationship; return $relationship;
} }
/**
* get Collection View Stream ?
* @param type $collection_pid
* @return type
*/
function getCollectionViewStream($collection_pid) { function getCollectionViewStream($collection_pid) {
$this->collectionViewStream = $this->getStream($collection_pid, CollectionClass :: $COLLECTION_CLASS_COLLECTION_VIEW_STREAM, 0); $this->collectionViewStream = $this->getStream($collection_pid, CollectionClass :: $COLLECTION_CLASS_COLLECTION_VIEW_STREAM, 0);
return $this->collectionViewStream; return $this->collectionViewStream;
} }
/**
* get Stream ?
* @param type $pid
* @param type $dsid
* @param type $showError
* @return type
*/
function getStream($pid, $dsid, $showError = 1) { function getStream($pid, $dsid, $showError = 1) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new fedora_item($pid); $item = new fedora_item($pid);
return isset($item->datastreams[$dsid]) ? $item->get_datastream_dissemination($dsid) : NULL; return isset($item->datastreams[$dsid]) ? $item->get_datastream_dissemination($dsid) : NULL;
} }
/**
* get Pid name space ?
* @param type $pid
* @param type $dsid
* @return type
*/
function getPidNameSpace($pid, $dsid) { function getPidNameSpace($pid, $dsid) {
$stream = $this->getCollectionPolicyStream($pid); $stream = $this->getCollectionPolicyStream($pid);
try { try {
@ -148,6 +188,9 @@ class CollectionClass {
/** /**
* gets a list of content models from a collection policy * gets a list of content models from a collection policy
* @param type $collection_pid
* @param type $showError
* @return ContentModel
*/ */
function getContentModels($collection_pid, $showError = TRUE) { function getContentModels($collection_pid, $showError = TRUE) {
module_load_include('inc', 'Fedora_Repository', 'ContentModel'); module_load_include('inc', 'Fedora_Repository', 'ContentModel');
@ -218,6 +261,12 @@ class CollectionClass {
return NULL; return NULL;
} }
/**
* get Allowed Mime Types
* @param type $contentModelPid
* @param type $contentModel_dsid
* @return type
*/
function getAllowedMimeTypes($contentModelPid, $contentModel_dsid) { function getAllowedMimeTypes($contentModelPid, $contentModel_dsid) {
$stream = $this->getContentModelStream($contentModelPid, $contentModel_dsid); $stream = $this->getContentModelStream($contentModelPid, $contentModel_dsid);
try { try {
@ -235,6 +284,12 @@ class CollectionClass {
/** /**
* Grabs the rules from the content model stream * Grabs the rules from the content model stream
* file the file that has been uploaded * file the file that has been uploaded
*
* @param type $file
* @param type $mimetype
* @param type $pid
* @param type $dsid
* @return type
*/ */
function getAndDoRules($file, $mimetype, $pid, $dsid) { function getAndDoRules($file, $mimetype, $pid, $dsid) {
if (!user_access('ingest new fedora objects')) { if (!user_access('ingest new fedora objects')) {
@ -262,6 +317,10 @@ class CollectionClass {
/** /**
* calls the methods defined in the content model rules .xml file stored in a Fedora object * calls the methods defined in the content model rules .xml file stored in a Fedora object
*
* @param type $file
* @param type $methods
* @return type
*/ */
function callMethods($file, $methods) { function callMethods($file, $methods) {
foreach ($methods as $method) { foreach ($methods as $method) {
@ -294,6 +353,12 @@ class CollectionClass {
/** /**
* grabs a xml form definition from a content model and builds * grabs a xml form definition from a content model and builds
* the form using drupals forms api * the form using drupals forms api
*
* @param type $form
* @param type $form_state
* @param type $contentModelPid
* @param type $contentModelDsid
* @return type
*/ */
function build_ingest_form(&$form, &$form_state, $contentModelPid, $contentModelDsid) { function build_ingest_form(&$form, &$form_state, $contentModelPid, $contentModelDsid) {
$stream = $this->getContentModelStream($contentModelPid, $contentModelDsid); $stream = $this->getContentModelStream($contentModelPid, $contentModelDsid);
@ -357,8 +422,13 @@ class CollectionClass {
return $thisClass->$phpMethod($form, $ingest_form, $form_state['values'], $form_state); 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) { function createUserCollection(& $user) {
if (isset($user->fedora_personal_pid)) { if (isset($user->fedora_personal_pid)) {
return; return;
@ -403,6 +473,11 @@ class CollectionClass {
/** /**
* Queries a collection object for an xslt to format how the * Queries a collection object for an xslt to format how the
* collection of objects is displayed. * collection of objects is displayed.
*
* @param type $pid
* @param type $path
* @param type $canUseDefault
* @return type
*/ */
function getXslContent($pid, $path, $canUseDefault = TRUE) { function getXslContent($pid, $path, $canUseDefault = TRUE) {
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
@ -414,6 +489,13 @@ class CollectionClass {
return $xslContent; return $xslContent;
} }
/**
* show field sets ?
* @global type $base_url
* @global type $user
* @param type $page_number
* @return string
*/
function showFieldSets($page_number) { function showFieldSets($page_number) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
global $base_url; global $base_url;
@ -463,6 +545,11 @@ class CollectionClass {
return $tabset; return $tabset;
} }
/**
* get Ingest Interface ??
* @global type $base_url
* @return string
*/
function getIngestInterface() { function getIngestInterface() {
global $base_url; global $base_url;
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
@ -486,6 +573,16 @@ class CollectionClass {
return $ingestObject; return $ingestObject;
} }
/**
* render collection
* @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) { function renderCollection($content, $pid, $dsId, $collection, $pageNumber = NULL) {
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
global $base_url; global $base_url;
@ -554,6 +651,12 @@ class CollectionClass {
} }
/**
* collection creation form ?
* @param type $form_state
* @param type $parent_collection_pid
* @return type
*/
function collection_creation_form(&$form_state, $parent_collection_pid) { function collection_creation_form(&$form_state, $parent_collection_pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$restricted = FALSE; $restricted = FALSE;
@ -629,6 +732,12 @@ function collection_creation_form(&$form_state, $parent_collection_pid) {
return($form); return($form);
} }
/**
* collection creation form validate ?
* @param type $form
* @param type $form_state
* @return type
*/
function collection_creation_form_validate($form, &$form_state) { function collection_creation_form_validate($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$pid = $form_state['values']['collection_pid']; $pid = $form_state['values']['collection_pid'];
@ -639,6 +748,12 @@ function collection_creation_form_validate($form, &$form_state) {
} }
} }
/**
* collection creation form submit
* @global type $user
* @param type $form
* @param type $form_state
*/
function collection_creation_form_submit($form, &$form_state) { function collection_creation_form_submit($form, &$form_state) {
global $user; global $user;
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');

4
api/fedora_item.inc

@ -2,10 +2,6 @@
/** /**
* @file * @file
*
*/
/**
* @file
* Fedora Item * Fedora Item
*/ */
define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#'); define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#');

23
api/fedora_utils.inc

@ -6,11 +6,18 @@
* @file * @file
* Base utilities used by the Islandora fedora module. * Base utilities used by the Islandora fedora module.
*/ */
/*
* Functions that emulate php5.3 functionality for backwards compatiablity
*/
if (!function_exists('str_getcsv')) { if (!function_exists('str_getcsv')) {
/**
* Functions that emulate php5.3 functionality for backwards compatiablity
* @param type $input
* @param type $delimiter
* @param type $enclosure
* @param type $escape
* @param type $eol
* @return type
*/
function str_getcsv($input, $delimiter=',', $enclosure='"', $escape=NULL, $eol=NULL) { function str_getcsv($input, $delimiter=',', $enclosure='"', $escape=NULL, $eol=NULL) {
$temp = fopen("php://memory", "rw"); $temp = fopen("php://memory", "rw");
fwrite($temp, $input); fwrite($temp, $input);
@ -22,14 +29,6 @@ if (!function_exists('str_getcsv')) {
} }
/*
* Functions that emulate php5.3 functionality for backwards compatiablity
*/
/*
* Static functions used by the Fedora PHP API.
*/
/** /**
* do curl * do curl
* @global type $user * @global type $user
@ -230,4 +229,4 @@ function get_content_models_as_option_array() {
} }
return $options; return $options;
} }

Loading…
Cancel
Save