|
|
@ -2,14 +2,20 @@ |
|
|
|
|
|
|
|
|
|
|
|
// $Id$ |
|
|
|
// $Id$ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @file |
|
|
|
|
|
|
|
* Collection Policy Class |
|
|
|
|
|
|
|
*/ |
|
|
|
module_load_include('inc', 'fedora_repository', 'XMLDatastream'); |
|
|
|
module_load_include('inc', 'fedora_repository', 'XMLDatastream'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Collection Policy class ?? |
|
|
|
|
|
|
|
*/ |
|
|
|
class CollectionPolicy extends XMLDatastream { |
|
|
|
class CollectionPolicy extends XMLDatastream { |
|
|
|
|
|
|
|
|
|
|
|
static $SCHEMA_URI = 'http://syn.lib.umanitoba.ca/collection_policy.xsd'; |
|
|
|
static $SCHEMA_URI = 'http://syn.lib.umanitoba.ca/collection_policy.xsd'; |
|
|
|
static $DEFAULT_DSID = 'COLLECTION_POLICY'; |
|
|
|
static $DEFAULT_DSID = 'COLLECTION_POLICY'; |
|
|
|
|
|
|
|
private $staging_area = NULL; |
|
|
|
private $staging_area=NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets the default DSID to use for ContentModel datastreams. |
|
|
|
* Gets the default DSID to use for ContentModel datastreams. |
|
|
@ -36,22 +42,21 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
if (self::validPid($pid)) { |
|
|
|
if (self::validPid($pid)) { |
|
|
|
$dsid=CollectionPolicy::getDefaultDSID(); |
|
|
|
$dsid = CollectionPolicy::getDefaultDSID(); |
|
|
|
|
|
|
|
|
|
|
|
if ($preFetch) { |
|
|
|
if ($preFetch) { |
|
|
|
$fedoraItem = new Fedora_Item($pid); |
|
|
|
$fedoraItem = new Fedora_Item($pid); |
|
|
|
$ds = $fedoraItem->get_datastream_dissemination($dsid); |
|
|
|
$ds = $fedoraItem->get_datastream_dissemination($dsid); |
|
|
|
} else { |
|
|
|
|
|
|
|
$ds=null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
$ds = null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($ds) || !$preFetch) { |
|
|
|
if (!empty($ds) || !$preFetch) { |
|
|
|
$ret=new CollectionPolicy($ds, $pid, $dsid); |
|
|
|
$ret = new CollectionPolicy($ds, $pid, $dsid); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (SOAPException $e) { |
|
|
|
catch (SOAPException $e) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ret = FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
} |
|
|
|
} |
|
|
@ -133,7 +138,7 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function ingestBlankPolicy($pid, $name, $policyDsid, $model_pid, $model_namespace, $relationship, $searchField, $searchValue) { |
|
|
|
public static function ingestBlankPolicy($pid, $name, $policyDsid, $model_pid, $model_namespace, $relationship, $searchField, $searchValue) { |
|
|
|
$ret = FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if (($cp = self::loadFromCollection($pid )) === FALSE) { //removed second, non-existant variable |
|
|
|
if (($cp = self::loadFromCollection($pid)) === FALSE) { //removed second, non-existant variable |
|
|
|
module_load_include('inc', 'fedora_repository', 'ContentModel'); |
|
|
|
module_load_include('inc', 'fedora_repository', 'ContentModel'); |
|
|
|
if (($cm = ContentModel::loadFromModel($model_pid)) !== FALSE && $cm->validate()) { |
|
|
|
if (($cm = ContentModel::loadFromModel($model_pid)) !== FALSE && $cm->validate()) { |
|
|
|
$newDom = new DOMDocument('1.0', 'utf-8'); |
|
|
|
$newDom = new DOMDocument('1.0', 'utf-8'); |
|
|
@ -142,7 +147,7 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
$rootEl->setAttribute('name', $name); |
|
|
|
$rootEl->setAttribute('name', $name); |
|
|
|
$rootEl->setAttribute('xmlns', self::$XMLNS); |
|
|
|
$rootEl->setAttribute('xmlns', self::$XMLNS); |
|
|
|
$rootEl->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); |
|
|
|
$rootEl->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); |
|
|
|
$rootEl->setAttribute('xsi:schemaLocation', self::$XMLNS .' '. self::$SCHEMA_URI); |
|
|
|
$rootEl->setAttribute('xsi:schemaLocation', self::$XMLNS . ' ' . self::$SCHEMA_URI); |
|
|
|
|
|
|
|
|
|
|
|
$modelsEl = $newDom->createElement('content_models'); |
|
|
|
$modelsEl = $newDom->createElement('content_models'); |
|
|
|
|
|
|
|
|
|
|
@ -175,13 +180,11 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
$fedoraItem->add_datastream_from_string($cp->dumpXml(), $policyDsid, $name, 'text/xml', 'X'); |
|
|
|
$fedoraItem->add_datastream_from_string($cp->dumpXml(), $policyDsid, $name, 'text/xml', 'X'); |
|
|
|
$ret = $cp; |
|
|
|
$ret = $cp; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructor |
|
|
|
* Constructor |
|
|
|
* NOTE: Use the static constructor methods whenever possible. |
|
|
|
* NOTE: Use the static constructor methods whenever possible. |
|
|
@ -192,8 +195,8 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
* @return XMLDatastream $cm |
|
|
|
* @return XMLDatastream $cm |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function __construct($xmlStr, $pid = NULL, $dsid = NULL) { |
|
|
|
public function __construct($xmlStr, $pid = NULL, $dsid = NULL) { |
|
|
|
parent::__construct($xmlStr,$pid,$dsid); |
|
|
|
parent::__construct($xmlStr, $pid, $dsid); |
|
|
|
$this->name= 'Collection Policy'; |
|
|
|
$this->name = 'Collection Policy'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -215,7 +218,7 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
$rootEl->setAttribute('name', $sXml['name']); |
|
|
|
$rootEl->setAttribute('name', $sXml['name']); |
|
|
|
$rootEl->setAttribute('xmlns', self::$XMLNS); |
|
|
|
$rootEl->setAttribute('xmlns', self::$XMLNS); |
|
|
|
$rootEl->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); |
|
|
|
$rootEl->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); |
|
|
|
$rootEl->setAttribute('xsi:schemaLocation', self::$XMLNS .' '. self::$SCHEMA_URI); |
|
|
|
$rootEl->setAttribute('xsi:schemaLocation', self::$XMLNS . ' ' . self::$SCHEMA_URI); |
|
|
|
|
|
|
|
|
|
|
|
$content_modelsEl = $newDom->createElement('content_models'); |
|
|
|
$content_modelsEl = $newDom->createElement('content_models'); |
|
|
|
foreach ($sXml->contentmodels->contentmodel as $contentmodel) { |
|
|
|
foreach ($sXml->contentmodels->contentmodel as $contentmodel) { |
|
|
@ -247,7 +250,6 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
$this->xml = DOMDocument::loadXML($newDom->saveXml()); |
|
|
|
$this->xml = DOMDocument::loadXML($newDom->saveXml()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets the name of the relationship to use |
|
|
|
* Gets the name of the relationship to use |
|
|
|
* for members of this collection. |
|
|
|
* for members of this collection. |
|
|
@ -256,9 +258,9 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
* @return string $relationship |
|
|
|
* @return string $relationship |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getRelationship() { |
|
|
|
public function getRelationship() { |
|
|
|
$ret=FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
$ret=trim($this->xml->getElementsByTagName('relationship')->item(0)->nodeValue); |
|
|
|
$ret = trim($this->xml->getElementsByTagName('relationship')->item(0)->nodeValue); |
|
|
|
} |
|
|
|
} |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
@ -272,10 +274,10 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
* @return boolean $ret |
|
|
|
* @return boolean $ret |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function setRelationship($relationship) { |
|
|
|
public function setRelationship($relationship) { |
|
|
|
$ret=FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
$relationshipEl=$this->xml->getElementsByTagName('relationship')->item(0); |
|
|
|
$relationshipEl = $this->xml->getElementsByTagName('relationship')->item(0); |
|
|
|
$relationshipEl->nodeValue=trim($relationship); |
|
|
|
$relationshipEl->nodeValue = trim($relationship); |
|
|
|
$ret = TRUE; |
|
|
|
$ret = TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
@ -290,17 +292,18 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
* @return string $path |
|
|
|
* @return string $path |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getStagingArea($recurse=TRUE) { |
|
|
|
public function getStagingArea($recurse=TRUE) { |
|
|
|
$ret=FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->staging_area === NULL) { |
|
|
|
if ($this->staging_area === NULL) { |
|
|
|
$stagingEl=$this->xml->getElementsByTagName('staging_area'); |
|
|
|
$stagingEl = $this->xml->getElementsByTagName('staging_area'); |
|
|
|
|
|
|
|
|
|
|
|
if ($stagingEl->length > 0) { |
|
|
|
if ($stagingEl->length > 0) { |
|
|
|
$this->staging_area = trim($stagingEl->item(0)->nodeValue); |
|
|
|
$this->staging_area = trim($stagingEl->item(0)->nodeValue); |
|
|
|
} elseif ($recurse) { |
|
|
|
} |
|
|
|
|
|
|
|
elseif ($recurse) { |
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
$item=new Fedora_Item($this->pid); |
|
|
|
$item = new Fedora_Item($this->pid); |
|
|
|
$rels=$item->get_relationships(); |
|
|
|
$rels = $item->get_relationships(); |
|
|
|
if (count($rels) > 0) { |
|
|
|
if (count($rels) > 0) { |
|
|
|
foreach ($rels as $rel) { |
|
|
|
foreach ($rels as $rel) { |
|
|
|
$cp = CollectionPolicy::loadFromCollection($rel['object']); |
|
|
|
$cp = CollectionPolicy::loadFromCollection($rel['object']); |
|
|
@ -314,7 +317,6 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$ret = $this->staging_area; |
|
|
|
$ret = $this->staging_area; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
@ -329,21 +331,21 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
* @return string $relationship |
|
|
|
* @return string $relationship |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function setStagingArea($path) { |
|
|
|
public function setStagingArea($path) { |
|
|
|
$ret=FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
$rootEl=$this->xml->getElementsByTagName('collection_policy')->item(0); |
|
|
|
$rootEl = $this->xml->getElementsByTagName('collection_policy')->item(0); |
|
|
|
$stagingEl=$this->xml->getElementsByTagName('staging_area'); |
|
|
|
$stagingEl = $this->xml->getElementsByTagName('staging_area'); |
|
|
|
if ($stagingEl->length > 0) { |
|
|
|
if ($stagingEl->length > 0) { |
|
|
|
$stagingEl=$stagingEl->item(0); |
|
|
|
$stagingEl = $stagingEl->item(0); |
|
|
|
if (trim($path) == '') { |
|
|
|
if (trim($path) == '') { |
|
|
|
$rootEl->removeChild($stagingEl); |
|
|
|
$rootEl->removeChild($stagingEl); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
$stagingEl->nodeValue=trim($path); |
|
|
|
$stagingEl->nodeValue = trim($path); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
elseif (trim($path) != '') { |
|
|
|
elseif (trim($path) != '') { |
|
|
|
$stagingEl=$this->xml->createElement('staging_area', trim($path)); |
|
|
|
$stagingEl = $this->xml->createElement('staging_area', trim($path)); |
|
|
|
$rootEl->appendChild($stagingEl); |
|
|
|
$rootEl->appendChild($stagingEl); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -352,7 +354,6 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets the next available PID for the |
|
|
|
* Gets the next available PID for the |
|
|
|
* content model specified by the DSID |
|
|
|
* content model specified by the DSID |
|
|
@ -366,7 +367,7 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
if (self::validDsid($dsid) && $this->validate()) { |
|
|
|
if (self::validDsid($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++) { |
|
|
|
if (strtolower($content_models->item($i)->getAttribute('dsid')) == strtolower($dsid)) { |
|
|
|
if (strtolower($content_models->item($i)->getAttribute('dsid')) == strtolower($dsid)) { |
|
|
|
$namespace = $content_models->item($i)->getAttribute('namespace'); |
|
|
|
$namespace = $content_models->item($i)->getAttribute('namespace'); |
|
|
|
} |
|
|
|
} |
|
|
@ -386,27 +387,21 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
* @return ContentModel[] $models |
|
|
|
* @return ContentModel[] $models |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function getContentModels() { |
|
|
|
function getContentModels() { |
|
|
|
$ret=FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
module_load_include('inc', 'Fedora_Repository', 'ContentModel'); |
|
|
|
module_load_include('inc', 'Fedora_Repository', 'ContentModel'); |
|
|
|
$ret=array(); |
|
|
|
$ret = array(); |
|
|
|
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); |
|
|
|
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); |
|
|
|
for ($i=0;$i<$content_models->length;$i++) { |
|
|
|
for ($i = 0; $i < $content_models->length; $i++) { |
|
|
|
$cm=ContentModel::loadFromModel($content_models->item($i)->getAttribute('pid'), |
|
|
|
$cm = ContentModel::loadFromModel($content_models->item($i)->getAttribute('pid'), $content_models->item($i)->getAttribute('dsid'), $content_models->item($i)->getAttribute('namespace'), $content_models->item($i)->getAttribute('name')); |
|
|
|
$content_models->item($i)->getAttribute('dsid'), |
|
|
|
|
|
|
|
$content_models->item($i)->getAttribute('namespace'), |
|
|
|
|
|
|
|
$content_models->item($i)->getAttribute('name')); |
|
|
|
|
|
|
|
if ($cm !== FALSE) { |
|
|
|
if ($cm !== FALSE) { |
|
|
|
$ret[]=$cm; |
|
|
|
$ret[] = $cm; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets a list of search terms from the Collection Policy. If asArray is set |
|
|
|
* 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. |
|
|
|
* it will return an associative array with the value, field name, and the default value. |
|
|
@ -422,9 +417,10 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
function getSearchTerms($asArray = FALSE, $recurse = FALSE, $cache = FALSE) { |
|
|
|
function getSearchTerms($asArray = FALSE, $recurse = FALSE, $cache = FALSE) { |
|
|
|
$ret = FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
|
|
|
|
|
|
|
|
if ($cache == TRUE && ($cache = cache_get('collection_policy_search_terms-'.$this->pid)) !== 0 ) { |
|
|
|
if ($cache == TRUE && ($cache = cache_get('collection_policy_search_terms-' . $this->pid)) !== 0) { |
|
|
|
$ret=$cache->data; |
|
|
|
$ret = $cache->data; |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
|
|
|
|
if ($this->xml == NULL) { |
|
|
|
if ($this->xml == NULL) { |
|
|
|
$fedoraItem = new Fedora_Item($this->pid); |
|
|
|
$fedoraItem = new Fedora_Item($this->pid); |
|
|
@ -434,21 +430,21 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
$ret=array(); |
|
|
|
$ret = array(); |
|
|
|
$terms= $this->xml->getElementsByTagName('search_terms')->item(0)->getElementsByTagName('term'); |
|
|
|
$terms = $this->xml->getElementsByTagName('search_terms')->item(0)->getElementsByTagName('term'); |
|
|
|
for ($i=0;$i<$terms->length;$i++) { |
|
|
|
for ($i = 0; $i < $terms->length; $i++) { |
|
|
|
$default = $terms->item($i)->attributes->getNamedItem('default'); |
|
|
|
$default = $terms->item($i)->attributes->getNamedItem('default'); |
|
|
|
$default = ($default !== NULL) ? (strtolower($default->nodeValue) == 'true') : FALSE; |
|
|
|
$default = ($default !== NULL) ? (strtolower($default->nodeValue) == 'true') : FALSE; |
|
|
|
$ret[] = ($asArray)?array( 'value' => $terms->item($i)->nodeValue, |
|
|
|
$ret[] = ($asArray) ? array('value' => $terms->item($i)->nodeValue, |
|
|
|
'field' => $terms->item($i)->getAttribute('field'), |
|
|
|
'field' => $terms->item($i)->getAttribute('field'), |
|
|
|
'default' => $default): $terms->item($i)->nodeValue; |
|
|
|
'default' => $default) : $terms->item($i)->nodeValue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($recurse && count($ret) == 0) { |
|
|
|
if ($recurse && count($ret) == 0) { |
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
$item=new Fedora_Item($this->pid); |
|
|
|
$item = new Fedora_Item($this->pid); |
|
|
|
$rels=$item->get_relationships(); |
|
|
|
$rels = $item->get_relationships(); |
|
|
|
if (count($rels) > 0) { |
|
|
|
if (count($rels) > 0) { |
|
|
|
foreach ($rels as $rel) { |
|
|
|
foreach ($rels as $rel) { |
|
|
|
$cp = CollectionPolicy::loadFromCollection($rel['object']); |
|
|
|
$cp = CollectionPolicy::loadFromCollection($rel['object']); |
|
|
@ -459,14 +455,12 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cache_set('collection_policy_search_terms-'.$this->pid, $ret, 'cache', time()+3600); |
|
|
|
cache_set('collection_policy_search_terms-' . $this->pid, $ret, 'cache', time() + 3600); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Adds a search term to the collection policy. |
|
|
|
* Adds a search term to the collection policy. |
|
|
|
* Returns fase on failure. |
|
|
|
* Returns fase on failure. |
|
|
@ -476,12 +470,12 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
* @return boolean $success |
|
|
|
* @return boolean $success |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function addTerm($field, $value) { |
|
|
|
function addTerm($field, $value) { |
|
|
|
$ret=FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
$search_termsEl = $this->xml->getElementsByTagName('search_terms')->item(0); |
|
|
|
$search_termsEl = $this->xml->getElementsByTagName('search_terms')->item(0); |
|
|
|
$terms= $search_termsEl->getElementsByTagName('term'); |
|
|
|
$terms = $search_termsEl->getElementsByTagName('term'); |
|
|
|
$found=FALSE; |
|
|
|
$found = FALSE; |
|
|
|
for ($i=0;!$found && $i<$terms->length;$i++) { |
|
|
|
for ($i = 0; !$found && $i < $terms->length; $i++) { |
|
|
|
if ($terms->item($i)->getAttribute('field') == $field) { |
|
|
|
if ($terms->item($i)->getAttribute('field') == $field) { |
|
|
|
$found = TRUE; |
|
|
|
$found = TRUE; |
|
|
|
} |
|
|
|
} |
|
|
@ -504,12 +498,12 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
* @return boolean $success |
|
|
|
* @return boolean $success |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function removeTerm($field) { |
|
|
|
function removeTerm($field) { |
|
|
|
$ret=FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
$search_termsEl = $this->xml->getElementsByTagName('search_terms')->item(0); |
|
|
|
$search_termsEl = $this->xml->getElementsByTagName('search_terms')->item(0); |
|
|
|
$terms = $search_termsEl->getElementsByTagName('term'); |
|
|
|
$terms = $search_termsEl->getElementsByTagName('term'); |
|
|
|
$found = FALSE; |
|
|
|
$found = FALSE; |
|
|
|
for ($i=0; !$found && $i < $terms->length; $i++) { |
|
|
|
for ($i = 0; !$found && $i < $terms->length; $i++) { |
|
|
|
if ($terms->item($i)->getAttribute('field') == $field) { |
|
|
|
if ($terms->item($i)->getAttribute('field') == $field) { |
|
|
|
$found = $terms->item($i); |
|
|
|
$found = $terms->item($i); |
|
|
|
} |
|
|
|
} |
|
|
@ -523,21 +517,25 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* setDefaultTerm ?? |
|
|
|
|
|
|
|
* @param type $field |
|
|
|
|
|
|
|
* @return boolean |
|
|
|
|
|
|
|
*/ |
|
|
|
function setDefaultTerm($field) { |
|
|
|
function setDefaultTerm($field) { |
|
|
|
$ret = FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
$search_termsEl = $this->xml->getElementsByTagName('search_terms')->item(0); |
|
|
|
$search_termsEl = $this->xml->getElementsByTagName('search_terms')->item(0); |
|
|
|
$terms= $search_termsEl->getElementsByTagName('term'); |
|
|
|
$terms = $search_termsEl->getElementsByTagName('term'); |
|
|
|
$found=FALSE; |
|
|
|
$found = FALSE; |
|
|
|
for ($i=0;!$found && $i<$terms->length;$i++) { |
|
|
|
for ($i = 0; !$found && $i < $terms->length; $i++) { |
|
|
|
if ($terms->item($i)->getAttribute('field') == $field) { |
|
|
|
if ($terms->item($i)->getAttribute('field') == $field) { |
|
|
|
$found = $terms->item($i); |
|
|
|
$found = $terms->item($i); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($found !== FALSE) { |
|
|
|
if ($found !== FALSE) { |
|
|
|
for ($i=0;$i<$terms->length;$i++) |
|
|
|
for ($i = 0; $i < $terms->length; $i++) |
|
|
|
if ($terms->item($i)->attributes->getNamedItem('default') !== NULL) { |
|
|
|
if ($terms->item($i)->attributes->getNamedItem('default') !== NULL) { |
|
|
|
$terms->item($i)->removeAttribute('default'); |
|
|
|
$terms->item($i)->removeAttribute('default'); |
|
|
|
} |
|
|
|
} |
|
|
@ -548,7 +546,6 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Removes the specified content model from the collection policy. This will only |
|
|
|
* 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 |
|
|
|
* prevent future ingests of the removed model to the collection. $cm should be |
|
|
@ -559,14 +556,14 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
* @return boolean $valid |
|
|
|
* @return boolean $valid |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function removeModel($cm) { |
|
|
|
function removeModel($cm) { |
|
|
|
$ret=FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate() && $cm->validate()) { |
|
|
|
if ($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; |
|
|
|
for ($i=0; $found === FALSE && $i < $models->length; $i++) { |
|
|
|
for ($i = 0; $found === FALSE && $i < $models->length; $i++) { |
|
|
|
if ($models->item($i)->getAttribute('pid') == $cm->pid) { |
|
|
|
if ($models->item($i)->getAttribute('pid') == $cm->pid) { |
|
|
|
$found=$models->item($i); |
|
|
|
$found = $models->item($i); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -578,16 +575,19 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* addModel ?? |
|
|
|
|
|
|
|
* @param type $cm |
|
|
|
|
|
|
|
* @param type $namespace |
|
|
|
|
|
|
|
* @return type |
|
|
|
|
|
|
|
*/ |
|
|
|
function addModel($cm, $namespace) { |
|
|
|
function addModel($cm, $namespace) { |
|
|
|
$ret = FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if (self::validPid($namespace) && $this->validate() && $cm->validate()) { |
|
|
|
if (self::validPid($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; |
|
|
|
for ($i=0;!$found && $i<$models->length;$i++) { |
|
|
|
for ($i = 0; !$found && $i < $models->length; $i++) { |
|
|
|
if ($models->item($i)->getAttribute('pid') == $cm->pid) |
|
|
|
if ($models->item($i)->getAttribute('pid') == $cm->pid) |
|
|
|
$found = TRUE; |
|
|
|
$found = TRUE; |
|
|
|
} |
|
|
|
} |
|
|
@ -606,10 +606,14 @@ class CollectionPolicy extends XMLDatastream { |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* getName ?? |
|
|
|
|
|
|
|
* @return type |
|
|
|
|
|
|
|
*/ |
|
|
|
function getName() { |
|
|
|
function getName() { |
|
|
|
$ret=FALSE; |
|
|
|
$ret = FALSE; |
|
|
|
if ($this->validate()) { |
|
|
|
if ($this->validate()) { |
|
|
|
$ret=$this->xml->getElementsByTagName('collection_policy')->item(0)->getAttribute('name'); |
|
|
|
$ret = $this->xml->getElementsByTagName('collection_policy')->item(0)->getAttribute('name'); |
|
|
|
} |
|
|
|
} |
|
|
|
return $ret; |
|
|
|
return $ret; |
|
|
|
} |
|
|
|
} |
|
|
|