grammatista icon indicating copy to clipboard operation
grammatista copied to clipboard

Support for PHPTal parsing and MySQL storage

Open MrHash opened this issue 12 years ago • 7 comments

GrammatistaStoragePdo is now abstract so existing scripts should switch to GrammatistaStorageSQLite.

PHPTal parsing requires post parse transformations for quote handling.

MrHash avatar Oct 13 '12 16:10 MrHash

First, the storage stuff seems counter-intuitive; we'd have to add an implementation for each backend supported by PDO, so that needs fixing.

Second, since TAL templates must be valid XML, we shouldn't parse them using regular expressions, but use DOM instead.

dzuelke avatar Oct 13 '12 22:10 dzuelke

Unfortunately the PDO execute query API varies slightly between Sqlite and Mysql hence the need for the extra handlers.

Also regarding the tal, php can also be executed within the content of an element so it would need some pcre patterns anyway.

Thus the implementation I made seemed to be sufficient although perhaps not optimal.

MrHash avatar Oct 14 '12 02:10 MrHash

This modification was done some time ago so having taken another look it seems that there was perhaps a bug in the use of executeQuery() instead of query() for initialisation queries on the PDO connection. So actually all the Mysql support could be handled just by making the table construction commands configurable.

MrHash avatar Oct 14 '12 11:10 MrHash

Go for it :p

dzuelke avatar Oct 14 '12 16:10 dzuelke

I realize PHP can be executed inside, but that's not a reason not to parse the overall stuff properly :)

dzuelke avatar Oct 14 '12 16:10 dzuelke

My main concern with using the PHP DOM is the poor character set handling. It always represents internally as UTF-8 which will cause issues with content in other character sets such as EUC-JP. :(

MrHash avatar Oct 14 '12 19:10 MrHash

That's not poor handling, @MrHash, but in line with the DOM specification :) It always converts to UTF-8. That's what makes DOM portable - no matter what encoding your document is in, the content is represented in Unicode's UTF-8 encoding, so you don't have to figure out how to convert things anymore. It's supposed to be like that :)

dzuelke avatar Jan 31 '14 05:01 dzuelke