-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to active multiple templates #371
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,11 @@ class action_plugin_dw2pdf extends DokuWiki_Action_Plugin { | |
* @param string $title | ||
*/ | ||
public function __construct($title=null) { | ||
$this->tpl = $this->getExportConfig('template'); | ||
$templates = explode(',', $this->getExportConfig('template')); | ||
global $INPUT; | ||
$requestedTemplate = $INPUT->str('template', $templates[0]); // exp | ||
|
||
$this->tpl = $requestedTemplate; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please include all this logic in the btw, |
||
$this->title = $title ? $title : ''; | ||
} | ||
|
||
|
@@ -956,16 +960,21 @@ public function addbutton(Doku_Event $event) { | |
$params['rev'] = $REV; | ||
} | ||
|
||
// insert button at position before last (up to top) | ||
$event->data['items'] = array_slice($event->data['items'], 0, -1, true) + | ||
array('export_pdf' => | ||
'<li>' | ||
. '<a href="' . wl($ID, $params) . '" class="action export_pdf" rel="nofollow" title="' . $this->getLang('export_pdf_button') . '">' | ||
. '<span>' . $this->getLang('export_pdf_button') . '</span>' | ||
. '</a>' | ||
. '</li>' | ||
) + | ||
array_slice($event->data['items'], -1, 1, true); | ||
foreach($this->getExportConfig('template') AS $template){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use here |
||
|
||
$params['template'] = $template; | ||
|
||
// insert button at position before last (up to top) | ||
$event->data['items'] = array_slice($event->data['items'], 0, -1, true) + | ||
array('export_pdf_'.$template => | ||
'<li>' | ||
. '<a href="' . wl($ID, $params) . '" class="action export_pdf" rel="nofollow" title="' . $this->getLang('export_pdf_button') . ' ('. $template .'">' | ||
. '<span>' . $this->getLang('export_pdf_button') . '</span>' | ||
. '</a>' | ||
. '</li>' | ||
) + | ||
array_slice($event->data['items'], -1, 1, true); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -984,6 +993,8 @@ public function addsvgbutton(Doku_Event $event) { | |
return; | ||
} | ||
|
||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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'. |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
$conf['toc'] = 0; | ||
$conf['toclevels'] = ''; | ||
$conf['maxbookmarks'] = 5; | ||
$conf['template'] = 'default'; | ||
$conf['template'] = array('default'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be 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 |
||
$conf['output'] = 'file'; | ||
$conf['usecache'] = 1; | ||
$conf['usestyles'] = 'wrap,'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
$meta['toc'] = array('onoff'); | ||
$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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
$meta['output'] = array('multichoice', '_choices' => array('browser', 'file')); | ||
$meta['usecache'] = array('onoff'); | ||
$meta['usestyles'] = array('string'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strlen() is not needed to check whether $this->template is empty.