Phpword: is there a way to use the compatibility word function coming from templating method? - templating

Newbie with phpword, I am generating my word.docx using templating with the library phpword but need to remove the compatibility message when opening Word so I found that but don't know how to use it with TemplateProcessor..
I need to use correctly this method:
$phpWord->getCompatibility()->setOoxmlVersion(15);
My code is:
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('phpWord/Template.docx');
$templateProcessor->setValue('txt1', $txt1);
$templateProcessor->saveAs($nameFile);

Related

Twig, ZF2 and PoEdit

Using ZfcTwig for ZF2 and twig-gettext-extractor, I still cannot extract messages for translation from twig-files by poedit. I works if I used the formal twig keyword for translation {% trans(MY_TEXT) %} but not for the in-built view helper translate. {{ translate(MY_Text) }} does the translation but poedit is just ignoring it. For new twig files, I want as usual let poedit do the job....
Any ideas for a solution?
Maybe you need to edit catalog properties keywords to be visible for translations. Open PoEdit, go to Catalog -> Properties -> Sources keywords and add another keyword "translate". Here I attach an screenshot.
The problem is that the extractor you are using is just caching the files and running them through xgettext to extract calls to trans/translate/_/.. (keywords as suggested by Conti. Alas ZfcTwig will crosscompile calls to ZF2 plugins into plugin('translate')->__invoke('Your Text to be translated'). You could of course now add __invoke as a new keyword in poedit or whatever you favorite gui for using xgettext is, but it will now find all calls to all view helpers not just those to translate.
I ran into this problem myself and I have not come up with a satisfying solution. The Twig Gettext Extension looks promising in terms of writing your own customized POT-File generator that will handle translate and translatePlural view helper calls. Using the extension as is will bypass all translation from ZF2. ZF2 parses .mo files into an internal structure rather than using the php-gettext mod.
All in all I gave up on automated po(t) file generation for ZF2+ZfcTwig for now and am back to phpArray.

XQuery: How to get system path separator?

I would like to know if there is a possibility to get the system path separator inside my XQuery code without special libraries?
No. There's nothing defined in the XQuery 1.0 or XQuery 3.0 specs to identify details of the filesystem.
However, using fn:doc(), you should be able to reference filesystem URIs generally by preceding the file name with file:/// and using / as a separator for directory.
As already mentioned, I don't think it is possible to achieve this by using standard XQuery functionality. However, depending on what processor you are using, it is quite likely that you can use Java bindings. I am aware that at least BaseX, eXist and Saxon support this.
By using this technique you can get the separator
declare namespace system="java:java.lang.System";
system:getProperty("file.separator")
Or if your processor supports the expanded QName notation you can also write
Q{java:java.lang.System}getProperty("file.separator")

ZF2 BBCode Parser

Hiho,
I use the ckeditor on my website for special textareas like forum
or signatures.
But I have a problem with the output. I use ZF2 and would like to
use ZendMarkup to render the output bbcode back in html.
But at every time I call
$bbcode->render(...)
I got the error
There is no Zend_Markup_Root markup.
The ZendMarkup is an extension inspired by the Zend_Markup from ZF1.
But I can't find any thing on API or other guides.
Does someone has any idea what as the problem is?
The ZendMarkup library is very old (last update is 10 months ago!) so I wouldn't use such library. If you would like, I think I traced the error down.
On this line there is a reference to Zend_Markup_Root while that should be ZendMarkup\Renderer\Markup\Html\Root. Try to change that line and see what happens.
Another way is to replace the ZendMarkup library with another library which does work and is updated regularly. An example is Decoda. If you load mjohnson/decoda in your composer.json, you can use Decoda in your Zend Framework 2 application:
<?php
use Decoda\Decoda;
$parser = new Decoda($bbcode);
$html = $parser->parse();
With tools like composer, there is no need to use solely Zend* components when there are better alternatives.

c++ dom parsing problem

hi every body
i'm new to xercses C++dom parser.can anyone tell me
can we write our own getElementsBytagName,GetNodeValue etc function ?
how to write these function and use them in my code ?
can anybody explain me the process of Dom parsing?
xerces provides methods like getElementsBytagName so you can use them in your application.
Have a look at xerces programming guide you can find there how to parse xml file and how to get elements and attributes.

In Ruby, how can I inspect the class generated by a .html.erb template?

When doing J2EE development, I find it handy for debugging to view the Java classes that are generated by the JSP compiler.
How can I do the equivalent in Ruby? Since it is all in memory, it won't generate a file that I can view. I believe it's the ERB module that generates the corresponding object for a template, so how can I actually view the object? Can I drop a debugger statement somewhere and use rdb? Is there some configuration value I can tell it to dump the object definition? I'm using rails, in case that makes a difference.
I don't think rails generates a class for your view. It basically calls eval after processing the file. Or do you mean inspecting the erb object while it's parsing your template?
If it's the latter you can find erb.rb in lib\ruby\1.9.1 I'd imagine you could just drop a debugger statement throughout that file.
I always make a habit of adding the following to my views (layout) which allows me to inspect or debug the parameters being used by the view in question.
<%= debug(params) %>
This will format all the parameters in yaml and display them in a Hash format.
Have a look at the method in the source code to get a better understanding. SOURCE
There are some differences compared with the Java way due to language differences.
Most template libraries for Ruby follow these steps when compiling/optimizing:
The template is compiled into Ruby source code -- not a class but a long procedure that appends to a string buffer while traversing the logic of the original template.
This ruby code is evaluated in order to be bound for later reference, preferably within a method body. This way, it is only parsed once by the interpreter.
The method (or other context) containing the logic of the parsed template is invoked to render it.
Anyway, the compiled template code therefore looks a lot like a much noisier version of your original template, and will generally not help you debugging, unless you're debugging the template language itself.
Anyone interested in template language implementation might enjoy a look around the Tilt code (use different template languages with the same rendering interface and optimization), and Temple (a great template language meta-implementation).

Resources