@ -1,11 +1,11 @@
<?php
/**
* @file
*
* @file
*
*/
/**
* @file
* @file
* Content Model Class
*/
module_load_include('inc', 'fedora_repository', 'XMLDatastream');
@ -56,7 +56,7 @@ class ContentModel extends XMLDatastream {
}
/**
* Ingests a Content Model from a file to the specified pid/dsid .
* Ingests a Content Model from a file to the specified pid/dsid .
* Returns FALSE on failure.
*
* @param string $pid
@ -83,7 +83,7 @@ class ContentModel extends XMLDatastream {
}
/**
* Ingests a Content Model from an existing model to the specified pid/dsid .
* Ingests a Content Model from an existing model to the specified pid/dsid .
* Returns FALSE on failure.
*
* @param string $pid
@ -112,7 +112,7 @@ class ContentModel extends XMLDatastream {
}
/**
* Ingests a minimum Content Model to the specified pid/dsid.
* Ingests a minimum Content Model to the specified pid/dsid.
* Returns FALSE on failure.
*
* @param string $pid
@ -515,7 +515,7 @@ class ContentModel extends XMLDatastream {
* in the form builder if more complex forms or behaviour is required.
* Each element has the following keys: 'label', 'type', 'required', 'description', and if defined, 'authoritative_list' and/or 'parameters'
*
* @return string[] $elements
* @return string[] $elements
*/
public function getIngestFormElements() {
$ret = FALSE;
@ -575,14 +575,14 @@ class ContentModel extends XMLDatastream {
}
/**
* Decrements an ingest form element in the list of elements.
* Decrements an ingest form element in the list of elements.
* Updates the "order". This method is simply an overload to the incIngestFormElement
* which has a direction parameter.
*
* TODO: Might be useful to move multiple places at once, or define
* a method to move to an absolute position.
* TODO: Might be useful to move multiple places at once, or define
* a method to move to an absolute position.
*
* @param String $name
* @param String $name
* @return boolean $success
*/
public function decIngestFormElement($name) {
@ -590,14 +590,14 @@ class ContentModel extends XMLDatastream {
}
/**
* Increments (or decrements) ingest form element in the list of elements.
* Increments (or decrements) ingest form element in the list of elements.
* Updates the "order". The $reorder parameter accepts 'inc' or 'dec' to
* specify the direction to move (defaults to increment.)
*
* TODO: Might be useful to move multiple places at once, or define
* a method to move to an absolute position.
* TODO: Might be useful to move multiple places at once, or define
* a method to move to an absolute position.
*
* @param String $name
* @param String $name
* @param String $reorder
* @return boolean $success
*/
@ -658,7 +658,7 @@ class ContentModel extends XMLDatastream {
/**
* Sets a parameter of an ingest form element. If the value of the element is FALSE the parameter
* will be removed entirely (if you want to store FALSE as a value, then send the String "FALSE").
*
*
* @param String $elementName
* @param String $paramName
* @param String $paramValue
@ -729,7 +729,7 @@ class ContentModel extends XMLDatastream {
/**
* Gets a list of all parameters that belong to the specified ingest form element.
*
*
* @param String $elementName
* @return boolean success
*/
@ -762,7 +762,7 @@ class ContentModel extends XMLDatastream {
}
/**
* Edits the ingest form element specified.
* Edits the ingest form element specified.
* NOTE: The element name can not be changed. To update an elements name
* it must be deleted and added with the new name.
*
@ -854,12 +854,12 @@ class ContentModel extends XMLDatastream {
}
/**
* Decrements an authority list item from a form element in the list of elements.
* Decrements an authority list item from a form element in the list of elements.
* Updates the "order". This method is simply an overload to the incAuthListItem
* which has a direction parameter.
*
* @param String $elementName
* @param String $elementName
* @param String $value
* @return boolean $success
*/
@ -868,10 +868,10 @@ class ContentModel extends XMLDatastream {
}
/**
* Increments (or decrements) an authority list item from a form element in the list of elements.
* Updates the "order".
* Increments (or decrements) an authority list item from a form element in the list of elements.
* Updates the "order".
*
* @param String $elementName
* @param String $elementName
* @param String $value
* @param String $direction
* @return boolean $success
@ -921,7 +921,7 @@ class ContentModel extends XMLDatastream {
}
/**
* Removes an authority list item from a form element.
* Removes an authority list item from a form element.
* @param String $elementName
* @param String $value
* @return boolean $success
@ -966,7 +966,7 @@ class ContentModel extends XMLDatastream {
}
/**
* Adds an authority list item to a form element.
* Adds an authority list item to a form element.
* @param String $elementName
* @param String $value
* @param String $label (optional)
@ -1310,9 +1310,9 @@ class ContentModel extends XMLDatastream {
/**
* Executes the ingest rules that apply to the specified file/mimetype.
* Returns FALSE on failure.
*
* If $preview is TRUE, then only execute rules with
* Returns FALSE on failure.
*
* If $preview is TRUE, then only execute rules with
* a parameter 'preview'. Used to generate previews for the file chooser.
*
* @param string $file
@ -1475,19 +1475,30 @@ class ContentModel extends XMLDatastream {
self::$errors[] = 'Execute Form Handler: file \'' . $path . '\' does not exist.';
}
else {
require_once($path);
$className = $method->getAttribute('class');
$methodName = ($method->getAttribute('method'));
if (!class_exists($className)) {
self::$errors[] = 'Execute Form Handler: class \'' . $className . '\' does not exist.';
}
else {
$class = new $className($pid);
if (!method_exists($class, $methodName)) {
self::$errors[] = 'Execute Form Handler: method \'' . $className . '->' . $methodName . '\' does not exist.';
$file_extension = pathinfo($method->getAttribute('file'), PATHINFO_EXTENSION);
$file_path_without_extension = $method->getAttribute('file');
/* Only in PHP. This is meant to avoid file path
* concatenation issues.*/
$file_path_without_extension = substr($file_path_without_extension, 0, strlen($file_path_without_extension) - (strlen($file_extension) + 1));
/* Only try to execute if the module is present, this is
* necessarybecause we go outside of the expected
* 'Drupal Way' and have dynamic dependencies.*/
if (module_exists(!empty($module) ? $module : 'fedora_repository')) {
module_load_include($file_extension, !empty($module) ? $module : 'fedora_repository', $file_path_without_extension);
$className = $method->getAttribute('class');
$methodName = ($method->getAttribute('method'));
if (!class_exists($className)) {
self::$errors[] = 'Execute Form Handler: class \'' . $className . '\' does not exist.';
}
else {
$output = $class->$methodName($page_number);
$class = new $className($pid);
if (!method_exists($class, $methodName)) {
self::$errors[] = 'Execute Form Handler: method \'' . $className . '->' . $methodName . '\' does not exist.';
}
else {
$output = $class->$methodName($page_number);
}
}
}
}
@ -1527,8 +1538,8 @@ class ContentModel extends XMLDatastream {
}
/**
* Adds an allowed mimetype to the model.
*
* Adds an allowed mimetype to the model.
*
* @param String $type
* @return boolean $success
*/
@ -1581,7 +1592,7 @@ class ContentModel extends XMLDatastream {
/**
* getDisplayMethods ??
* @param type $ds
* @return type
* @return type
*/
public function getDisplayMethods($ds) {
$ret = FALSE;
@ -1603,7 +1614,7 @@ class ContentModel extends XMLDatastream {
* addDs ??
* @param type $dsid
* @param type $display_in_fieldset
* @return boolean
* @return boolean
*/
public function addDs($dsid, $display_in_fieldset = FALSE) {
$ret = FALSE;
@ -1632,7 +1643,7 @@ class ContentModel extends XMLDatastream {
/**
* removeDs ??
* @param type $dsid
* @return boolean
* @return boolean
*/
public function removeDs($dsid) {
$ret = FALSE;
@ -1648,7 +1659,7 @@ class ContentModel extends XMLDatastream {
/**
* displayInFieldset ??
* @param type $dsid
* @return type
* @return type
*/
public function displayInFieldset($dsid) {
$ret = FALSE;
@ -1662,7 +1673,7 @@ class ContentModel extends XMLDatastream {
* setDisplayInFieldset ??
* @param type $dsid
* @param type $value
* @return boolean
* @return boolean
*/
public function setDisplayInFieldset($dsid, $value = TRUE) {
$ret = FALSE;
@ -1686,7 +1697,7 @@ class ContentModel extends XMLDatastream {
* @param type $file
* @param type $class
* @param type $method
* @return boolean
* @return boolean
*/
public function setDefaultDispMeth($dsid, $module, $file, $class, $method) {
$ret = FALSE;
@ -1725,7 +1736,7 @@ class ContentModel extends XMLDatastream {
* @param type $file
* @param type $class
* @param type $method
* @return boolean
* @return boolean
*/
public function removeDispMeth($dsid, $module, $file, $class, $method) {
$ret = FALSE;
@ -1757,7 +1768,7 @@ class ContentModel extends XMLDatastream {
* @param type $class
* @param type $method
* @param type $default
* @return boolean
* @return boolean
*/
public function addDispMeth($dsid, $module, $file, $class, $method, $default = FALSE) {
$ret = FALSE;
@ -1779,7 +1790,7 @@ class ContentModel extends XMLDatastream {
/**
* getAddDsMethod ??
* @param type $ds
* @return type
* @return type
*/
public function getAddDsMethod($ds) {
$ret = FALSE;
@ -1801,7 +1812,7 @@ class ContentModel extends XMLDatastream {
/**
* getIngestRule ??
* @param type $rule_id
* @return type
* @return type
*/
public function getIngestRule($rule_id) {
$ret = FALSE;
@ -1817,7 +1828,7 @@ class ContentModel extends XMLDatastream {
* removeAppliesTo ??
* @param type $rule_id
* @param type $type
* @return boolean
* @return boolean
*/
public function removeAppliesTo($rule_id, $type) {
$ret = FALSE;
@ -1842,7 +1853,7 @@ class ContentModel extends XMLDatastream {
* addAppliesTo ??
* @param type $rule_id
* @param type $type
* @return boolean
* @return boolean
*/
public function addAppliesTo($rule_id, $type) {
$ret = FALSE;
@ -1871,7 +1882,7 @@ class ContentModel extends XMLDatastream {
* @param type $method
* @param type $dsid
* @param type $modified_files_ext
* @return boolean
* @return boolean
*/
public function addIngestMethod($rule_id, $module, $file, $class, $method, $dsid, $modified_files_ext) {
$ret = FALSE;
@ -1898,7 +1909,7 @@ class ContentModel extends XMLDatastream {
* @param type $file
* @param type $class
* @param type $method
* @return boolean
* @return boolean
*/
public function removeIngestMethod($rule_id, $module, $file, $class, $method) {
$ret = FALSE;
@ -1929,7 +1940,7 @@ class ContentModel extends XMLDatastream {
* @param type $method
* @param type $name
* @param type $value
* @return boolean
* @return boolean
*/
public function addIngestMethodParam($rule_id, $module, $file, $class, $method, $name, $value) {
$ret = FALSE;
@ -1981,7 +1992,7 @@ class ContentModel extends XMLDatastream {
* @param type $class
* @param type $method
* @param type $name
* @return boolean
* @return boolean
*/
public function removeIngestMethodParam($rule_id, $module, $file, $class, $method, $name) {
$ret = FALSE;
@ -2024,7 +2035,7 @@ class ContentModel extends XMLDatastream {
/**
* removeIngestRule ??
* @param type $rule_id
* @return type
* @return type
*/
public function removeIngestRule($rule_id) {
$ret = FALSE;
@ -2043,7 +2054,7 @@ class ContentModel extends XMLDatastream {
* @param type $method
* @param type $dsid
* @param type $modified_files_ext
* @return type
* @return type
*/
public function addIngestRule($applies_to, $module, $file, $class, $method, $dsid, $modified_files_ext) {
$ret = FALSE;
@ -2061,7 +2072,7 @@ class ContentModel extends XMLDatastream {
/**
* getIngestRules ??
* @return type
* @return type
*/
public function getIngestRules() {
$ret = FALSE;
@ -2105,7 +2116,7 @@ class ContentModel extends XMLDatastream {
/**
* getIngestFormAttributes ??
* @return type
* @return type
*/
public function getIngestFormAttributes() {
$ret = FALSE;
@ -2125,7 +2136,7 @@ class ContentModel extends XMLDatastream {
* @param type $page
* @param type $hide_file_chooser
* @param type $redirect
* @return boolean
* @return boolean
*/
public function editIngestFormAttributes($dsid, $page, $hide_file_chooser = FALSE, $redirect = TRUE) {
$ret = FALSE;
@ -2152,7 +2163,7 @@ class ContentModel extends XMLDatastream {
/**
* getIngestFormBuilderMethod
* @return type
* @return type
*/
public function getIngestFormBuilderMethod() {
$ret = FALSE;
@ -2174,7 +2185,7 @@ class ContentModel extends XMLDatastream {
* @param type $class
* @param type $method
* @param type $handler
* @return boolean
* @return boolean
*/
public function editIngestFormBuilderMethod($module, $file, $class, $method, $handler) {
$ret = FALSE;
@ -2192,7 +2203,7 @@ class ContentModel extends XMLDatastream {
/**
* Find the form element with name $name.
*
*
* @param string $name
* The name of the form element to find.
* @return DOMElement
@ -2263,7 +2274,7 @@ class ContentModel extends XMLDatastream {
*
* @param string $name
* Name of the form to remove.
*
*
* @return boolean
* TRUE on success, FALSE otherwise.
*/