mirror of
https://github.com/splitbrain/dokuwiki-plugin-dw2pdf.git
synced 2025-08-15 21:41:19 +00:00
Added export button for 'dokuwiki' tpl pagetools, can be disabled in plugin config. Fixes #86
This commit is contained in:
41
action.php
41
action.php
@ -9,7 +9,6 @@
|
||||
|
||||
// must be run within Dokuwiki
|
||||
if (!defined('DOKU_INC')) die();
|
||||
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
|
||||
|
||||
class action_plugin_dw2pdf extends DokuWiki_Action_Plugin {
|
||||
|
||||
@ -18,7 +17,7 @@ class action_plugin_dw2pdf extends DokuWiki_Action_Plugin {
|
||||
/**
|
||||
* Constructor. Sets the correct template
|
||||
*/
|
||||
function __construct(){
|
||||
public function __construct(){
|
||||
$tpl = false;
|
||||
if(isset($_REQUEST['tpl'])){
|
||||
$tpl = trim(preg_replace('/[^A-Za-z0-9_\-]+/','',$_REQUEST['tpl']));
|
||||
@ -33,8 +32,9 @@ class action_plugin_dw2pdf extends DokuWiki_Action_Plugin {
|
||||
/**
|
||||
* Register the events
|
||||
*/
|
||||
function register(Doku_Event_Handler $controller) {
|
||||
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'convert',array());
|
||||
public function register(Doku_Event_Handler $controller) {
|
||||
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'convert', array());
|
||||
$controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'addbutton', array());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +44,7 @@ class action_plugin_dw2pdf extends DokuWiki_Action_Plugin {
|
||||
* @param array $param
|
||||
* @return bool
|
||||
*/
|
||||
function convert(&$event, $param) {
|
||||
public function convert(&$event, $param) {
|
||||
global $ACT;
|
||||
global $REV;
|
||||
global $ID;
|
||||
@ -173,6 +173,31 @@ class action_plugin_dw2pdf extends DokuWiki_Action_Plugin {
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 'export pdf'-button to pagetools
|
||||
*
|
||||
* @param Doku_Event $event
|
||||
* @param mixed $param not defined
|
||||
*/
|
||||
public function addbutton(&$event, $param) {
|
||||
global $ID, $REV, $conf;
|
||||
|
||||
if($this->getConf('showexportbutton') && $event->data['view'] == 'main') {
|
||||
$params = array('do' => 'export_pdf');
|
||||
if($REV) $params['rev'] = $REV;
|
||||
|
||||
switch($conf['template']) {
|
||||
case 'dokuwiki':
|
||||
$event->data['items']['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>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the various template files and prepare the HTML/CSS for insertion
|
||||
@ -313,7 +338,6 @@ class action_plugin_dw2pdf extends DokuWiki_Action_Plugin {
|
||||
return $css;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of possible Plugin PDF Styles
|
||||
*
|
||||
@ -321,7 +345,7 @@ class action_plugin_dw2pdf extends DokuWiki_Action_Plugin {
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function css_pluginPDFstyles(){
|
||||
protected function css_pluginPDFstyles(){
|
||||
$list = array();
|
||||
$plugins = plugin_list();
|
||||
|
||||
@ -340,5 +364,4 @@ class action_plugin_dw2pdf extends DokuWiki_Action_Plugin {
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -5,3 +5,4 @@ $conf['template'] = 'default';
|
||||
$conf['maxbookmarks'] = 5;
|
||||
$conf['usestyles'] = '';
|
||||
$conf['qrcodesize'] = '120x120';
|
||||
$conf['showexportbutton'] = 1;
|
||||
|
@ -5,3 +5,4 @@ $meta['template'] = array('dirchoice', '_dir' => DOKU_PLUGIN.'dw2pdf/tpl/');
|
||||
$meta['maxbookmarks'] = array('numeric');
|
||||
$meta['usestyles'] = array('string');
|
||||
$meta['qrcodesize'] = array('string', '_pattern'=>'/^(|\d+x\d+)$/');
|
||||
$meta['showexportbutton'] = array('onoff');
|
||||
|
@ -14,3 +14,4 @@ $lang['template'] = 'Which template should be used for formatting the PD
|
||||
$lang['maxbookmarks'] = 'How many section levels should be used in the PDF bookmarks? <small>(0=none, 5=all)</small>';
|
||||
$lang['usestyles'] = 'You can give a comma separated list of plugins of which the <code>style.css</code> or <code>screen.css</code> should be used for PDF generation. By default only <code>print.css</code> and <code>pdf.css</code> are used.';
|
||||
$lang['qrcodesize'] = 'Size of embedded QR code (in pixels <code><i>width</i><b>x</b><i>height</i></code>). Empty to disable';
|
||||
$lang['showexportbutton'] = 'Show PDF export button (only when supported by your template, and the template is whitelisted)';
|
||||
|
@ -1,7 +1,7 @@
|
||||
base dw2pdf
|
||||
author Andreas Gohr and Luigi Micco
|
||||
email l.micco@tiscali.it
|
||||
date 2012-05-20
|
||||
date 2014-01-06
|
||||
name Dw2Pdf plugin
|
||||
desc DokuWiki to PDF converter
|
||||
url http://www.dokuwiki.org/plugin:dw2pdf
|
||||
|
Reference in New Issue
Block a user