Browse Source

ISLANDORA-581 On content model trigered tabs we use module_exists to verify if a module is present and enabled before calling code. We also use module_load_include instead of including directly.

pull/139/head
William Panting 13 years ago
parent
commit
8c3da4569a
  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.'; self::$errors[] = 'Execute Form Handler: file \'' . $path . '\' does not exist.';
} }
else { else {
require_once($path);
$className = $method->getAttribute('class'); $file_extension = pathinfo($method->getAttribute('file'), PATHINFO_EXTENSION);
$methodName = ($method->getAttribute('method')); $file_path_without_extension = $method->getAttribute('file');
if (!class_exists($className)) { /* Only in PHP. This is meant to avoid file path
self::$errors[] = 'Execute Form Handler: class \'' . $className . '\' does not exist.'; * concatenation issues.*/
} $file_path_without_extension = substr($file_path_without_extension, 0, strlen($file_path_without_extension) - (strlen($file_extension) + 1));
else { /* Only try to execute if the module is present, this is
$class = new $className($pid); * necessarybecause we go outside of the expected
if (!method_exists($class, $methodName)) { * 'Drupal Way' and have dynamic dependencies.*/
self::$errors[] = 'Execute Form Handler: method \'' . $className . '->' . $methodName . '\' does not exist.'; 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 { 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