import net.pterodactylus.sone.core.Options;
import net.pterodactylus.sone.web.page.Page.Request.Method;
import net.pterodactylus.util.number.Numbers;
-import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.Template;
+import net.pterodactylus.util.template.TemplateContext;
/**
* This page lets the user edit the options of the Sone plugin.
* {@inheritDoc}
*/
@Override
- protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
- super.processTemplate(request, dataProvider);
+ protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+ super.processTemplate(request, templateContext);
Options options = webInterface.getCore().getOptions();
if (request.getMethod() == Method.POST) {
Integer insertionDelay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("insertion-delay", 16));
options.getIntegerOption("InsertionDelay").set(insertionDelay);
+ Integer positiveTrust = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("positive-trust", 3), options.getIntegerOption("PositiveTrust").getReal());
+ options.getIntegerOption("PositiveTrust").set(positiveTrust);
+ Integer negativeTrust = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("negative-trust", 3), options.getIntegerOption("NegativeTrust").getReal());
+ options.getIntegerOption("NegativeTrust").set(negativeTrust);
+ String trustComment = request.getHttpRequest().getPartAsStringFailsafe("trust-comment", 256);
+ if (trustComment.trim().length() == 0) {
+ trustComment = null;
+ }
+ options.getStringOption("TrustComment").set(trustComment);
boolean soneRescueMode = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("sone-rescue-mode", 5));
options.getBooleanOption("SoneRescueMode").set(soneRescueMode);
boolean clearOnNextRestart = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("clear-on-next-restart", 5));
webInterface.getCore().saveConfiguration();
throw new RedirectException(getPath());
}
- dataProvider.set("insertion-delay", options.getIntegerOption("InsertionDelay").get());
- dataProvider.set("sone-rescue-mode", options.getBooleanOption("SoneRescueMode").get());
- dataProvider.set("clear-on-next-restart", options.getBooleanOption("ClearOnNextRestart").get());
- dataProvider.set("really-clear-on-next-restart", options.getBooleanOption("ReallyClearOnNextRestart").get());
+ templateContext.set("insertion-delay", options.getIntegerOption("InsertionDelay").get());
+ templateContext.set("positive-trust", options.getIntegerOption("PositiveTrust").get());
+ templateContext.set("negative-trust", options.getIntegerOption("NegativeTrust").get());
+ templateContext.set("trust-comment", options.getStringOption("TrustComment").get());
+ templateContext.set("sone-rescue-mode", options.getBooleanOption("SoneRescueMode").get());
+ templateContext.set("clear-on-next-restart", options.getBooleanOption("ClearOnNextRestart").get());
+ templateContext.set("really-clear-on-next-restart", options.getBooleanOption("ReallyClearOnNextRestart").get());
}
}