Support for arrays in PHP filter

Issue #203 on hold
Former user created an issue

Original issue 203 created by @ysavourel on 2012-01-24T12:44:30.000Z:

Currently the PHP filter does not know how to make the difference between key and value in arrays: array("key" => "value");

See also http://tech.groups.yahoo.com/group/okapitools/message/2601

Comments (12)

  1. Chase Tingley

    Note that in newer versions of PHP, the syntax looks like

    $array = [
    "foo" => "bar",
    "bar" => "foo",
    ];
    

    However this older syntax is still supported by the language:

    $array = array(
    "foo" => "bar",
    "bar" => "foo",
    );
    
  2. Chase Tingley

    Also, arrays can be nestable:

    $array = [
      "foo" => "bar",
      "baz" => [
            'A' => "Value A",
            'B' => "Value B",
        ],
    ]
    
  3. Chase Tingley

    I think the correct behavior here is just to expose the values, so in that last example, the translation set would be "bar", "Value A", "Value B".

  4. Denis Konovalyenko

    I was wondering, should we also support all variations of "array" structure? Hence, the code snippet below is supposed to be a valid one (please, pay attention to quotes):

    $array = [
        'foo',
        "bar",
        $varKey => "bar",
        [
            'A' => "Value A",
            "B" => 'Value B',
        ],
        'foo' => array(
            'C' => "Value C",
            "D" => 'Value D',
        ),  
    ];
    

    So, the translation set would be "foo", "bar", "bar" (again), "Value A", "Value B", "Value C", "Value D".

  5. Denis Konovalyenko

    So far, two different approaches have been investigated. The first is to extend the current processing logic of the PHP content filter. The second is to re-implement the filter with the help of Jericho and JavaCC and should be considered as the best one to follow (for additional information please refer to the topic in the okapi-devel group).

    So, the main concept of the second approach is to use Jericho to parse out the full tags (HTML + PHP), and then pull out the wanted stuff from the PHP tags with the help of a generated PHP parser by the JavaCC.

    The current state of clarified requirements on the matter could be found attached in the "Re PHP filter re-implementation requirements.eml" file. The plan of development could be found attached in the "The plan of development with estimates.eml" file.

  6. Log in to comment