This is a suggestion for how to clean up the implementation to allow the creation of a command-line interface.
Changes would need to be made so that it can handle loading local files. I don't know if that's possible in all cases using the current URL-load method, it certainly didn't work when I tried to run it under the CLI:
@$xml->open('zip://'.$odt_file.'#content.xml')
I'm not sure what the proper replacement for this would be, you might need to depend on zlib or something. Or maybe there's a way to get this working with local files somehow?
Also, right now, odt2html returns errors wrapped in HTML tags for easy presentation. In order for the caller to understand if this is an error or successful HTML output you'd need to structure the call a bit differently. Some alternatives I could think of are:
- Make it return an object/array with 'error' and 'result' members that can be inspected by the caller.
- Make it return an integer representing an error code (or a boolean representing succeed/fail) and pass the HTML output as a string parameter by reference.
- Keep the API the same but throw an exception on error.
And I think the caller should be responsible for presenting errors... if they need to be wrapped in HTML that can be done by file_upload.php.
Thanks for considering this!
This is a suggestion for how to clean up the implementation to allow the creation of a command-line interface.
Changes would need to be made so that it can handle loading local files. I don't know if that's possible in all cases using the current URL-load method, it certainly didn't work when I tried to run it under the CLI:
I'm not sure what the proper replacement for this would be, you might need to depend on zlib or something. Or maybe there's a way to get this working with local files somehow?
Also, right now, odt2html returns errors wrapped in HTML tags for easy presentation. In order for the caller to understand if this is an error or successful HTML output you'd need to structure the call a bit differently. Some alternatives I could think of are:
And I think the caller should be responsible for presenting errors... if they need to be wrapped in HTML that can be done by file_upload.php.
Thanks for considering this!