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/bureaucracyau/' . $scriptName; if (!file_exists($path)) { $shortPath = 'conf/plugin/bureaucracyau/' . $scriptName; throw new InvalidArgumentException("Script $shortPath doesn't exist!"); } require $path; $classFragment = substr($scriptName, 0, strpos($scriptName, '.')); $className = 'helper_plugin_bureaucracyau_handler_' . $classFragment; $deprecatedClassName = 'bureaucracyau_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\bureaucracyau\interfaces\bureaucracyau_handler_interface $handler */ $handler = new $className; if (!is_a($handler, dokuwiki\plugin\bureaucracyau\interfaces\bureaucracyau_handler_interface::class)) { throw new InvalidArgumentException('The handler must implement the interface dokuwiki\\plugin\\bureaucracyau\\interfaces\\bureaucracyau_handler_interface !'); } return $handler->handleData($fields, $thanks); } /** * @param $scriptName * * @return bool */ protected function validateScriptName($scriptName) { $valid = preg_match($this->scriptNamePattern, $scriptName); return $valid === 1; } }