validateScriptName($scriptName)) {
$cleanedScriptName = hsc($scriptName);
throw new InvalidArgumentException("The supplied scriptname \"$cleanedScriptName
\" is invalid! It must conform to {hsc($this->scriptNamePattern)}
!");
}
$path = DOKU_CONF . 'plugin/bureaucracy/' . $scriptName;
if (!file_exists($path)) {
$shortPath = 'conf/plugin/bureaucracy/' . $scriptName;
throw new InvalidArgumentException("Script $shortPath
doesn't exist!");
}
require $path;
$classFragment = substr($scriptName, 0, strpos($scriptName, '.'));
$className = 'helper_plugin_bureaucracy_handler_' . $classFragment;
$deprecatedClassName = 'bureaucracy_handler_' . $classFragment;
if (!class_exists($className) && class_exists($deprecatedClassName)) {
msg("Please change this script's class-name to $className
.
Your current scheme $deprecatedClassName
is deprecated and will stop working in the future.", 2);
$className = $deprecatedClassName;
}
/** @var dokuwiki\plugin\bureaucracy\interfaces\bureaucracy_handler_interface $handler */
$handler = new $className;
if (!is_a($handler, dokuwiki\plugin\bureaucracy\interfaces\bureaucracy_handler_interface::class)) {
throw new InvalidArgumentException('The handler must implement the interface dokuwiki\\plugin\\bureaucracy\\interfaces\\bureaucracy_handler_interface
!');
}
return $handler->handleData($fields, $thanks);
}
/**
* @param $scriptName
*
* @return bool
*/
protected function validateScriptName($scriptName) {
$valid = preg_match($this->scriptNamePattern, $scriptName);
return $valid === 1;
}
}