Added option to active multiple templates#371
Added option to active multiple templates#371choules wants to merge 1 commit intosplitbrain:masterfrom
Conversation
Klap-in
left a comment
There was a problem hiding this comment.
Please have a look at the comments.
If it is workable for you that the order cannot be set in the config, current approach is sufficient. If this order is relevant, I think another config settings is the only way.
| global $INPUT; | ||
| $requestedTemplate = $INPUT->str('template', $templates[0]); // exp | ||
|
|
||
| $this->tpl = $requestedTemplate; |
There was a problem hiding this comment.
Please include all this logic in the loadExportConfig() function. The getExportConfig() should return the value which is used during the generation of the pdf.
btw, template is the wrong url-parameter, for the template this is actually tpl. But if you update loadExportConfig() this line is not needed anymore.
| . '</li>' | ||
| ) + | ||
| array_slice($event->data['items'], -1, 1, true); | ||
| foreach($this->getExportConfig('template') AS $template){ |
There was a problem hiding this comment.
Please use here $this->getConf('template'), not getExportConfig(). Please note that $this->getConf('showexportbutton') is also only configurable from configuration manager. It is not useful to change the GUI by looking to the url-parameter value of tpl.
| $meta['toclevels'] = array('string', '_pattern' => '/^(|[1-5]-[1-5])$/'); | ||
| $meta['maxbookmarks'] = array('numeric'); | ||
| $meta['template'] = array('dirchoice', '_dir' => DOKU_PLUGIN . 'dw2pdf/tpl/'); | ||
| $meta['template'] = array('multicheckbox', '_other' => 'exists', '_choices' => array_map(function($path) { return basename($path); }, glob(DOKU_PLUGIN . 'dw2pdf/tpl/*', GLOB_ONLYDIR))); |
There was a problem hiding this comment.
Admin can not set the order of the selected templates. So the first template is, for people using multiple templates, relative random the first of these selected templates.
I like the automatic addition of all available templates.
|
|
||
| array_splice($event->data['items'], -1, 0, [new \dokuwiki\plugin\dw2pdf\MenuItem()]); | ||
| foreach(explode(',', $this->getExportConfig('template')) AS $template){ | ||
| array_splice($event->data['items'], -1, 0, [new \dokuwiki\plugin\dw2pdf\MenuItem($template)]); |
There was a problem hiding this comment.
I would prefer that the MenuItem($template) is only set to a specific template, if it is needed. So if more than one template is set in the config 'template'.
|
|
||
| $suffix = ''; | ||
|
|
||
| if(strlen($this->template) > 0) { |
There was a problem hiding this comment.
strlen() is not needed to check whether $this->template is empty.
| $conf['toclevels'] = ''; | ||
| $conf['maxbookmarks'] = 5; | ||
| $conf['template'] = 'default'; | ||
| $conf['template'] = array('default'); |
There was a problem hiding this comment.
This should be a string.
Since I did not save yet my config manager, this throws a warning, because the conf returns the default array instead of a string.
PHP Warning: explode() expects parameter 2 to be string, array given in /path/dokuwiki/dokuwiki/lib/plugins/dw2pdf/action.php on line 37
This change enables the user to select more than one template in the config. A button in the pagetools gets created for each enabled template.