rehamaltamimi / gwtwiki

Automatically exported from code.google.com/p/gwtwiki
0 stars 0 forks source link

template parameters don't get replaced if not currently in template #81

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. create a new page with the following content
"{{#time:z|{{{1|April 14}}}}}"
2. try to render that page

What is the expected output? What do you see instead?
the time template function gets the following as its parameter: "{{{1|April 
14}}}" (which obviously is no valid time) but this should have been replaced by 
"April 14" since we didn't give any parameter

What version of the product are you using? On what operating system?
3.0.18-SNAPSHOT

Please provide any additional information below.
https://secure.wikimedia.org/wikipedia/en/wiki/Help:Template#Handling_parameters

Original issue reported on code.google.com by nico.kru...@googlemail.com on 11 Apr 2012 at 12:51

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Make this change in the Time function please:

Index: bliki-core/src/main/java/info/bliki/wiki/template/Time.java
===================================================================
--- bliki-core/src/main/java/info/bliki/wiki/template/Time.java (revision 3995)
+++ bliki-core/src/main/java/info/bliki/wiki/template/Time.java (working copy)
@@ -150,7 +150,7 @@
            Date date;
            DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, model.getLocale());
            if (list.size() > 1) {
-               String dateTimeParameter = list.get(1);
+               String dateTimeParameter = parse(list.get(1), model);

                try {
                    date = df.parse(dateTimeParameter);

Original comment by axelclk@gmail.com on 11 Apr 2012 at 1:33

GoogleCodeExporter commented 8 years ago
yes, that worked - on a side-note, the locale for parsing the given date should 
be English (that's what PHP's strtotime() accepts which is what mediawiki uses) 
- I had that wrong, previously

diff --git a/bliki-core/src/main/java/info/bliki/wiki/template/Time.java 
b/bliki-core/src/main/java/info/bliki/wiki/template/Time.java
index eb3836e..0c1862c 100644
--- a/bliki-core/src/main/java/info/bliki/wiki/template/Time.java
+++ b/bliki-core/src/main/java/info/bliki/wiki/template/Time.java
@@ -148,9 +148,9 @@ public class Time extends AbstractTemplateFunction {
    public String parseFunction(List<String> list, IWikiModel model, char[] src, int beginIndex, int endIndex) {
        if (list.size() > 0) {
            Date date;
-           DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, 
model.getLocale());
+           DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, 
Locale.ENGLISH);
            if (list.size() > 1) {
-               String dateTimeParameter = list.get(1);
+               String dateTimeParameter = parse(list.get(1), model);

                try {
                    date = df.parse(dateTimeParameter);

Original comment by nico.kru...@googlemail.com on 11 Apr 2012 at 1:41

GoogleCodeExporter commented 8 years ago
Problem should be fixed with r4457

Original comment by axelclk@gmail.com on 14 Apr 2012 at 11:39

GoogleCodeExporter commented 8 years ago
thank you

Original comment by nico.kru...@googlemail.com on 16 Apr 2012 at 12:10

GoogleCodeExporter commented 8 years ago

Original comment by axelclk@gmail.com on 27 Apr 2012 at 9:46