@ -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::validP id($pid)) {
if (self::valid_p id($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::validP id($pid)) {
if (self::valid_p id($pid)) {
$fedoraItem = new Fedora_Item($pid);
$fedoraItem = new Fedora_Item($pid);
$dsid = ($dsid != NULL & & self::validD sid($dsid)) ? $dsid : ContentModel::getDefaultDSID();
$dsid = ($dsid != NULL & & self::valid_d sid($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::validD sid($dsid) & & $this->validate()) {
if (self::valid_d sid($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;
$refE l = FALSE;
$ref_e l = 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;
$refE l = $elements->item($i);
$ref_e l = $elements->item($i);
}
}
}
}
}
}
if ($found !== FALSE) {
if ($found !== FALSE) {
$elementsEl->removeChild($found);
$elementsEl->removeChild($found);
$elementsEl->insertBefore($found, $refE l);
$elementsEl->insertBefore($found, $ref_e l);
$ret = TRUE;
$ret = TRUE;
}
}
}
}
@ -867,23 +870,23 @@ class ContentModel extends XMLDatastream {
$items = $authListEl->getElementsByTagName('item');
$items = $authListEl->getElementsByTagName('item');
$found = FALSE;
$found = FALSE;
$refE l = FALSE;
$ref_e l = 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') {
$refE l = ($i > 0) ? $items->item($i - 1) : FALSE;
$ref_e l = ($i > 0) ? $items->item($i - 1) : FALSE;
$found = $items->item($i);
$found = $items->item($i);
}
}
else {
else {
$refE l = $items->item($i);
$ref_e l = $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 & & $refE l !== FALSE) {
if ($found !== FALSE & & $ref_e l !== FALSE) {
$authListEl->removeChild($found);
$authListEl->removeChild($found);
$authListEl->insertBefore($found, $refE l);
$authListEl->insertBefore($found, $ref_e l);
$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::validD sid($dsid) & & $this->validate()) {
if (self::valid_d sid($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::validD sid($dsid) & & $this->validate()) {
if (self::valid_d sid($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::validD sid($dsid) & & $this->validate() & & ($ds = $this->getDSModel($dsid)) !== FALSE) {
if (self::valid_d sid($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::validD sid($dsid) & & ($ds = $this->getDSModel($dsid)) === FALSE) {
if (self::valid_d sid($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::validD sid($dsid) & & ($ds = $this->getDSModel($dsid)) !== FALSE) {
if (self::valid_d sid($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::validD sid($dsid) & & ($ds = $this->getDSModel($dsid)) !== FALSE) {
if (self::valid_d sid($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::validD sid($dsid) & & ($ds = $this->getDSModel($dsid)) !== FALSE) {
if (self::valid_d sid($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::validD sid($dsid) & & ($ds = $this->getDSModel($dsid)) !== FALSE) {
if (self::valid_d sid($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::validD sid($dsid) & & ($ds = $this->getDSModel($dsid)) !== FALSE) {
if (self::valid_d sid($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::validD sid($dsid) & & ($ds = $this->getDSModel($dsid)) !== FALSE) {
if (self::valid_d sid($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::validD sid($dsid) & & ($rule = $this->getIngestRule($rule_id)) !== FALSE) {
if (self::valid_d sid($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::validD sid($dsid) & & $this->validate()) {
if (self::valid_d sid($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::validD sid($dsid) & & $this->validate()) {
if (self::valid_d sid($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);