Browse Source

Merge pull request #139 from willtp87/ISLANDORA-581

ISLANDORA-581 On content model trigered tabs we use module_exists to ver...
pull/140/merge
Jonathan Green 13 years ago
parent
commit
7c9aefc8ec
  1. 33
      ContentModel.inc

33
ContentModel.inc

@ -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);
}
}
}
}

Loading…
Cancel
Save