]> WPIA git - gigi.git/commitdiff
Fix templating. Add language to IterableDataset.
authorFelix Dörre <felix@dogcraft.de>
Mon, 14 Jul 2014 20:00:09 +0000 (22:00 +0200)
committerFelix Dörre <felix@dogcraft.de>
Tue, 15 Jul 2014 22:08:09 +0000 (00:08 +0200)
src/org/cacert/gigi/output/template/ForeachStatement.java
src/org/cacert/gigi/output/template/IterableDataset.java
src/org/cacert/gigi/output/template/Template.java
src/org/cacert/gigi/pages/account/MailCertificateAdd.java

index 0b3c52697efe2554e89bd6cdf89ca51c9282fa42..38aad35f8f95d1d9573aaddb98807ccc546027f3 100644 (file)
@@ -22,7 +22,7 @@ final class ForeachStatement implements Outputable {
                if (o instanceof IterableDataset) {
                        IterableDataset id = (IterableDataset) o;
                        Map<String, Object> subcontext = new HashMap<String, Object>(vars);
                if (o instanceof IterableDataset) {
                        IterableDataset id = (IterableDataset) o;
                        Map<String, Object> subcontext = new HashMap<String, Object>(vars);
-                       while (id.next(subcontext)) {
+                       while (id.next(l, subcontext)) {
                                body.output(out, l, subcontext);
                        }
                }
                                body.output(out, l, subcontext);
                        }
                }
index d908fccc59f1ffcdf4245e68d22c8df72222edf2..bd7b99b25b3d5cf9a975b7e92e924dfac18e11eb 100644 (file)
@@ -2,6 +2,8 @@ package org.cacert.gigi.output.template;
 
 import java.util.Map;
 
 
 import java.util.Map;
 
+import org.cacert.gigi.Language;
+
 /**
  * Represents some kind of data, that may be iterated over in a template.
  */
 /**
  * Represents some kind of data, that may be iterated over in a template.
  */
@@ -9,11 +11,13 @@ public interface IterableDataset {
        /**
         * Moves to the next Dataset.
         * 
        /**
         * Moves to the next Dataset.
         * 
+        * @param l
+        *            the language for l10n-ed strings
         * @param vars
         *            the variables used in this template. They need to be updated
         *            for each line.
         * @return true, iff there was a data-line "installed". False of this set is
         *         already empty.
         */
         * @param vars
         *            the variables used in this template. They need to be updated
         *            for each line.
         * @return true, iff there was a data-line "installed". False of this set is
         *         already empty.
         */
-       public boolean next(Map<String, Object> vars);
+       public boolean next(Language l, Map<String, Object> vars);
 }
 }
index 08f261afce3dc64c9c07d2e42d90544a2fa56b3c..b8dd7424c5248b9f1ca523988d488e9e9d8de637 100644 (file)
@@ -57,24 +57,23 @@ public class Template implements Outputable {
                LinkedList<String> splitted = new LinkedList<String>();
                LinkedList<Outputable> commands = new LinkedList<Outputable>();
                StringBuffer buf = new StringBuffer();
                LinkedList<String> splitted = new LinkedList<String>();
                LinkedList<Outputable> commands = new LinkedList<Outputable>();
                StringBuffer buf = new StringBuffer();
-               int ch = r.read();
                outer: while (true) {
                        while (!endsWith(buf, "<?")) {
                outer: while (true) {
                        while (!endsWith(buf, "<?")) {
+                               int ch = r.read();
                                if (ch == -1) {
                                        break outer;
                                }
                                buf.append((char) ch);
                                if (ch == -1) {
                                        break outer;
                                }
                                buf.append((char) ch);
-                               ch = r.read();
                        }
                        buf.delete(buf.length() - 2, buf.length());
                        splitted.add(buf.toString());
                        buf.delete(0, buf.length());
                        while (!endsWith(buf, "?>")) {
                        }
                        buf.delete(buf.length() - 2, buf.length());
                        splitted.add(buf.toString());
                        buf.delete(0, buf.length());
                        while (!endsWith(buf, "?>")) {
-                               buf.append((char) ch);
-                               ch = r.read();
+                               int ch = r.read();
                                if (ch == -1) {
                                        throw new EOFException();
                                }
                                if (ch == -1) {
                                        throw new EOFException();
                                }
+                               buf.append((char) ch);
                        }
                        buf.delete(buf.length() - 2, buf.length());
                        String com = buf.toString().replace("\n", "");
                        }
                        buf.delete(buf.length() - 2, buf.length());
                        String com = buf.toString().replace("\n", "");
index 769f9e1ad0d8aaf60de7f1d2ef7fedd744ff7403..5a343954fb2b719032d331f9a7cd720881621212 100644 (file)
@@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.cacert.gigi.Certificate;
 import javax.servlet.http.HttpServletResponse;
 
 import org.cacert.gigi.Certificate;
+import org.cacert.gigi.Language;
 import org.cacert.gigi.User;
 import org.cacert.gigi.database.DatabaseConnection;
 import org.cacert.gigi.output.ClientCSRGenerate;
 import org.cacert.gigi.User;
 import org.cacert.gigi.database.DatabaseConnection;
 import org.cacert.gigi.output.ClientCSRGenerate;
@@ -40,7 +41,7 @@ public class MailCertificateAdd extends Page {
                        vars.put("emails", new IterableDataset() {
 
                                @Override
                        vars.put("emails", new IterableDataset() {
 
                                @Override
-                               public boolean next(Map<String, Object> vars) {
+                               public boolean next(Language l, Map<String, Object> vars) {
                                        try {
                                                if (!rs.next()) {
                                                        return false;
                                        try {
                                                if (!rs.next()) {
                                                        return false;