🔀 Merge “release/v81” into “master”
[Sone.git] / src / main / java / net / pterodactylus / sone / template / SoneAccessor.java
index 4bb78af..4bc6a5f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - SoneAccessor.java - Copyright © 2010–2015 David Roden
+ * Sone - SoneAccessor.java - Copyright © 2010–2020 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,8 +32,7 @@ import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.data.Sone.SoneStatus;
 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
 import net.pterodactylus.sone.freenet.wot.Trust;
-import net.pterodactylus.sone.web.WebInterface;
-import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage;
+import net.pterodactylus.sone.text.TimeTextConverter;
 import net.pterodactylus.util.template.Accessor;
 import net.pterodactylus.util.template.ReflectionAccessor;
 import net.pterodactylus.util.template.TemplateContext;
@@ -52,8 +51,6 @@ import net.pterodactylus.util.template.TemplateContext;
  * <dd>Will return {@code true} if the sone in question is the currently logged
  * in Sone.</dd>
  * </dl>
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public class SoneAccessor extends ReflectionAccessor {
 
@@ -62,6 +59,7 @@ public class SoneAccessor extends ReflectionAccessor {
 
        /** The core. */
        private final Core core;
+       private final TimeTextConverter timeTextConverter;
 
        /**
         * Creates a new Sone accessor.
@@ -69,8 +67,9 @@ public class SoneAccessor extends ReflectionAccessor {
         * @param core
         *            The Sone core
         */
-       public SoneAccessor(Core core) {
+       public SoneAccessor(Core core, TimeTextConverter timeTextConverter) {
                this.core = core;
+               this.timeTextConverter = timeTextConverter;
        }
 
        /**
@@ -104,7 +103,7 @@ public class SoneAccessor extends ReflectionAccessor {
                } else if (member.equals("locked")) {
                        return core.isLocked(sone);
                } else if (member.equals("lastUpdatedText")) {
-                       return GetTimesAjaxPage.getTime((WebInterface) templateContext.get("webInterface"), sone.getTime());
+                       return timeTextConverter.getTimeText(sone.getTime()).getL10nText();
                } else if (member.equals("trust")) {
                        Sone currentSone = (Sone) templateContext.get("currentSone");
                        if (currentSone == null) {