libreliodev / wordpress

Librelio Wordpress plug-in
0 stars 1 forks source link

Implement Header for plists #46

Closed libreliodev closed 9 years ago

libreliodev commented 9 years ago

In #31, we implemented iterator for plists. This assumes that the root element of the plist is an array.

Now, in some cases, we need to have a header.

In this case, the structure of the file will be as follows

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Header</key>
    <dict>
        <key>Title</key>
        <string>My Title</string>
        <key>Date</key>
        <date>2015-05-15T16:50:07Z</date>
    </dict>
    <key>Items</key>
    <array/>
</dict>
</plist>

The parser should iterate the "Items" element.

It should be possible to access the header elements using a syntax such as "Header.Title"

Also, please pay attention to the fact that we need to be able to keep using legacy plists, with Array at the root level.

AlirezaAlgo commented 9 years ago

@libreliodev Done. Tested with the following Template for /drpat/drpat-2015-0243_20150428/toc_20150428.plist.

Librelio

"My Title"=[librelio id="Header.Title"]

"Date"=[librelio id="date('Y-m-d', Header.Date)"]

[librelio foreach="document as item"]

[librelio id="item.Title"]
___________________________

[librelio endforeach]

And with following template for /dph/dph-2015-1001_20150309/toc_20150309.plist.

Librelio

[librelio foreach="document as item"]

[librelio id="item.Title"]

___________________________

[librelio endforeach]
libreliodev commented 9 years ago

@serverfire

Tested as you suggested with http://www.droit-patrimoine.fr/librelio.php?watemplate=sommaire&waurl=/drpat/drpat-2015-0243_20150428/toc_20150428.plist

This returns an error Object does not contain property: Header

Also tested with http://www.droit-patrimoine.fr/librelio.php?watemplate=sommaire&waurl=/dph/dph-2015-1009_20150504/toc_20150504.plist

This returns the same error

AlirezaAlgo commented 9 years ago

@libreliodev Apparently this file is changed. /drpat/drpat-2015-0243_20150428/toc_20150428.plist. I uploaded another plist file in there. Now the error has changed to Object does not contain property: FileName.

Please change template as follows. [librelio id="item.Title"]

libreliodev commented 9 years ago

Successfully tested with http://www.droit-patrimoine.fr/librelio.php?watemplate=sommaire&waurl=/dph/dph-2015-1009_20150504/toc_20150504.plist